Search in sources :

Example 16 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar 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 17 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project strimzi by strimzi.

the class KafkaSetOperatorTest method testNeedsRollingUpdateEnvOffsetsRepFactor.

@Test
public void testNeedsRollingUpdateEnvOffsetsRepFactor() {
    String envVar = KEY_KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR;
    a.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, containerEnvVars(a.getSpec().getTemplate().getSpec().getContainers().get(0)).get(envVar) + "-foo", null));
    assertTrue(KafkaSetOperator.needsRollingUpdate(diff()));
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Example 18 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project strimzi by strimzi.

the class KafkaSetOperatorTest method testNeedsRollingUpdateEnvSomeOtherThing.

@Test
public void testNeedsRollingUpdateEnvSomeOtherThing() {
    String envVar = "SOME_RANDOM_ENV";
    a.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, "foo", null));
    assertTrue(KafkaSetOperator.needsRollingUpdate(diff()));
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Example 19 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project strimzi by strimzi.

the class KafkaSetOperatorTest method testNeedsRollingUpdateEnvTxnRepFactor.

@Test
public void testNeedsRollingUpdateEnvTxnRepFactor() {
    String envVar = KEY_KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR;
    a.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, containerEnvVars(a.getSpec().getTemplate().getSpec().getContainers().get(0)).get(envVar) + "-foo", null));
    assertTrue(KafkaSetOperator.needsRollingUpdate(diff()));
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Example 20 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project strimzi by strimzi.

the class ZookeeperSetOperatiorTest method testNeedsRollingUpdateEnvSomeOtherThing.

@Test
public void testNeedsRollingUpdateEnvSomeOtherThing() {
    String envVar = "SOME_RANDOM_ENV";
    a.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, "foo", null));
    assertTrue(ZookeeperSetOperator.needsRollingUpdate(diff()));
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Aggregations

EnvVar (io.fabric8.kubernetes.api.model.EnvVar)51 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)15 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)11 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)10 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)10 HashMap (java.util.HashMap)10 Container (io.fabric8.kubernetes.api.model.Container)9 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)9 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)9 File (java.io.File)8 List (java.util.List)8 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)7 Pod (io.fabric8.kubernetes.api.model.Pod)7 ServiceSpecBuilder (io.fabric8.kubernetes.api.model.ServiceSpecBuilder)7 Map (java.util.Map)7 Test (org.testng.annotations.Test)7 LinkedList (java.util.LinkedList)6 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)5 VolumeMount (io.fabric8.kubernetes.api.model.VolumeMount)5