This is an automated email from the ASF dual-hosted git repository.
christophd 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 6691af2da chore: use Citrus autoClose for Kafka endpoints in tests
6691af2da is described below
commit 6691af2da877bfdfcb1b41d70f3362cd683475b2
Author: Christoph Deppisch <[email protected]>
AuthorDate: Fri Nov 20 09:37:01 2026 +0100
chore: use Citrus autoClose for Kafka endpoints in tests
Reliably close Kafka producer/consumer instances via Citrus autoClose
instead of manual teardown in KafkaIT. This avoids logs being flushed
with connection errors once the testcontainer is stopped.
Also renames the Ceph S3 event-based test files to follow the aws-s3-*
naming convention.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
.../src/test/java/KafkaIT.java | 39 +---------------------
...h-event-based-source-get-object.citrus.it.yaml} | 9 ++---
...aws-s3-ceph-event-based-source-get-object.yaml} | 0
.../kafka/kafka-batch-source-route.citrus.it.yaml | 1 +
...kafka-manual-commit-action-route.citrus.it.yaml | 1 +
.../kafka/kafka-router-route.citrus.it.yaml | 1 +
.../kafka/kafka-sink-route.citrus.it.yaml | 1 +
.../kafka/kafka-source-route.citrus.it.yaml | 1 +
8 files changed, 11 insertions(+), 42 deletions(-)
diff --git a/tests/camel-kamelets-itest/src/test/java/KafkaIT.java
b/tests/camel-kamelets-itest/src/test/java/KafkaIT.java
index a80e53a33..306313d9a 100644
--- a/tests/camel-kamelets-itest/src/test/java/KafkaIT.java
+++ b/tests/camel-kamelets-itest/src/test/java/KafkaIT.java
@@ -17,17 +17,13 @@
import java.util.stream.Stream;
-import org.citrusframework.TestAction;
-import org.citrusframework.api.common.ShutdownPhase;
import org.citrusframework.api.common.TestLoader;
import org.citrusframework.container.SequenceAfterTest;
import org.citrusframework.container.SequenceBeforeTest;
-import org.citrusframework.endpoint.Endpoint;
import org.citrusframework.http.server.HttpServer;
import org.citrusframework.junit.jupiter.CitrusSupport;
import org.citrusframework.junit.jupiter.CitrusTestFactory;
import org.citrusframework.junit.jupiter.CitrusTestFactorySupport;
-import org.citrusframework.kafka.endpoint.KafkaEndpoint;
import org.citrusframework.spi.BindToRegistry;
import org.citrusframework.util.SocketUtils;
import org.junit.jupiter.api.DynamicTest;
@@ -62,43 +58,10 @@ public class KafkaIT {
@BindToRegistry
public SequenceAfterTest afterKafka() {
return new SequenceAfterTest.Builder().onTests("kafka-*").actions(
- purgeEndpoints().endpoint(kafkaSinkServer),
- this::stopKafkaConsumers
+ purgeEndpoints().endpoint(kafkaSinkServer)
).build();
}
- @BindToRegistry
- public TestAction stopKafkaConsumers() {
- return context -> {
- try {
- Endpoint endpoint =
context.getEndpointFactory().create("kafkaRouterConsumer", context);
- if (endpoint instanceof ShutdownPhase destroyable) {
- destroyable.destroy();
- }
- } catch (Exception e) {
- // ignore
- }
-
- try {
- Endpoint endpoint =
context.getEndpointFactory().create("kafkaSinkConsumer", context);
- if (endpoint instanceof ShutdownPhase destroyable) {
- destroyable.destroy();
- }
- } catch (Exception e) {
- // ignore
- }
-
- try {
- Endpoint endpoint =
context.getEndpointFactory().create("kafkaProducer", context);
- if (endpoint instanceof KafkaEndpoint kafkaEndpoint) {
- kafkaEndpoint.createProducer().getProducer().close();
- }
- } catch (Exception e) {
- // ignore
- }
- };
- }
-
@CitrusTestFactory
public Stream<DynamicTest> kafka() {
return
CitrusTestFactorySupport.factory(TestLoader.YAML).packageScan("kafka");
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/ceph-event-based-source-get-object.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.citrus.it.yaml
similarity index 93%
rename from
tests/camel-kamelets-itest/src/test/resources/aws/s3/ceph-event-based-source-get-object.citrus.it.yaml
rename to
tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.citrus.it.yaml
index 62c079e19..f8ae399f0 100644
---
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/ceph-event-based-source-get-object.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.citrus.it.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
# ---------------------------------------------------------------------------
-name: ceph-event-based-source-get-object-test
+name: aws-s3-ceph-event-based-source-get-object-test
variables:
- name: "aws.s3.bucketNameOrArn"
value: "bucket-ceph-events"
@@ -61,7 +61,7 @@ actions:
cli:
run:
integration:
- file: "aws/s3/ceph-event-based-source-get-object.yaml"
+ file: "aws/s3/aws-s3-ceph-event-based-source-get-object.yaml"
systemProperties:
properties:
- name: "kafka.topic"
@@ -81,6 +81,7 @@ actions:
- createEndpoint:
name: cephEventsProducer
type: "kafka"
+ autoClose: true
properties:
topic: "${kafka.topic}"
server: "${CITRUS_TESTCONTAINERS_REDPANDA_BOOTSTRAP_SERVERS}"
@@ -99,10 +100,10 @@ actions:
- camel:
cli:
verify:
- integration: "ceph-event-based-source-get-object"
+ integration: "aws-s3-ceph-event-based-source-get-object"
logMessage: "Read dir/my file+x=1.txt: Content of the first file"
- camel:
cli:
verify:
- integration: "ceph-event-based-source-get-object"
+ integration: "aws-s3-ceph-event-based-source-get-object"
logMessage: "Read reports/a&b=c.txt: Content of the second file"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/aws/s3/ceph-event-based-source-get-object.yaml
b/tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.yaml
similarity index 100%
rename from
tests/camel-kamelets-itest/src/test/resources/aws/s3/ceph-event-based-source-get-object.yaml
rename to
tests/camel-kamelets-itest/src/test/resources/aws/s3/aws-s3-ceph-event-based-source-get-object.yaml
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-batch-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-batch-source-route.citrus.it.yaml
index 50ac57e10..9ac822fb1 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-batch-source-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-batch-source-route.citrus.it.yaml
@@ -27,6 +27,7 @@ actions:
- createEndpoint:
name: kafka-batch-source-route-producer
type: "kafka"
+ autoClose: true
properties:
topic: "${kafka.topic}"
server: "${CITRUS_TESTCONTAINERS_REDPANDA_BOOTSTRAP_SERVERS}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-manual-commit-action-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-manual-commit-action-route.citrus.it.yaml
index 704fb8ba6..d8aa9b140 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-manual-commit-action-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-manual-commit-action-route.citrus.it.yaml
@@ -47,6 +47,7 @@ actions:
- createEndpoint:
name: kafka-manual-commit-action-route-producer
type: "kafka"
+ autoClose: true
properties:
topic: "${kafka.topic}"
server: "${CITRUS_TESTCONTAINERS_REDPANDA_BOOTSTRAP_SERVERS}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-route.citrus.it.yaml
index b40519bdc..9b6f807c1 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-router-route.citrus.it.yaml
@@ -63,6 +63,7 @@ actions:
- createEndpoint:
name: kafkaRouterConsumer
type: "kafka"
+ autoClose: true
properties:
topic: "${topic}"
server: "${CITRUS_TESTCONTAINERS_REDPANDA_BOOTSTRAP_SERVERS}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-route.citrus.it.yaml
index 67938e3f9..5edbe93bc 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-sink-route.citrus.it.yaml
@@ -47,6 +47,7 @@ actions:
- createEndpoint:
name: kafkaSinkConsumer
type: "kafka"
+ autoClose: true
properties:
topic: "${kafka.topic}"
server: "${CITRUS_TESTCONTAINERS_REDPANDA_BOOTSTRAP_SERVERS}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-route.citrus.it.yaml
index 8e81659ba..29dff3e49 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafka/kafka-source-route.citrus.it.yaml
@@ -56,6 +56,7 @@ actions:
- createEndpoint:
name: kafkaProducer
type: "kafka"
+ autoClose: true
properties:
topic: "${kafka.topic}"
server: "${CITRUS_TESTCONTAINERS_REDPANDA_BOOTSTRAP_SERVERS}"