use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class EntityOperatorTest method testTopicOperatorContainerEnvVars.
@ParallelTest
public void testTopicOperatorContainerEnvVars() {
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 topicOperatorContainer = new ContainerTemplate();
topicOperatorContainer.setEnv(testEnvs);
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withNewEntityOperator().withTopicOperator(entityTopicOperatorSpec).withUserOperator(entityUserOperatorSpec).withNewTemplate().withTopicOperatorContainer(topicOperatorContainer).endTemplate().endEntityOperator().endSpec().build();
List<EnvVar> containerEnvVars = EntityOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource, VERSIONS).getTopicOperator().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));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class EntityOperatorTest method testUserOperatorContainerEnvVarsConflict.
@ParallelTest
public void testUserOperatorContainerEnvVarsConflict() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = EntityUserOperator.ENV_VAR_FULL_RECONCILIATION_INTERVAL_MS;
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = EntityUserOperator.ENV_VAR_KAFKA_BOOTSTRAP_SERVERS;
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 prevent over writing existing container environment variable: " + testEnvOneKey, containerEnvVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(false));
assertThat("Failed to prevent over writing existing container environment variable: " + testEnvTwoKey, containerEnvVars.stream().filter(env -> testEnvTwoKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvTwoValue), is(false));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi 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));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class KafkaClusterTest method testKafkaContainerEnvVarsConflict.
@ParallelTest
public void testKafkaContainerEnvVarsConflict() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = KafkaCluster.ENV_VAR_KAFKA_JMX_ENABLED;
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = KafkaCluster.ENV_VAR_STRIMZI_KAFKA_GC_LOG_ENABLED;
String testEnvTwoValue = "test.env.two";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
testEnvs.add(envVar2);
ContainerTemplate kafkaContainer = new ContainerTemplate();
kafkaContainer.setEnv(testEnvs);
Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withNewTemplate().withKafkaContainer(kafkaContainer).endTemplate().withNewJmxOptions().withNewKafkaJmxAuthenticationPassword().endKafkaJmxAuthenticationPassword().endJmxOptions().endKafka().endSpec().build();
KafkaCluster kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS);
List<EnvVar> kafkaEnvVars = kc.getEnvVars();
assertThat("Failed to prevent over writing existing container environment variable: " + testEnvOneKey, kafkaEnvVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(false));
assertThat("Failed to prevent over writing existing container environment variable: " + testEnvTwoKey, kafkaEnvVars.stream().filter(env -> testEnvTwoKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvTwoValue), is(false));
}
use of io.strimzi.api.kafka.model.ContainerEnvVar in project strimzi by strimzi.
the class EntityOperatorTest method testTlsSidecarContainerEnvVarsConflict.
@ParallelTest
public void testTlsSidecarContainerEnvVarsConflict() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = EntityOperator.ENV_VAR_ZOOKEEPER_CONNECT;
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
List<ContainerEnvVar> testEnvs = new ArrayList<>();
testEnvs.add(envVar1);
ContainerTemplate tlsContainer = new ContainerTemplate();
tlsContainer.setEnv(testEnvs);
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withNewEntityOperator().withTopicOperator(entityTopicOperatorSpec).withUserOperator(entityUserOperatorSpec).withNewTemplate().withTlsSidecarContainer(tlsContainer).endTemplate().endEntityOperator().endSpec().build();
List<EnvVar> containerEnvVars = EntityOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource, VERSIONS).getTlsSidecarEnvVars();
assertThat("Failed to prevent over writing existing container environment variable: " + testEnvOneKey, containerEnvVars.stream().filter(env -> testEnvOneKey.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").equals(testEnvOneValue), is(false));
}
Aggregations