-
Notifications
You must be signed in to change notification settings - Fork 593
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
Add E2E tests for Installation flow #4803
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
bipuladh:install_test_ocp
Apr 3, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...nd/packages/ceph-storage-plugin/integration-tests/tests/ocp-tests/installFlow.scenario.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { execSync } from 'child_process'; | ||
import { browser, ExpectedConditions as until } from 'protractor'; | ||
import * as crudView from '@console/internal-integration-tests/views/crud.view'; | ||
import { click } from '@console/shared/src/test-utils/utils'; | ||
import { | ||
MINUTE, | ||
SECOND, | ||
NS, | ||
OCS_NODE_LABEL, | ||
STORAGE_CLUSTER_NAME, | ||
CATALOG_SRC, | ||
} from '../../utils/consts'; | ||
import { | ||
selectWorkerRows, | ||
InstallCluster, | ||
ocsOperator, | ||
createLink, | ||
sizeDropdown, | ||
optionSmallSize, | ||
primaryButton, | ||
} from '../../views/installFlow.view'; | ||
import { getStorageClusterLink } from '../../views/add-capacity.view'; | ||
import { hasTaints, hasOCSTaint, refreshIfNotVisible } from '../../utils/helpers'; | ||
|
||
const Installer = new InstallCluster(NS); | ||
|
||
const testNodeLabel = (node) => { | ||
const nodeJSON = JSON.parse(execSync(`kubectl get nodes ${node} -o json`).toString()); | ||
const labelKeys = Object.keys(nodeJSON.metadata.labels); | ||
expect(labelKeys).toContain(OCS_NODE_LABEL); | ||
expect(hasOCSTaint(nodeJSON) || !hasTaints(nodeJSON)).toBe(true); | ||
}; | ||
|
||
describe('Testing OCS Cluster Creation', () => { | ||
beforeAll(async () => { | ||
await Installer.createNamespace(); | ||
expect(browser.getCurrentUrl()).toContain(NS); | ||
await Installer.subscribeToOperator(CATALOG_SRC); | ||
await click(ocsOperator); | ||
await browser.wait(until.and(crudView.untilNoLoadersPresent)); | ||
// This can fail in a fresh cluster | ||
try { | ||
await browser.wait(until.visibilityOf(createLink), 10 * SECOND); | ||
} catch { | ||
await refreshIfNotVisible(createLink, 5); | ||
} | ||
const storageClusterLink = await getStorageClusterLink(); | ||
await click(storageClusterLink); | ||
}, 3 * MINUTE); | ||
|
||
it( | ||
'Test Storage Cluster Creation', | ||
async () => { | ||
await browser.wait(until.and(crudView.untilNoLoadersPresent)); | ||
// Node list fluctuates | ||
await browser.sleep(5 * SECOND); | ||
const nodes = await selectWorkerRows(); | ||
bipuladh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await click(sizeDropdown); | ||
await click(optionSmallSize); | ||
await browser.wait(until.elementToBeClickable(primaryButton)); | ||
await click(primaryButton); | ||
await browser.wait(until.and(crudView.untilNoLoadersPresent)); | ||
// eslint-disable-next-line no-useless-escape | ||
const defaultSC = execSync(`kubectl get storageclasses | grep -Po '\\w+(?=.*default)'`) | ||
.toString() | ||
.trim(); | ||
const storageCR = JSON.parse( | ||
execSync(`kubectl get storageclusters ${STORAGE_CLUSTER_NAME} -n ${NS} -o json`).toString(), | ||
); | ||
const scFromYAML = | ||
storageCR?.spec?.storageDeviceSets?.[0]?.dataPVCTemplate?.spec?.storageClassName; | ||
const size = | ||
storageCR?.spec?.storageDeviceSets?.[0]?.dataPVCTemplate?.spec?.resources?.requests | ||
?.storage; | ||
expect(defaultSC).toEqual(scFromYAML); | ||
// Tests for storage class | ||
expect(size).toEqual('512Gi'); | ||
nodes.forEach((node, i) => testNodeLabel(nodes[i])); | ||
}, | ||
5 * MINUTE, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { execSync } from 'child_process'; | ||
import * as crudView from '@console/internal-integration-tests/views/crud.view'; | ||
import { ExpectedConditions as until, browser, $ } from 'protractor'; | ||
import * as _ from 'lodash'; | ||
import { OSD, POD_NAME_PATTERNS, SECOND } from './consts'; | ||
import { ExpectedConditions as until, browser, $ } from 'protractor'; | ||
import * as crudView from '@console/internal-integration-tests/views/crud.view'; | ||
import { OSD, POD_NAME_PATTERNS, SECOND, ocsTaint } from './consts'; | ||
|
||
export const checkIfClusterIsReady = async () => { | ||
let stillLoading = true; | ||
|
@@ -159,6 +159,15 @@ export const verifyNodeOSDMapping = ( | |
return filteredOsds.length === 0; | ||
}; | ||
|
||
export const hasTaints = (node) => { | ||
return !_.isEmpty(node.spec?.taints); | ||
}; | ||
|
||
export const hasOCSTaint = (node) => { | ||
const taints = node?.spec?.taints || []; | ||
return taints.some((taint) => _.isEqual(taint, ocsTaint)); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why you have defined the functions again here? You can reuse the function from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can't pull that code into e2e tests and vice versa, |
||
|
||
export type NodeType = { | ||
id: number; | ||
name: string; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are testing cluster creation there are e2e-tests for operators-hub that test installation of an operator.