Search in sources :

Example 31 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testWithServerPortAndServerContextPathAndManagementContextPath.

@Test
public void testWithServerPortAndServerContextPathAndManagementContextPath() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Properties props = new Properties();
    props.put(propertyHelper.getServerPortPropertyKey(), "8282");
    props.put(propertyHelper.getManagementContextPathPropertyKey(), "/p1");
    props.put(propertyHelper.getServerContextPathPropertyKey(), "/p2");
    Probe probe = enricher.buildProbe(props, 10, null);
    assertNotNull(probe);
    assertNotNull(probe.getHttpGet());
    assertEquals("/p2/p1" + propertyHelper.getActuatorDefaultBasePath() + "/health", probe.getHttpGet().getPath());
    assertEquals(8282, probe.getHttpGet().getPort().getIntVal().intValue());
}
Also used : Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 32 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testCustomInitialDelayForLivenessAndReadiness.

@Test
public void testCustomInitialDelayForLivenessAndReadiness() {
    Map<String, TreeMap> globalConfig = new HashMap<>();
    TreeMap<String, String> enricherConfig = new TreeMap<>();
    globalConfig.put(SpringBootHealthCheckEnricher.ENRICHER_NAME, enricherConfig);
    enricherConfig.put("readinessProbeInitialDelaySeconds", "20");
    enricherConfig.put("livenessProbeInitialDelaySeconds", "360");
    final ProcessorConfig config = new ProcessorConfig(null, null, globalConfig);
    new Expectations() {

        {
            context.getConfig();
            result = config;
        }
    };
    withAllRequiredClasses();
    withProjectProperties(new Properties());
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Probe probe = enricher.getReadinessProbe();
    assertNotNull(probe);
    assertEquals(20, probe.getInitialDelaySeconds().intValue());
    assertNull(probe.getPeriodSeconds());
    probe = enricher.getLivenessProbe();
    assertNotNull(probe);
    assertEquals(360, probe.getInitialDelaySeconds().intValue());
    assertNull(probe.getPeriodSeconds());
}
Also used : Expectations(mockit.Expectations) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 33 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testWithServerPortAndManagementContextPath.

@Test
public void testWithServerPortAndManagementContextPath() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Properties props = new Properties();
    props.put(propertyHelper.getServerPortPropertyKey(), "8282");
    props.put(propertyHelper.getManagementContextPathPropertyKey(), "/p1");
    Probe probe = enricher.buildProbe(props, 10, null);
    assertNotNull(probe);
    assertNotNull(probe.getHttpGet());
    assertEquals("/p1" + propertyHelper.getActuatorDefaultBasePath() + "/health", probe.getHttpGet().getPath());
    assertEquals(8282, probe.getHttpGet().getPort().getIntVal().intValue());
}
Also used : Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 34 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testWithServerPort.

@Test
public void testWithServerPort() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Properties props = new Properties();
    props.put(propertyHelper.getServerPortPropertyKey(), "8282");
    Probe probe = enricher.buildProbe(props, 10, null);
    assertNotNull(probe);
    assertNotNull(probe.getHttpGet());
    assertEquals(propertyHelper.getActuatorDefaultBasePath() + "/health", probe.getHttpGet().getPath());
    assertEquals(8282, probe.getHttpGet().getPort().getIntVal().intValue());
}
Also used : Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 35 with Context

use of io.fabric8.kubernetes.api.model.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testSchemeWithServerPort.

@Test
public void testSchemeWithServerPort() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Properties props = new Properties();
    props.put(propertyHelper.getServerPortPropertyKey(), "8443");
    Probe probe = enricher.buildProbe(props, 10, null);
    assertNotNull(probe);
    assertNotNull(probe.getHttpGet());
    assertEquals("HTTP", probe.getHttpGet().getScheme());
    assertEquals(8443, probe.getHttpGet().getPort().getIntVal().intValue());
}
Also used : Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)135 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 Reconciliation (io.strimzi.controller.cluster.Reconciliation)24 File (java.io.File)23 Git (org.eclipse.jgit.api.Git)23 GitContext (io.fabric8.api.GitContext)21 IOException (java.io.IOException)21 ConfigMapOperator (io.strimzi.controller.cluster.operator.resource.ConfigMapOperator)20 ServiceOperator (io.strimzi.controller.cluster.operator.resource.ServiceOperator)20 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 HashMap (java.util.HashMap)17 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