use of com.hotels.styx.api.Id in project styx by ExpediaGroup.
the class HttpErrorStatusMetricsTest method backendFaultArgs.
private static Stream<Arguments> backendFaultArgs() {
Id appId = Id.id("fakeApp");
Id originId = Id.id("fakeApp1");
Origin origin = Origin.newOriginBuilder("fakeHost", 9999).applicationId(appId).id(originId.toString()).build();
Exception cause = new Exception();
return Stream.of(Arguments.of(new NoAvailableHostsException(appId), "noHostsLiveForApplication"), Arguments.of(new OriginUnreachableException(origin, cause), "cannotConnect"), Arguments.of(new BadHttpResponseException(origin, cause), "badHttpResponse"), Arguments.of(new MaxPendingConnectionTimeoutException(origin, 1), "connectionsHeldTooLong"), Arguments.of(new MaxPendingConnectionsExceededException(origin, 1, 1), "tooManyConnections"), Arguments.of(new ResponseTimeoutException(origin, "test", 1, 1, 1, 1), "responseTooSlow"));
}
use of com.hotels.styx.api.Id in project styx by ExpediaGroup.
the class OriginsInventoryHandlerTest method respondsWithCorrectSnapshot.
@Test
public void respondsWithCorrectSnapshot() throws IOException {
EventBus eventBus = new EventBus();
OriginsInventoryHandler handler = new OriginsInventoryHandler(eventBus);
Set<Origin> activeOrigins = generateOrigins(3);
Set<Origin> inactiveOrigins = generateOrigins(4);
Set<Origin> disabledOrigins = generateOrigins(2);
eventBus.post(new OriginsSnapshot(APP_ID, pool(activeOrigins), pool(inactiveOrigins), pool(disabledOrigins)));
HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
assertThat(response.bodyAs(UTF_8).split("\n").length, is(1));
Map<Id, OriginsSnapshot> output = deserialiseJson(response.bodyAs(UTF_8));
assertThat(output.keySet(), contains(APP_ID));
OriginsSnapshot snapshot = output.get(APP_ID);
assertThat(snapshot.appId(), is(APP_ID));
assertThat(snapshot.activeOrigins(), is(activeOrigins));
assertThat(snapshot.inactiveOrigins(), is(inactiveOrigins));
assertThat(snapshot.disabledOrigins(), is(disabledOrigins));
}
Aggregations