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