test: HandoverIT-POC - clients are stopped after some time
authorKai Moritz <kai@juplo.de>
Wed, 28 Feb 2024 09:09:56 +0000 (10:09 +0100)
committerKai Moritz <kai@juplo.de>
Wed, 28 Feb 2024 09:09:56 +0000 (10:09 +0100)
src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java
src/test/java/de/juplo/kafka/chat/backend/TestClient.java

index a9148f0..743b9bb 100644 (file)
@@ -13,6 +13,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.util.Arrays;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.stream.IntStream;
@@ -57,6 +58,9 @@ public abstract class AbstractHandoverIT
         .toArray(size -> new TestClient[size]);
 
     Thread.sleep(10000);
+    Arrays
+        .stream(testClients)
+        .forEach(testClient -> testClient.running = false);
 
     Flux
         .fromArray(chatRooms)
index 964a06b..524c297 100644 (file)
@@ -19,7 +19,7 @@ public class TestClient implements Runnable
   @Override
   public void run()
   {
-    for (int i = 0; i < 100; i++)
+    for (int i = 0; running; i++)
     {
       String message = "Message #" + i;
       for (ChatRoomInfoTo chatRoom : chatRooms)
@@ -76,6 +76,8 @@ public class TestClient implements Runnable
   private final ChatRoomInfoTo[] chatRooms;
   private final User user;
 
+  volatile boolean running = true;
+
 
   TestClient(Integer port, ChatRoomInfoTo[] chatRooms, String username)
   {