From debfc2ee1b77b138f2f675881e2b7aee8643876d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 22 Feb 2024 21:46:10 +0100 Subject: [PATCH] WIP:neu --- .../kafka/chat/backend/KafkaHandoverIT.java | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java b/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java index fbad99f5..3146db18 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java @@ -34,44 +34,51 @@ class KafkaHandoverIT extends AbstractHandoverIT @Container - KafkaContainer kafka = + KafkaContainer KAFKA = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.0")) .withNetwork(network) .withNetworkAliases("kafka") - .withKraft(); + .withKraft() + .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("KAFKA")); @Container - GenericContainer backend1 = + GenericContainer BACKEND_1 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) .withImagePullPolicy(NEVER_PULL) .withNetwork(network) .withNetworkAliases("backend-1") .withCommand( + "--chat.backend.instance-id=backend-1", "--chat.backend.services=kafka", "--chat.backend.kafka.bootstrap-servers=kafka:9102" - ); + ) + .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("BACKEND-1")); @Container - GenericContainer backend2 = + GenericContainer BACKEND_2 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) .withImagePullPolicy(NEVER_PULL) .withNetwork(network) .withNetworkAliases("backend-2") .withCommand( + "--chat.backend.instance-id=backend-2", "--chat.backend.services=kafka", "--chat.backend.kafka.bootstrap-servers=kafka:9102" - ); + ) + .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("BACKEND-2")); @Container - GenericContainer backend3 = + GenericContainer BACKEND_3 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) .withImagePullPolicy(NEVER_PULL) .withNetwork(network) .withNetworkAliases("backend-3") .withCommand( + "--chat.backend.instance-id=backend-3", "--chat.backend.services=kafka", "--chat.backend.kafka.bootstrap-servers=kafka:9102" - ); + ) + .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("BACKEND-3")); @BeforeAll @@ -82,18 +89,6 @@ class KafkaHandoverIT extends AbstractHandoverIT @Test void test() throws InterruptedException { - Thread.sleep(60000); - } - - - @BeforeEach - void setUpLogging() - { - Slf4jLogConsumer logConsumer1 = new Slf4jLogConsumer(log, true).withPrefix("BACKEND-1"); - backend1.followOutput(logConsumer1); - Slf4jLogConsumer logConsumer2 = new Slf4jLogConsumer(log, true).withPrefix("BACKEND-2"); - backend2.followOutput(logConsumer2); - Slf4jLogConsumer logConsumer3 = new Slf4jLogConsumer(log, true).withPrefix("BACKEND-3"); - backend2.followOutput(logConsumer3); + Thread.sleep(15000); } } -- 2.20.1