I have an issue getting an AsyncHealthCheck working;
@Readiness
@ApplicationScoped
public class CoreApiHealthCheck implements AsyncHealthCheck {
@RestClient
OqmCoreApiClientService oqmCoreApiClient;
@Override
public Uni<HealthCheckResponse> call() {
//fails with "The current thread cannot be blocked: vert.x-eventloop-thread-0"
HealthCheckResponseBuilder responseBuilder = HealthCheckResponse.named("OqmCoreApi");
return this.oqmCoreApiClient.getApiServerHealth()
.map((ObjectNode coreApiHealth) -> {
ObjectNode returned = this.oqmCoreApiClient.getApiServerHealth().await().indefinitely();
String status = returned.get("status").asText();
if(status.equalsIgnoreCase(HealthCheckResponse.Status.UP.name())){
responseBuilder.up();
} else {
responseBuilder.down();
}
return responseBuilder.build();
})
.onFailure().recoverWithItem(e -> {
return responseBuilder.down().withData("error", e.getMessage()).build();
})
;
}
}
This is the healthcheck I provide in my extension. The call this.oqmCoreApiClient.getApiServerHealth() returns a Uni, as I am using quarkus-rest-client-reactive. In my extension's test, I perform a simple healthcheck call:
public class CoreApiLibHealthCheckTest {
@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication()
.overrideConfigKey("quarkus."+Constants.CONFIG_ROOT_NAME + ".health.enabled", "true");
@Test
public void testDataSourceHealthCheckExclusion() {
ValidatableResponse response = RestAssured.when().get("/q/health")
.then();
System.out.println(response.extract().body().asPrettyString());
response.statusCode(200)
.body("status", CoreMatchers.equalTo("UP"));
}
}
Which comes back with:
{
"status": "DOWN",
"checks": [
{
"name": "OqmCoreApi",
"status": "DOWN",
"data": {
"error": "java.lang.IllegalStateException - The current thread cannot be blocked: vert.x-eventloop-thread-0"
}
}
]
}
It appears that the test server spun up has issues with reactive, what can I do to ensure it is using Reactive?