Skip to content

Commit 32f7dd2

Browse files
authored
ST: Make several systemtests checks more resilient (#11373)
Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
1 parent 05dfb2e commit 32f7dd2

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

systemtest/src/main/java/io/strimzi/systemtest/resources/NamespaceManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public void deleteAllNamespacesFromSet() {
240240
* @param namespaceName name of the Namespace that should be deleted
241241
*/
242242
private void waitForNamespaceDeletion(String namespaceName) {
243-
TestUtils.waitFor("Namespace: " + namespaceName + "to be deleted", TestConstants.POLL_INTERVAL_FOR_RESOURCE_DELETION, DELETION_TIMEOUT, () -> {
243+
TestUtils.waitFor("Namespace: " + namespaceName + " to be deleted", TestConstants.POLL_INTERVAL_FOR_RESOURCE_DELETION, DELETION_TIMEOUT, () -> {
244244
Namespace namespace = kubeClient().getNamespace(namespaceName);
245245

246246
if (namespace == null) {
@@ -249,6 +249,9 @@ private void waitForNamespaceDeletion(String namespaceName) {
249249
LOGGER.debug("There are KafkaTopics with finalizers remaining in Namespace: {}, going to set those finalizers to null", namespaceName);
250250
KafkaTopicUtils.setFinalizersInAllTopicsToNull(namespaceName);
251251
}
252+
// Try to delete it once-again in case something is stuck
253+
deleteNamespace(namespaceName);
254+
252255
return false;
253256
});
254257
}

systemtest/src/main/java/io/strimzi/systemtest/resources/operator/specific/HelmResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void clusterOperator(long operationTimeout, long reconciliationInterval,
9090
values.put("kafkaBridge.image.tag", bridgeTag);
9191

9292
// Additional config
93-
values.put("image.imagePullPolicy", Environment.OPERATOR_IMAGE_PULL_POLICY);
93+
values.put("image.imagePullPolicy", Environment.COMPONENTS_IMAGE_PULL_POLICY);
9494
values.put("resources.requests.memory", TestConstants.CO_REQUESTS_MEMORY);
9595
values.put("resources.requests.cpu", TestConstants.CO_REQUESTS_CPU);
9696
values.put("resources.limits.memory", TestConstants.CO_LIMITS_MEMORY);

systemtest/src/main/java/io/strimzi/systemtest/utils/ClientUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ public static void waitForClientNotContainsMessage(String namespaceName, String
321321
}
322322

323323
private static long timeoutForClientFinishJob(int messagesCount) {
324-
// need to add at least 2minutes for finishing the job
325-
return (long) messagesCount * 1000 + Duration.ofMinutes(2).toMillis();
324+
// need to add at least 3 minutes for finishing the job (due to slow environments)
325+
return (long) messagesCount * 1000 + Duration.ofMinutes(3).toMillis();
326326
}
327327

328328
/**

systemtest/src/test/java/io/strimzi/systemtest/kafka/KafkaST.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,15 @@ void testKafkaJBODDeleteClaimsTrueFalse() {
413413

414414
Map<String, String> brokerPods = PodUtils.podSnapshot(testStorage.getNamespaceName(), testStorage.getBrokerSelector());
415415
// kafka cluster already deployed
416-
verifyVolumeNamesAndLabels(testStorage.getNamespaceName(), testStorage.getClusterName(), testStorage.getBrokerComponentName(), kafkaReplicas, 2, diskSizeGi);
416+
TestUtils.waitFor("expected labels on PVCs", TestConstants.GLOBAL_POLL_INTERVAL_5_SECS, TestConstants.GLOBAL_STATUS_TIMEOUT, () -> {
417+
try {
418+
verifyVolumeNamesAndLabels(testStorage.getNamespaceName(), testStorage.getClusterName(), testStorage.getBrokerComponentName(), kafkaReplicas, 2, diskSizeGi);
419+
return true;
420+
} catch (AssertionError ex) {
421+
LOGGER.info("Some of the expected labels are not in place, rerunning the check...");
422+
return false;
423+
}
424+
});
417425

418426
//change value of first PVC to delete its claim once Kafka is deleted.
419427
LOGGER.info("Update Volume with id=0 in Kafka CR by setting 'Delete Claim' property to false");
@@ -841,8 +849,16 @@ void testMessagesAndConsumerOffsetFilesOnDisk() {
841849
String brokerPodName = kubeClient().listPods(testStorage.getNamespaceName(), testStorage.getBrokerSelector()).get(0).getMetadata().getName();
842850

843851
TestUtils.waitFor("KafkaTopic creation inside Kafka Pod", TestConstants.GLOBAL_POLL_INTERVAL, TestConstants.GLOBAL_TIMEOUT,
844-
() -> cmdKubeClient(testStorage.getNamespaceName()).execInPod(brokerPodName, "/bin/bash",
845-
"-c", "cd /var/lib/kafka/data/kafka-log0; ls -1").out().contains(testStorage.getTopicName()));
852+
() -> {
853+
String output = cmdKubeClient(testStorage.getNamespaceName()).execInPod(brokerPodName, "/bin/bash",
854+
"-c", "cd /var/lib/kafka/data/kafka-log0; ls -1").out();
855+
if (output.contains(testStorage.getTopicName())) {
856+
return true;
857+
} else {
858+
LOGGER.debug("{} should be in {}, trying again...", testStorage.getTopicName(), output);
859+
return false;
860+
}
861+
});
846862

847863
String topicDirNameInPod = cmdKubeClient(testStorage.getNamespaceName()).execInPod(brokerPodName, "/bin/bash",
848864
"-c", "cd /var/lib/kafka/data/kafka-log0; ls -1 | sed -n '/" + testStorage.getTopicName() + "/p'").out();
@@ -1323,7 +1339,7 @@ void verifyVolumeNamesAndLabels(String namespaceName, String clusterName, String
13231339
.forEach(volume -> {
13241340
String volumeName = volume.getMetadata().getName();
13251341
pvcs.add(volumeName);
1326-
LOGGER.info("Checking labels for volume:" + volumeName);
1342+
LOGGER.info("Checking labels for volume: " + volumeName);
13271343
assertThat(volume.getMetadata().getLabels().get(Labels.STRIMZI_CLUSTER_LABEL), is(clusterName));
13281344
assertThat(volume.getMetadata().getLabels().get(Labels.STRIMZI_KIND_LABEL), is(Kafka.RESOURCE_KIND));
13291345
assertThat(volume.getMetadata().getLabels().get(Labels.STRIMZI_NAME_LABEL), is(clusterName.concat("-kafka")));

systemtest/src/test/java/io/strimzi/systemtest/upgrade/KRaftKafkaUpgradeDowngradeST.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.strimzi.systemtest.utils.TestKafkaVersion;
2424
import io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils;
2525
import io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils;
26+
import io.strimzi.test.TestUtils;
2627
import org.apache.logging.log4j.LogManager;
2728
import org.apache.logging.log4j.Logger;
2829
import org.junit.jupiter.api.BeforeAll;
@@ -249,13 +250,17 @@ void runVersionChange(TestStorage testStorage, TestKafkaVersion initialVersion,
249250

250251
if (!isUpgrade) {
251252
LOGGER.info("Verifying that metadataVersion attribute updated correctly to version {}", initMetadataVersion);
252-
assertThat(Crds.kafkaOperation(kubeClient().getClient()).inNamespace(testStorage.getNamespaceName()).withName(CLUSTER_NAME)
253-
.get().getStatus().getKafkaMetadataVersion().contains(initMetadataVersion), is(true));
253+
TestUtils.waitFor(String.format("metadataVersion attribute updated correctly to version %s", initMetadataVersion),
254+
TestConstants.GLOBAL_POLL_INTERVAL, TestConstants.GLOBAL_STATUS_TIMEOUT,
255+
() -> Crds.kafkaOperation(kubeClient().getClient()).inNamespace(testStorage.getNamespaceName()).withName(CLUSTER_NAME)
256+
.get().getStatus().getKafkaMetadataVersion().contains(initMetadataVersion));
254257
} else {
255258
if (currentMetadataVersion != null) {
256259
LOGGER.info("Verifying that metadataVersion attribute updated correctly to version {}", newVersion.metadataVersion());
257-
assertThat(Crds.kafkaOperation(kubeClient().getClient()).inNamespace(testStorage.getNamespaceName()).withName(CLUSTER_NAME)
258-
.get().getStatus().getKafkaMetadataVersion().contains(newVersion.metadataVersion()), is(true));
260+
TestUtils.waitFor(String.format("metadataVersion attribute updated correctly to version %s", newVersion.metadataVersion()),
261+
TestConstants.GLOBAL_POLL_INTERVAL, TestConstants.GLOBAL_STATUS_TIMEOUT,
262+
() -> Crds.kafkaOperation(kubeClient().getClient()).inNamespace(testStorage.getNamespaceName()).withName(CLUSTER_NAME)
263+
.get().getStatus().getKafkaMetadataVersion().contains(newVersion.metadataVersion()));
259264
}
260265
}
261266

0 commit comments

Comments
 (0)