Search in sources :

Example 71 with Result

use of io.fabric8.insight.metrics.model.Result 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 72 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.

the class DefaultControllerEnricherTest method setupExpectations.

protected void setupExpectations(final BuildImageConfiguration buildConfig, final TreeMap controllerConfig) {
    new Expectations() {

        {
            project.getArtifactId();
            result = "fmp-controller-test";
            project.getBuild().getOutputDirectory();
            result = Files.createTempDir().getAbsolutePath();
            context.getProject();
            result = project;
            context.getConfig();
            result = new ProcessorConfig(null, null, Collections.singletonMap("fmp-controller", controllerConfig));
            imageConfiguration.getBuildConfiguration();
            result = buildConfig;
            imageConfiguration.getName();
            result = "helloworld";
            context.getImages();
            result = Arrays.asList(imageConfiguration);
        }
    };
}
Also used : Expectations(mockit.Expectations) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig)

Example 73 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.

the class MavenProjectEnricherTest method testOldStyleGeneratedResources.

@Test
public void testOldStyleGeneratedResources() {
    final Properties properties = new Properties();
    properties.setProperty("fabric8.enricher.fmp-project.useProjectLabel", "true");
    new Expectations() {

        {
            mavenProject.getProperties();
            result = properties;
        }
    };
    ProjectEnricher projectEnricher = new ProjectEnricher(context);
    KubernetesListBuilder builder = createListWithDeploymentConfig();
    projectEnricher.adapt(builder);
    KubernetesList list = builder.build();
    Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
    assertNotNull(labels);
    assertEquals("groupId", labels.get("group"));
    assertEquals("artifactId", labels.get("project"));
    assertEquals("version", labels.get("version"));
    assertNull(labels.get("app"));
    Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
    assertEquals("groupId", selectors.get("group"));
    assertEquals("artifactId", selectors.get("project"));
    assertNull(selectors.get("version"));
    assertNull(selectors.get("app"));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Properties(java.util.Properties) Test(org.junit.Test)

Example 74 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.

the class RevisionHistoryEnricherTest method testCustomRevisionHistoryLimit.

@Test
public void testCustomRevisionHistoryLimit() throws JsonProcessingException {
    // Setup mock behaviour
    final String revisionNumber = "10";
    new Expectations() {

        {
            context.getConfig();
            result = prepareEnricherConfig(revisionNumber);
        }
    };
    // Given
    KubernetesListBuilder builder = new KubernetesListBuilder().addNewDeploymentItem().endDeploymentItem();
    RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
    // When
    enricher.addMissingResources(builder);
    // Then
    assertRevisionHistory(builder.build(), Integer.parseInt(revisionNumber));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Test(org.junit.Test)

Example 75 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8-maven-plugin by fabric8io.

the class PrometheusEnricherTest method testNoDefinedPrometheusPort.

@Test
public void testNoDefinedPrometheusPort() throws Exception {
    final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap(PrometheusEnricher.ENRICHER_NAME, new TreeMap()));
    final BuildImageConfiguration imageConfig = new BuildImageConfiguration.Builder().build();
    // Setup mock behaviour
    new Expectations() {

        {
            context.getConfig();
            result = config;
            imageConfiguration.getBuildConfiguration();
            result = imageConfig;
            context.getImages();
            result = Arrays.asList(imageConfiguration);
        }
    };
    PrometheusEnricher enricher = new PrometheusEnricher(context);
    Map<String, String> annotations = enricher.getAnnotations(Kind.SERVICE);
    assertNull(annotations);
}
Also used : Expectations(mockit.Expectations) TreeMap(java.util.TreeMap) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) 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