From: Kai Moritz Date: Wed, 28 Feb 2024 09:09:56 +0000 (+0100) Subject: test: HandoverIT-POC - Clients are stopped after some time X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=84ac08c566270986e8de41785d0c62eac3eba7b6;p=demos%2Fkafka%2Fchat test: HandoverIT-POC - Clients are stopped after some time --- 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) {