Search in sources :

Example 21 with Project

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

the class DaemonSetHandlerTest method daemonTemplateHandlerWithoutControllerTest.

@Test(expected = IllegalArgumentException.class)
public void daemonTemplateHandlerWithoutControllerTest() {
    // without controller name
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    DaemonSetHandler daemonSetHandler = new DaemonSetHandler(podTemplateHandler);
    // without controller name
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").withServiceAccount("test-account").volumes(volumes1).build();
    daemonSetHandler.getDaemonSet(config, images);
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 22 with Project

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

the class DeploymentHandlerTest method deploymentTemplateHandlerTest.

@Test
public void deploymentTemplateHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    DeploymentHandler deploymentHandler = new DeploymentHandler(podTemplateHandler);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    Deployment deployment = deploymentHandler.getDeployment(config, images);
    // Assertion
    assertNotNull(deployment.getSpec());
    assertNotNull(deployment.getMetadata());
    assertEquals(5, deployment.getSpec().getReplicas().intValue());
    assertNotNull(deployment.getSpec().getTemplate());
    assertEquals("testing", deployment.getMetadata().getName());
    assertEquals("test-account", deployment.getSpec().getTemplate().getSpec().getServiceAccountName());
    assertFalse(deployment.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
    assertEquals("test", deployment.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
    assertEquals("/test/path", deployment.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
    assertNotNull(deployment.getSpec().getTemplate().getSpec().getContainers());
}
Also used : Deployment(io.fabric8.kubernetes.api.model.extensions.Deployment) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 23 with Project

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

the class DeploymentHandlerTest method deploymentTemplateHandlerWithoutControllerTest.

@Test(expected = IllegalArgumentException.class)
public void deploymentTemplateHandlerWithoutControllerTest() {
    // without controller name
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    DeploymentHandler deploymentHandler = new DeploymentHandler(podTemplateHandler);
    // without controller name
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    deploymentHandler.getDeployment(config, images);
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 24 with Project

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

the class EnvVarHandlerTest method envVarHandlerTest.

@Test
public void envVarHandlerTest() {
    // Some Environment Variable in Config
    EnvVar var1 = new EnvVarBuilder().withName("TEST1").withValue("OK").build();
    EnvVar var2 = new EnvVarBuilder().withName("TEST2").withValue("DONE").build();
    EnvVar var3 = new EnvVarBuilder().withName("TEST3").withValue("").build();
    env.clear();
    env.put(var1.getName(), var1.getValue());
    env.put(var2.getName(), var2.getValue());
    env.put(var3.getName(), var3.getValue());
    EnvVarHandler envVarHandler = new EnvVarHandler(project);
    new Expectations() {

        {
            externalEnvVarHandler.getExportedEnvironmentVariables(project, env);
            ret.putAll(env);
            result = ret;
        }
    };
    List<EnvVar> envVars = envVarHandler.getEnvironmentVariables(env);
    assertNotNull(envVars);
    assertEquals(4, envVars.size());
    assertTrue(envVars.contains(var1));
    assertTrue(envVars.contains(var2));
    assertTrue(envVars.contains(var3));
    assertTrue(envVars.contains(var4));
}
Also used : Expectations(mockit.Expectations) ExternalEnvVarHandler(io.fabric8.maven.core.extenvvar.ExternalEnvVarHandler) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) Test(org.junit.Test)

Example 25 with Project

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

the class JobHandlerTest method daemonTemplateHandlerWithoutControllerTest.

@Test(expected = IllegalArgumentException.class)
public void daemonTemplateHandlerWithoutControllerTest() {
    // without controller name
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    JobHandler jobHandler = new JobHandler(podTemplateHandler);
    // without controller name
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").withServiceAccount("test-account").volumes(volumes1).build();
    jobHandler.getJob(config, images);
}
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