Skip to content

Commit

Permalink
Minor improvement
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless committed Dec 7, 2023
1 parent f360e41 commit a706809
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 15 additions & 0 deletions src/main/java/io/odh/test/platform/KubeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
*/
package io.odh.test.platform;

import io.odh.test.TestConstants;
import io.odh.test.TestUtils;
import io.odh.test.framework.manager.ResourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.NoSuchElementException;

public class KubeUtils {

Expand Down Expand Up @@ -39,6 +42,18 @@ public static void deleteDefaultDSCI() {
ResourceManager.getKubeCmdClient().exec(false, "delete", "dsci", "--all");
}

public static void waitForInstallPlan(String namespace, String csvName) {
TestUtils.waitFor("Install paln with new version", TestConstants.GLOBAL_POLL_INTERVAL_SHORT, TestConstants.GLOBAL_TIMEOUT, () -> {
try {
ResourceManager.getClient().getNonApprovedInstallPlan(namespace, csvName);
return true;
} catch (NoSuchElementException ex) {
LOGGER.debug("No new install plan available. Checking again ...");
return false;
}
}, () -> { });
}

private KubeUtils() {
}
}
14 changes: 2 additions & 12 deletions src/test/java/io/odh/test/e2e/upgrade/OlmUpgradeST.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.InstallPlan;
import io.odh.test.OdhConstants;
import io.odh.test.TestConstants;
import io.odh.test.TestUtils;
import io.odh.test.e2e.Abstract;
import io.odh.test.framework.listeners.OdhResourceCleaner;
import io.odh.test.framework.listeners.ResourceManagerDeleteHandler;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.install.OlmInstall;
import io.odh.test.platform.KubeUtils;
import io.odh.test.utils.DeploymentUtils;
import io.odh.test.utils.PodUtils;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
Expand Down Expand Up @@ -41,7 +41,6 @@
import static org.hamcrest.core.IsNot.not;

import java.util.Map;
import java.util.NoSuchElementException;

@Tag("upgrade")
@ExtendWith(OdhResourceCleaner.class)
Expand Down Expand Up @@ -102,16 +101,7 @@ void testUpgradeOlm() {
ResourceManager.getInstance().createResourceWithWait(dsc);

// Approve upgrade to newer version
// TODO - add dynamic wait
TestUtils.waitFor("Install paln with new version", TestConstants.GLOBAL_POLL_INTERVAL_SHORT, TestConstants.GLOBAL_TIMEOUT, () -> {
try {
ResourceManager.getClient().getNonApprovedInstallPlan(olmInstall.getNamespace(), olmInstall.getCsvName());
return true;
} catch (NoSuchElementException ex) {
LOGGER.debug("No new install plan available. Checking again ...");
return false;
}
}, () -> { });
KubeUtils.waitForInstallPlan(olmInstall.getNamespace(), olmInstall.getCsvName());

ip = ResourceManager.getClient().getNonApprovedInstallPlan(olmInstall.getNamespace(), olmInstall.getCsvName());
ResourceManager.getClient().approveInstallPlan(olmInstall.getNamespace(), ip.getMetadata().getName());
Expand Down

0 comments on commit a706809

Please sign in to comment.