use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class JmxTransTest method testContainerEnvVarsConflict.
@ParallelTest
public void testContainerEnvVarsConflict() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = JmxTrans.ENV_VAR_JMXTRANS_LOGGING_LEVEL;
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
ContainerTemplate container = new ContainerTemplate();
container.setEnv(testEnvs);
Kafka resource = new KafkaBuilder(kafkaAssembly).editSpec().editJmxTrans().withNewTemplate().withNewContainer().withEnv(testEnvs).endContainer().endTemplate().endJmxTrans().endSpec().build();
List<EnvVar> envVars = JmxTrans.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS).getEnvVars();
assertThat("Failed to prevent over writing existing container environment variable: " + testEnvOneKey, envVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(false));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class JmxTransTest method testContainerEnvVars.
@ParallelTest
public void testContainerEnvVars() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = "TEST_ENV_1";
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = "TEST_ENV_2";
String testEnvTwoValue = "test.env.two";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
testEnvs.add(envVar2);
ContainerTemplate container = new ContainerTemplate();
container.setEnv(testEnvs);
Kafka resource = new KafkaBuilder(kafkaAssembly).editSpec().editJmxTrans().withNewTemplate().withNewContainer().withEnv(testEnvs).endContainer().endTemplate().endJmxTrans().endSpec().build();
List<EnvVar> envVars = JmxTrans.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS).getEnvVars();
assertThat("Failed to correctly set container environment variable: " + testEnvOneKey, envVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(true));
assertThat("Failed to correctly set container environment variable: " + testEnvTwoKey, envVars.stream().filter(env -> testEnvTwoKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvTwoValue), is(true));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class KafkaClusterTest method testInitContainerEnvVars.
@ParallelTest
public void testInitContainerEnvVars() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = "TEST_ENV_1";
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = "TEST_ENV_2";
String testEnvTwoValue = "test.env.two";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
testEnvs.add(envVar2);
ContainerTemplate initContainer = new ContainerTemplate();
initContainer.setEnv(testEnvs);
Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withNewTemplate().withInitContainer(initContainer).endTemplate().endKafka().endSpec().build();
List<EnvVar> kafkaEnvVars = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS).getInitContainerEnvVars();
assertThat("Failed to correctly set container environment variable: " + testEnvOneKey, kafkaEnvVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(true));
assertThat("Failed to correctly set container environment variable: " + testEnvTwoKey, kafkaEnvVars.stream().filter(env -> testEnvTwoKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvTwoValue), is(true));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class KafkaBridgeClusterTest method testKafkaBridgeContainerEnvVars.
@ParallelTest
public void testKafkaBridgeContainerEnvVars() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = "TEST_ENV_1";
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = "TEST_ENV_2";
String testEnvTwoValue = "test.env.two";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
testEnvs.add(envVar2);
ContainerTemplate kafkaBridgeContainer = new ContainerTemplate();
kafkaBridgeContainer.setEnv(testEnvs);
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewTemplate().withBridgeContainer(kafkaBridgeContainer).endTemplate().endSpec().build();
List<EnvVar> kafkaEnvVars = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS).getEnvVars();
assertThat("Failed to correctly set container environment variable: " + testEnvOneKey, kafkaEnvVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(true));
assertThat("Failed to correctly set container environment variable: " + testEnvTwoKey, kafkaEnvVars.stream().filter(env -> testEnvTwoKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvTwoValue), is(true));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi-kafka-operator by strimzi.
the class EntityOperatorTest method testUserOperatorContainerEnvVars.
@ParallelTest
public void testUserOperatorContainerEnvVars() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = "TEST_ENV_1";
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = "TEST_ENV_2";
String testEnvTwoValue = "test.env.two";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
testEnvs.add(envVar2);
ContainerTemplate userOperatorContainer = new ContainerTemplate();
userOperatorContainer.setEnv(testEnvs);
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withNewEntityOperator().withTopicOperator(entityTopicOperatorSpec).withUserOperator(entityUserOperatorSpec).withNewTemplate().withUserOperatorContainer(userOperatorContainer).endTemplate().endEntityOperator().endSpec().build();
List<EnvVar> containerEnvVars = EntityOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource, VERSIONS).getUserOperator().getEnvVars();
assertThat("Failed to correctly set container environment variable: " + testEnvOneKey, containerEnvVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(true));
assertThat("Failed to correctly set container environment variable: " + testEnvTwoKey, containerEnvVars.stream().filter(env -> testEnvTwoKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvTwoValue), is(true));
}
Aggregations