Skip to content

Commit

Permalink
Add Internal Mode Installation Test to Cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
bipuladh committed Nov 19, 2020
1 parent 87ed788 commit 030e58a
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"reporterOptions": {
"configFile": "reporter-config.json"
},
"supportFile": "../../integration-tests-cypress/support/index.ts",
"supportFile": "./support/index.ts",
"pluginsFile": "../../integration-tests-cypress/plugins/index.js",
"fixturesFolder": false,
"defaultCommandTimeout": 30000,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import * as _ from 'lodash';
import '../../../integration-tests-cypress/support/index.ts';

declare global {
namespace Cypress {
interface Chainable<Subject> {
install(mode?: 'Internal' | 'Attached', encrypted?: boolean): Chainable<Element>;
uninstall(): Chainable<Element>;
}
}
}

Cypress.Commands.add('install', (mode: 'Internal' | 'Attached' = 'Internal', encrypted = false) => {
cy.log('Search in Operator Hub');
cy.clickNavLink(['Operators', 'OperatorHub']);
cy.byTestID('search-operatorhub').type('Openshift Container Storage');
cy.byTestID('ocs-operator-redhat-operators-openshift-marketplace').click();

cy.log('Subscribe to OCS Operator');
cy.byLegacyTestID('operator-install-btn').click({ force: true });
cy.byTestID('Operator recommended namespace:-radio-input').should('be.checked');
cy.byTestID('enable-monitoring').click();
cy.byTestID('install-operator').click();
cy.byTestID('success-icon', { timeout: 180000 }).should('be.visible');
cy.exec('oc get project openshift-storage -o json').then((res) => {
const obj = JSON.parse(res.stdout);
expect(obj.metadata.labels?.['openshift.io/cluster-monitoring']).toEqual('true');
});
// Rook, Noobaa and OCS pod should come up after installation.
cy.exec('oc get po -n openshift-storage -o json').then((res) => {
const { items } = JSON.parse(res.stdout);
expect(items.find((item) => _.startsWith(item.metadata.name, 'noobaa-operator'))).toBeDefined();
expect(items.find((item) => _.startsWith(item.metadata.name, 'ocs-operator'))).toBeDefined();
expect(
items.find((item) => _.startsWith(item.metadata.name, 'rook-ceph-operator')),
).toBeDefined();
});

// Make changes to this once we add annotation
cy.log(`Install OCS in ${mode} Mode`);
cy.clickNavLink(['Installed Operators']);
cy.byLegacyTestID('item-filter').type('ocs-operator');
cy.byTestOperatorRow('OpenShift Container Storage').click();
cy.byLegacyTestID('horizontal-link-Storage Cluster').click();
cy.byTestID('yaml-create').click();

cy.log(`Select ${mode}`);
cy.byTestID('Internal-radio-input').should('be.checked');

// Step 1
// Select all worker Nodes
cy.get('input[name=check-all]').click();
// Two dropdowns in the same page.
// (Todo: )make dropdown data-test-id be something that can be passed as a prop
cy.byLegacyTestID('dropdown-button')
.first()
.click();
cy.byTestDropDownMenu('512Gi').click();
cy.get('.pf-c-button.pf-m-primary')
.contains('Next')
.click();

// Step 2
if (encrypted) {
cy.log('Enabling Encryption');
cy.byTestID('encryption-checkbox').click();
}
cy.get('.pf-c-button.pf-m-primary')
.contains('Next')
.click();

// Final Step
cy.get('.pf-c-button.pf-m-primary')
.contains('Create')
.click();

// Check worker nodes for labels
cy.exec('oc get nodes -o json').then((res) => {
const { items } = JSON.parse(res.stdout);
items
.map((item) => item.metadata.labels)
.filter((item) => item.hasOwnProperty('node-role.kubernetes.io/worker'))
.forEach((item) =>
expect(item.hasOwnProperty('cluster.ocs.openshift.io/openshift-storage')).toBeTruthy(),
);
});

// Wait for the storage cluster to reach Ready
// Storage Cluster CR flickers so wait for 10 seconds
// Disablng until ocs-operator fixes above issue
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(10000);

cy.byTestID('resource-status').contains('Ready', { timeout: 900000 });
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { checkErrors } from '../../../integration-tests-cypress/support';

describe('OCS Operator Basic Tests', () => {
before(() => {
cy.login();
cy.visit('/');

cy.install();
});

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

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

it('Add capacity to Storage Cluster', () => {});
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const EncryptionFormGroup: React.FC<EncryptionFormGroupProps> = ({
}) => (
<FormGroup fieldId="configure-encryption" label="Encryption">
<Checkbox
data-test="encryption-checkbox"
id="configure-encryption"
isChecked={isChecked}
label="Enable Encryption"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const SelectCapacityAndNodes: React.FC<SelectCapacityAndNodesProps> = ({
noSelection
filter={filterSCWithoutNoProv}
hideClassName="ocs-install-wizard__storage-class-label"
data-test="storage-class-dropdown"
/>
</GridItem>
<GridItem span={7} />
Expand Down
1 change: 1 addition & 0 deletions frontend/public/components/utils/resource-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const ResourceStatus: React.FC<ResourceStatusProps> = ({
'co-resource-item__resource-status-badge--alt': badgeAlt,
})}
isRead
data-test="resource-status"
>
{children}
</Badge>
Expand Down

0 comments on commit 030e58a

Please sign in to comment.