Search in sources :

Example 6 with MemoryBackedRegistry

use of com.hotels.styx.infrastructure.MemoryBackedRegistry 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)

Example 7 with MemoryBackedRegistry

use of com.hotels.styx.infrastructure.MemoryBackedRegistry in project styx by ExpediaGroup.

the class OriginsHandlerTest method respondsWithEmptyArrayWhenNoOrigins.

@Test
public void respondsWithEmptyArrayWhenNoOrigins() {
    Registry<BackendService> backendServicesRegistry = new MemoryBackedRegistry<>();
    OriginsHandler handler = new OriginsHandler(backendServicesRegistry);
    HttpResponse response = Mono.from(handler.handle(get("/admin/configuration/origins").build(), requestContext())).block();
    assertThat(response.status(), is(OK));
    assertThat(response.contentType(), isValue(APPLICATION_JSON));
    assertThat(response.bodyAs(UTF_8), is("[]"));
}
Also used : BackendService(com.hotels.styx.api.extension.service.BackendService) MemoryBackedRegistry(com.hotels.styx.infrastructure.MemoryBackedRegistry) HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Aggregations

MemoryBackedRegistry (com.hotels.styx.infrastructure.MemoryBackedRegistry)7 BackendService (com.hotels.styx.api.extension.service.BackendService)6 Test (org.junit.jupiter.api.Test)6 Origin (com.hotels.styx.api.extension.Origin)2 OriginsSnapshot (com.hotels.styx.api.extension.OriginsSnapshot)2 BackendServices (com.hotels.styx.applications.BackendServices)2 BackendServices.newBackendServices (com.hotels.styx.applications.BackendServices.newBackendServices)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 EventBus (com.google.common.eventbus.EventBus)1 Version (com.hotels.styx.Version)1 HttpResponse (com.hotels.styx.api.HttpResponse)1 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)1 Registry (com.hotels.styx.api.extension.service.spi.Registry)1 RegistryServiceAdapter (com.hotels.styx.infrastructure.RegistryServiceAdapter)1 StaticPipelineFactory (com.hotels.styx.routing.StaticPipelineFactory)1 StyxServerComponents (com.hotels.styx.startup.StyxServerComponents)1 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)1