From 8c545b71ad13bbba3ee4c631905d6e9b7f90df65 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 24 Feb 2024 18:57:12 +0100 Subject: [PATCH] WIP:wait --- .../kafka/chat/backend/KafkaHandoverIT.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java b/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java index 2637b9e7..df530b5a 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java @@ -4,8 +4,10 @@ import de.juplo.kafka.chat.backend.api.ChatRoomInfoTo; import de.juplo.kafka.chat.backend.api.MessageTo; import lombok.EqualsAndHashCode; import lombok.Getter; +import lombok.Setter; import lombok.ToString; import lombok.extern.slf4j.Slf4j; +import org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -104,6 +106,28 @@ class KafkaHandoverIT extends AbstractHandoverIT { Integer port = HAPROXY.getMappedPort(8400); webClient = WebClient.create("http://localhost:" + port); + + Awaitility + .await() + .until(() -> webClient + .get() + .uri("/actuator/health") + .exchangeToMono(response -> + { + if (response.statusCode().equals(HttpStatus.OK)) + { + return response.bodyToMono(StatusTo.class); + } + else + { + return response.createError(); + } + }) + .map(StatusTo::getStatus) + .map(status -> status.equalsIgnoreCase("UP")) + .block()); + + log.info("Some backend was UP"); } WebClient webClient; @@ -254,4 +278,11 @@ class KafkaHandoverIT extends AbstractHandoverIT return ++serial; } } + + @Getter + @Setter + static class StatusTo + { + String status; + } } -- 2.20.1