Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ST] Parallelize kubeClient interactions in AbstractUpgradeST #10514

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.stream.IntStream;

import static io.strimzi.systemtest.TestConstants.CO_NAMESPACE;
import static io.strimzi.systemtest.TestConstants.DEFAULT_SINK_FILE_PATH;
Expand Down Expand Up @@ -222,16 +224,15 @@ protected void logPodImagesWithConnect(String namespaceName) {
}

protected void logPodImages(String namespaceName, LabelSelector... labelSelectors) {
for (LabelSelector labelSelector : labelSelectors) {
List<Pod> pods = kubeClient().listPods(namespaceName, labelSelector);

pods.forEach(pod ->
Arrays.stream(labelSelectors)
.parallel()
.map(selector -> kubeClient().listPods(namespaceName, selector))
.flatMap(Collection::stream)
.forEach(pod ->
pod.getSpec().getContainers().forEach(container ->
LOGGER.info("Pod: {}/{} has image {}",
pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getImage())
)
);
}
));
}

protected void waitForKafkaClusterRollingUpdate() {
Expand Down Expand Up @@ -355,9 +356,13 @@ protected void setupEnvAndUpgradeClusterOperator(BundleVersionModificationData u
} else {
kafkaTopicYaml = new File(dir, upgradeData.getFromExamples() + "/examples/topic/kafka-topic.yaml");
}
for (int x = 0; x < upgradeTopicCount; x++) {
cmdKubeClient().applyContent(TestUtils.getContent(kafkaTopicYaml, TestUtils::toYamlString).replace("name: \"my-topic\"", "name: \"" + topicName + "-" + x + "\""));
}

String topicNameTemplate = topicName + "-%s";
IntStream.range(0, upgradeTopicCount)
.mapToObj(topicNameTemplate::formatted)
.map(this::getKafkaYamlWithName)
.parallel()
.forEach(cmdKubeClient()::applyContent);
}

if (upgradeData.getContinuousClientsMessages() != 0) {
Expand Down Expand Up @@ -398,6 +403,13 @@ protected void setupEnvAndUpgradeClusterOperator(BundleVersionModificationData u
makeSnapshots();
}

private String getKafkaYamlWithName(String name) {
String initialName = "name: \"my-topic\"";
String newName = "name: \"%s\"".formatted(name);

return TestUtils.getContent(kafkaTopicYaml, TestUtils::toYamlString).replace(initialName, newName);
}

protected void verifyProcedure(BundleVersionModificationData upgradeData, String producerName, String consumerName, String namespace, boolean wasUTOUsedBefore) {

if (upgradeData.getAdditionalTopics() != null) {
Expand Down
Loading