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
}
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());
}
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());
}
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());
}
Aggregations