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

Bug 1835597: Add easier way to support selectors for multiple versions in OCS Tests #5137

Merged
merged 1 commit into from May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,19 +3,20 @@ import { browser } from 'protractor';
import * as crudView from '@console/internal-integration-tests/views/crud.view';
import {
MINUTE,
NS,
OCS_NODE_LABEL,
POD_NAME_PATTERNS,
STORAGE_CLASS_PATTERNS,
STORAGE_CLUSTER_NAME,
SECOND,
SUCCESS,
NS as OCS_NS,
} from '../../utils/consts';
import {
InstallCluster,
filterInput,
goToStorageClasses,
ocsOperatorStatus,
currentSelectors,
TEST_PLATFORM,
} from '../../views/installFlow.view';
import {
checkIfClusterIsReady,
Expand All @@ -26,21 +27,26 @@ import {
sendKeys,
testPodIsRunning,
verifyNodeLabels,
testPodIsSucceeded,
} from '../../utils/helpers';

const Installer = new InstallCluster(NS);
const Installer = new InstallCluster();

describe('Testing OCS Subscription', () => {
beforeAll(async () => {
await Installer.createNamespace();
expect(browser.getCurrentUrl()).toContain(NS);
}, 2 * MINUTE);
/**
* - Tests the namespace creation (Remove this)
* - Installs OCS Operator from Operator Hub
* - Tests for various resources associated with OCS Operator to be in acceptable state
* - Creates Storage Cluster
* - Tests for resources associated with Storage Cluster to be in acceptable state
*/

describe('Testing OCS Subscription', () => {
it(
'tests subscription flow for ocs operator',
'tests subscription flow for OCS Operator',
async () => {
await Installer.subscribeToOperator();
const text = await ocsOperatorStatus.getText();
const text = await currentSelectors.ocsOperatorStatus.getText();
// Operator is installed successfully
expect(text.includes(SUCCESS)).toBe(true);
},
3 * MINUTE,
Expand All @@ -66,101 +72,128 @@ describe('Test creation of Storage Cluster', () => {
it(
'creates a storage cluster',
async () => {
const nodes = await Installer.createStorageCluster();
const { selectedNodes } = await Installer.createStorageCluster();
browser.sleep(2 * SECOND);
const text = await crudView.resourceTitle.getText();
expect(text).toEqual(STORAGE_CLUSTER_NAME);
// Verify all the nodes have the required labels
// Wait for 5 seconds for label to apply
await browser.sleep(5 * SECOND);
nodes.forEach((node) => {
expect(verifyNodeLabels(node, OCS_NODE_LABEL)).toBe(true);
});
// Wait for cluster to come to ready state
await checkIfClusterIsReady();
let nodes: string[] = await Promise.all(selectedNodes);
// Data syntax Node\nN\n<node-name>
nodes = nodes.map((node) => node.split('\n')[2]);
nodes.forEach((node) => expect(verifyNodeLabels(node, OCS_NODE_LABEL)).toBeTruthy());
const storageCR = JSON.parse(
execSync(
`kubectl get storageclusters ${STORAGE_CLUSTER_NAME} -n ${OCS_NS} -o json`,
).toString(),
);
const scFromCR =
storageCR?.spec?.storageDeviceSets?.[0]?.dataPVCTemplate?.spec?.storageClassName;
const size =
storageCR?.spec?.storageDeviceSets?.[0]?.dataPVCTemplate?.spec?.resources?.requests
?.storage;
const defaultSC = execSync(`kubectl get storageclasses | grep -Po '\\w+(?=.*default)'`)
.toString()
.trim();
expect(size).toEqual('512Gi');
expect(defaultSC).toEqual(scFromCR);
},
16 * MINUTE,
);
});

describe('Tests for pods and storage classes', () => {
let pods = null;
if (TEST_PLATFORM === 'OCS') {
describe('Tests for pods and storage classes', () => {
let pods = null;

beforeAll(() => {
const podList = JSON.parse(
execSync('kubectl get po -n openshift-storage -o json').toString('utf-8'),
);
pods = podList.items;
});

it('tests if ocs-operator is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.OCS);
testPodIsRunning(getPodPhase(pod));
});
beforeAll(async () => {
// Wait for cluster to come to ready state
await checkIfClusterIsReady();
const podList = JSON.parse(
execSync('kubectl get po -n openshift-storage -o json').toString('utf-8'),
);
pods = podList.items;
});

it('tests if rook-ceph-operator is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.ROOK);
testPodIsRunning(getPodPhase(pod));
});
it('tests if ocs-operator is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.OCS);
testPodIsRunning(getPodPhase(pod));
});

it('tests if noobaa-operator is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.NOOBA_OPERATOR);
testPodIsRunning(getPodPhase(pod));
});
it('tests if rook-ceph-operator is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.ROOK);
testPodIsRunning(getPodPhase(pod));
});

it('tests if noobaa-core is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.NOOBAA_CORE);
testPodIsRunning(getPodPhase(pod));
});
it('tests if noobaa-operator is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.NOOBA_OPERATOR);
testPodIsRunning(getPodPhase(pod));
});

it("tests if 3 rook-ceph-mon's are running", () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.ROOK_CEPH_MON);
expect(podList.length).toBe(3);
podList.forEach((pod) => {
it('tests if noobaa-core is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.NOOBAA_CORE);
testPodIsRunning(getPodPhase(pod));
});
});

it('tests if rook-ceph-mgr is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.ROOK_CEPH_MGR);
testPodIsRunning(getPodPhase(pod));
});
it("tests if 3 rook-ceph-mon's are running", () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.ROOK_CEPH_MON);
expect(podList.length).toBe(3);
podList.forEach((pod) => {
testPodIsRunning(getPodPhase(pod));
});
});

