use of io.fabric8.mockwebserver.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");
}
use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.
the class VertxHealthCheckEnricherTest method testDisabledUsingInvalidPort.
@Test
public void testDisabledUsingInvalidPort() {
VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
final Properties props = new Properties();
props.put("vertx.health.port", " none ");
props.put("vertx.health.path", " /ping ");
new Expectations() {
{
context.getProject().getProperties();
result = props;
}
};
Probe probe = enricher.getLivenessProbe();
assertNull(probe);
probe = enricher.getReadinessProbe();
assertNull(probe);
}
use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.
the class VertxHealthCheckEnricherTest method testDisabledUsingEmptyPath.
@Test
public void testDisabledUsingEmptyPath() {
VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
final Properties props = new Properties();
props.put("vertx.health.path", "");
new Expectations() {
{
context.getProject().getProperties();
result = props;
}
};
Probe probe = enricher.getLivenessProbe();
assertNull(probe);
probe = enricher.getReadinessProbe();
assertNull(probe);
}
use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.
the class VertxHealthCheckEnricherTest method testLivenessDisabledAndReadinessEnabled.
@Test
public void testLivenessDisabledAndReadinessEnabled() {
VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
final Properties props = new Properties();
props.put("vertx.health.readiness.path", "/ping");
props.put("vertx.health.path", "");
new Expectations() {
{
context.getProject().getProperties();
result = props;
}
};
Probe probe = enricher.getLivenessProbe();
assertNull(probe);
probe = enricher.getReadinessProbe();
assertNotNull(probe);
assertEquals(probe.getHttpGet().getPath(), "/ping");
}
use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.
the class DefaultControllerEnricherTest method enrichAndAssert.
protected void enrichAndAssert(int sizeOfObjects, int replicaCount) throws com.fasterxml.jackson.core.JsonProcessingException {
// Setup a sample docker build configuration
final BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().ports(Arrays.asList("8080")).build();
final TreeMap controllerConfig = new TreeMap();
controllerConfig.put("replicaCount", String.valueOf(replicaCount));
setupExpectations(buildConfig, controllerConfig);
// Enrich
DefaultControllerEnricher controllerEnricher = new DefaultControllerEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder();
controllerEnricher.addMissingResources(builder);
// Validate that the generated resource contains
KubernetesList list = builder.build();
assertEquals(sizeOfObjects, list.getItems().size());
String json = KubernetesResourceUtil.toJson(list.getItems().get(0));
assertThat(json, JsonPathMatchers.isJson());
assertThat(json, JsonPathMatchers.hasJsonPath("$.spec.replicas", Matchers.equalTo(replicaCount)));
}
Aggregations