use of io.strimzi.test.annotations.IsolatedTest in project strimzi by strimzi.
the class FeatureGatesIsolatedST method testControlPlaneListenerFeatureGate.
/**
* Control Plane Listener
* https://github.com/strimzi/proposals/blob/main/025-control-plain-listener.md
*/
@IsolatedTest("Feature Gates test for disabled ControlPlainListener")
@Tag(INTERNAL_CLIENTS_USED)
public void testControlPlaneListenerFeatureGate(ExtensionContext extensionContext) {
assumeFalse(Environment.isOlmInstall() || Environment.isHelmInstall());
final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
final String producerName = "producer-test-" + new Random().nextInt(Integer.MAX_VALUE);
final String consumerName = "consumer-test-" + new Random().nextInt(Integer.MAX_VALUE);
final String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
int messageCount = 300;
List<EnvVar> testEnvVars = new ArrayList<>();
int kafkaReplicas = 1;
testEnvVars.add(new EnvVar(Environment.STRIMZI_FEATURE_GATES_ENV, "-ControlPlaneListener", null));
clusterOperator.unInstall();
clusterOperator = new SetupClusterOperator.SetupClusterOperatorBuilder().withExtensionContext(BeforeAllOnce.getSharedExtensionContext()).withNamespace(INFRA_NAMESPACE).withWatchingNamespaces(Constants.WATCH_ALL_NAMESPACES).withExtraEnvVars(testEnvVars).createInstallation().runInstallation();
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaPersistent(clusterName, kafkaReplicas).build());
LOGGER.info("Check for presence of ContainerPort 9090/tcp (tcp-ctrlplane) in first Kafka pod.");
final Pod kafkaPod = PodUtils.getPodsByPrefixInNameWithDynamicWait(clusterOperator.getDeploymentNamespace(), clusterName + "-kafka-").get(0);
ContainerPort expectedControlPlaneContainerPort = new ContainerPort(9090, null, null, "tcp-ctrlplane", "TCP");
List<ContainerPort> kafkaPodPorts = kafkaPod.getSpec().getContainers().get(0).getPorts();
assertTrue(kafkaPodPorts.contains(expectedControlPlaneContainerPort));
Map<String, String> kafkaPods = PodUtils.podSnapshot(clusterOperator.getDeploymentNamespace(), kafkaSelector);
LOGGER.info("Try to send some messages to Kafka over next few minutes.");
KafkaTopic kafkaTopic = KafkaTopicTemplates.topic(clusterName, topicName).editSpec().withReplicas(kafkaReplicas).withPartitions(kafkaReplicas).endSpec().build();
resourceManager.createResource(extensionContext, kafkaTopic);
KafkaClients kafkaBasicClientJob = new KafkaClientsBuilder().withProducerName(producerName).withConsumerName(consumerName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(clusterName)).withTopicName(topicName).withMessageCount(messageCount).withDelayMs(500).withNamespaceName(clusterOperator.getDeploymentNamespace()).build();
resourceManager.createResource(extensionContext, kafkaBasicClientJob.producerStrimzi());
resourceManager.createResource(extensionContext, kafkaBasicClientJob.consumerStrimzi());
JobUtils.waitForJobRunning(consumerName, clusterOperator.getDeploymentNamespace());
LOGGER.info("Delete first found Kafka broker pod.");
kubeClient().deletePod(clusterOperator.getDeploymentNamespace(), kafkaPod);
RollingUpdateUtils.waitForComponentAndPodsReady(kafkaSelector, kafkaReplicas);
LOGGER.info("Force Rolling Update of Kafka via annotation.");
kafkaPods.keySet().forEach(podName -> {
kubeClient(clusterOperator.getDeploymentNamespace()).editPod(podName).edit(pod -> new PodBuilder(pod).editMetadata().addToAnnotations(Annotations.ANNO_STRIMZI_IO_MANUAL_ROLLING_UPDATE, "true").endMetadata().build());
});
LOGGER.info("Wait for next reconciliation to happen.");
RollingUpdateUtils.waitTillComponentHasRolled(clusterOperator.getDeploymentNamespace(), kafkaSelector, kafkaReplicas, kafkaPods);
LOGGER.info("Waiting for clients to finish sending/receiving messages.");
ClientUtils.waitForClientSuccess(producerName, clusterOperator.getDeploymentNamespace(), MESSAGE_COUNT);
ClientUtils.waitForClientSuccess(consumerName, clusterOperator.getDeploymentNamespace(), MESSAGE_COUNT);
}
use of io.strimzi.test.annotations.IsolatedTest in project strimzi-kafka-operator by strimzi.
the class KafkaConnectApiTest method testChangeLoggers.
@IsolatedTest
public void testChangeLoggers(VertxTestContext context) throws InterruptedException {
String desired = "log4j.rootLogger=TRACE, CONSOLE\n" + "log4j.logger.org.apache.zookeeper=WARN\n" + "log4j.logger.org.I0Itec.zkclient=INFO\n" + "log4j.logger.org.reflections.Reflection=INFO\n" + "log4j.logger.org.reflections=FATAL\n" + "log4j.logger.foo=WARN\n" + "log4j.logger.foo.bar=TRACE\n" + "log4j.logger.foo.bar.quux=DEBUG";
KafkaConnectApi client = new KafkaConnectApiImpl(vertx);
Checkpoint async = context.checkpoint();
OrderedProperties ops = new OrderedProperties();
ops.addStringPairs(desired);
client.updateConnectLoggers(Reconciliation.DUMMY_RECONCILIATION, "localhost", PORT, desired, ops).onComplete(context.succeeding(wasChanged -> context.verify(() -> assertEquals(true, wasChanged)))).compose(a -> client.listConnectLoggers(Reconciliation.DUMMY_RECONCILIATION, "localhost", PORT).onComplete(context.succeeding(map -> context.verify(() -> {
assertThat(map.get("root"), is("TRACE"));
assertThat(map.get("org.apache.zookeeper"), is("WARN"));
assertThat(map.get("org.I0Itec.zkclient"), is("INFO"));
assertThat(map.get("org.reflections"), is("FATAL"));
assertThat(map.get("org.reflections.Reflection"), is("INFO"));
assertThat(map.get("org.reflections.Reflection"), is("INFO"));
assertThat(map.get("foo"), is("WARN"));
assertThat(map.get("foo.bar"), is("TRACE"));
assertThat(map.get("foo.bar.quux"), is("DEBUG"));
})))).compose(a -> client.updateConnectLoggers(Reconciliation.DUMMY_RECONCILIATION, "localhost", PORT, desired, ops).onComplete(context.succeeding(wasChanged -> context.verify(() -> {
assertEquals(false, wasChanged);
async.flag();
}))));
}
use of io.strimzi.test.annotations.IsolatedTest in project strimzi-kafka-operator by strimzi.
the class TopicScalabilityIsolatedST method testModifyBigAmountOfTopicConfigs.
@IsolatedTest
void testModifyBigAmountOfTopicConfigs(ExtensionContext extensionContext) {
Map<String, Object> modifiedConfig = new HashMap<>();
// Create topics
KafkaTopicScalabilityUtils.createTopicsViaK8s(extensionContext, clusterOperator.getDeploymentNamespace(), sharedClusterName, topicPrefix, NUMBER_OF_TOPICS, 2, 3, 2);
KafkaTopicScalabilityUtils.waitForTopicsReady(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS);
// Add set of configs and expect topics to have ready status
modifiedConfig.put("compression.type", "gzip");
modifiedConfig.put("cleanup.policy", "delete");
modifiedConfig.put("message.timestamp.type", "LogAppendTime");
modifiedConfig.put("min.insync.replicas", 6);
KafkaTopicScalabilityUtils.modifyBigAmountOfTopics(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, new KafkaTopicSpecBuilder().withConfig(modifiedConfig).build());
KafkaTopicScalabilityUtils.waitForTopicsContainConfig(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, modifiedConfig);
// Set time configs
modifiedConfig.clear();
modifiedConfig.put("max.compaction.lag.ms", 54321);
modifiedConfig.put("min.compaction.lag.ms", 54);
modifiedConfig.put("retention.ms", 3690);
modifiedConfig.put("segment.ms", 123456);
modifiedConfig.put("flush.ms", 456123);
KafkaTopicScalabilityUtils.modifyBigAmountOfTopics(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, new KafkaTopicSpecBuilder().withConfig(modifiedConfig).build());
KafkaTopicScalabilityUtils.waitForTopicsContainConfig(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, modifiedConfig);
// Set size configs
modifiedConfig.clear();
modifiedConfig.put("retention.bytes", 9876543);
modifiedConfig.put("segment.bytes", 321654);
modifiedConfig.put("max.message.bytes", 654321);
modifiedConfig.put("flush.messages", 456123);
KafkaTopicScalabilityUtils.modifyBigAmountOfTopics(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, new KafkaTopicSpecBuilder().withConfig(modifiedConfig).build());
KafkaTopicScalabilityUtils.waitForTopicsContainConfig(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, modifiedConfig);
// Set back to default state
modifiedConfig.clear();
KafkaTopicScalabilityUtils.modifyBigAmountOfTopics(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, new KafkaTopicSpecBuilder().withConfig(modifiedConfig).build());
KafkaTopicScalabilityUtils.waitForTopicsReady(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS);
}
use of io.strimzi.test.annotations.IsolatedTest in project strimzi-kafka-operator by strimzi.
the class TopicScalabilityIsolatedST method testModifyBigAmountOfTopicPartitions.
@IsolatedTest
void testModifyBigAmountOfTopicPartitions(ExtensionContext extensionContext) {
final int defaultPartitionCount = 2;
// Create topics
KafkaTopicScalabilityUtils.createTopicsViaK8s(extensionContext, clusterOperator.getDeploymentNamespace(), sharedClusterName, topicPrefix, NUMBER_OF_TOPICS, defaultPartitionCount, 1, 1);
KafkaTopicScalabilityUtils.waitForTopicsReady(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS);
// Decrease partitions and expect not ready status
KafkaTopicScalabilityUtils.modifyBigAmountOfTopics(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, new KafkaTopicSpecBuilder().withPartitions(defaultPartitionCount - 1).build());
KafkaTopicScalabilityUtils.waitForTopicsNotReady(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS);
// Set back to default and check if topic becomes ready
KafkaTopicScalabilityUtils.modifyBigAmountOfTopics(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS, new KafkaTopicSpecBuilder().withPartitions(defaultPartitionCount).build());
KafkaTopicScalabilityUtils.waitForTopicsReady(clusterOperator.getDeploymentNamespace(), topicPrefix, NUMBER_OF_TOPICS);
}
use of io.strimzi.test.annotations.IsolatedTest in project strimzi-kafka-operator by strimzi.
the class FeatureGatesIsolatedST method testSwitchingStrimziPodSetFeatureGateOnAndOff.
@IsolatedTest
void testSwitchingStrimziPodSetFeatureGateOnAndOff(ExtensionContext extensionContext) {
assumeFalse(Environment.isOlmInstall() || Environment.isHelmInstall());
final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
final String producerName = "producer-test-" + new Random().nextInt(Integer.MAX_VALUE);
final String consumerName = "consumer-test-" + new Random().nextInt(Integer.MAX_VALUE);
final String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
int zkReplicas = 1;
int kafkaReplicas = 3;
final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
int messageCount = 500;
List<EnvVar> coEnvVars = new ArrayList<>();
coEnvVars.add(new EnvVar(Environment.STRIMZI_FEATURE_GATES_ENV, "-UseStrimziPodSets", null));
LOGGER.info("Deploying CO with STS - SPS is disabled");
clusterOperator.unInstall();
clusterOperator = new SetupClusterOperator.SetupClusterOperatorBuilder().withExtensionContext(BeforeAllOnce.getSharedExtensionContext()).withNamespace(INFRA_NAMESPACE).withWatchingNamespaces(Constants.WATCH_ALL_NAMESPACES).withExtraEnvVars(coEnvVars).createInstallation().runInstallation();
LOGGER.info("Deploying Kafka");
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaPersistent(clusterName, kafkaReplicas, zkReplicas).build());
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(clusterName, topicName).build());
Map<String, String> kafkaPods = PodUtils.podSnapshot(clusterOperator.getDeploymentNamespace(), kafkaSelector);
Map<String, String> zkPods = PodUtils.podSnapshot(clusterOperator.getDeploymentNamespace(), zkSelector);
Map<String, String> coPod = DeploymentUtils.depSnapshot(ResourceManager.getCoDeploymentName());
KafkaClients clients = new KafkaClientsBuilder().withProducerName(producerName).withConsumerName(consumerName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(clusterName)).withTopicName(topicName).withMessageCount(messageCount).withDelayMs(1000).withNamespaceName(clusterOperator.getDeploymentNamespace()).build();
resourceManager.createResource(extensionContext, clients.producerStrimzi(), clients.consumerStrimzi());
LOGGER.info("Changing FG env variable to enable SPS");
coEnvVars = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME).getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
coEnvVars.stream().filter(env -> env.getName().equals(Environment.STRIMZI_FEATURE_GATES_ENV)).findFirst().get().setValue("+UseStrimziPodSets");
Deployment coDep = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME);
coDep.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(coEnvVars);
kubeClient().getClient().apps().deployments().inNamespace(clusterOperator.getDeploymentNamespace()).withName(Constants.STRIMZI_DEPLOYMENT_NAME).replace(coDep);
coPod = DeploymentUtils.waitTillDepHasRolled(Constants.STRIMZI_DEPLOYMENT_NAME, 1, coPod);
zkPods = RollingUpdateUtils.waitTillComponentHasRolled(zkSelector, zkReplicas, zkPods);
kafkaPods = RollingUpdateUtils.waitTillComponentHasRolled(kafkaSelector, kafkaReplicas, kafkaPods);
KafkaUtils.waitForKafkaReady(clusterName);
LOGGER.info("Changing FG env variable to disable again SPS");
coEnvVars.stream().filter(env -> env.getName().equals(Environment.STRIMZI_FEATURE_GATES_ENV)).findFirst().get().setValue("");
coDep = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME);
coDep.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(coEnvVars);
kubeClient().getClient().apps().deployments().inNamespace(clusterOperator.getDeploymentNamespace()).withName(Constants.STRIMZI_DEPLOYMENT_NAME).replace(coDep);
DeploymentUtils.waitTillDepHasRolled(Constants.STRIMZI_DEPLOYMENT_NAME, 1, coPod);
RollingUpdateUtils.waitTillComponentHasRolled(zkSelector, zkReplicas, zkPods);
RollingUpdateUtils.waitTillComponentHasRolled(kafkaSelector, kafkaReplicas, kafkaPods);
ClientUtils.waitForClientsSuccess(producerName, consumerName, clusterOperator.getDeploymentNamespace(), messageCount);
}
Aggregations