Search in sources :

Example 1 with BackendServices

use of com.hotels.styx.applications.BackendServices in project styx by ExpediaGroup.

the class DashboardDataTest method providesBackendTotalConnections.

@Test
public void providesBackendTotalConnections() {
    BackendServices backendServices = newBackendServices(application("app", origin("app-01", "localhost", 9090), origin("app-02", "localhost", 9091)));
    MemoryBackedRegistry<BackendService> backendServicesRegistry = new MemoryBackedRegistry<>();
    backendServices.forEach(backendServicesRegistry::add);
    metricRegistry.register("origins.app.app-01.connectionspool.available-connections", gauge(100));
    metricRegistry.register("origins.app.app-01.connectionspool.busy-connections", gauge(300));
    metricRegistry.register("origins.app.app-01.connectionspool.pending-connections", gauge(500));
    metricRegistry.register("origins.app.app-02.connectionspool.available-connections", gauge(200));
    metricRegistry.register("origins.app.app-02.connectionspool.busy-connections", gauge(400));
    metricRegistry.register("origins.app.app-02.connectionspool.pending-connections", gauge(600));
    DashboardData.Backend backend = newDashboardData(backendServicesRegistry).downstream().firstBackend();
    DashboardData.ConnectionsPoolsAggregate connectionsPool = backend.totalConnections();
    assertThat(connectionsPool.available(), is(300));
    assertThat(connectionsPool.busy(), is(700));
    assertThat(connectionsPool.pending(), is(1100));
}
Also used : BackendService(com.hotels.styx.api.extension.service.BackendService) BackendServices(com.hotels.styx.applications.BackendServices) BackendServices.newBackendServices(com.hotels.styx.applications.BackendServices.newBackendServices) MemoryBackedRegistry(com.hotels.styx.infrastructure.MemoryBackedRegistry) Test(org.junit.jupiter.api.Test)

Example 2 with BackendServices

use of com.hotels.styx.applications.BackendServices in project styx by ExpediaGroup.

the class DashboardDataTest method providesBackendStatuses.

@Test
public void providesBackendStatuses() {
    BackendServices backendServices = newBackendServices(application("app", origin("app-01", "localhost", 9090), origin("app-02", "localhost", 9091)));
    MemoryBackedRegistry<BackendService> backendServicesRegistry = new MemoryBackedRegistry<>();
    backendServices.forEach(backendServicesRegistry::add);
    DashboardData.Backend backend = newDashboardData(backendServicesRegistry).downstream().firstBackend();
    eventBus.post(new OriginsSnapshot(id("app"), singleton(pool(origin("app", "app-01", "localhost", 9090))), emptyList(), singleton(pool(origin("app", "app-02", "localhost", 9091)))));
    assertThat(backend.statuses(), containsInAnyOrder("active", "disabled"));
}
Also used : BackendService(com.hotels.styx.api.extension.service.BackendService) BackendServices(com.hotels.styx.applications.BackendServices) BackendServices.newBackendServices(com.hotels.styx.applications.BackendServices.newBackendServices) MemoryBackedRegistry(com.hotels.styx.infrastructure.MemoryBackedRegistry) OriginsSnapshot(com.hotels.styx.api.extension.OriginsSnapshot) Test(org.junit.jupiter.api.Test)

Aggregations

BackendService (com.hotels.styx.api.extension.service.BackendService)2 BackendServices (com.hotels.styx.applications.BackendServices)2 BackendServices.newBackendServices (com.hotels.styx.applications.BackendServices.newBackendServices)2 MemoryBackedRegistry (com.hotels.styx.infrastructure.MemoryBackedRegistry)2 Test (org.junit.jupiter.api.Test)2 OriginsSnapshot (com.hotels.styx.api.extension.OriginsSnapshot)1