Search in sources :

Example 21 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class AbstractSpringBootHealthCheckEnricherTestSupport method testCustomInitialDelayForLivenessAndReadinessAndTimeout.

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

        {
            context.getConfiguration();
            result = Configuration.builder().processorConfig(config).build();
            context.getProjectClassLoaders();
            result = new ProjectClassLoaders(new URLClassLoader(new URL[0], AbstractSpringBootHealthCheckEnricherTestSupport.class.getClassLoader())) {

                @Override
                public boolean isClassInCompileClasspath(boolean all, String... clazz) {
                    return true;
                }
            };
        }
    };
    withProjectProperties(new Properties());
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Probe probe = enricher.getReadinessProbe();
    assertNotNull(probe);
    assertEquals(20, probe.getInitialDelaySeconds().intValue());
    assertNull(probe.getPeriodSeconds());
    assertEquals(120, probe.getTimeoutSeconds().intValue());
    probe = enricher.getLivenessProbe();
    assertNotNull(probe);
    assertEquals(360, probe.getInitialDelaySeconds().intValue());
    assertNull(probe.getPeriodSeconds());
    assertEquals(120, probe.getTimeoutSeconds().intValue());
}
Also used : Expectations(mockit.Expectations) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Properties(java.util.Properties) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) ProjectClassLoaders(org.eclipse.jkube.kit.common.util.ProjectClassLoaders) URLClassLoader(java.net.URLClassLoader) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test)

Example 22 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class AbstractSpringBootHealthCheckEnricherTestSupport method testCustomPropertiesForLivenessAndReadiness.

@Test
public void testCustomPropertiesForLivenessAndReadiness() {
    Map<String, Map<String, Object>> globalConfig = new HashMap<>();
    TreeMap<String, Object> 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.getConfiguration();
            result = Configuration.builder().processorConfig(config).build();
            context.getProjectClassLoaders();
            result = new ProjectClassLoaders(new URLClassLoader(new URL[0], AbstractSpringBootHealthCheckEnricherTestSupport.class.getClassLoader())) {

                @Override
                public boolean isClassInCompileClasspath(boolean all, String... clazz) {
                    return true;
                }
            };
        }
    };
    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) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Properties(java.util.Properties) Probe(io.fabric8.kubernetes.api.model.Probe) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) ProjectClassLoaders(org.eclipse.jkube.kit.common.util.ProjectClassLoaders) URLClassLoader(java.net.URLClassLoader) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test)

Example 23 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class WildflyJARHealthCheckEnricherTest method setupExpectations.

private void setupExpectations(Map<String, Map<String, Object>> jkubeConfig) {
    ProcessorConfig c = new ProcessorConfig(null, null, jkubeConfig);
    new Expectations() {

        {
            Configuration.ConfigurationBuilder configBuilder = Configuration.builder();
            configBuilder.processorConfig(c);
            context.getConfiguration();
            result = configBuilder.build();
        }
    };
}
Also used : Expectations(mockit.Expectations) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig)

Example 24 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class WildflyJARHealthCheckEnricherTest method setupExpectations.

private void setupExpectations(JavaProject project, Map<String, Object> bootableJarconfig, Map<String, Map<String, Object>> jkubeConfig) {
    Plugin plugin = Plugin.builder().artifactId(WildflyJARHealthCheckEnricher.BOOTABLE_JAR_ARTIFACT_ID).groupId(WildflyJARHealthCheckEnricher.BOOTABLE_JAR_GROUP_ID).configuration(bootableJarconfig).build();
    List<Plugin> lst = new ArrayList<>();
    lst.add(plugin);
    ProcessorConfig c = new ProcessorConfig(null, null, jkubeConfig);
    new Expectations() {

        {
            project.getPlugins();
            result = lst;
            context.getProject();
            result = project;
            Configuration.ConfigurationBuilder configBuilder = Configuration.builder();
            configBuilder.processorConfig(c);
            context.getConfiguration();
            result = configBuilder.build();
        }
    };
}
Also used : Expectations(mockit.Expectations) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) ArrayList(java.util.ArrayList) Plugin(org.eclipse.jkube.kit.common.Plugin) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig)

Example 25 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class WildflyJARGeneratorTest method contextForSlimServer.

private GeneratorContext contextForSlimServer(JavaProject project, Map<String, Object> bootableJarconfig, Path dir) {
    Plugin plugin = Plugin.builder().artifactId(WildflyJARHealthCheckEnricher.BOOTABLE_JAR_ARTIFACT_ID).groupId(WildflyJARHealthCheckEnricher.BOOTABLE_JAR_GROUP_ID).configuration(bootableJarconfig).build();
    List<Plugin> lst = new ArrayList<>();
    lst.add(plugin);
    ProcessorConfig c = new ProcessorConfig(null, null, Collections.emptyMap());
    if (dir == null) {
        new Expectations() {

            {
                project.getPlugins();
                result = lst;
                context.getProject();
                result = project;
            }
        };
    } else {
        new Expectations() {

            {
                project.getPlugins();
                result = lst;
                project.getBaseDirectory();
                result = dir.toFile();
                context.getProject();
                result = project;
            }
        };
    }
    return context;
}
Also used : Expectations(mockit.Expectations) ArrayList(java.util.ArrayList) Plugin(org.eclipse.jkube.kit.common.Plugin) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig)

Aggregations

ProcessorConfig (org.eclipse.jkube.kit.config.resource.ProcessorConfig)33 Expectations (mockit.Expectations)22 Before (org.junit.Before)14 Test (org.junit.Test)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)12 Properties (java.util.Properties)12 TreeMap (java.util.TreeMap)6 Configuration (org.eclipse.jkube.kit.enricher.api.model.Configuration)6 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)4 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)4 ArrayList (java.util.ArrayList)4 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)4 File (java.io.File)3 URLClassLoader (java.net.URLClassLoader)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ProjectClassLoaders (org.eclipse.jkube.kit.common.util.ProjectClassLoaders)3 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)3 TypeToken (com.google.common.reflect.TypeToken)2 Gson (com.google.gson.Gson)2