use of io.strimzi.operator.common.Reconciliation in project strimzi by strimzi.
the class EntityOperatorTest method testUserOperatorContainerEnvVarsWithKRaft.
@ParallelTest
public void testUserOperatorContainerEnvVarsWithKRaft() {
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withNewEntityOperator().withUserOperator(entityUserOperatorSpec).endEntityOperator().endSpec().build();
List<EnvVar> containerEnvVars = EntityOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource, VERSIONS, false).userOperator().getEnvVars();
assertThat(containerEnvVars.stream().filter(env -> EntityUserOperator.ENV_VAR_KRAFT_ENABLED.equals(env.getName())).map(EnvVar::getValue).findFirst().orElse(""), is("false"));
}
use of io.strimzi.operator.common.Reconciliation in project strimzi by strimzi.
the class EntityOperatorTest method testRole.
@ParallelTest
public void testRole() {
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().editOrNewEntityOperator().withNewTopicOperator().endTopicOperator().endEntityOperator().endSpec().build();
EntityOperator eo = EntityOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource, VERSIONS, true);
Role role = eo.generateRole(namespace, namespace);
assertThat(role.getMetadata().getName(), is("foo-entity-operator"));
assertThat(role.getMetadata().getNamespace(), is(namespace));
List<PolicyRule> rules = new ArrayList<>();
rules.add(new PolicyRuleBuilder().addToResources("kafkatopics", "kafkatopics/status", "kafkausers", "kafkausers/status").addToVerbs("get", "list", "watch", "create", "patch", "update", "delete").addToApiGroups(Constants.RESOURCE_GROUP_NAME).build());
rules.add(new PolicyRuleBuilder().addToResources("events").addToVerbs("create").addToApiGroups("").build());
rules.add(new PolicyRuleBuilder().addToResources("secrets").addToVerbs("get", "list", "watch", "create", "delete", "patch", "update").addToApiGroups("").build());
assertThat(role.getRules(), is(rules));
}
use of io.strimzi.operator.common.Reconciliation in project strimzi by strimzi.
the class EntityTopicOperatorTest method testFromCrdNoTopicOperatorInEntityOperator.
@ParallelTest
public void testFromCrdNoTopicOperatorInEntityOperator() {
EntityOperatorSpec entityOperatorSpec = new EntityOperatorSpecBuilder().build();
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withEntityOperator(entityOperatorSpec).endSpec().build();
EntityTopicOperator entityTopicOperator = EntityTopicOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource);
assertThat(entityTopicOperator, is(nullValue()));
}
use of io.strimzi.operator.common.Reconciliation in project strimzi by strimzi.
the class EntityTopicOperatorTest method testNoWatchedNamespace.
@ParallelTest
public void testNoWatchedNamespace() {
EntityOperatorSpec entityOperatorSpec = new EntityOperatorSpecBuilder().withNewTopicOperator().endTopicOperator().build();
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withEntityOperator(entityOperatorSpec).endSpec().build();
EntityTopicOperator entityTopicOperator = EntityTopicOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource);
assertThat(entityTopicOperator.watchedNamespace(), is(namespace));
}
use of io.strimzi.operator.common.Reconciliation in project strimzi by strimzi.
the class EntityTopicOperatorTest method testWatchedNamespace.
@ParallelTest
public void testWatchedNamespace() {
EntityOperatorSpec entityOperatorSpec = new EntityOperatorSpecBuilder().withNewTopicOperator().withWatchedNamespace("some-other-namespace").endTopicOperator().build();
Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().withEntityOperator(entityOperatorSpec).endSpec().build();
EntityTopicOperator entityTopicOperator = EntityTopicOperator.fromCrd(new Reconciliation("test", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()), resource);
assertThat(entityTopicOperator.watchedNamespace(), is("some-other-namespace"));
}
Aggregations