From 84ac08c566270986e8de41785d0c62eac3eba7b6 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 28 Feb 2024 10:09:56 +0100 Subject: [PATCH] test: HandoverIT-POC - Clients are stopped after some time --- .../de/juplo/kafka/chat/backend/AbstractHandoverIT.java | 7 ++++++- src/test/java/de/juplo/kafka/chat/backend/TestClient.java | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java b/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java index a2803479..18e15b40 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java @@ -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; @@ -58,9 +59,13 @@ public abstract class AbstractHandoverIT Thread.sleep(2000); + Arrays + .stream(testClients) + .forEach(testClient -> testClient.running = false); + Flux .fromArray(chatRooms) - .flatMap(chatRoom ->receiveMessages(chatRoom).take(100)) + .flatMap(chatRoom ->receiveMessages(chatRoom).take(2)) .doOnNext(message -> log.info("message: {}", message)) .then() .block(); diff --git a/src/test/java/de/juplo/kafka/chat/backend/TestClient.java b/src/test/java/de/juplo/kafka/chat/backend/TestClient.java index 964a06ba..524c297c 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/TestClient.java +++ b/src/test/java/de/juplo/kafka/chat/backend/TestClient.java @@ -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) { -- 2.20.1