Skip to content
Open
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 @@ -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}`);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down