Search in sources :

Example 1 with ProjectClassLoaders

use of org.eclipse.jkube.kit.common.util.ProjectClassLoaders in project jkube by eclipse.

the class ThorntailV2HealthCheckEnricherTest method setUp.

@Before
public void setUp() {
    properties = new Properties();
    processorConfig = new ProcessorConfig();
    klb = new KubernetesListBuilder();
    // @formatter:off
    klb.addToItems(new DeploymentBuilder().editOrNewSpec().editOrNewTemplate().editOrNewMetadata().withName("template-name").endMetadata().editOrNewSpec().addNewContainer().withImage("container/image").endContainer().endSpec().endTemplate().endSpec().build());
    new Expectations() {

        {
            context.getProperties();
            result = properties;
            context.getConfiguration().getProcessorConfig();
            result = processorConfig;
            context.hasDependency("io.thorntail", "monitor");
            result = true;
            context.getProjectClassLoaders();
            result = new ProjectClassLoaders(new URLClassLoader(new URL[0], ThorntailV2HealthCheckEnricherTest.class.getClassLoader()));
        }
    };
// @formatter:on
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Expectations(mockit.Expectations) ProjectClassLoaders(org.eclipse.jkube.kit.common.util.ProjectClassLoaders) URLClassLoader(java.net.URLClassLoader) Properties(java.util.Properties) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 2 with ProjectClassLoaders

use of org.eclipse.jkube.kit.common.util.ProjectClassLoaders 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 3 with ProjectClassLoaders

use of org.eclipse.jkube.kit.common.util.ProjectClassLoaders in project jkube by eclipse.

the class AbstractSpringBootHealthCheckEnricherTestSupport method testDefaultInitialDelayForLivenessAndReadiness.

@Test
public void testDefaultInitialDelayForLivenessAndReadiness() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    withProjectProperties(new Properties());
    new Expectations() {

        {
            context.getProjectClassLoaders();
            result = new ProjectClassLoaders(new URLClassLoader(new URL[0], AbstractSpringBootHealthCheckEnricherTestSupport.class.getClassLoader())) {

                @Override
                public boolean isClassInCompileClasspath(boolean all, String... clazz) {
                    return true;
                }
            };
        }
    };
    Probe probe = enricher.getReadinessProbe();
    assertNotNull(probe);
    assertEquals(10, probe.getInitialDelaySeconds().intValue());
    probe = enricher.getLivenessProbe();
    assertNotNull(probe);
    assertEquals(180, probe.getInitialDelaySeconds().intValue());
}
Also used : Expectations(mockit.Expectations) ProjectClassLoaders(org.eclipse.jkube.kit.common.util.ProjectClassLoaders) URLClassLoader(java.net.URLClassLoader) Properties(java.util.Properties) Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Example 4 with ProjectClassLoaders

use of org.eclipse.jkube.kit.common.util.ProjectClassLoaders 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)

Aggregations

URLClassLoader (java.net.URLClassLoader)4 Properties (java.util.Properties)4 Expectations (mockit.Expectations)4 ProjectClassLoaders (org.eclipse.jkube.kit.common.util.ProjectClassLoaders)4 Probe (io.fabric8.kubernetes.api.model.Probe)3 ProcessorConfig (org.eclipse.jkube.kit.config.resource.ProcessorConfig)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)1 Before (org.junit.Before)1