diff --git a/src/main/java/io/odh/test/platform/KubeUtils.java b/src/main/java/io/odh/test/platform/KubeUtils.java index ad8c9645..4282a664 100644 --- a/src/main/java/io/odh/test/platform/KubeUtils.java +++ b/src/main/java/io/odh/test/platform/KubeUtils.java @@ -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 { @@ -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() { } } diff --git a/src/test/java/io/odh/test/e2e/upgrade/OlmUpgradeST.java b/src/test/java/io/odh/test/e2e/upgrade/OlmUpgradeST.java index b5099507..0c3327de 100644 --- a/src/test/java/io/odh/test/e2e/upgrade/OlmUpgradeST.java +++ b/src/test/java/io/odh/test/e2e/upgrade/OlmUpgradeST.java @@ -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; @@ -41,7 +41,6 @@ import static org.hamcrest.core.IsNot.not; import java.util.Map; -import java.util.NoSuchElementException; @Tag("upgrade") @ExtendWith(OdhResourceCleaner.class) @@ -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());