WIP:neu
authorKai Moritz <kai@juplo.de>
Thu, 22 Feb 2024 20:40:17 +0000 (21:40 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 23 Feb 2024 15:40:03 +0000 (16:40 +0100)
src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java

index 0950576..fbad99f 100644 (file)
@@ -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);
   }
 }