You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by fm...@apache.org on 2023/06/27 10:12:52 UTC
[camel] branch main updated: Fix test and use single kafka instance
This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 18b93dca7a1 Fix test and use single kafka instance
18b93dca7a1 is described below
commit 18b93dca7a1d5f80bee198c197a13672baa53114
Author: Croway <fe...@gmail.com>
AuthorDate: Tue Jun 27 11:39:20 2023 +0200
Fix test and use single kafka instance
---
.../kafka/integration/health/KafkaConsumerHealthCheckIT.java | 12 +-----------
.../integration/health/KafkaHealthCheckTestSupport.java | 9 ++++++---
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaConsumerHealthCheckIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaConsumerHealthCheckIT.java
index f30ccdc0cb6..5f14ebc86f5 100644
--- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaConsumerHealthCheckIT.java
+++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaConsumerHealthCheckIT.java
@@ -30,10 +30,6 @@ import org.apache.camel.component.kafka.MockConsumerInterceptor;
import org.apache.camel.component.kafka.integration.common.KafkaTestUtil;
import org.apache.camel.health.HealthCheck;
import org.apache.camel.health.HealthCheckHelper;
-import org.apache.camel.test.infra.core.CamelContextExtension;
-import org.apache.camel.test.infra.core.DefaultCamelContextExtension;
-import org.apache.camel.test.infra.kafka.services.KafkaService;
-import org.apache.camel.test.infra.kafka.services.KafkaServiceFactory;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
@@ -48,7 +44,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,12 +62,6 @@ public class KafkaConsumerHealthCheckIT extends KafkaHealthCheckTestSupport {
public static final String PROPAGATED_CUSTOM_HEADER = "PropagatedCustomHeader";
public static final byte[] PROPAGATED_HEADER_VALUE = "propagated header value".getBytes();
- @Order(1)
- @RegisterExtension
- public static KafkaService service = KafkaServiceFactory.createService();
- @Order(2)
- @RegisterExtension
- public static CamelContextExtension contextExtension = new DefaultCamelContextExtension();
protected static AdminClient kafkaAdminClient;
private static final Logger LOG = LoggerFactory.getLogger(KafkaConsumerHealthCheckIT.class);
@@ -160,6 +149,7 @@ public class KafkaConsumerHealthCheckIT extends KafkaHealthCheckTestSupport {
CamelContext context = contextExtension.getContext();
// and shutdown Kafka which will make readiness report as DOWN
service.shutdown();
+ serviceShutdown = true;
// health-check liveness should be UP
final Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaHealthCheckTestSupport.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaHealthCheckTestSupport.java
index f3decba14b5..c8206f54d77 100644
--- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaHealthCheckTestSupport.java
+++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/health/KafkaHealthCheckTestSupport.java
@@ -55,6 +55,7 @@ abstract class KafkaHealthCheckTestSupport implements ConfigurableRoute, Configu
protected org.apache.kafka.clients.producer.KafkaProducer<String, String> producer;
@EndpointInject("mock:result")
protected MockEndpoint to;
+ protected boolean serviceShutdown = false;
@BeforeAll
public static void beforeClass() {
@@ -74,9 +75,11 @@ abstract class KafkaHealthCheckTestSupport implements ConfigurableRoute, Configu
@BeforeEach
public void before() {
- Properties props = KafkaTestUtil.getDefaultProperties(service);
- producer = new org.apache.kafka.clients.producer.KafkaProducer<>(props);
- MockConsumerInterceptor.recordsCaptured.clear();
+ if (!serviceShutdown) {
+ Properties props = KafkaTestUtil.getDefaultProperties(service);
+ producer = new org.apache.kafka.clients.producer.KafkaProducer<>(props);
+ MockConsumerInterceptor.recordsCaptured.clear();
+ }
}
@ContextFixture