From: Kai Moritz Date: Thu, 22 Feb 2024 20:40:17 +0000 (+0100) Subject: WIP:neu X-Git-Tag: rebase--2024-02-26--19-46~33 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=1e5390c4e017bc82d466c27d9f5131318ed95aec;p=demos%2Fkafka%2Fchat WIP:neu --- 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 09505768..fbad99f5 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java @@ -17,6 +17,7 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.test.context.EmbeddedKafka; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.containers.Network; import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.images.ImagePullPolicy; import org.testcontainers.junit.jupiter.Container; @@ -29,9 +30,13 @@ import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.INFO_TOPIC; @Slf4j class KafkaHandoverIT extends AbstractHandoverIT { + Network network = Network.newNetwork(); + + @Container KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.0")) + .withNetwork(network) .withNetworkAliases("kafka") .withKraft(); @@ -39,6 +44,7 @@ class KafkaHandoverIT extends AbstractHandoverIT GenericContainer backend1 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) .withImagePullPolicy(NEVER_PULL) + .withNetwork(network) .withNetworkAliases("backend-1") .withCommand( "--chat.backend.services=kafka", @@ -49,6 +55,7 @@ class KafkaHandoverIT extends AbstractHandoverIT GenericContainer backend2 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) .withImagePullPolicy(NEVER_PULL) + .withNetwork(network) .withNetworkAliases("backend-2") .withCommand( "--chat.backend.services=kafka", @@ -59,6 +66,7 @@ class KafkaHandoverIT extends AbstractHandoverIT GenericContainer backend3 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) .withImagePullPolicy(NEVER_PULL) + .withNetwork(network) .withNetworkAliases("backend-3") .withCommand( "--chat.backend.services=kafka", @@ -72,16 +80,20 @@ class KafkaHandoverIT extends AbstractHandoverIT } @Test - void test() + void test() throws InterruptedException { - + Thread.sleep(60000); } @BeforeEach void setUpLogging() { - Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log); - backend1.followOutput(logConsumer); + 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); } }