Skip to content

Commit

Permalink
OCPBUGS-10562: re-enable operator-uninstall.spec.ts and improve other…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
rhamilto committed Jul 25, 2023
1 parent 0d2f847 commit 125e665
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe(`Interacting with CatalogSource page`, () => {
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(testName);
cy.exec(`oc new-project ${testName}`);
create(testCatalogSource);
});

Expand All @@ -38,7 +38,7 @@ describe(`Interacting with CatalogSource page`, () => {
});

after(() => {
cy.deleteProject(testName);
cy.exec(`oc delete project ${testName}`);
cy.logout();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ describe('Create namespace from install operators', () => {
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(testName);
cy.exec(`oc new-project ${testName}`);
});

afterEach(() => {
checkErrors();
});

after(() => {
cy.deleteProject(testName);
cy.exec(`oc delete project ${testName}`);
cy.logout();
});

Expand Down Expand Up @@ -58,6 +58,6 @@ describe('Create namespace from install operators', () => {
);

// Verify namespace was created successfully
cy.deleteProject(nsName);
cy.exec(`oc delete project ${nsName}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ describe('Using OLM descriptor components', () => {
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(testName);
cy.exec(`oc new-project ${testName}`);
create(testCRD);
create(testCSV);
});

afterEach(() => {
cy.visit('/');
cy.exec(`oc delete ${testCRD.spec.names.kind} ${testCR.metadata.name} -n ${testName}`);
checkErrors();
});

after(() => {
cy.exec(`oc delete crd ${testCRD.metadata.name}`);
cy.exec(`oc delete -n ${testName} clusterserviceversion ${testCSV.metadata.name}`);
cy.deleteProject(testName);
cy.exec(`oc delete project ${testName}`);
cy.logout();
});

Expand Down Expand Up @@ -55,20 +54,18 @@ describe('Using OLM descriptor components', () => {
const getOperandFormFieldLabel = (id) => cy.get(`[for=${id}]`);
const getOperandFormFieldInput = (id) => cy.get(`#${id}`);

const {
group,
names: { kind },
} = testCRD.spec;
const version = testCRD.spec.versions[0].name;
const URL = `/k8s/ns/${testName}/operators.coreos.com~v1alpha1~ClusterServiceVersion/${testCSV.metadata.name}/${group}~${version}~${kind}`;

it('displays list and detail views of an operand', () => {
create(testCR);
cy.visit(
`/k8s/ns/${testName}/operators.coreos.com~v1alpha1~ClusterServiceVersion/${testCSV.metadata.name}/${testCRD.spec.group}~${testCRD.spec.versions[0].name}~${testCRD.spec.names.kind}`,
);
cy.visit(URL);
cy.byTestOperandLink('olm-descriptors-test').should('exist');
const {
group,
names: { kind },
} = testCRD.spec;
const version = testCRD.spec.versions[0].name;
cy.visit(
`/k8s/ns/${testName}/operators.coreos.com~v1alpha1~ClusterServiceVersion/${testCSV.metadata.name}/${group}~${version}~${kind}/${testCR.metadata.name}`,
);
cy.visit(`${URL}/${testCR.metadata.name}`);
cy.byLegacyTestID('resource-title').should('have.text', `${testCR.metadata.name}`);
testCSV.spec.customresourcedefinitions.owned[0].specDescriptors.forEach((descriptor) => {
if (descriptor.path === 'hidden') {
Expand All @@ -90,9 +87,11 @@ describe('Using OLM descriptor components', () => {
});

it('creates an operand using the form', () => {
cy.visit(
`/k8s/ns/${testName}/operators.coreos.com~v1alpha1~ClusterServiceVersion/${testCSV.metadata.name}/${testCRD.spec.group}~${testCRD.spec.versions[0].name}~${testCRD.spec.names.kind}`,
);
// enure the app is loaded before visting the form
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.visit(URL);
// TODO figure out why this element is detaching
cy.byTestID('item-create').click({ force: true });
cy.byLegacyTestID('resource-title').should('have.text', 'Create App');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { checkErrors } from '../../../integration-tests-cypress/support';
import { detailsPage } from '../../../integration-tests-cypress/views/details-page';
import { modal } from '../../../integration-tests-cypress/views/modal';
import { nav } from '../../../integration-tests-cypress/views/nav';

describe('Create namespace from install operators', () => {
before(() => {
Expand All @@ -17,7 +18,7 @@ describe('Create namespace from install operators', () => {

it('disables default catalog sources from operatorHub details page', () => {
cy.log('navigate to operatorHub page');
cy.visit(`/settings/cluster`);
nav.sidenav.clickNavLink(['Administration', 'Cluster Settings']);
cy.byLegacyTestID('horizontal-link-Configuration').click();
cy.byLegacyTestID('OperatorHub').click();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { checkErrors, testName } from '../../../integration-tests-cypress/support';
import { checkErrors } from '../../../integration-tests-cypress/support';
import { nav } from '../../../integration-tests-cypress/views/nav';

describe('Interacting with OperatorHub', () => {
Expand All @@ -7,22 +7,20 @@ describe('Interacting with OperatorHub', () => {
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(testName);
});

afterEach(() => {
checkErrors();
});

after(() => {
cy.deleteProject(testName);
cy.logout();
});

it('displays OperatorHub tile view with expected available Operators', () => {
cy.log('navigate to OperatorHub');
nav.sidenav.clickNavLink(['Operators', 'OperatorHub']);
cy.url().should('include', `/operatorhub/ns/${testName}`);
cy.url().should('include', '/operatorhub/all-namespaces');
cy.log('more than one tile should be present');
cy.get('.catalog-tile-pf').its('length').should('be.gt', 0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import { nav } from '../../../integration-tests-cypress/views/nav';
import { operator, GlobalInstalledNamespace, TestOperandProps } from '../views/operator.view';

const testOperator = {
name: 'Service Binding Operator',
operatorHubCardTestID: 'rh-service-binding-operator-redhat-operators-openshift-marketplace',
name: 'Data Grid',
operatorHubCardTestID: 'datagrid-redhat-operators-openshift-marketplace',
};

const testOperand: TestOperandProps = {
name: 'ServiceBinding',
group: 'binding.operators.coreos.com',
version: 'v1alpha1',
kind: 'ServiceBinding',
createActionID:
'list-page-create-dropdown-item-binding.operators.coreos.com~v1alpha1~ServiceBinding',
exampleName: 'example-servicebinding',
name: 'Infinispan',
group: 'infinispan.org',
version: 'v1',
kind: 'Infinispan',
createActionID: 'list-page-create-dropdown-item-infinispan.org~v1~Infinispan',
exampleName: 'example-infinispan',
};

describe(`Globally installing "${testOperator.name}" operator in ${GlobalInstalledNamespace}`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { nav } from '../../../integration-tests-cypress/views/nav';
import { GlobalInstalledNamespace, operator, TestOperandProps } from '../views/operator.view';

const testOperator = {
name: 'Red Hat Integration - 3scale',
operatorHubCardTestID: '3scale-operator-redhat-operators-openshift-marketplace',
name: 'Data Grid',
operatorHubCardTestID: 'datagrid-redhat-operators-openshift-marketplace',
installedNamespace: testName,
};

const testOperand: TestOperandProps = {
name: '3scale Backend',
group: 'capabilities.3scale.net',
version: 'v1beta1',
kind: 'Backend',
exampleName: `backend1-sample`,
name: 'Backup',
group: 'infinispan.org',
version: 'v1',
kind: 'Backup',
exampleName: 'example-backup',
};

describe(`Installing "${testOperator.name}" operator in test namespace`, () => {
Expand All @@ -24,17 +24,16 @@ describe(`Installing "${testOperator.name}" operator in test namespace`, () => {
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(testName);
cy.exec(`oc new-project ${testName}`);
});

afterEach(() => {
checkErrors();
});

after(() => {
operator.uninstall(testOperator.name, testOperator.installedNamespace);
operator.shouldNotExist(testOperator.name, testOperator.installedNamespace);
cy.deleteProject(testName);
cy.visit('/');
cy.exec(`oc delete project ${testName}`);
cy.logout();
});

Expand Down Expand Up @@ -77,5 +76,8 @@ describe(`Installing "${testOperator.name}" operator in test namespace`, () => {

operator.deleteOperand(testOperator.name, testOperand, testOperator.installedNamespace);
operator.operandShouldNotExist(testOperator.name, testOperand, testOperator.installedNamespace);

operator.uninstall(testOperator.name, testOperator.installedNamespace);
operator.shouldNotExist(testOperator.name, testOperator.installedNamespace);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ import { modal } from '../../../integration-tests-cypress/views/modal';
import { nav } from '../../../integration-tests-cypress/views/nav';
import { operator, TestOperandProps } from '../views/operator.view';

// TODO Update to valid operator. This is deprecated.
const testOperator = {
name: 'Business Automation',
operatorHubCardTestID: 'businessautomation-operator-redhat-operators-openshift-marketplace',
name: 'Data Grid',
operatorHubCardTestID: 'datagrid-redhat-operators-openshift-marketplace',
installedNamespace: testName,
};

const testOperand: TestOperandProps = {
name: 'KieApp',
kind: 'KieApp',
group: 'KieApp',
name: 'Backup',
group: 'infinispan.org',
version: 'v1',
exampleName: `example-kieappk`,
deleteURL: '/api/kubernetes/apis/app.kiegroup.org/*/namespaces/*/kieapps/*',
kind: 'Backup',
exampleName: 'example-backup',
deleteURL: '/api/kubernetes/apis/infinispan.org/*/namespaces/*/backups/*',
};

const alertExists = (titleText: string) => {
Expand All @@ -37,13 +36,13 @@ const uninstallAndVerify = () => {
cy.resourceShouldBeDeleted(testName, testOperand.kind, testOperand.exampleName);
};

xdescribe(`Testing uninstall of ${testOperator.name} Operator`, () => {
describe(`Testing uninstall of ${testOperator.name} Operator`, () => {
before(() => {
cy.login();
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(testName);
cy.exec(`oc new-project ${testName}`);
operator.install(
testOperator.name,
testOperator.operatorHubCardTestID,
Expand All @@ -64,10 +63,7 @@ xdescribe(`Testing uninstall of ${testOperator.name} Operator`, () => {
});

after(() => {
cy.visit('/');
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.deleteProject(testName);
cy.exec(`oc delete project ${testName}`);
cy.logout();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ export const operator = {
} else {
cy.byTestID('All namespaces on the cluster-radio-input').should('be.checked');
}
if (!useOperatorRecommendedNamespace) {
cy.log(`verify namespace dropdown shows the "${installToNamespace}" namespace`);
if (installToNamespace !== GlobalInstalledNamespace && !useOperatorRecommendedNamespace) {
cy.byTestID('dropdown-selectbox').click();
cy.byLegacyTestID('dropdown-text-filter').type(installToNamespace);
cy.byTestID('dropdown-menu-item-link').click();
cy.byTestID('dropdown-selectbox').should('contain', installToNamespace);
}
// Install
Expand All @@ -74,7 +76,7 @@ export const operator = {
nav.sidenav.clickNavLink(['Operators', 'Installed Operators']);
listPage.titleShouldHaveText('Installed Operators');
listPage.filter.byName(operatorName);
cy.byTestOperatorRow(operatorName, { timeout: 180000 }).should('exist'); // 3 minutes
cy.byTestOperatorRow(operatorName, { timeout: 300000 }).should('exist'); // 5 minutes
listPage.rows.countShouldBe(1);
cy.byTestID('status-text', { timeout: 720000 }).should('contain.text', 'Succeeded'); // 12 minutes
},
Expand Down Expand Up @@ -144,7 +146,7 @@ export const operator = {
}
cy.byTestID(exampleName).should('exist');
cy.log(`navigate to the operand "Details" tab`);
cy.byTestID(exampleName).click();
cy.byTestID(exampleName).click({ force: true });
cy.url().should('match', new RegExp(`${exampleName}$`)); // url should end with example operand name
},
deleteOperand: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ const OperandsLoadedErrorAlert: React.FC<{ operandsLoadedErrorMessage: string }>
{t(
'olm~There was an error loading operands for this operator. Operands will need to be deleted manually.',
)}
<div>{operandsLoadedErrorMessage}</div>
</p>
<p>{operandsLoadedErrorMessage}</p>
</Alert>
);
};
Expand Down Expand Up @@ -582,27 +582,25 @@ const OperandsTable: React.FC<OperandsTableProps> = ({ operands, loaded, csvName
{operands
.sort((a, b) => a.metadata.name.localeCompare(b.metadata.name))
.map((operand) => (
<>
<tr key={operand.metadata.uid}>
<td>
<OperandLink obj={operand} csvName={csvName} onClick={cancel} />
</td>
<td className="co-break-word" data-test-operand-kind={operand.kind}>
{operand.kind}
</td>
<td>
{operand.metadata.namespace ? (
<ResourceLink
kind="Namespace"
name={operand.metadata.namespace}
onClick={cancel}
/>
) : (
'-'
)}
</td>
</tr>
</>
<tr key={operand.metadata.uid}>
<td>
<OperandLink obj={operand} csvName={csvName} onClick={cancel} />
</td>
<td className="co-break-word" data-test-operand-kind={operand.kind}>
{operand.kind}
</td>
<td>
{operand.metadata.namespace ? (
<ResourceLink
kind="Namespace"
name={operand.metadata.namespace}
onClick={cancel}
/>
) : (
'-'
)}
</td>
</tr>
))}
</tbody>
</table>
Expand Down

0 comments on commit 125e665

Please sign in to comment.