This is an automated email from the ASF dual-hosted git repository.
cdeppisch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new a5116e70 chore: Integration test improvements
a5116e70 is described below
commit a5116e70c6ce5f144a891112d585edd46dce0e6d
Author: Christoph Deppisch <[email protected]>
AuthorDate: Tue Jan 21 08:53:20 2025 +0100
chore: Integration test improvements
- Update to Citrus 4.5.1
- Automatically purge Http server endpoint after each test
- Remove obsolete workaround to create dump output folders in before suite
- Use general Docker registry mirror
---
.github/workflows/integration-tests.yaml | 3 +-
pom.xml | 2 +-
.../src/test/java/EndpointAutoConfiguration.java | 41 +++++++++++-----------
.../aws/kinesis/amazonKinesisClient.groovy | 7 ----
.../test/resources/aws/s3/amazonS3Client.groovy | 8 -----
.../test/resources/aws/s3/aws-s3-to-http.it.yaml | 5 ---
.../test/resources/aws/sqs/amazonSQSClient.groovy | 7 ----
.../test/resources/citrus-application.properties | 14 +++++++-
.../earthquake/earthquake-to-http.it.yaml | 5 ---
.../jira/jira-add-comment-sink-pipe.it.yaml | 5 ---
.../jira/jira-add-issue-sink-pipe.it.yaml | 5 ---
.../test/resources/jira/jira-source-pipe.it.yaml | 5 ---
.../test/resources/kafka/kafka-router-pipe.it.yaml | 5 ---
.../test/resources/kafka/kafka-sink-pipe.it.yaml | 5 ---
.../test/resources/kafka/kafka-source-pipe.it.yaml | 5 ---
.../openapi/rest-openapi-sink-add-pet.it.yaml | 5 ---
.../openapi/rest-openapi-sink-delete-pet.it.yaml | 5 ---
.../test/resources/slack/slack-sink-pipe.it.yaml | 5 ---
.../test/resources/slack/slack-source-pipe.it.yaml | 5 ---
.../resources/timer/timer-to-http-pipe.it.yaml | 5 ---
.../src/test/resources/timer/timer-to-http.it.yaml | 5 ---
.../transformation/data-type-action-pipe.it.yaml | 5 ---
.../extract-field-action-pipe.it.yaml | 5 ---
.../insert-field-action-pipe.it.yaml | 5 ---
24 files changed, 36 insertions(+), 131 deletions(-)
diff --git a/.github/workflows/integration-tests.yaml
b/.github/workflows/integration-tests.yaml
index bea929d2..f1d42628 100644
--- a/.github/workflows/integration-tests.yaml
+++ b/.github/workflows/integration-tests.yaml
@@ -62,7 +62,8 @@ jobs:
./mvnw clean install -DskipTests -DskipITs
- name: Run Tests
env:
- CITRUS_TESTCONTAINERS_LOCALSTACK_IMAGE_NAME:
"mirror.gcr.io/localstack/localstack"
+ CITRUS_TESTCONTAINERS_REGISTRY_MIRROR: "mirror.gcr.io"
+ CITRUS_TESTCONTAINERS_REGISTRY_MIRROR_ENABLED: "true"
run: |
echo "Install JBang via SDKMAN"
diff --git a/pom.xml b/pom.xml
index f2b09a36..96598ff1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@
<camel.version>4.9.0</camel.version>
- <citrus.version>4.5.0</citrus.version>
+ <citrus.version>4.5.1</citrus.version>
<cucumber.version>7.20.1</cucumber.version>
<!-- Versions used inside Kamelets (add them also to the
dependencyManagement section and the groovy script below) -->
diff --git
a/tests/camel-kamelets-itest/src/test/java/EndpointAutoConfiguration.java
b/tests/camel-kamelets-itest/src/test/java/EndpointAutoConfiguration.java
index 390a6414..7eac291a 100644
--- a/tests/camel-kamelets-itest/src/test/java/EndpointAutoConfiguration.java
+++ b/tests/camel-kamelets-itest/src/test/java/EndpointAutoConfiguration.java
@@ -15,42 +15,41 @@
* limitations under the License.
*/
-import java.nio.file.Path;
-
import org.citrusframework.annotations.CitrusConfiguration;
-import org.citrusframework.camel.jbang.CamelJBangSettings;
-import org.citrusframework.container.SequenceBeforeSuite;
-import org.citrusframework.exceptions.CitrusRuntimeException;
+import org.citrusframework.container.SequenceAfterTest;
import org.citrusframework.http.server.HttpServer;
import org.citrusframework.spi.BindToRegistry;
import org.springframework.http.HttpStatus;
+import static
org.citrusframework.actions.PurgeEndpointAction.Builder.purgeEndpoints;
import static org.citrusframework.http.endpoint.builder.HttpEndpoints.http;
+import static org.citrusframework.jbang.actions.JBangAction.Builder.jbang;
@CitrusConfiguration
public class EndpointAutoConfiguration {
+ private final HttpServer httpServer = http()
+ .server()
+ .port(8081)
+ .defaultStatus(HttpStatus.CREATED)
+ .timeout(60000L)
+ .autoStart(true)
+ .build();
+
@BindToRegistry
public HttpServer httpServer() {
- return http()
- .server()
- .port(8081)
- .defaultStatus(HttpStatus.CREATED)
- .timeout(120000L)
- .autoStart(true)
- .build();
+ return httpServer;
}
@BindToRegistry
- public SequenceBeforeSuite setup() {
- // TODO: Workaround - remove when Citrus 4.5.1 is released
- return SequenceBeforeSuite.Builder.beforeSuite()
- .actions(context -> {
- Path workDir = CamelJBangSettings.getWorkDir();
- if (!workDir.toFile().exists() &&
!workDir.toFile().mkdirs()) {
- throw new CitrusRuntimeException("Failed to create
JBang working directory: %s".formatted(workDir.toAbsolutePath().toString()));
- }
- })
+ public SequenceAfterTest afterTest() {
+ return SequenceAfterTest.Builder.afterTest()
+ .actions(
+ // Workaround to stop all Camel JBang integrations after
test - remove when Citrus 4.5.2 is released
+ jbang().app("camel@apache/camel").command("stop"),
+ // Auto purge Http server endpoint
+ purgeEndpoints().endpoint(httpServer)
+ )
.build();
}
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/amazonKinesisClient.groovy
b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/amazonKinesisClient.groovy
index 3865d7c3..bc109020 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/amazonKinesisClient.groovy
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/kinesis/amazonKinesisClient.groovy
@@ -15,18 +15,11 @@
* limitations under the License.
*/
-
-import org.apache.camel.CamelContext
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.kinesis.KinesisClient
-if (context.getReferenceResolver().isResolvable(CamelContext.class)) {
- println "Destroying former KINESIS client instance"
-
context.getReferenceResolver().resolve(CamelContext.class).getRegistry().unbind("amazonKinesisClient")
-}
-
KinesisClient kinesisClient = KinesisClient
.builder()
.endpointOverride(URI.create('${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}'))
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/amazonS3Client.groovy
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/amazonS3Client.groovy
index cca1d583..4c6470e9 100644
--- a/tests/camel-kamelets-itest/src/test/resources/aws/s3/amazonS3Client.groovy
+++ b/tests/camel-kamelets-itest/src/test/resources/aws/s3/amazonS3Client.groovy
@@ -15,19 +15,11 @@
* limitations under the License.
*/
-
-
-import org.apache.camel.CamelContext
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.s3.S3Client
-if (context.getReferenceResolver().isResolvable(CamelContext.class)) {
- println "Destroying former S3 client instance"
-
context.getReferenceResolver().resolve(CamelContext.class).getRegistry().unbind("amazonS3Client")
-}
-
S3Client s3 = S3Client
.builder()
.endpointOverride(URI.create('${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}'))
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml
index 4a876d02..ef5f90e7 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-to-http.it.yaml
@@ -34,11 +34,6 @@ actions:
http:
url: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}"
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create AWS-S3 client
- camel:
createComponent:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/amazonSQSClient.groovy
b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/amazonSQSClient.groovy
index 2668bafe..80676fac 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/sqs/amazonSQSClient.groovy
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/sqs/amazonSQSClient.groovy
@@ -15,18 +15,11 @@
* limitations under the License.
*/
-
-import org.apache.camel.CamelContext
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.sqs.SqsClient
-if (context.getReferenceResolver().isResolvable(CamelContext.class)) {
- println "Destroying former SQS client instance"
-
context.getReferenceResolver().resolve(CamelContext.class).getRegistry().unbind("amazonSQSClient")
-}
-
SqsClient sqsClient = SqsClient
.builder()
.endpointOverride(URI.create('${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}'))
diff --git
a/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties
b/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties
index 659448a0..2e723804 100644
---
a/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties
+++
b/tests/camel-kamelets-itest/src/test/resources/citrus-application.properties
@@ -1,3 +1,4 @@
+# Configure endpoints used in tests (e.g. generic Http server)
citrus.java.config=EndpointAutoConfiguration
citrus.file.encoding=UTF-8
@@ -7,11 +8,22 @@ citrus.type.converter=camel
citrus.mail.marshaller.type=JSON
citrus.cluster.type=local
-citrus.camelk.max.attempts=10
citrus.camel.jbang.max.attempts=10
+# Camel JBang version (should align with version used in pom.xml)
citrus.camel.jbang.version=4.9.0
+# Kamelets version (should point to the next snapshot release version)
citrus.camel.jbang.kamelets.version=4.10.0-SNAPSHOT
+# Tests should use local Kamelets
citrus.camel.jbang.kamelets.local.dir=../../../kamelets
+
+# Enable dump of Camel JBang integration output
citrus.camel.jbang.dump.integration.output=true
+
+# Workaround to stop all Camel JBang integrations after test - remove when
Citrus 4.5.2 is released
+citrus.camel.jbang.auto.remove.resources=false
+
+# Use general registry mirror for Docker images (e.g. Testcontainers)
+citrus.testcontainers.registry.mirror=mirror.gcr.io
+citrus.testcontainers.registry.mirror.enabled=true
diff --git
a/tests/camel-kamelets-itest/src/test/resources/earthquake/earthquake-to-http.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/earthquake/earthquake-to-http.it.yaml
index eb1cc9ec..f9b45d92 100644
---
a/tests/camel-kamelets-itest/src/test/resources/earthquake/earthquake-to-http.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/earthquake/earthquake-to-http.it.yaml
@@ -17,11 +17,6 @@
name: earthquake-to-http-test
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-comment-sink-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-comment-sink-pipe.it.yaml
index 108ba32c..9041dee6 100644
---
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-comment-sink-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-comment-sink-pipe.it.yaml
@@ -46,11 +46,6 @@ variables:
- name: "jira.password"
value: "secr3t"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink-pipe.it.yaml
index a36b91e2..625442a6 100644
---
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-add-issue-sink-pipe.it.yaml
@@ -42,11 +42,6 @@ variables:
- name: "jira.password"
value: "secr3t"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-source-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-source-pipe.it.yaml
index 6d4a9e57..3cc4f489 100644
---
a/tests/camel-kamelets-itest/src/test/resources/jira/jira-source-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/jira/jira-source-pipe.it.yaml
@@ -34,11 +34,6 @@ variables:
- name: "jira.jql"
value: "assignee=citrus"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml
index 4c1333fb..5d3a79a0 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-pipe.it.yaml
@@ -39,11 +39,6 @@ actions:
start:
redpanda: {}
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-pipe.it.yaml
index 1223054b..2c9baa4f 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-pipe.it.yaml
@@ -37,11 +37,6 @@ actions:
start:
redpanda: {}
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml
index 10bb7c2a..65afcdd6 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-pipe.it.yaml
@@ -39,11 +39,6 @@ actions:
start:
redpanda: {}
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-add-pet.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-add-pet.it.yaml
index 33ea6aa0..b3363a68 100644
---
a/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-add-pet.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-add-pet.it.yaml
@@ -26,11 +26,6 @@ variables:
- name: "openApiSpec"
value: "citrus:readFile(openapi/openapi.json)"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-delete-pet.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-delete-pet.it.yaml
index da2d7d42..aab3f378 100644
---
a/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-delete-pet.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/openapi/rest-openapi-sink-delete-pet.it.yaml
@@ -26,11 +26,6 @@ variables:
- name: "openApiSpec"
value: "citrus:readFile(openapi/openapi.json)"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/slack/slack-sink-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/slack/slack-sink-pipe.it.yaml
index cbf6eddc..1b1c259b 100644
---
a/tests/camel-kamelets-itest/src/test/resources/slack/slack-sink-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/slack/slack-sink-pipe.it.yaml
@@ -32,11 +32,6 @@ variables:
- name: "timer.source.period"
value: "10000"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/slack/slack-source-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/slack/slack-source-pipe.it.yaml
index 0749806c..e1b42d00 100644
---
a/tests/camel-kamelets-itest/src/test/resources/slack/slack-source-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/slack/slack-source-pipe.it.yaml
@@ -30,11 +30,6 @@ variables:
- name: "slack.message"
value: "Camel rocks!"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http-pipe.it.yaml
index aae896c1..41816072 100644
---
a/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http-pipe.it.yaml
@@ -22,11 +22,6 @@ variables:
- name: "timer.message"
value: "Camel rocks!"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http.it.yaml
index 9d723ba8..4f4753e3 100644
--- a/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http.it.yaml
+++ b/tests/camel-kamelets-itest/src/test/resources/timer/timer-to-http.it.yaml
@@ -22,11 +22,6 @@ variables:
- name: "timer.message"
value: "Camel rocks!"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/transformation/data-type-action-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/transformation/data-type-action-pipe.it.yaml
index 4ef771d1..f7d67927 100644
---
a/tests/camel-kamelets-itest/src/test/resources/transformation/data-type-action-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/transformation/data-type-action-pipe.it.yaml
@@ -22,11 +22,6 @@ variables:
- name: "uuid"
value: "citrus:randomUUID()"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/transformation/extract-field-action-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/transformation/extract-field-action-pipe.it.yaml
index a6176264..70705893 100644
---
a/tests/camel-kamelets-itest/src/test/resources/transformation/extract-field-action-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/transformation/extract-field-action-pipe.it.yaml
@@ -24,11 +24,6 @@ variables:
- name: "field.value"
value: "Camel rocks!"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/transformation/insert-field-action-pipe.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/transformation/insert-field-action-pipe.it.yaml
index 7a83d95d..9fb0c677 100644
---
a/tests/camel-kamelets-itest/src/test/resources/transformation/insert-field-action-pipe.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/transformation/insert-field-action-pipe.it.yaml
@@ -26,11 +26,6 @@ variables:
- name: "field.name"
value: "subject"
actions:
- # Purge Http service
- - purge:
- endpoints:
- - name: "httpServer"
-
# Create Camel JBang integration
- camel:
jbang: