From: Kai Moritz Date: Sat, 24 Feb 2024 17:57:12 +0000 (+0100) Subject: WIP:wait X-Git-Tag: rebase--2024-02-26--19-46~14 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=8c545b71ad13bbba3ee4c631905d6e9b7f90df65;p=demos%2Fkafka%2Fchat WIP:wait --- 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; + } }