use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.
the class DockerHealthCheckEnricherTest method testEnrichFromSingleImage.
@Test
public void testEnrichFromSingleImage() throws Exception {
// Setup mock behaviour
new Expectations() {
{
context.getImages();
result = Arrays.asList(new ImageConfiguration.Builder().alias("myImage").buildConfig(new BuildImageConfiguration.Builder().healthCheck(new HealthCheckConfiguration.Builder().mode(HealthCheckMode.cmd).cmd("/bin/check").timeout("1s").interval("1h1s").retries(3).build()).build()).build(), new ImageConfiguration.Builder().alias("myImage2").buildConfig(new BuildImageConfiguration.Builder().healthCheck(new HealthCheckConfiguration.Builder().mode(HealthCheckMode.cmd).cmd("/xxx/check").timeout("3s").interval("3h1s").retries(9).build()).build()).build());
}
};
KubernetesListBuilder builder = createDeployment("myImage");
DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
enricher.addMissingResources(builder);
KubernetesList list = builder.build();
assertEquals(1, list.getItems().size());
assertHealthCheckMatching(builder.build().getItems().get(0), "livenessProbe", "/bin/check", 1, 3601, 3);
assertHealthCheckMatching(builder.build().getItems().get(0), "readinessProbe", "/bin/check", 1, 3601, 3);
}
use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.
the class VertxHealthCheckEnricherTest method testDefaultConfiguration.
@Test
public void testDefaultConfiguration() {
VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
final Properties props = new Properties();
new Expectations() {
{
context.getProject().getProperties();
result = props;
}
};
Probe probe = enricher.getLivenessProbe();
assertNull(probe);
probe = enricher.getReadinessProbe();
assertNull(probe);
}
use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.
the class VertxHealthCheckEnricherTest method testCustomConfiguration.
@Test
public void testCustomConfiguration() {
VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
final Properties props = new Properties();
props.put("vertx.health.path", "/health");
props.put("vertx.health.port", " 8081 ");
props.put("vertx.health.scheme", " https");
new Expectations() {
{
context.getProject().getProperties();
result = props;
}
};
Probe probe = enricher.getLivenessProbe();
assertNotNull(probe);
assertNull(probe.getHttpGet().getHost());
assertEquals(probe.getHttpGet().getScheme(), "https");
assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 8081);
assertEquals(probe.getHttpGet().getPath(), "/health");
probe = enricher.getReadinessProbe();
assertNotNull(probe);
assertEquals(probe.getHttpGet().getScheme(), "https");
assertNull(probe.getHttpGet().getHost());
assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 8081);
assertEquals(probe.getHttpGet().getPath(), "/health");
}
use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.
the class VertxHealthCheckEnricherTest method testLivenessDisabledAndReadinessEnabledUsingConfig.
@Test
public void testLivenessDisabledAndReadinessEnabledUsingConfig() {
final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap("vertx-health-check", new TreeMap(ImmutableMap.of(VertxHealthCheckEnricher.Config.readiness.name(), "/ping", VertxHealthCheckEnricher.Config.path.name(), ""))));
new Expectations() {
{
context.getConfig();
result = config;
}
};
VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
Probe probe = enricher.getLivenessProbe();
assertNull(probe);
probe = enricher.getReadinessProbe();
assertNotNull(probe);
assertEquals(probe.getHttpGet().getPath(), "/ping");
}
use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.
the class VertxHealthCheckEnricherTest method testDifferentPathForLivenessAndReadiness.
@Test
public void testDifferentPathForLivenessAndReadiness() {
VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
final Properties props = new Properties();
props.put("vertx.health.path", "/ping");
props.put("vertx.health.readiness.path", "/ready");
new Expectations() {
{
context.getProject().getProperties();
result = props;
}
};
Probe probe = enricher.getLivenessProbe();
assertNotNull(probe);
assertNull(probe.getHttpGet().getHost());
assertEquals(probe.getHttpGet().getScheme(), "HTTP");
assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 8080);
assertEquals(probe.getHttpGet().getPath(), "/ping");
probe = enricher.getReadinessProbe();
assertNotNull(probe);
assertEquals(probe.getHttpGet().getScheme(), "HTTP");
assertNull(probe.getHttpGet().getHost());
assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 8080);
assertEquals(probe.getHttpGet().getPath(), "/ready");
}
Aggregations