Skip to content

Commit

Permalink
[ST] Upgrade tests removal of resources from co-namespace (#10512)
Browse files Browse the repository at this point in the history
Signed-off-by: hzrncik <[email protected]>
  • Loading branch information
henryZrncik authored Sep 4, 2024
1 parent 20806a8 commit c12ed36
Show file tree
Hide file tree
Showing 17 changed files with 542 additions and 482 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public static boolean requiresSharedNamespace(final ExtensionContext extensionCo
TestConstants.DYNAMIC_CONFIGURATION, // Dynamic configuration also because in DynamicConfSharedST we use @TestFactory
TestConstants.TRACING, // Tracing, because we deploy Jaeger operator inside additional namespace
TestConstants.KAFKA_SMOKE, // KafkaVersionsST, MigrationST because here we use @ParameterizedTest
TestConstants.MIGRATION
TestConstants.MIGRATION,
TestConstants.UPGRADE,
TestConstants.KRAFT_UPGRADE
);

for (TestIdentifier testIdentifier : testCases) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,13 @@ public static void setCoDeploymentName(String newName) {
coDeploymentName = newName;
}

public static void waitForResourceReadiness(String resourceType, String resourceName) {
public static void waitForResourceReadiness(String namespaceName, String resourceType, String resourceName) {
LOGGER.info("Waiting for " + resourceType + "/" + resourceName + " readiness");

TestUtils.waitFor("readiness of resource " + resourceType + "/" + resourceName,
TestConstants.GLOBAL_POLL_INTERVAL, TestConstants.GLOBAL_CMD_CLIENT_TIMEOUT,
() -> ResourceManager.cmdKubeClient().getResourceReadiness(resourceType, resourceName));
LOGGER.info("Resource " + resourceType + "/" + resourceName + " is ready");
() -> ResourceManager.cmdKubeClient().namespace(namespaceName).getResourceReadiness(resourceType, resourceName));
LOGGER.info("Resource " + resourceType + "/" + resourceName + " in namespace:" + namespaceName + " is ready");
}

public static <T extends CustomResource<? extends Spec, ? extends Status>> boolean waitForResourceStatusMessage(MixedOperation<T, ?, ?> operation, T resource, String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ private void olmInstallation() {
* Upgrade cluster operator by updating subscription and obtaining new install plan,
* which has not been used yet and also approves the installation
*/
public void upgradeClusterOperator(OlmConfiguration olmConfiguration) {
if (kubeClient().listPodsByPrefixInName(ResourceManager.getCoDeploymentName()).isEmpty()) {
public void upgradeClusterOperator(String namespaceName, OlmConfiguration olmConfiguration) {
if (kubeClient(namespaceName).listPodsByPrefixInName(ResourceManager.getCoDeploymentName()).isEmpty()) {
throw new RuntimeException("We can not perform upgrade! Cluster Operator Pod is not present.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ public static void waitForInstantConsumerClientSuccess(TestStorage testStorage)
waitForClientSuccess(testStorage.getConsumerName(), testStorage.getNamespaceName(), testStorage.getMessageCount());
}

/**
* Waits for the instant producer client to succeed with explicitly specified namespace automatically deleting the associated job afterward.
*
* @param namespaceName Explicit namespace name.
* @param testStorage The {@link TestStorage} instance containing details about the client's name.
*/
public static void waitForInstantProducerClientSuccess(String namespaceName, TestStorage testStorage) {
waitForClientSuccess(testStorage.getProducerName(), namespaceName, testStorage.getMessageCount());
}

/**
* Waits for the instant producer client to succeed, automatically deleting the associated job afterward.
* {@link TestStorage#getProducerName()} is used for identifying producer Job and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,10 @@ public static void waitUntilLogFromPodContainsString(String namespaceName, Strin
* Change Deployment configuration before applying it. We set different namespace, log level and image pull policy.
* It's mostly used for use cases where we use direct kubectl command instead of fabric8 calls to api.
* @param deploymentFile loaded Strimzi deployment file
* @param namespace Namespace where Strimzi should be installed
* @param strimziFeatureGatesValue feature gates value
* @return deployment file content as String
*/
public static String changeDeploymentConfiguration(File deploymentFile, String namespace, final String strimziFeatureGatesValue) {
public static String changeDeploymentConfiguration(String namespaceName, File deploymentFile, final String strimziFeatureGatesValue) {
YAMLMapper mapper = new YAMLMapper();
try {
JsonNode node = mapper.readTree(deploymentFile);
Expand All @@ -339,7 +338,7 @@ public static String changeDeploymentConfiguration(File deploymentFile, String n
if (varName.matches("STRIMZI_NAMESPACE")) {
// Replace all the default images with ones from the $DOCKER_ORG org and with the $DOCKER_TAG tag
((ObjectNode) envVar).remove("valueFrom");
((ObjectNode) envVar).put("value", namespace);
((ObjectNode) envVar).put("value", namespaceName);
}

if (varName.matches("STRIMZI_LOG_LEVEL")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public static void waitUntilKafkaStatusConditionContainsMessage(String clusterNa
});
}

public static void waitUntilStatusKafkaVersionMatchesExpectedVersion(String clusterName, String namespace, String expectedKafkaVersion) {
public static void waitUntilStatusKafkaVersionMatchesExpectedVersion(String namespaceName, String clusterName, String expectedKafkaVersion) {
TestUtils.waitFor("Kafka version '" + expectedKafkaVersion + "' in Kafka cluster '" + clusterName + "' to match",
TestConstants.GLOBAL_POLL_INTERVAL, TestConstants.GLOBAL_STATUS_TIMEOUT, () -> {
String kafkaVersionInStatus = KafkaResource.kafkaClient().inNamespace(namespace).withName(clusterName).get().getStatus().getKafkaVersion();
String kafkaVersionInStatus = KafkaResource.kafkaClient().inNamespace(namespaceName).withName(clusterName).get().getStatus().getKafkaVersion();
return expectedKafkaVersion.equals(kafkaVersionInStatus);
});
}
Expand Down Expand Up @@ -409,9 +409,9 @@ public static String generateRandomNameOfKafka(String clusterName) {
return clusterName + "-" + RANDOM.nextInt(Integer.MAX_VALUE);
}

public static String getVersionFromKafkaPodLibs(String kafkaPodName) {
public static String getVersionFromKafkaPodLibs(String namespaceName, String kafkaPodName) {
String command = "ls libs | grep -Po 'kafka_\\d+.\\d+-\\K(\\d+.\\d+.\\d+)(?=.*jar)' | head -1 | cut -d \"-\" -f2";
return cmdKubeClient().execInPodContainer(
return cmdKubeClient(namespaceName).execInPodContainer(
kafkaPodName,
"kafka",
"/bin/bash",
Expand Down
Loading

0 comments on commit c12ed36

Please sign in to comment.