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