use of io.fabric8.openshift.api.model.Project 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());
}
use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getImageNameTest.
@Test
public void getImageNameTest() {
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
// Image Configuration with name and without registry
ImageConfiguration imageConfiguration2 = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration1).build();
// Image Configuration without name and with registry
ImageConfiguration imageConfiguration3 = new ImageConfiguration.Builder().alias("test-app").buildConfig(buildImageConfiguration1).registry("docker.io").build();
// Image Configuration without name and registry
ImageConfiguration imageConfiguration4 = new ImageConfiguration.Builder().alias("test-app").buildConfig(buildImageConfiguration1).build();
images.clear();
images.add(imageConfiguration1);
images.add(imageConfiguration2);
images.add(imageConfiguration3);
images.add(imageConfiguration4);
containers = handler.getContainers(config1, images);
assertEquals("docker.io/test", containers.get(0).getImage());
assertEquals("test", containers.get(1).getImage());
assertNull(containers.get(2).getImage());
assertNull(containers.get(3).getImage());
}
use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class ContainerHandlerTest method getContainersWithAliasTest.
@Test
public void getContainersWithAliasTest() {
project.setArtifactId("test-artifact");
project.setGroupId("test-group");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
// container name with alias
BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals("test-app", containers.get(0).getName());
assertEquals("docker.io/test", containers.get(0).getImage());
assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class DaemonSetHandlerTest method daemonTemplateHandlerTest.
@Test
public void daemonTemplateHandlerTest() {
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler);
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").volumes(volumes1).build();
DaemonSet daemonSet = daemonSetHandler.getDaemonSet(config, images);
// Assertion
assertNotNull(daemonSet.getSpec());
assertNotNull(daemonSet.getMetadata());
assertNotNull(daemonSet.getSpec().getTemplate());
assertEquals("testing", daemonSet.getMetadata().getName());
assertEquals("test-account", daemonSet.getSpec().getTemplate().getSpec().getServiceAccountName());
assertFalse(daemonSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
assertEquals("test", daemonSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
assertEquals("/test/path", daemonSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
assertNotNull(daemonSet.getSpec().getTemplate().getSpec().getContainers());
}
use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class DaemonSetHandlerTest method daemonTemplateHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void daemonTemplateHandlerWithInvalidNameTest() {
// invalid controller name
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler);
// with invalid controller name
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").withServiceAccount("test-account").volumes(volumes1).build();
daemonSetHandler.getDaemonSet(config, images);
}
Aggregations