Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and enable the UninstallST test #116

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ public boolean waitForReadiness(DataScienceCluster resource) {
// Check that DSC reconciliation has been successfully finalized
// https://github.com/red-hat-data-services/rhods-operator/blob/rhoai-2.8/controllers/datasciencecluster/datasciencecluster_controller.go#L257

// Wait for standard Kubernetes condition types (status for the whole DSC)
record ConditionExpectation(String conditionType, String expectedStatus) { }
List<ConditionExpectation> conditionExpectations = List.of(
new ConditionExpectation("Available", "True"),
new ConditionExpectation("Progressing", "False"),
new ConditionExpectation("Degraded", "False"),
new ConditionExpectation("Upgradeable", "True")
);
for (ConditionExpectation conditionExpectation : conditionExpectations) {
String conditionType = conditionExpectation.conditionType;
String expectedStatus = conditionExpectation.expectedStatus;
String conditionStatus = KubeUtils.getDscConditionByType(dsc.getStatus().getConditions(), conditionType).getStatus();
LOGGER.debug("DataScienceCluster {} {} status: {}", resource.getMetadata().getName(), conditionType, conditionStatus);
dscReady = dscReady && Objects.equals(conditionStatus, expectedStatus);
}

// Wait for ReconcileComplete condition (for the whole DSC)
String reconcileStatus = KubeUtils.getDscConditionByType(dsc.getStatus().getConditions(), "ReconcileComplete").getStatus();
LOGGER.debug("DataScienceCluster {} ReconcileComplete status: {}", resource.getMetadata().getName(), reconcileStatus);
Expand Down
32 changes: 19 additions & 13 deletions src/test/java/io/odh/test/e2e/standard/UninstallST.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.odh.test.OdhConstants;
import io.odh.test.TestUtils;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.install.InstallTypes;
import io.odh.test.utils.DscUtils;
import io.odh.test.utils.NamespaceUtils;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
Expand All @@ -23,9 +24,9 @@
import io.skodjob.annotations.TestDoc;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.api.condition.EnabledIf;

@SuiteDoc(
description = @Desc("Verifies that uninstall process removes all resources created by ODH installation"),
Expand All @@ -38,7 +39,7 @@
@Step(value = "Deploy DSC", expected = "DSC is created and ready")
}
)
@Disabled("Disabled because of the https://issues.redhat.com/browse/RHOAIENG-499")
@EnabledIf("installMethodIsOlm")
@DisabledIfEnvironmentVariable(
named = Environment.SKIP_DEPLOY_DSCI_DSC_ENV,
matches = "true",
Expand Down Expand Up @@ -69,23 +70,24 @@ public class UninstallST extends StandardAbstract {
)
@Test
void testUninstallSimpleScenario() {
if (!ResourceManager.getKubeCmdClient().namespace(OdhConstants.OLM_OPERATOR_NAMESPACE)
if (ResourceManager.getKubeCmdClient().namespace(OdhConstants.OLM_OPERATOR_NAMESPACE)
.list("configmap").contains(DELETE_CONFIG_MAP_NAME)) {
ConfigMap cm = new ConfigMapBuilder()
.withNewMetadata()
.withName(DELETE_CONFIG_MAP_NAME)
.withNamespace(OdhConstants.OLM_OPERATOR_NAMESPACE)
.withAnnotations(Map.ofEntries(Map.entry(DELETE_ANNOTATION, "true")))
.endMetadata()
.build();
ResourceManager.getInstance().createResourceWithWait(cm);
} else {
Assertions.fail(String.format("The configmap '%s' is present on the cluster before the uninstall test started!", DELETE_CONFIG_MAP_NAME));
}

// https://access.redhat.com/documentation/en-us/red_hat_openshift_ai_self-managed/2-latest/html-single/installing_and_uninstalling_openshift_ai_self-managed/index#uninstalling-openshift-ai-self-managed-using-CLI_uninstalling-openshift-ai-self-managed
ConfigMap cm = new ConfigMapBuilder()
.withNewMetadata()
.withName(DELETE_CONFIG_MAP_NAME)
.withNamespace(OdhConstants.OLM_OPERATOR_NAMESPACE)
.withLabels(Map.ofEntries(Map.entry(DELETE_ANNOTATION, "true")))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's label, not annotation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I have it fixed in my branch

.endMetadata()
.build();
ResourceManager.getInstance().createResourceWithWait(cm);

// Now the product should start to uninstall, let's wait a bit and check the result.
TestUtils.waitFor(String.format("the '%s' namespace to be removed as operator is being uninstalled",
OdhConstants.CONTROLLERS_NAMESPACE), 2000, 20000,
OdhConstants.CONTROLLERS_NAMESPACE), 2000, 120 * 1000,
() -> !ResourceManager.getKubeClient().namespaceExists(OdhConstants.CONTROLLERS_NAMESPACE));

// Let's remove the operator namespace now
Expand Down Expand Up @@ -122,4 +124,8 @@ void deployDataScienceCluster() {
ResourceManager.getInstance().createResourceWithWait(dsci);
ResourceManager.getInstance().createResourceWithWait(dsc);
}

static boolean installMethodIsOlm() {
return Environment.OPERATOR_INSTALL_TYPE.equalsIgnoreCase(InstallTypes.OLM.toString());
}
}
Loading