diff --git a/frontend/packages/integration-tests-cypress/support/index.ts b/frontend/packages/integration-tests-cypress/support/index.ts index b0e3003f583..929599ae278 100644 --- a/frontend/packages/integration-tests-cypress/support/index.ts +++ b/frontend/packages/integration-tests-cypress/support/index.ts @@ -129,6 +129,6 @@ export const create = (obj) => { `${obj.metadata.name}.${obj.kind.toLowerCase()}.json`, ].join('/'); cy.writeFile(filename, JSON.stringify(obj)); - cy.exec(`oc create -f ${filename}`); + cy.exec(`oc apply -f ${filename}`); cy.exec(`rm ${filename}`); }; diff --git a/frontend/packages/operator-lifecycle-manager/integration-tests-cypress/tests/deprecated-operator-warnings.cy.ts b/frontend/packages/operator-lifecycle-manager/integration-tests-cypress/tests/deprecated-operator-warnings.cy.ts index 5e4c683d8c4..ae8cf5785fa 100644 --- a/frontend/packages/operator-lifecycle-manager/integration-tests-cypress/tests/deprecated-operator-warnings.cy.ts +++ b/frontend/packages/operator-lifecycle-manager/integration-tests-cypress/tests/deprecated-operator-warnings.cy.ts @@ -20,34 +20,49 @@ const DEPRECATED_OPERATOR_WARNING_CHANNEL_ID = 'deprecated-operator-warning-chan const DEPRECATED_OPERATOR_WARNING_VERSION_ID = 'deprecated-operator-warning-version'; describe('Deprecated operator warnings', () => { - before(() => { - cy.login(); - // Make test idempotent for local testing by deleting test resources if they exist + const subscriptionName = testDeprecatedSubscription.metadata.name; + const subscriptionNamespace = testDeprecatedSubscription.metadata.namespace; + const csvName = testDeprecatedSubscription.spec.startingCSV; + const catalogSourceName = testDeprecatedCatalogSource.metadata.name; + const catalogSourceNamespace = testDeprecatedCatalogSource.metadata.namespace; + + const cleanupOperatorResources = () => { + // Delete subscription first to stop operator reconciliation cy.exec( - `oc delete subscription ${testDeprecatedSubscription.metadata.name} -n ${testDeprecatedSubscription.metadata.namespace}`, - { failOnNonZeroExit: false }, + `oc delete subscription ${subscriptionName} -n ${subscriptionNamespace} --ignore-not-found --wait=false`, + { failOnNonZeroExit: false, timeout: 60000 }, ); + // Delete CSV to remove the operator cy.exec( - `oc delete clusterserviceversion ${testDeprecatedSubscription.spec.startingCSV} -n ${testDeprecatedSubscription.metadata.namespace}`, - { failOnNonZeroExit: false }, + `oc delete clusterserviceversion ${csvName} -n ${subscriptionNamespace} --ignore-not-found --wait=false`, + { failOnNonZeroExit: false, timeout: 60000 }, ); - // eslint-disable-next-line promise/catch-or-return + // Delete any InstallPlans related to the operator cy.exec( - `oc delete ${testDeprecatedCatalogSource.kind} ${testDeprecatedCatalogSource.metadata.name} -n ${testDeprecatedCatalogSource.metadata.namespace}`, - { failOnNonZeroExit: false }, - ).then(({ stderr }) => { - if (stderr && !stderr.includes('not found')) { - throw new Error(stderr); - } - return create(testDeprecatedCatalogSource); - }); + `oc delete installplan -n ${subscriptionNamespace} -l operators.coreos.com/${subscriptionName}.${subscriptionNamespace}= --ignore-not-found --wait=false`, + { failOnNonZeroExit: false, timeout: 60000 }, + ); + }; + + before(() => { + cy.login(); + // Clean up any existing resources from previous failed runs + cleanupOperatorResources(); + cy.exec( + `oc delete catalogsource ${catalogSourceName} -n ${catalogSourceNamespace} --ignore-not-found --wait=false`, + { failOnNonZeroExit: false, timeout: 60000 }, + ); + create(testDeprecatedCatalogSource); }); after(() => { cy.visit('/'); - operator.uninstall(testOperator.name); + // Clean up operator resources + cleanupOperatorResources(); + // Clean up catalog source cy.exec( - `oc delete ${testDeprecatedCatalogSource.kind} ${testDeprecatedCatalogSource.metadata.name} -n ${testDeprecatedCatalogSource.metadata.namespace}`, + `oc delete catalogsource ${catalogSourceName} -n ${catalogSourceNamespace} --ignore-not-found --wait=false`, + { failOnNonZeroExit: false, timeout: 60000 }, ); checkErrors(); });