Search in sources :

Example 21 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class JobHandlerTest method jobHandlerTest.

@Test
public void jobHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    JobHandler jobHandler = new JobHandler(podTemplateHandler);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").volumes(volumes1).build();
    Job job = jobHandler.getJob(config, images);
    // Assertion
    assertNotNull(job.getSpec());
    assertNotNull(job.getMetadata());
    assertNotNull(job.getSpec().getTemplate());
    assertEquals("testing", job.getMetadata().getName());
    assertEquals("test-account", job.getSpec().getTemplate().getSpec().getServiceAccountName());
    assertFalse(job.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
    assertEquals("test", job.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
    assertEquals("/test/path", job.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
    assertNotNull(job.getSpec().getTemplate().getSpec().getContainers());
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Job(io.fabric8.kubernetes.api.model.Job) Test(org.junit.Test)

Example 22 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class PodTemplateHandlerTest method podWithoutVolumeTemplateHandlerTest.

@Test
public void podWithoutVolumeTemplateHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    // Pod without Volume Config
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, images);
    // Assertion
    assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
    assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
    assertEquals("test-app", podTemplateSpec.getSpec().getContainers().get(0).getName());
    assertEquals("docker.io/test", podTemplateSpec.getSpec().getContainers().get(0).getImage());
    assertEquals("IfNotPresent", podTemplateSpec.getSpec().getContainers().get(0).getImagePullPolicy());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 23 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class PodTemplateHandlerTest method podWithoutEmptyTypeTemplateHandlerTest.

@Test
public void podWithoutEmptyTypeTemplateHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    // empty type
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).build();
    volumes1.clear();
    volumes1.add(volumeConfig1);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, images);
    // Assertion
    assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
    assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) Test(org.junit.Test)

Example 24 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class ReplicaSetHandlerTest method replicaSetHandlerTest.

@Test
public void replicaSetHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    ReplicaSetHandler replicaSetHandler = new ReplicaSetHandler(podTemplateHandler);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    ReplicaSet replicaSet = replicaSetHandler.getReplicaSet(config, images);
    // Assertion
    assertNotNull(replicaSet.getSpec());
    assertNotNull(replicaSet.getMetadata());
    assertEquals(5, replicaSet.getSpec().getReplicas().intValue());
    assertNotNull(replicaSet.getSpec().getTemplate());
    assertEquals("testing", replicaSet.getMetadata().getName());
    assertEquals("test-account", replicaSet.getSpec().getTemplate().getSpec().getServiceAccountName());
    assertFalse(replicaSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
    assertEquals("test", replicaSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
    assertEquals("/test/path", replicaSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
    assertNotNull(replicaSet.getSpec().getTemplate().getSpec().getContainers());
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) ReplicaSet(io.fabric8.kubernetes.api.model.extensions.ReplicaSet) Test(org.junit.Test)

Example 25 with ResourceConfig

use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.

the class ReplicationControllerHandlerTest method replicationControllerHandlerWithInvalidNameTest.

@Test(expected = IllegalArgumentException.class)
public void replicationControllerHandlerWithInvalidNameTest() {
    // invalid controller name
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    ReplicationControllerHandler replicationControllerHandler = new ReplicationControllerHandler(podTemplateHandler);
    // with invalid controller name
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    replicationControllerHandler.getReplicationController(config, images);
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Aggregations

ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)31 Test (org.junit.Test)29 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)9 ArrayList (java.util.ArrayList)6 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)5 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)2 TypedVisitor (io.fabric8.kubernetes.api.builder.TypedVisitor)1 Container (io.fabric8.kubernetes.api.model.Container)1 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)1 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 Job (io.fabric8.kubernetes.api.model.Job)1 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)1 PodSpecBuilder (io.fabric8.kubernetes.api.model.PodSpecBuilder)1 Probe (io.fabric8.kubernetes.api.model.Probe)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 VolumeMount (io.fabric8.kubernetes.api.model.VolumeMount)1 VolumeMountBuilder (io.fabric8.kubernetes.api.model.VolumeMountBuilder)1 DaemonSet (io.fabric8.kubernetes.api.model.extensions.DaemonSet)1 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)1