use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class ReplicaSetHandlerTest method replicaSetHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void replicaSetHandlerWithInvalidNameTest() {
// invalid controller name
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
ReplicaSetHandler replicaSetHandler = new ReplicaSetHandler(podTemplateHandler);
// with invalid controller name
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
replicaSetHandler.getReplicaSet(config, images);
}
use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class ReplicationControllerHandlerTest method replicationControllerHandlerWithoutControllerTest.
@Test(expected = IllegalArgumentException.class)
public void replicationControllerHandlerWithoutControllerTest() {
// without controller name
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
ReplicationControllerHandler replicationControllerHandler = new ReplicationControllerHandler(podTemplateHandler);
// without controller name
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").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 StatefulSetHandlerTest method statefulSetHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void statefulSetHandlerWithInvalidNameTest() {
// invalid controller name
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
StatefulSetHandler statefulSetHandler = new StatefulSetHandler(podTemplateHandler);
// with invalid controller name
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
statefulSetHandler.getStatefulSet(config, images);
}
use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class StatefulSetHandlerTest method statefulSetHandlerTest.
@Test
public void statefulSetHandlerTest() {
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
StatefulSetHandler statefulSetHandler = new StatefulSetHandler(podTemplateHandler);
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
StatefulSet statefulSet = statefulSetHandler.getStatefulSet(config, images);
// Assertion
assertNotNull(statefulSet.getSpec());
assertNotNull(statefulSet.getMetadata());
assertEquals(5, statefulSet.getSpec().getReplicas().intValue());
assertNotNull(statefulSet.getSpec().getTemplate());
assertEquals("testing", statefulSet.getMetadata().getName());
assertEquals("testing", statefulSet.getSpec().getServiceName());
assertEquals("test-account", statefulSet.getSpec().getTemplate().getSpec().getServiceAccountName());
assertFalse(statefulSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
assertEquals("test", statefulSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
assertEquals("/test/path", statefulSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
assertNotNull(statefulSet.getSpec().getTemplate().getSpec().getContainers());
}
use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.
the class ContainerHandler method getContainers.
List<Container> getContainers(ResourceConfig config, List<ImageConfiguration> images) {
List<Container> ret = new ArrayList<>();
for (ImageConfiguration imageConfig : images) {
if (imageConfig.getBuildConfiguration() != null) {
Probe livenessProbe = probeHandler.getProbe(config.getLiveness());
Probe readinessProbe = probeHandler.getProbe(config.getReadiness());
Container container = new ContainerBuilder().withName(KubernetesResourceUtil.extractContainerName(project, imageConfig)).withImage(getImageName(imageConfig)).withImagePullPolicy(getImagePullPolicy(config)).withEnv(envVarHandler.getEnvironmentVariables(config.getEnv())).withSecurityContext(createSecurityContext(config)).withPorts(getContainerPorts(imageConfig)).withVolumeMounts(getVolumeMounts(config)).withLivenessProbe(livenessProbe).withReadinessProbe(readinessProbe).build();
ret.add(container);
}
}
return ret;
}
Aggregations