use of io.fabric8.core.jmx.HealthCheck in project docker-maven-plugin by fabric8io.
the class DockerFileBuilderTest method testHealthCheckNone.
@Test
public void testHealthCheckNone() {
HealthCheckConfiguration hc = new HealthCheckConfiguration.Builder().mode(HealthCheckMode.none).build();
String dockerfileContent = new DockerFileBuilder().healthCheck(hc).content();
assertThat(dockerfileToMap(dockerfileContent), hasEntry("HEALTHCHECK", "NONE"));
}
use of io.fabric8.core.jmx.HealthCheck in project fabric8-maven-plugin by fabric8io.
the class DockerHealthCheckEnricherTest method testUnmatchingHealthCheck.
@Test
public void testUnmatchingHealthCheck() 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());
}
};
KubernetesListBuilder builder = createDeployment("myUnmatchingImage");
DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
enricher.addMissingResources(builder);
KubernetesList list = builder.build();
assertEquals(1, list.getItems().size());
assertNoProbes(list.getItems().get(0));
}
use of io.fabric8.core.jmx.HealthCheck 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.core.jmx.HealthCheck in project strimzi by strimzi.
the class OpenShiftTemplatesTest method testStrimziPersistentWithCustomParameters.
@Test
public void testStrimziPersistentWithCustomParameters() throws IOException {
String clusterName = "test-persistent-with-custom-parameters";
oc.newApp("strimzi-persistent", map("CLUSTER_NAME", clusterName, "ZOOKEEPER_HEALTHCHECK_DELAY", "30", "ZOOKEEPER_HEALTHCHECK_TIMEOUT", "10", "KAFKA_HEALTHCHECK_DELAY", "30", "KAFKA_HEALTHCHECK_TIMEOUT", "10", "KAFKA_DEFAULT_REPLICATION_FACTOR", "2", "KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", "5", "KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "5", "ZOOKEEPER_VOLUME_CAPACITY", "2Gi", "KAFKA_VOLUME_CAPACITY", "2Gi"));
// TODO Add assertions to check that Kafka brokers have a custom configuration
ConfigMap cm = client.configMaps().inNamespace(NAMESPACE).withName(clusterName).get();
assertNotNull(cm);
Map<String, String> cmData = cm.getData();
assertEquals("30", cmData.get("zookeeper-healthcheck-delay"));
assertEquals("10", cmData.get("zookeeper-healthcheck-timeout"));
assertEquals("30", cmData.get("kafka-healthcheck-delay"));
assertEquals("10", cmData.get("kafka-healthcheck-timeout"));
assertEquals("2", cmData.get("KAFKA_DEFAULT_REPLICATION_FACTOR"));
assertEquals("5", cmData.get("KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR"));
assertEquals("5", cmData.get("KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR"));
assertEquals("2Gi", mapper.readTree(cmData.get("kafka-storage")).get("size").asText());
assertEquals("2Gi", mapper.readTree(cmData.get("zookeeper-storage")).get("size").asText());
}
use of io.fabric8.core.jmx.HealthCheck in project docker-maven-plugin by fabric8io.
the class HealthCheckChecker method check.
@Override
public boolean check() {
try {
final ContainerDetails container = docker.getContainer(containerId);
if (container == null) {
log.debug("HealthWaitChecker: Container %s not found");
return false;
}
if (container.getHealthcheck() == null) {
throw new IllegalArgumentException("Can not wait for healthstate of " + imageConfigDesc + ". No HEALTHCHECK configured.");
}
if (first) {
log.info("%s: Waiting to become healthy", imageConfigDesc);
log.debug("HealthWaitChecker: Waiting for healthcheck: '%s'", container.getHealthcheck());
first = false;
} else if (log.isDebugEnabled()) {
log.debug("HealthWaitChecker: Waiting on healthcheck '%s'", container.getHealthcheck());
}
return container.isHealthy();
} catch (DockerAccessException e) {
log.warn("Error while checking health: %s", e.getMessage());
return false;
}
}
Aggregations