Search in sources :

Example 26 with Context

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

the class IconEnricher method getDefaultIconRef.

/**
 * Lets use the project and its classpath to try figure out what default icon to use
 *
 * @return the icon ref if we can detect one or return null
 */
private String getDefaultIconRef() {
    MavenProject project = getProject();
    EnricherContext context = getContext();
    if (hasClass(project, "io.fabric8.funktion.runtime.Main") || MavenUtil.hasDependencyOnAnyArtifactOfGroup(project, "io.fabric8.funktion")) {
        return "funktion";
    }
    if (hasClass(project, "org.apache.camel.CamelContext")) {
        return "camel";
    }
    if (hasPlugin(project, "org.springframework.boot:spring-boot-maven-plugin") || hasClass(project, "org.springframework.boot.SpringApplication")) {
        return "spring-boot";
    }
    if (hasClass(project, "org.springframework.core.Constants")) {
        return "spring";
    }
    if (hasClass(project, "org.vertx.java.core.Handler", "io.vertx.core.Handler")) {
        return "vertx";
    }
    if (hasPlugin(project, "org.wildfly.swarm:wildfly-swarm-plugin") || MavenUtil.hasDependencyOnAnyArtifactOfGroup(project, "org.wildfly.swarm")) {
        return "wildfly-swarm";
    }
    return null;
}
Also used : MavenProject(org.apache.maven.project.MavenProject) EnricherContext(io.fabric8.maven.enricher.api.EnricherContext)

Example 27 with Context

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

the class AbstractSpringBootHealthCheckEnricherSupport method testSchemeWithServerPortAndServerKeystore.

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

Example 28 with Context

use of io.fabric8.kubernetes.api.model.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 29 with Context

use of io.fabric8.kubernetes.api.model.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 30 with Context

use of io.fabric8.kubernetes.api.model.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)

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