Search in sources :

Example 6 with Environment

use of com.hotels.styx.Environment in project styx by ExpediaGroup.

the class StyxServerComponentsTest method createsEnvironment.

@Test
public void createsEnvironment() {
    Configuration config = new Configuration.MapBackedConfiguration().set("foo", "abc").set("bar", "def");
    StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig(config)).build();
    Environment environment = components.environment();
    assertThat(environment.configuration().get("foo", String.class), isValue("abc"));
    assertThat(environment.configuration().get("bar", String.class), isValue("def"));
    assertThat(environment.eventBus(), is(notNullValue()));
    assertThat(environment.metricRegistry(), is(notNullValue()));
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) StyxConfig(com.hotels.styx.StyxConfig) Configuration(com.hotels.styx.api.configuration.Configuration) Environment(com.hotels.styx.Environment) Test(org.junit.jupiter.api.Test)

Example 7 with Environment

use of com.hotels.styx.Environment in project styx by ExpediaGroup.

the class PluginLoadingForStartupTest method appliesDefaultMetricsScopeForPlugins.

@Test
public void appliesDefaultMetricsScopeForPlugins() {
    String yaml = "" + "plugins:\n" + "  active: myPlugin, myAnotherPlugin\n" + "  all:\n" + "    myPlugin:\n" + "      factory:\n" + "        class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + "        classPath: " + FIXTURES_CLASS_PATH + "\n" + "      config:\n" + "        testConfiguration: test-foo-bar\n" + "    myAnotherPlugin:\n" + "      factory:\n" + "        class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + "        classPath: " + FIXTURES_CLASS_PATH + "\n" + "      config:\n" + "        testConfiguration: test-foo-bar\n";
    Environment environment = environment(yaml);
    PluginLoadingForStartup.loadPlugins(environment);
    assertThat(environment.meterRegistry().get("plugin.internal.myplugin.initialised").counter().count(), is(1D));
    assertThat(environment.meterRegistry().get("plugin.internal.myanotherplugin.initialised").counter().count(), is(1D));
    assertThat(environment.meterRegistry().get("plugin.internal.myPlugin.legacy").tags(Tags.of("attribute", "count", "metricSource", "dropwizard")).gauge().value(), is(1D));
    assertThat(environment.meterRegistry().get("plugin.internal.myAnotherPlugin.legacy").tags(Tags.of("attribute", "count", "metricSource", "dropwizard")).gauge().value(), is(1D));
    assertThat(environment.metricRegistry().counter("plugin.internal.myPlugin.legacy").getCount(), is(1L));
    assertThat(environment.metricRegistry().counter("plugin.internal.myAnotherPlugin.legacy").getCount(), is(1L));
}
Also used : Environment(com.hotels.styx.Environment) Test(org.junit.jupiter.api.Test)

Example 8 with Environment

use of com.hotels.styx.Environment in project styx by ExpediaGroup.

the class StaticPipelineBuilderTest method staticPipelineBuilderTest.

@BeforeEach
public void staticPipelineBuilderTest() {
    environment = new Environment.Builder().registry(new MicrometerRegistry(new SimpleMeterRegistry())).build();
    clientFactory = (backendService, originsInventory, originStatsFactory) -> (request, context) -> Mono.just(response(OK).build());
    registry = backendRegistry(newBackendServiceBuilder().origins(newOriginBuilder("localhost", 0).build()).path("/foo").build());
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Environment(com.hotels.styx.Environment) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Environment (com.hotels.styx.Environment)8 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)6 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Test (org.junit.jupiter.api.Test)4 StyxConfig (com.hotels.styx.StyxConfig)2 NamedPlugin (com.hotels.styx.proxy.plugin.NamedPlugin)2 NamedPlugin.namedPlugin (com.hotels.styx.proxy.plugin.NamedPlugin.namedPlugin)2 Eventual (com.hotels.styx.api.Eventual)1 HttpHandler (com.hotels.styx.api.HttpHandler)1 HttpInterceptor (com.hotels.styx.api.HttpInterceptor)1 Chain (com.hotels.styx.api.HttpInterceptor.Chain)1 OK (com.hotels.styx.api.HttpResponseStatus.OK)1 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)1 LiveHttpRequest.get (com.hotels.styx.api.LiveHttpRequest.get)1 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)1 LiveHttpResponse.response (com.hotels.styx.api.LiveHttpResponse.response)1 MeterRegistry (com.hotels.styx.api.MeterRegistry)1 Configuration (com.hotels.styx.api.configuration.Configuration)1 Origin (com.hotels.styx.api.extension.Origin)1