use of io.fabric8.kubernetes.api.model.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.kubernetes.api.model.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.kubernetes.api.model.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.kubernetes.api.model.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)));
}
use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.
the class MavenProjectEnricherTest method testOldStyleGeneratedResources.
@Test
public void testOldStyleGeneratedResources() {
final Properties properties = new Properties();
properties.setProperty("fabric8.enricher.fmp-project.useProjectLabel", "true");
new Expectations() {
{
mavenProject.getProperties();
result = properties;
}
};
ProjectEnricher projectEnricher = new ProjectEnricher(context);
KubernetesListBuilder builder = createListWithDeploymentConfig();
projectEnricher.adapt(builder);
KubernetesList list = builder.build();
Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
assertNotNull(labels);
assertEquals("groupId", labels.get("group"));
assertEquals("artifactId", labels.get("project"));
assertEquals("version", labels.get("version"));
assertNull(labels.get("app"));
Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
assertEquals("groupId", selectors.get("group"));
assertEquals("artifactId", selectors.get("project"));
assertNull(selectors.get("version"));
assertNull(selectors.get("app"));
}
Aggregations