WIP:neu
authorKai Moritz <kai@juplo.de>
Thu, 22 Feb 2024 20:46:10 +0000 (21:46 +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 fbad99f..3146db1 100644 (file)
@@ -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);
   }
 }