Search in sources :

Example 31 with Context

use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testWithServerPortAndManagementContextPathAndServletPath.

@Test
public void testWithServerPortAndManagementContextPathAndServletPath() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Properties props = new Properties();
    props.put(propertyHelper.getServerPortPropertyKey(), "8282");
    props.put(propertyHelper.getServletPathPropertyKey(), "/servlet");
    props.put(propertyHelper.getManagementContextPathPropertyKey(), "/p1");
    Probe probe = enricher.buildProbe(props, 10, null);
    assertNotNull(probe);
    assertNotNull(probe.getHttpGet());
    assertEquals("/servlet/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.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testWithServerPortAndServletPath.

@Test
public void testWithServerPortAndServletPath() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Properties props = new Properties();
    props.put(propertyHelper.getServerPortPropertyKey(), "8282");
    props.put(propertyHelper.getServletPathPropertyKey(), "/servlet");
    Probe probe = enricher.buildProbe(props, 10, null);
    assertNotNull(probe);
    assertNotNull(probe.getHttpGet());
    assertEquals("/servlet" + 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 33 with Context

use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testCustomPropertiesForLivenessAndReadiness.

@Test
public void testCustomPropertiesForLivenessAndReadiness() {
    Map<String, TreeMap> globalConfig = new HashMap<>();
    TreeMap<String, String> enricherConfig = new TreeMap<>();
    globalConfig.put(SpringBootHealthCheckEnricher.ENRICHER_NAME, enricherConfig);
    enricherConfig.put("readinessProbeInitialDelaySeconds", "30");
    enricherConfig.put("readinessProbePeriodSeconds", "40");
    enricherConfig.put("livenessProbeInitialDelaySeconds", "460");
    enricherConfig.put("livenessProbePeriodSeconds", "50");
    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(30, probe.getInitialDelaySeconds().intValue());
    assertEquals(40, probe.getPeriodSeconds().intValue());
    probe = enricher.getLivenessProbe();
    assertNotNull(probe);
    assertEquals(460, probe.getInitialDelaySeconds().intValue());
    assertEquals(50, probe.getPeriodSeconds().intValue());
}
Also used : Expectations(mockit.Expectations) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 34 with Context

use of io.fabric8.mockwebserver.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 35 with Context

use of io.fabric8.mockwebserver.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)

Aggregations

Test (org.junit.jupiter.api.Test)593 Checkpoint (io.vertx.junit5.Checkpoint)574 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)543 VertxTestContext (io.vertx.junit5.VertxTestContext)542 Vertx (io.vertx.core.Vertx)539 Reconciliation (io.strimzi.operator.common.Reconciliation)532 VertxExtension (io.vertx.junit5.VertxExtension)514 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)514 BeforeAll (org.junit.jupiter.api.BeforeAll)466 AfterAll (org.junit.jupiter.api.AfterAll)462 CoreMatchers.is (org.hamcrest.CoreMatchers.is)458 Future (io.vertx.core.Future)429 Mockito.when (org.mockito.Mockito.when)410 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)379 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)368 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)360 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)356 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)352 List (java.util.List)352 KubernetesVersion (io.strimzi.operator.KubernetesVersion)344