Search in sources :

Example 46 with Context

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

Example 47 with Context

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

Example 48 with Context

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

Example 49 with Context

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

Example 50 with Context

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)));
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) TreeMap(java.util.TreeMap) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration)

Aggregations

Test (org.junit.Test)138 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)58 Async (io.vertx.ext.unit.Async)52 Expectations (mockit.Expectations)34 Probe (io.fabric8.kubernetes.api.model.Probe)33 File (java.io.File)26 Reconciliation (io.strimzi.controller.cluster.Reconciliation)24 IOException (java.io.IOException)24 Git (org.eclipse.jgit.api.Git)23 GitContext (io.fabric8.api.GitContext)21 ConfigMapOperator (io.strimzi.controller.cluster.operator.resource.ConfigMapOperator)20 ServiceOperator (io.strimzi.controller.cluster.operator.resource.ServiceOperator)20 HashMap (java.util.HashMap)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 LockHandle (io.fabric8.api.LockHandle)15 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)15 NonNamespaceOperation (io.fabric8.kubernetes.client.dsl.NonNamespaceOperation)15 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)15 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)14 Resource (io.fabric8.kubernetes.client.dsl.Resource)14