Search in sources :

Example 1 with HEALTHY

use of com.hotels.styx.client.healthcheck.OriginHealthCheckFunction.OriginState.HEALTHY in project styx by ExpediaGroup.

the class UrlRequestHealthCheckTest method declaresOriginHealthyOnOkResponseCode.

@Test
public void declaresOriginHealthyOnOkResponseCode() {
    HttpClient client = request -> respondWith(OK);
    new UrlRequestHealthCheck("/version.txt", metrics).check(client, someOrigin, state -> this.originState = state);
    assertThat(originState, is(HEALTHY));
    assertThat(meters(id -> id.getName().equals("proxy.client.originHealthCheckFailures")).size(), is(0));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) HttpResponse(com.hotels.styx.api.HttpResponse) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) OriginState(com.hotels.styx.client.healthcheck.OriginHealthCheckFunction.OriginState) Predicate(java.util.function.Predicate) HttpResponse.response(com.hotels.styx.api.HttpResponse.response) NOT_FOUND(com.hotels.styx.api.HttpResponseStatus.NOT_FOUND) Origin.newOriginBuilder(com.hotels.styx.api.extension.Origin.newOriginBuilder) Meter(io.micrometer.core.instrument.Meter) CompletableFuture(java.util.concurrent.CompletableFuture) HttpClient(com.hotels.styx.client.HttpClient) HttpResponseStatus(com.hotels.styx.api.HttpResponseStatus) Collectors(java.util.stream.Collectors) UNHEALTHY(com.hotels.styx.client.healthcheck.OriginHealthCheckFunction.OriginState.UNHEALTHY) Test(org.junit.jupiter.api.Test) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Origin(com.hotels.styx.api.extension.Origin) OK(com.hotels.styx.api.HttpResponseStatus.OK) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) Matchers.is(org.hamcrest.Matchers.is) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HEALTHY(com.hotels.styx.client.healthcheck.OriginHealthCheckFunction.OriginState.HEALTHY) HttpClient(com.hotels.styx.client.HttpClient) Test(org.junit.jupiter.api.Test)

Aggregations

HttpResponse (com.hotels.styx.api.HttpResponse)1 HttpResponse.response (com.hotels.styx.api.HttpResponse.response)1 HttpResponseStatus (com.hotels.styx.api.HttpResponseStatus)1 NOT_FOUND (com.hotels.styx.api.HttpResponseStatus.NOT_FOUND)1 OK (com.hotels.styx.api.HttpResponseStatus.OK)1 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)1 Origin (com.hotels.styx.api.extension.Origin)1 Origin.newOriginBuilder (com.hotels.styx.api.extension.Origin.newOriginBuilder)1 HttpClient (com.hotels.styx.client.HttpClient)1 OriginState (com.hotels.styx.client.healthcheck.OriginHealthCheckFunction.OriginState)1 HEALTHY (com.hotels.styx.client.healthcheck.OriginHealthCheckFunction.OriginState.HEALTHY)1 UNHEALTHY (com.hotels.styx.client.healthcheck.OriginHealthCheckFunction.OriginState.UNHEALTHY)1 CentralisedMetrics (com.hotels.styx.metrics.CentralisedMetrics)1 Meter (io.micrometer.core.instrument.Meter)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1