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;
{
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;
return ++serial;
}
}
+
+ @Getter
+ @Setter
+ static class StatusTo
+ {
+ String status;
+ }
}