use of io.fabric8.maven.core.config.ResourceConfig 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());
}
use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.
the class StatefulSetHandlerTest method statefulSetHandlerWithoutControllerTest.
@Test(expected = IllegalArgumentException.class)
public void statefulSetHandlerWithoutControllerTest() {
// without controller name
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
StatefulSetHandler statefulSetHandler = new StatefulSetHandler(podTemplateHandler);
// without controller name
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
statefulSetHandler.getStatefulSet(config, images);
}
use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getVolumeMountWithNameAndMountTest.
@Test
public void getVolumeMountWithNameAndMountTest() {
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
List<String> mounts = new ArrayList<>();
mounts.add("/path/etc");
images.clear();
images.add(imageConfiguration1);
// volume config with name and single mount
VolumeConfig volumeConfig3 = new VolumeConfig.Builder().name("third").mounts(mounts).build();
volumes1.clear();
volumes1.add(volumeConfig3);
ResourceConfig config3 = new ResourceConfig.Builder().volumes(volumes1).build();
containers = handler.getContainers(config3, images);
assertEquals(1, containers.get(0).getVolumeMounts().size());
assertEquals("third", containers.get(0).getVolumeMounts().get(0).getName());
assertEquals("/path/etc", containers.get(0).getVolumeMounts().get(0).getMountPath());
}
use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getVolumeMountWithEmptyVolumeTest.
@Test
public void getVolumeMountWithEmptyVolumeTest() {
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
images.clear();
images.add(imageConfiguration1);
// empty volume
ResourceConfig config5 = new ResourceConfig.Builder().volumes(volumes2).build();
containers = handler.getContainers(config5, images);
assertTrue(containers.get(0).getVolumeMounts().isEmpty());
}
use of io.fabric8.maven.core.config.ResourceConfig in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getVolumeMountWithoutNameTest.
@Test
public void getVolumeMountWithoutNameTest() {
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
images.clear();
images.add(imageConfiguration1);
List<String> mounts = new ArrayList<>();
mounts.add("/path/etc");
// volume config without name but with mount
VolumeConfig volumeConfig2 = new VolumeConfig.Builder().mounts(mounts).build();
volumes1.clear();
volumes1.add(volumeConfig2);
ResourceConfig config2 = new ResourceConfig.Builder().volumes(volumes1).build();
containers = handler.getContainers(config2, images);
assertEquals(1, containers.get(0).getVolumeMounts().size());
assertEquals(null, containers.get(0).getVolumeMounts().get(0).getName());
assertEquals("/path/etc", containers.get(0).getVolumeMounts().get(0).getMountPath());
}
Aggregations