Search in sources :

Example 1 with HealthCheckConfig

use of com.hotels.styx.api.extension.service.HealthCheckConfig in project styx by ExpediaGroup.

the class OriginHealthStatusMonitorFactoryTest method createsNoOpMonitorForAbsentHealthCheckUri.

@Test
public void createsNoOpMonitorForAbsentHealthCheckUri() {
    HealthCheckConfig healthCheckConfig = newHealthCheckConfigBuilder().build();
    assertThat(factory.create(id, healthCheckConfig, null, null), is(instanceOf(NoOriginHealthStatusMonitor.class)));
}
Also used : HealthCheckConfig(com.hotels.styx.api.extension.service.HealthCheckConfig) Test(org.junit.jupiter.api.Test)

Example 2 with HealthCheckConfig

use of com.hotels.styx.api.extension.service.HealthCheckConfig in project styx by ExpediaGroup.

the class OriginHealthStatusMonitorFactoryTest method createsScheduledOriginStatusMonitor.

@Test
public void createsScheduledOriginStatusMonitor() {
    HealthCheckConfig healthCheckConfig = newHealthCheckConfigBuilder().uri("/version.txt").interval(5, MILLISECONDS).build();
    OriginHealthCheckFunction checkFunction = (client, origin, callback) -> {
    };
    assertThat(factory.create(id, healthCheckConfig, () -> checkFunction, mock(HttpClient.class)), is(instanceOf(AnomalyExcludingOriginHealthStatusMonitor.class)));
}
Also used : HealthCheckConfig.newHealthCheckConfigBuilder(com.hotels.styx.api.extension.service.HealthCheckConfig.newHealthCheckConfigBuilder) IsInstanceOf.instanceOf(org.hamcrest.core.IsInstanceOf.instanceOf) GENERIC_APP(com.hotels.styx.api.Id.GENERIC_APP) HttpClient(com.hotels.styx.client.HttpClient) NoOriginHealthStatusMonitor(com.hotels.styx.client.healthcheck.monitors.NoOriginHealthStatusMonitor) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) AnomalyExcludingOriginHealthStatusMonitor(com.hotels.styx.client.healthcheck.monitors.AnomalyExcludingOriginHealthStatusMonitor) Test(org.junit.jupiter.api.Test) OriginHealthStatusMonitorFactory(com.hotels.styx.client.healthcheck.OriginHealthStatusMonitorFactory) OriginHealthCheckFunction(com.hotels.styx.client.healthcheck.OriginHealthCheckFunction) Is.is(org.hamcrest.core.Is.is) HealthCheckConfig(com.hotels.styx.api.extension.service.HealthCheckConfig) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Id(com.hotels.styx.api.Id) Mockito.mock(org.mockito.Mockito.mock) OriginHealthCheckFunction(com.hotels.styx.client.healthcheck.OriginHealthCheckFunction) HealthCheckConfig(com.hotels.styx.api.extension.service.HealthCheckConfig) Test(org.junit.jupiter.api.Test)

Example 3 with HealthCheckConfig

use of com.hotels.styx.api.extension.service.HealthCheckConfig in project styx by ExpediaGroup.

the class HealthCheckSettingsTest method configuresTheHealthCheckWithTheDefaultValues.

@Test
public void configuresTheHealthCheckWithTheDefaultValues() throws Exception {
    HealthCheckConfig healthCheckConfig = newHealthCheckConfigBuilder().build();
    assertThat(healthCheckConfig, is(newHealthCheckConfigBuilder().healthyThreshold(2).unhealthyThreshold(2).interval(5000, MILLISECONDS).timeout(2000, MILLISECONDS).build()));
}
Also used : HealthCheckConfig(com.hotels.styx.api.extension.service.HealthCheckConfig) Test(org.junit.jupiter.api.Test)

Aggregations

HealthCheckConfig (com.hotels.styx.api.extension.service.HealthCheckConfig)3 Test (org.junit.jupiter.api.Test)3 Id (com.hotels.styx.api.Id)1 GENERIC_APP (com.hotels.styx.api.Id.GENERIC_APP)1 HealthCheckConfig.newHealthCheckConfigBuilder (com.hotels.styx.api.extension.service.HealthCheckConfig.newHealthCheckConfigBuilder)1 HttpClient (com.hotels.styx.client.HttpClient)1 OriginHealthCheckFunction (com.hotels.styx.client.healthcheck.OriginHealthCheckFunction)1 OriginHealthStatusMonitorFactory (com.hotels.styx.client.healthcheck.OriginHealthStatusMonitorFactory)1 AnomalyExcludingOriginHealthStatusMonitor (com.hotels.styx.client.healthcheck.monitors.AnomalyExcludingOriginHealthStatusMonitor)1 NoOriginHealthStatusMonitor (com.hotels.styx.client.healthcheck.monitors.NoOriginHealthStatusMonitor)1 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Is.is (org.hamcrest.core.Is.is)1 IsInstanceOf.instanceOf (org.hamcrest.core.IsInstanceOf.instanceOf)1 Mockito.mock (org.mockito.Mockito.mock)1