use of io.strimzi.systemtest.Constants.INFRA_NAMESPACE in project strimzi-kafka-operator by strimzi.
the class MirrorMaker2IsolatedST method testKafkaMirrorMaker2ReflectsConnectorsState.
@ParallelNamespaceTest
void testKafkaMirrorMaker2ReflectsConnectorsState(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(INFRA_NAMESPACE, extensionContext);
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClusterSourceName = clusterName + "-source";
String kafkaClusterTargetName = clusterName + "-target";
String errorMessage = "One or more connectors are in FAILED state";
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterSourceName, 1, 1).build(), KafkaTemplates.kafkaEphemeral(kafkaClusterTargetName, 1, 1).build());
resourceManager.createResource(extensionContext, false, KafkaMirrorMaker2Templates.kafkaMirrorMaker2(clusterName, kafkaClusterTargetName, kafkaClusterSourceName, 1, false).editSpec().editMatchingCluster(spec -> spec.getAlias().equals(kafkaClusterSourceName)).withBootstrapServers(KafkaResources.bootstrapServiceName(kafkaClusterSourceName) + ".:9092").endCluster().endSpec().build());
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2StatusMessage(namespaceName, clusterName, errorMessage);
KafkaMirrorMaker2Resource.replaceKafkaMirrorMaker2ResourceInSpecificNamespace(clusterName, mm2 -> mm2.getSpec().getClusters().stream().filter(mm2ClusterSpec -> mm2ClusterSpec.getAlias().equals(kafkaClusterSourceName)).findFirst().get().setBootstrapServers(KafkaUtils.namespacedPlainBootstrapAddress(kafkaClusterSourceName, namespaceName)), namespaceName);
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2Ready(namespaceName, clusterName);
KafkaMirrorMaker2Status kmm2Status = KafkaMirrorMaker2Resource.kafkaMirrorMaker2Client().inNamespace(namespaceName).withName(clusterName).get().getStatus();
assertFalse(kmm2Status.getConditions().stream().anyMatch(condition -> condition.getMessage() != null && condition.getMessage().contains(errorMessage)));
}
use of io.strimzi.systemtest.Constants.INFRA_NAMESPACE in project strimzi-kafka-operator by strimzi.
the class MirrorMaker2IsolatedST method testStrimziIdentityReplicationPolicy.
/*
* This test is using the Strimzi Identity Replication policy. This is needed for backwards compatibility for users
* who might still have it configured.
*
* This ST should be deleted once we drop the Strimzi policy completely.
*/
@ParallelNamespaceTest
void testStrimziIdentityReplicationPolicy(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(INFRA_NAMESPACE, extensionContext);
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClusterSourceName = clusterName + "-source";
String kafkaClusterTargetName = clusterName + "-target";
String originalTopicName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClientsName = mapWithKafkaClientNames.get(extensionContext.getDisplayName());
// Deploy source kafka
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterSourceName, 1, 1).build());
// Deploy target kafka
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterTargetName, 1, 1).build());
// Create topic
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(kafkaClusterSourceName, originalTopicName, 3).build());
resourceManager.createResource(extensionContext, false, KafkaClientsTemplates.kafkaClients(namespaceName, false, kafkaClientsName).build());
final String kafkaClientsPodName = PodUtils.getPodsByPrefixInNameWithDynamicWait(namespaceName, kafkaClientsName).get(0).getMetadata().getName();
resourceManager.createResource(extensionContext, KafkaMirrorMaker2Templates.kafkaMirrorMaker2(clusterName, kafkaClusterTargetName, kafkaClusterSourceName, 1, false).editSpec().editMirror(0).editSourceConnector().addToConfig("replication.policy.class", "io.strimzi.kafka.connect.mirror.IdentityReplicationPolicy").endSourceConnector().endMirror().endSpec().build());
LOGGER.info("Sending and receiving messages via {}", kafkaClusterSourceName);
InternalKafkaClient internalKafkaClient = new InternalKafkaClient.Builder().withNamespaceName(namespaceName).withTopicName(originalTopicName).withClusterName(kafkaClusterSourceName).withMessageCount(MESSAGE_COUNT).withUsingPodName(kafkaClientsPodName).withListenerName(Constants.PLAIN_LISTENER_DEFAULT_NAME).build();
internalKafkaClient.assertSentAndReceivedMessages(internalKafkaClient.sendMessagesPlain(), internalKafkaClient.receiveMessagesPlain());
LOGGER.info("Changing to {} and will try to receive messages", kafkaClusterTargetName);
internalKafkaClient = internalKafkaClient.toBuilder().withClusterName(kafkaClusterTargetName).build();
assertThat(internalKafkaClient.receiveMessagesPlain(), equalTo(MESSAGE_COUNT));
LOGGER.info("Checking if the mirrored topic name is same as the original one");
List<String> kafkaTopics = KafkaCmdClient.listTopicsUsingPodCli(namespaceName, kafkaClusterTargetName, 0);
assertNotNull(kafkaTopics.stream().filter(kafkaTopic -> kafkaTopic.equals(originalTopicName)).findAny());
List<String> kafkaTopicSpec = KafkaCmdClient.describeTopicUsingPodCli(namespaceName, kafkaClusterTargetName, 0, originalTopicName);
assertThat(kafkaTopicSpec.stream().filter(token -> token.startsWith("Topic:")).findFirst().orElse(null), equalTo("Topic:" + originalTopicName));
assertThat(kafkaTopicSpec.stream().filter(token -> token.startsWith("PartitionCount:")).findFirst().orElse(null), equalTo("PartitionCount:3"));
}
use of io.strimzi.systemtest.Constants.INFRA_NAMESPACE in project strimzi-kafka-operator by strimzi.
the class NamespaceRbacScopeOperatorIsolatedST method testNamespacedRbacScopeDeploysRoles.
@IsolatedTest("This test case needs own Cluster Operator")
void testNamespacedRbacScopeDeploysRoles(ExtensionContext extensionContext) {
assumeFalse(Environment.isOlmInstall() || Environment.isHelmInstall());
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
clusterOperator.unInstall();
clusterOperator = new SetupClusterOperator.SetupClusterOperatorBuilder().withExtensionContext(BeforeAllOnce.getSharedExtensionContext()).withNamespace(INFRA_NAMESPACE).withExtraEnvVars(Collections.singletonList(new EnvVar(Environment.STRIMZI_RBAC_SCOPE_ENV, Environment.STRIMZI_RBAC_SCOPE_NAMESPACE, null))).createInstallation().runInstallation();
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3, 3).editMetadata().addToLabels("app", "strimzi").endMetadata().build());
// Wait for Kafka to be Ready to ensure all potentially erroneous ClusterRole applications have happened
KafkaUtils.waitForKafkaReady(clusterName);
// Assert that no ClusterRoles are present on the server that have app strimzi
// Naturally returns false positives if another Strimzi operator has been installed
List<ClusterRole> strimziClusterRoles = kubeClient().listClusterRoles().stream().filter(cr -> {
Map<String, String> labels = cr.getMetadata().getLabels() != null ? cr.getMetadata().getLabels() : Collections.emptyMap();
return "strimzi".equals(labels.get("app"));
}).collect(Collectors.toList());
assertThat(strimziClusterRoles, is(Collections.emptyList()));
}
use of io.strimzi.systemtest.Constants.INFRA_NAMESPACE in project strimzi by strimzi.
the class MirrorMaker2IsolatedST method testKafkaMirrorMaker2ReflectsConnectorsState.
@ParallelNamespaceTest
void testKafkaMirrorMaker2ReflectsConnectorsState(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(INFRA_NAMESPACE, extensionContext);
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClusterSourceName = clusterName + "-source";
String kafkaClusterTargetName = clusterName + "-target";
String errorMessage = "One or more connectors are in FAILED state";
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterSourceName, 1, 1).build(), KafkaTemplates.kafkaEphemeral(kafkaClusterTargetName, 1, 1).build());
resourceManager.createResource(extensionContext, false, KafkaMirrorMaker2Templates.kafkaMirrorMaker2(clusterName, kafkaClusterTargetName, kafkaClusterSourceName, 1, false).editSpec().editMatchingCluster(spec -> spec.getAlias().equals(kafkaClusterSourceName)).withBootstrapServers(KafkaResources.bootstrapServiceName(kafkaClusterSourceName) + ".:9092").endCluster().endSpec().build());
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2StatusMessage(namespaceName, clusterName, errorMessage);
KafkaMirrorMaker2Resource.replaceKafkaMirrorMaker2ResourceInSpecificNamespace(clusterName, mm2 -> mm2.getSpec().getClusters().stream().filter(mm2ClusterSpec -> mm2ClusterSpec.getAlias().equals(kafkaClusterSourceName)).findFirst().get().setBootstrapServers(KafkaUtils.namespacedPlainBootstrapAddress(kafkaClusterSourceName, namespaceName)), namespaceName);
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2Ready(namespaceName, clusterName);
KafkaMirrorMaker2Status kmm2Status = KafkaMirrorMaker2Resource.kafkaMirrorMaker2Client().inNamespace(namespaceName).withName(clusterName).get().getStatus();
assertFalse(kmm2Status.getConditions().stream().anyMatch(condition -> condition.getMessage() != null && condition.getMessage().contains(errorMessage)));
}
use of io.strimzi.systemtest.Constants.INFRA_NAMESPACE in project strimzi by strimzi.
the class MirrorMaker2IsolatedST method testStrimziIdentityReplicationPolicy.
/*
* This test is using the Strimzi Identity Replication policy. This is needed for backwards compatibility for users
* who might still have it configured.
*
* This ST should be deleted once we drop the Strimzi policy completely.
*/
@ParallelNamespaceTest
void testStrimziIdentityReplicationPolicy(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(INFRA_NAMESPACE, extensionContext);
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClusterSourceName = clusterName + "-source";
String kafkaClusterTargetName = clusterName + "-target";
String originalTopicName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClientsName = mapWithKafkaClientNames.get(extensionContext.getDisplayName());
// Deploy source kafka
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterSourceName, 1, 1).build());
// Deploy target kafka
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterTargetName, 1, 1).build());
// Create topic
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(kafkaClusterSourceName, originalTopicName, 3).build());
resourceManager.createResource(extensionContext, false, KafkaClientsTemplates.kafkaClients(namespaceName, false, kafkaClientsName).build());
final String kafkaClientsPodName = PodUtils.getPodsByPrefixInNameWithDynamicWait(namespaceName, kafkaClientsName).get(0).getMetadata().getName();
resourceManager.createResource(extensionContext, KafkaMirrorMaker2Templates.kafkaMirrorMaker2(clusterName, kafkaClusterTargetName, kafkaClusterSourceName, 1, false).editSpec().editMirror(0).editSourceConnector().addToConfig("replication.policy.class", "io.strimzi.kafka.connect.mirror.IdentityReplicationPolicy").endSourceConnector().endMirror().endSpec().build());
LOGGER.info("Sending and receiving messages via {}", kafkaClusterSourceName);
InternalKafkaClient internalKafkaClient = new InternalKafkaClient.Builder().withNamespaceName(namespaceName).withTopicName(originalTopicName).withClusterName(kafkaClusterSourceName).withMessageCount(MESSAGE_COUNT).withUsingPodName(kafkaClientsPodName).withListenerName(Constants.PLAIN_LISTENER_DEFAULT_NAME).build();
internalKafkaClient.assertSentAndReceivedMessages(internalKafkaClient.sendMessagesPlain(), internalKafkaClient.receiveMessagesPlain());
LOGGER.info("Changing to {} and will try to receive messages", kafkaClusterTargetName);
internalKafkaClient = internalKafkaClient.toBuilder().withClusterName(kafkaClusterTargetName).build();
assertThat(internalKafkaClient.receiveMessagesPlain(), equalTo(MESSAGE_COUNT));
LOGGER.info("Checking if the mirrored topic name is same as the original one");
List<String> kafkaTopics = KafkaCmdClient.listTopicsUsingPodCli(namespaceName, kafkaClusterTargetName, 0);
assertNotNull(kafkaTopics.stream().filter(kafkaTopic -> kafkaTopic.equals(originalTopicName)).findAny());
List<String> kafkaTopicSpec = KafkaCmdClient.describeTopicUsingPodCli(namespaceName, kafkaClusterTargetName, 0, originalTopicName);
assertThat(kafkaTopicSpec.stream().filter(token -> token.startsWith("Topic:")).findFirst().orElse(null), equalTo("Topic:" + originalTopicName));
assertThat(kafkaTopicSpec.stream().filter(token -> token.startsWith("PartitionCount:")).findFirst().orElse(null), equalTo("PartitionCount:3"));
}
Aggregations