use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MetricsHandlerTest method exposesRegisteredMetrics.
@Disabled
@Test
public void exposesRegisteredMetrics() {
metricRegistry.counter("foo").inc();
HttpResponse response = Mono.from(handler.handle(get("/admin/metrics").build(), requestContext())).block();
assertThat(response.bodyAs(UTF_8), matchesRegex(quote("{\"version\":\"") + "\\d+\\.\\d+\\.\\d+" + quote("\",\"gauges\":{},\"counters\":{\"foo\":{\"count\":1}},\"histograms\":{},\"meters\":{},\"timers\":{}}")));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MetricsHandlerTest method canRequestMetricsBeginningWithPrefixAndSearchForTermTogether.
@Test
public void canRequestMetricsBeginningWithPrefixAndSearchForTermTogether() {
metricRegistry.counter("foo.bar.a").inc(1);
metricRegistry.counter("foo.bar.b").inc(1);
metricRegistry.counter("baz.bar.foo").inc(1);
metricRegistry.counter("foo.baz.a").inc(1);
metricRegistry.counter("foo.baz.a.bar").inc(1);
HttpResponse response = Mono.from(handler.handle(get("/admin/metrics/foo?filter=bar").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.bodyAs(UTF_8), is("{" + "\"foo.bar.a\":{\"count\":1}," + "\"foo.bar.b\":{\"count\":1}," + "\"foo.baz.a.bar\":{\"count\":1}" + "}"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MetricsHandlerTest method ifNoMetricsMatchNameThen404NotFoundIsReturned.
@Test
public void ifNoMetricsMatchNameThen404NotFoundIsReturned() {
HttpResponse response = Mono.from(handler.handle(get("/admin/metrics/foo.bar").build(), requestContext())).block();
assertThat(response.status(), is(NOT_FOUND));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MetricsHandlerTest method respondsToRequestWithJsonResponse.
@Test
public void respondsToRequestWithJsonResponse() {
HttpResponse response = Mono.from(handler.handle(get("/admin/metrics").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.contentType().get(), is(APPLICATION_JSON.toString()));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class OriginsHandlerTest method healthCheckIsAbsentWhenNotConfigured.
@Test
public void healthCheckIsAbsentWhenNotConfigured() throws IOException {
String originsFile = fixturesHome() + "conf/origins/origins-for-jsontest-no-healthcheck.yml";
Iterable<BackendService> expected = loadFromPath(originsFile).get();
withOriginsHandler(originsFile, handler -> {
HttpResponse response = Mono.from(handler.handle(get("/admin/configuration/origins").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.contentType(), isValue(APPLICATION_JSON));
String body = response.bodyAs(UTF_8);
assertThat(body, not(containsString("healthCheck")));
Iterable<BackendService> result = newBackendServices(unmarshalApplications(body));
assertThat(result, is(expected));
});
}
Aggregations