Search in sources :

Example 6 with Id

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"));
}
Also used : Origin(com.hotels.styx.api.extension.Origin) ResponseTimeoutException(com.hotels.styx.api.exceptions.ResponseTimeoutException) NoAvailableHostsException(com.hotels.styx.api.exceptions.NoAvailableHostsException) OriginUnreachableException(com.hotels.styx.api.exceptions.OriginUnreachableException) MaxPendingConnectionTimeoutException(com.hotels.styx.client.connectionpool.MaxPendingConnectionTimeoutException) MaxPendingConnectionsExceededException(com.hotels.styx.client.connectionpool.MaxPendingConnectionsExceededException) BadHttpResponseException(com.hotels.styx.client.BadHttpResponseException) Id(com.hotels.styx.api.Id) MaxPendingConnectionTimeoutException(com.hotels.styx.client.connectionpool.MaxPendingConnectionTimeoutException) NoAvailableHostsException(com.hotels.styx.api.exceptions.NoAvailableHostsException) PluginException(com.hotels.styx.api.plugins.spi.PluginException) OriginUnreachableException(com.hotels.styx.api.exceptions.OriginUnreachableException) ResponseTimeoutException(com.hotels.styx.api.exceptions.ResponseTimeoutException) MaxPendingConnectionsExceededException(com.hotels.styx.client.connectionpool.MaxPendingConnectionsExceededException) BadHttpResponseException(com.hotels.styx.client.BadHttpResponseException)

Example 7 with Id

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));
}
Also used : Origin(com.hotels.styx.api.extension.Origin) HttpResponse(com.hotels.styx.api.HttpResponse) EventBus(com.google.common.eventbus.EventBus) Id(com.hotels.styx.api.Id) OriginsSnapshot(com.hotels.styx.api.extension.OriginsSnapshot) Test(org.junit.jupiter.api.Test)

Aggregations

Id (com.hotels.styx.api.Id)7 Origin (com.hotels.styx.api.extension.Origin)5 Test (org.junit.jupiter.api.Test)5 Eventual (com.hotels.styx.api.Eventual)3 HttpHandler (com.hotels.styx.api.HttpHandler)3 GENERIC_APP (com.hotels.styx.api.Id.GENERIC_APP)3 NoAvailableHostsException (com.hotels.styx.api.exceptions.NoAvailableHostsException)3 OriginUnreachableException (com.hotels.styx.api.exceptions.OriginUnreachableException)3 RemoteHost (com.hotels.styx.api.extension.RemoteHost)3 RemoteHost.remoteHost (com.hotels.styx.api.extension.RemoteHost.remoteHost)3 BackendService (com.hotels.styx.api.extension.service.BackendService)3 CentralisedMetrics (com.hotels.styx.metrics.CentralisedMetrics)3 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)3 Mockito.mock (org.mockito.Mockito.mock)3 EventBus (com.google.common.eventbus.EventBus)2 HostAndPort (com.google.common.net.HostAndPort)2 HttpHeaderNames (com.hotels.styx.api.HttpHeaderNames)2 CHUNKED (com.hotels.styx.api.HttpHeaderNames.CHUNKED)2 CONTENT_LENGTH (com.hotels.styx.api.HttpHeaderNames.CONTENT_LENGTH)2 TRANSFER_ENCODING (com.hotels.styx.api.HttpHeaderNames.TRANSFER_ENCODING)2