Search in sources :

Example 61 with Config

use of io.fabric8.agent.model.Config in project fabric8-maven-plugin by fabric8io.

the class PodTemplateHandlerTest method podWithInvalidVolumeTypeTemplateHandlerTest.

@Test
public void podWithInvalidVolumeTypeTemplateHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    // invalid type
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hoStPath").path("/test/path").build();
    volumes1.clear();
    volumes1.add(volumeConfig1);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, images);
    // Assertion
    assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
    assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) Test(org.junit.Test)

Example 62 with Config

use of io.fabric8.agent.model.Config in project fabric8-maven-plugin by fabric8io.

the class PodTemplateHandlerTest method podWithEmotyVolumeTemplateHandlerTest.

@Test
public void podWithEmotyVolumeTemplateHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    // Pod with empty Volume Config and wihtout ServiceAccount
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withReplicas(5).volumes(volumes1).build();
    PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, images);
    // Assertion
    assertNull(podTemplateSpec.getSpec().getServiceAccountName());
    assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
    assertNotNull(podTemplateSpec.getSpec().getContainers());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) Test(org.junit.Test)

Example 63 with Config

use of io.fabric8.agent.model.Config in project fabric8-maven-plugin by fabric8io.

the class ReplicaSetHandlerTest method before.

@Before
public void before() {
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // 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.add(imageConfiguration);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Example 64 with Config

use of io.fabric8.agent.model.Config in project fabric8-maven-plugin by fabric8io.

the class ReplicaSetHandlerTest method replicaSetHandlerWithoutControllerTest.

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

Example 65 with Config

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

Aggregations

Test (org.junit.Test)128 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)44 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)43 IOException (java.io.IOException)41 HashMap (java.util.HashMap)40 File (java.io.File)31 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)28 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)28 Map (java.util.Map)28 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)24 ArrayList (java.util.ArrayList)24 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)23 AbstractConfigHandlerTest (io.fabric8.maven.docker.config.handler.AbstractConfigHandlerTest)21 Expectations (mockit.Expectations)20 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)19 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)17 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)16 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)15 AuthConfig (io.fabric8.maven.docker.access.AuthConfig)14 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)12