Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless committed Dec 11, 2023
1 parent c34ed0e commit debf524
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/main/java/io/odh/test/install/OlmInstall.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,22 @@ public Subscription prepareSubscription() {
}

public void deleteCSV() {
LOGGER.info("Deleting CSV {}/{}", namespace, olmAppBundlePrefix);
ResourceManager.getClient().getClient().adapt(OpenShiftClient.class).operatorHub().clusterServiceVersions().inNamespace(namespace)
.list().getItems().stream().filter(csv -> csv.getMetadata().getName().contains(olmAppBundlePrefix)).toList()
.forEach(csv -> {
LOGGER.info("Deleting CSV {}", csv.getMetadata().getName());
ResourceManager.getClient().getClient().adapt(OpenShiftClient.class).operatorHub().clusterServiceVersions().resource(csv).delete();
});
deleteInstallPlans();
}

public void deleteInstallPlans() {
ResourceManager.getClient().getClient().adapt(OpenShiftClient.class).operatorHub().installPlans().inNamespace(namespace)
.list().getItems().stream().filter(ip -> ip.getSpec().getClusterServiceVersionNames().stream().toList().toString().contains(olmAppBundlePrefix)).toList()
.forEach(ip -> {
LOGGER.info("Deleting InstallPlan {}", ip.getMetadata().getName());
ResourceManager.getClient().getClient().adapt(OpenShiftClient.class).operatorHub().installPlans().resource(ip).delete();
});
}

/**
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/io/odh/test/platform/KubeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.InstallPlanBuilder;
import io.fabric8.openshift.client.OpenShiftClient;
import io.odh.test.Environment;
import io.odh.test.TestConstants;
import io.odh.test.TestUtils;
import io.odh.test.platform.executor.Exec;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.v1alpha.OdhDashboardConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -368,15 +369,23 @@ public InstallPlan getInstallPlan(String namespaceName, String installPlanName)
return client.adapt(OpenShiftClient.class).operatorHub().installPlans().inNamespace(namespaceName).withName(installPlanName).get();
}

public void approveInstallPlan(String namespaceName, String installPlanName) {
public void approveInstallPlan(String namespaceName, String installPlanName) throws InterruptedException {
InstallPlan installPlan = new InstallPlanBuilder(this.getInstallPlan(namespaceName, installPlanName))
.editSpec()
.withApproved()
.endSpec()
.build();

LOGGER.debug("Approving InstallPlan {}", installPlanName);
client.adapt(OpenShiftClient.class).operatorHub().installPlans().inNamespace(namespaceName).withName(installPlanName).patch(installPlan);
TestUtils.waitFor("InstallPlan approval", TestConstants.GLOBAL_POLL_INTERVAL_SHORT, 15_000, () -> {
try {
client.adapt(OpenShiftClient.class).operatorHub().installPlans().inNamespace(namespaceName).withName(installPlanName).patch(installPlan);
return true;
} catch (Exception ex) {
LOGGER.error(String.valueOf(ex));
return false;
}
});
}

public InstallPlan getNonApprovedInstallPlan(String namespaceName, String csvPrefix) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/odh/test/e2e/upgrade/OlmUpgradeST.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class OlmUpgradeST extends UpgradeAbstract {
private final String startingVersion = "2.3.0";

@Test
void testUpgradeOlm() throws IOException {
void testUpgradeOlm() throws IOException, InterruptedException {
String ntbName = "test-odh-notebook";
String ntbNamespace = "test-odh-notebook-upgrade";

Expand Down

0 comments on commit debf524

Please sign in to comment.