Search in sources :

Example 76 with Project

use of io.fabric8.openshift.api.model.Project 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);
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 77 with Project

use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.

the class ContainerHandlerTest method containerPortsWithoutPortTest.

@Test
public void containerPortsWithoutPortTest() {
    ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
    // without Ports
    BuildImageConfiguration buildImageConfiguration2 = new BuildImageConfiguration.Builder().from("fabric8/maven:latest").cleanup("try").compression("gzip").build();
    ImageConfiguration imageConfiguration2 = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration2).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration2);
    containers = handler.getContainers(config, images);
    assertTrue(containers.get(0).getPorts().isEmpty());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 78 with Project

use of io.fabric8.openshift.api.model.Project in project fabric8-maven-plugin by fabric8io.

the class ContainerHandlerTest method getContainerWithGroupArtifactTest.

@Test
public void getContainerWithGroupArtifactTest() {
    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 group id and aritact id without alias and user
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compression("gzip").dockerFile("testFile").dockerFileDir("/demo").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("test-group-test-artifact", containers.get(0).getName());
    assertEquals("docker.io/test", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 79 with Project

use of io.fabric8.openshift.api.model.Project 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());
}
Also used : ArrayList(java.util.ArrayList) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) Test(org.junit.Test)

Example 80 with Project

use of io.fabric8.openshift.api.model.Project 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());
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)51 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)29 File (java.io.File)14 Expectations (mockit.Expectations)14 ArrayList (java.util.ArrayList)13 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)11 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)11 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)9 IOException (java.io.IOException)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)8 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)7 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)6 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)6 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)5 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)5 MojoFailureException (org.apache.maven.plugin.MojoFailureException)5 MavenProject (org.apache.maven.project.MavenProject)5 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3