Search in sources :

Example 6 with HealthCheck

use of io.fabric8.core.jmx.HealthCheck in project docker-maven-plugin by fabric8io.

the class DockerFileBuilderTest method testHealthCheckCmdParams.

@Test
public void testHealthCheckCmdParams() {
    HealthCheckConfiguration hc = new HealthCheckConfiguration.Builder().cmd("echo hello").interval("5s").timeout("3s").retries(4).build();
    String dockerfileContent = new DockerFileBuilder().healthCheck(hc).content();
    assertThat(dockerfileToMap(dockerfileContent), hasEntry("HEALTHCHECK", "--interval=5s --timeout=3s --retries=4 CMD echo hello"));
}
Also used : HealthCheckConfiguration(io.fabric8.maven.docker.config.HealthCheckConfiguration) Test(org.junit.Test)

Example 7 with HealthCheck

use of io.fabric8.core.jmx.HealthCheck in project fabric8 by jboss-fuse.

the class FabricMBeanRegistrationListener method registerFabricMBeans.

private void registerFabricMBeans() {
    this.healthCheck = new HealthCheck(fabricService.get());
    this.managerMBean = new FabricManager((FabricServiceImpl) fabricService.get());
    this.zooKeeperMBean = new ZooKeeperFacade((FabricServiceImpl) fabricService.get());
    this.fileSystemMBean = new FileSystem(runtimeProperties.get());
    healthCheck.registerMBeanServer(shutdownTracker, mbeanServer.get());
    managerMBean.registerMBeanServer(shutdownTracker, mbeanServer.get());
    fileSystemMBean.registerMBeanServer(shutdownTracker, mbeanServer.get());
    zooKeeperMBean.registerMBeanServer(shutdownTracker, mbeanServer.get());
}
Also used : FabricManager(io.fabric8.core.jmx.FabricManager) ZooKeeperFacade(io.fabric8.core.jmx.ZooKeeperFacade) FileSystem(io.fabric8.core.jmx.FileSystem) HealthCheck(io.fabric8.core.jmx.HealthCheck)

Example 8 with HealthCheck

use of io.fabric8.core.jmx.HealthCheck in project strimzi by strimzi.

the class OpenShiftTemplatesTest method testStrimziEphemeralWithCustomParameters.

@Test
public void testStrimziEphemeralWithCustomParameters() {
    String clusterName = "test-ephemeral-with-custom-parameters";
    oc.newApp("strimzi-ephemeral", 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"));
    // 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"));
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Test(org.junit.Test)

Example 9 with HealthCheck

use of io.fabric8.core.jmx.HealthCheck in project fabric8-maven-plugin by fabric8io.

the class DockerHealthCheckEnricherTest method testEnrichFromDoubleImage.

@Test
public void testEnrichFromDoubleImage() 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 = addDeployment(createDeployment("myImage"), "myImage2");
    DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
    enricher.addMissingResources(builder);
    KubernetesList list = builder.build();
    assertEquals(2, 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);
    assertHealthCheckMatching(builder.build().getItems().get(1), "livenessProbe", "/xxx/check", 3, 10801, 9);
    assertHealthCheckMatching(builder.build().getItems().get(1), "readinessProbe", "/xxx/check", 3, 10801, 9);
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.Test)

Example 10 with HealthCheck

use of io.fabric8.core.jmx.HealthCheck in project fabric8-maven-plugin by fabric8io.

the class DockerHealthCheckEnricherTest method testInvalidHealthCheck.

@Test
public void testInvalidHealthCheck() 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.none).build()).build()).build());
        }
    };
    KubernetesListBuilder builder = createDeployment("myImage");
    DockerHealthCheckEnricher enricher = new DockerHealthCheckEnricher(context);
    enricher.addMissingResources(builder);
    KubernetesList list = builder.build();
    assertEquals(1, list.getItems().size());
    assertNoProbes(list.getItems().get(0));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)4 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)4 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)4 Expectations (mockit.Expectations)4 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 HealthCheckConfiguration (io.fabric8.maven.docker.config.HealthCheckConfiguration)2 FabricManager (io.fabric8.core.jmx.FabricManager)1 FileSystem (io.fabric8.core.jmx.FileSystem)1 HealthCheck (io.fabric8.core.jmx.HealthCheck)1 ZooKeeperFacade (io.fabric8.core.jmx.ZooKeeperFacade)1 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1 ContainerDetails (io.fabric8.maven.docker.model.ContainerDetails)1