Search in sources :

Example 36 with DeploymentBuilder

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());
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Properties(java.util.Properties) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 37 with DeploymentBuilder

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());
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Properties(java.util.Properties) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 38 with DeploymentBuilder

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
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Expectations(mockit.Expectations) Properties(java.util.Properties) File(java.io.File) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 39 with DeploymentBuilder

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
}
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 40 with DeploymentBuilder

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()));
}
Also used : ReplicaSetBuilder(io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder) DaemonSetBuilder(io.fabric8.kubernetes.api.model.apps.DaemonSetBuilder) ReplicationControllerBuilder(io.fabric8.kubernetes.api.model.ReplicationControllerBuilder) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) DeploymentConfigBuilder(io.fabric8.openshift.api.model.DeploymentConfigBuilder) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) StatefulSetBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder) Test(org.junit.Test)

Aggregations

DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)153 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)80 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)60 Test (org.junit.Test)60 Test (org.junit.jupiter.api.Test)32 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)26 Expectations (mockit.Expectations)26 Test (org.testng.annotations.Test)22 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)17 ArrayList (java.util.ArrayList)17 Container (io.fabric8.kubernetes.api.model.Container)16 HashMap (java.util.HashMap)16 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)15 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)15 DeploymentBuilder (io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder)14 Properties (java.util.Properties)14 Pod (io.fabric8.kubernetes.api.model.Pod)13 PodTemplateSpecBuilder (io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder)13 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)12 InternalRecipe (org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe)12