Search in sources :

Example 21 with ProcessorConfig

use of io.fabric8.maven.core.config.ProcessorConfig in project fabric8-maven-plugin by fabric8io.

the class ProfileUtilTest method simple.

@Test
public void simple() throws IOException {
    InputStream is = getClass().getResourceAsStream("/fabric8/config/profiles-lookup-dir/profiles.yaml");
    assertNotNull(is);
    List<Profile> profiles = ProfileUtil.fromYaml(is);
    assertNotNull(profiles);
    assertEquals(profiles.size(), 2);
    Profile profile = profiles.get(0);
    assertEquals("simple", profile.getName());
    ProcessorConfig config = profile.getEnricherConfig();
    assertTrue(config.use("base"));
    assertFalse(config.use("blub"));
    config = profile.getGeneratorConfig();
    assertFalse(config.use("java.app"));
    assertTrue(config.use("spring.swarm"));
}
Also used : InputStream(java.io.InputStream) Profile(io.fabric8.maven.core.config.Profile) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 22 with ProcessorConfig

use of io.fabric8.maven.core.config.ProcessorConfig in project fabric8-maven-plugin by fabric8io.

the class ProfileUtilTest method blendProfiles.

@Test
public void blendProfiles() throws Exception {
    ProcessorConfig origConfig = new ProcessorConfig(Arrays.asList("i1", "i2"), Collections.singleton("spring.swarm"), null);
    ProcessorConfig mergeConfig = ProfileUtil.blendProfileWithConfiguration(ProfileUtil.ENRICHER_CONFIG, "simple", getProfileDir(), origConfig);
    assertTrue(mergeConfig.use("base"));
    assertTrue(mergeConfig.use("i1"));
    assertEquals(mergeConfig.getConfig("base", "url"), "http://jolokia.org");
    mergeConfig = ProfileUtil.blendProfileWithConfiguration(ProfileUtil.GENERATOR_CONFIG, "simple", getProfileDir(), origConfig);
    assertTrue(mergeConfig.use("i2"));
    assertFalse(mergeConfig.use("spring.swarm"));
}
Also used : ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 23 with ProcessorConfig

use of io.fabric8.maven.core.config.ProcessorConfig in project fabric8-maven-plugin by fabric8io.

the class VertxHealthCheckEnricherTest method testWithCustomConfigurationForLivenessAndReadinessComingFromConf.

@Test
public void testWithCustomConfigurationForLivenessAndReadinessComingFromConf() {
    final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap("vertx-health-check", new TreeMap(ImmutableMap.of(VertxHealthCheckEnricher.Config.path.name(), "health", VertxHealthCheckEnricher.Config.port.name(), "1234", VertxHealthCheckEnricher.Config.scheme.name(), "HTTPS", VertxHealthCheckEnricher.Config.readiness.name(), "/ready"))));
    new Expectations() {

        {
            context.getConfig();
            result = config;
        }
    };
    VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
    Probe probe = enricher.getLivenessProbe();
    assertNotNull(probe);
    assertNull(probe.getHttpGet().getHost());
    assertEquals(probe.getHttpGet().getScheme(), "HTTPS");
    assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 1234);
    assertEquals(probe.getHttpGet().getPath(), "/health");
    probe = enricher.getReadinessProbe();
    assertNotNull(probe);
    assertEquals(probe.getHttpGet().getScheme(), "HTTPS");
    assertNull(probe.getHttpGet().getHost());
    assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 1234);
    assertEquals(probe.getHttpGet().getPath(), "/ready");
}
Also used : Expectations(mockit.Expectations) TreeMap(java.util.TreeMap) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 24 with ProcessorConfig

use of io.fabric8.maven.core.config.ProcessorConfig in project fabric8-maven-plugin by fabric8io.

the class VertxHealthCheckEnricherTest method testWithCustomConfigurationComingFromConf.

@Test
public void testWithCustomConfigurationComingFromConf() {
    final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap("vertx-health-check", new TreeMap(ImmutableMap.of(VertxHealthCheckEnricher.Config.path.name(), "health", VertxHealthCheckEnricher.Config.port.name(), "1234", VertxHealthCheckEnricher.Config.scheme.name(), "HTTPS"))));
    new Expectations() {

        {
            context.getConfig();
            result = config;
        }
    };
    VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
    Probe probe = enricher.getLivenessProbe();
    assertNotNull(probe);
    assertNull(probe.getHttpGet().getHost());
    assertEquals(probe.getHttpGet().getScheme(), "HTTPS");
    assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 1234);
    assertEquals(probe.getHttpGet().getPath(), "/health");
    probe = enricher.getReadinessProbe();
    assertNotNull(probe);
    assertEquals(probe.getHttpGet().getScheme(), "HTTPS");
    assertNull(probe.getHttpGet().getHost());
    assertEquals(probe.getHttpGet().getPort().getIntVal().intValue(), 1234);
    assertEquals(probe.getHttpGet().getPath(), "/health");
}
Also used : Expectations(mockit.Expectations) TreeMap(java.util.TreeMap) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Example 25 with ProcessorConfig

use of io.fabric8.maven.core.config.ProcessorConfig in project fabric8-maven-plugin by fabric8io.

the class VertxHealthCheckEnricherTest method testReadinessDisabledUsingConfig.

@Test
public void testReadinessDisabledUsingConfig() {
    final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap("vertx-health-check", new TreeMap(ImmutableMap.of(VertxHealthCheckEnricher.Config.readiness.name(), "", VertxHealthCheckEnricher.Config.path.name(), "/ping"))));
    new Expectations() {

        {
            context.getConfig();
            result = config;
        }
    };
    VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context);
    Probe probe = enricher.getLivenessProbe();
    assertNotNull(probe);
    assertEquals(probe.getHttpGet().getPath(), "/ping");
    probe = enricher.getReadinessProbe();
    assertNull(probe);
}
Also used : Expectations(mockit.Expectations) TreeMap(java.util.TreeMap) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Aggregations

ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)27 Test (org.junit.Test)21 Expectations (mockit.Expectations)17 TreeMap (java.util.TreeMap)10 Probe (io.fabric8.kubernetes.api.model.Probe)7 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)5 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)4 ArrayList (java.util.ArrayList)3 MavenProject (org.apache.maven.project.MavenProject)3 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)2 Logger (io.fabric8.maven.docker.util.Logger)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 PodTemplate (io.fabric8.kubernetes.api.model.PodTemplate)1 ReplicaSet (io.fabric8.kubernetes.api.model.extensions.ReplicaSet)1 PlatformMode (io.fabric8.maven.core.config.PlatformMode)1 Profile (io.fabric8.maven.core.config.Profile)1 Generator (io.fabric8.maven.generator.api.Generator)1 Watcher (io.fabric8.maven.watcher.api.Watcher)1