Search in sources :

Example 71 with Project

use of io.fabric8.openshift.api.model.Project 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 72 with Project

use of io.fabric8.openshift.api.model.Project 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 73 with Project

use of io.fabric8.openshift.api.model.Project 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 74 with Project

use of io.fabric8.openshift.api.model.Project 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)

Example 75 with Project

use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.

the class ReplicationControllerHandlerTest method replicationControllerHandlerTest.

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

Aggregations

Test (org.junit.Test)51 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)29 File (java.io.File)14 Expectations (mockit.Expectations)14 ArrayList (java.util.ArrayList)13 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)11 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)11 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)9 IOException (java.io.IOException)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)8 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)7 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)6 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)6 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)5 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)5 MojoFailureException (org.apache.maven.plugin.MojoFailureException)5 MavenProject (org.apache.maven.project.MavenProject)5 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3