// 3 cephfsplugin-* 2 csi-cephfsplugin-provisioner-*
it('tests if 5 csi-cephfsplugin are running', () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.CSI_CEPHFS);
expect(podList.length).toBe(5);
podList.forEach((pod) => {
it('tests if rook-ceph-mgr is running', () => {
const pod = getPodData(pods, POD_NAME_PATTERNS.ROOK_CEPH_MGR);
testPodIsRunning(getPodPhase(pod));
});
});

// 2 csi-rbdplugin-provisioner-* 3 csi-rbd-plugin-*
it('tests if 5 csi-rbdplugin are running', () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.CSI_RBD);
expect(podList.length).toBe(5);
podList.forEach((pod) => {
testPodIsRunning(getPodPhase(pod));
// 3 cephfsplugin-* 2 csi-cephfsplugin-provisioner-*
it('tests if 5 csi-cephfsplugin are running', () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.CSI_CEPHFS);
expect(podList.length).toBe(5);
podList.forEach((pod) => {
testPodIsRunning(getPodPhase(pod));
});
});
});

it('tests if 2 rook-ceph-mds-ocs-storagecluster-cephfilesystem pods are running', () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.ROOK_CEPH_MDS);
expect(podList.length).toBe(2);
podList.forEach((pod) => {
testPodIsRunning(getPodPhase(pod));
// 2 csi-rbdplugin-provisioner-* 3 csi-rbd-plugin-*
it('tests if 5 csi-rbdplugin are running', () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.CSI_RBD);
expect(podList.length).toBe(5);
podList.forEach((pod) => {
testPodIsRunning(getPodPhase(pod));
});
});

it('tests if 2 rook-ceph-mds-ocs-storagecluster-cephfilesystem pods are running', () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.ROOK_CEPH_MDS);
expect(podList.length).toBe(2);
podList.forEach((pod) => {
testPodIsRunning(getPodPhase(pod));
});
});
});

it('tests if all ceph-rbd, cephfs, noobaa storage classes are shown', async () => {
await goToStorageClasses();
await sendKeys(filterInput, STORAGE_CLASS_PATTERNS.RBD);
const rdbClass = await getDataFromRowAndCol(0, 1, podNameFilter);
expect(rdbClass.includes(STORAGE_CLASS_PATTERNS.RBD)).toBe(true);
await sendKeys(filterInput, STORAGE_CLASS_PATTERNS.FS);
const fsClass = await getDataFromRowAndCol(0, 1, podNameFilter);
expect(fsClass.includes(STORAGE_CLASS_PATTERNS.FS)).toBe(true);
await sendKeys(filterInput, STORAGE_CLASS_PATTERNS.NOOBAA);
const noobaaClass = await getDataFromRowAndCol(0, 1, podNameFilter);
expect(noobaaClass.includes(STORAGE_CLASS_PATTERNS.NOOBAA)).toBe(true);
it('tests if 3 rook-ceph-osd-prepare-ocs-deviceset have succeeded', () => {
const podList = getPodData(pods, POD_NAME_PATTERNS.ROOK_CEPH_OSD_PREPARE);
expect(podList.length).toBe(2);
podList.forEach((pod) => {
testPodIsSucceeded(getPodPhase(pod));
});
});

it('tests if all ceph-rbd, cephfs, noobaa storage classes are shown', async () => {
await goToStorageClasses();
await sendKeys(filterInput, STORAGE_CLASS_PATTERNS.RBD);
const rdbClass = await getDataFromRowAndCol(0, 1, podNameFilter);
expect(rdbClass.includes(STORAGE_CLASS_PATTERNS.RBD)).toBe(true);
await sendKeys(filterInput, STORAGE_CLASS_PATTERNS.FS);
const fsClass = await getDataFromRowAndCol(0, 1, podNameFilter);
expect(fsClass.includes(STORAGE_CLASS_PATTERNS.FS)).toBe(true);
await sendKeys(filterInput, STORAGE_CLASS_PATTERNS.NOOBAA);
const noobaaClass = await getDataFromRowAndCol(0, 1, podNameFilter);
expect(noobaaClass.includes(STORAGE_CLASS_PATTERNS.NOOBAA)).toBe(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also add check for osd pods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

osd pods cause flakiness.

});
});
}
Expand Up @@ -12,7 +12,6 @@ import {
ocsOp,
storageClusterRow,
verifyFields,
getStorageClusterLink,
} from '../../views/add-capacity.view';
import {
CLUSTER_STATUS,
Expand Down Expand Up @@ -42,6 +41,7 @@ import {
verifyNodeOSDMapping,
verifyZoneOSDMapping,
} from '../../utils/helpers';
import { currentSelectors } from '../../views/installFlow.view';

const storageCluster = JSON.parse(execSync(`kubectl get -o json -n ${NS} ${KIND}`).toString());
const cephValue = JSON.parse(execSync(`kubectl get cephCluster -n ${NS} -o json`).toString());
Expand Down Expand Up @@ -110,7 +110,7 @@ if (clusterStatus && cephHealth) {

await goToInstalledOperators();
await click(ocsOp);
const storageClusterLink = await getStorageClusterLink();
const storageClusterLink = await currentSelectors.getStorageClusterLink();
await click(storageClusterLink);

await clickKebabAction(uid, 'Add Capacity');
Expand Down

This file was deleted.

Expand Up @@ -18,6 +18,15 @@ export const checkIfClusterIsReady = async () => {
}
};

export const waitUntil = async (functor, expected, count = 1) => {
const value = await functor();
if (value < expected) {
await browser.sleep(2 * SECOND);
await waitUntil(functor, expected, count - 1);
}
return true;
};

export const waitFor = async (element, text, count = 1) => {
let rowNumber = 0;
while (rowNumber !== count) {
Expand Down