test: HandoverIT-POC - Each `TestWriter` writes only to one chat-room
authorKai Moritz <kai@juplo.de>
Fri, 1 Mar 2024 13:05:11 +0000 (14:05 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 1 Mar 2024 13:07:45 +0000 (14:07 +0100)
src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java
src/test/java/de/juplo/kafka/chat/backend/TestWriter.java

index 0fd10d6..41d9e49 100644 (file)
@@ -52,7 +52,7 @@ public abstract class AbstractHandoverIT
         .range(0, NUM_CLIENTS)
         .map(i -> new TestWriter(
             port,
-            chatRooms,
+            chatRooms[i % NUM_CHATROOMS],
             "user-" + Integer.toString(i)))
         .doOnNext(testClient -> executorService.execute(testClient))
         .toStream()
index 076376e..929d84f 100644 (file)
@@ -24,7 +24,7 @@ public class TestWriter implements Runnable
     for (int i = 0; running; i++)
     {
       String message = "Message #" + i;
-      for (ChatRoomInfoTo chatRoom : chatRooms)
+      try
       {
         sendMessage(chatRoom, message)
             .retryWhen(Retry.fixedDelay(10, Duration.ofSeconds(1)))
@@ -39,9 +39,7 @@ public class TestWriter implements Runnable
                 user,
                 chatRoom,
                 result));
-      }
-      try
-      {
+
         Thread.sleep(ThreadLocalRandom.current().nextLong(700, 1000));
       }
       catch (Exception e)
@@ -80,16 +78,16 @@ public class TestWriter implements Runnable
 
 
   private final WebClient webClient;
-  private final ChatRoomInfoTo[] chatRooms;
+  private final ChatRoomInfoTo chatRoom;
   private final User user;
 
   volatile boolean running = true;
 
 
-  TestWriter(Integer port, ChatRoomInfoTo[] chatRooms, String username)
+  TestWriter(Integer port, ChatRoomInfoTo chatRoom, String username)
   {
     webClient = WebClient.create("http://localhost:" + port);
-    this.chatRooms = chatRooms;
+    this.chatRoom = chatRoom;
     user = new User(username);
   }
 }