Search in sources :

Example 66 with Result

use of io.fabric8.insight.metrics.model.Result 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");
}
Also used : Expectations(mockit.Expectations) Properties(java.util.Properties) Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 67 with Result

use of io.fabric8.insight.metrics.model.Result 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");
}
Also used : Expectations(mockit.Expectations) TreeMap(java.util.TreeMap) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 68 with Result

use of io.fabric8.insight.metrics.model.Result 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");
}
Also used : Expectations(mockit.Expectations) Properties(java.util.Properties) Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 69 with Result

use of io.fabric8.insight.metrics.model.Result 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);
}
Also used : Expectations(mockit.Expectations) Properties(java.util.Properties) Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 70 with Result

use of io.fabric8.insight.metrics.model.Result 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);
}
Also used : Expectations(mockit.Expectations) Properties(java.util.Properties) Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)104 Expectations (mockit.Expectations)49 HashMap (java.util.HashMap)32 Map (java.util.Map)24 ArrayList (java.util.ArrayList)23 File (java.io.File)21 GitContext (io.fabric8.api.GitContext)20 IOException (java.io.IOException)20 Exchange (org.apache.camel.Exchange)20 Processor (org.apache.camel.Processor)20 DefaultPullPushPolicy (io.fabric8.git.internal.DefaultPullPushPolicy)18 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)17 Probe (io.fabric8.kubernetes.api.model.Probe)16 PatchResult (io.fabric8.patch.management.PatchResult)13 Properties (java.util.Properties)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)11 Patch (io.fabric8.patch.management.Patch)11 PatchException (io.fabric8.patch.management.PatchException)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 TreeMap (java.util.TreeMap)10