use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class AbstractHealthCheckEnricherTest method enrichAllContainers.
@Test
public void enrichAllContainers() {
final Properties properties = new Properties();
properties.put(AbstractHealthCheckEnricher.ENRICH_ALL_CONTAINERS, "true");
KubernetesListBuilder list = new KubernetesListBuilder().addToItems(new DeploymentBuilder().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withName("app").withImage("app:latest").endContainer().addNewContainer().withName("app2").withImage("app2:latest").endContainer().endSpec().endTemplate().endSpec().build());
createEnricher(properties, Collections.emptyMap()).create(PlatformMode.kubernetes, list);
final AtomicInteger containerFound = new AtomicInteger(0);
list.accept(new TypedVisitor<ContainerBuilder>() {
@Override
public void visit(ContainerBuilder container) {
if (container.getName().equals("app")) {
assertNotNull(container.build().getLivenessProbe());
assertNotNull(container.build().getReadinessProbe());
containerFound.incrementAndGet();
} else if (container.getName().equals("app2")) {
assertNotNull(container.build().getLivenessProbe());
assertNotNull(container.build().getReadinessProbe());
containerFound.incrementAndGet();
}
}
});
assertEquals(2, containerFound.get());
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class AbstractHealthCheckEnricherTest method enrichSingleContainer.
@Test
public void enrichSingleContainer() {
KubernetesListBuilder list = new KubernetesListBuilder().addToItems(new DeploymentBuilder().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withName("app").withImage("app:latest").endContainer().endSpec().endTemplate().endSpec().build());
createEnricher(new Properties(), Collections.emptyMap()).create(PlatformMode.kubernetes, list);
final AtomicInteger containerFound = new AtomicInteger(0);
list.accept(new TypedVisitor<ContainerBuilder>() {
@Override
public void visit(ContainerBuilder container) {
assertNotNull(container.build().getLivenessProbe());
assertNotNull(container.build().getReadinessProbe());
containerFound.incrementAndGet();
}
});
assertEquals(1, containerFound.get());
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class QuarkusHealthCheckEnricherTest method setUp.
@SuppressWarnings("ResultOfMethodCallIgnored")
@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;
javaProject.getProperties();
result = properties;
minTimes = 0;
javaProject.getOutputDirectory();
result = new File("/tmp/ignored");
minTimes = 0;
}
};
// @formatter:on
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder 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 io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class KubernetesHelperTest method testIsControllerResource.
@Test
public void testIsControllerResource() {
assertTrue(KubernetesHelper.isControllerResource(new DeploymentBuilder().build()));
assertTrue(KubernetesHelper.isControllerResource(new StatefulSetBuilder().build()));
assertTrue(KubernetesHelper.isControllerResource(new ReplicationControllerBuilder().build()));
assertTrue(KubernetesHelper.isControllerResource(new ReplicaSetBuilder().build()));
assertTrue(KubernetesHelper.isControllerResource(new DeploymentConfigBuilder().build()));
assertTrue(KubernetesHelper.isControllerResource(new DaemonSetBuilder().build()));
assertFalse(KubernetesHelper.isControllerResource(new ConfigMapBuilder().build()));
}
Aggregations