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 1798581: Add tests for pvc creation with different options #3708
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
ebondare:pvc-creation-tests
Feb 6, 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
105 changes: 105 additions & 0 deletions
105
frontend/packages/ceph-storage-plugin/integration-tests/tests/2-tests/pvc.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,105 @@ | ||
import { browser } from 'protractor'; | ||
import { appHost } from '@console/internal-integration-tests/protractor.conf'; | ||
import { resourceRowsPresent } from '@console/internal-integration-tests/views/crud.view'; | ||
import { | ||
createNewPersistentVolumeClaim, | ||
deletePersistentVolumeClaim, | ||
goToPersistentVolumeClaims, | ||
pvcStatus, | ||
pvcSize, | ||
} from '../../views/pvc.view'; | ||
import { | ||
NS, | ||
PVC_STATUS, | ||
SIZE_UNITS, | ||
STORAGE_CLASS_PATTERNS, | ||
VOLUME_ACCESS_MODES, | ||
} from '../../utils/consts'; | ||
|
||
describe('Test PVC creation with options.', () => { | ||
beforeAll(async () => { | ||
await browser.get(`${appHost}/`); | ||
}); | ||
|
||
it('Test RBD PVC is created and gets bound', async () => { | ||
const testPvc = { | ||
name: 'rbdpvc', | ||
namespace: NS, | ||
size: '5', | ||
sizeUnits: SIZE_UNITS.GI, | ||
storageClass: STORAGE_CLASS_PATTERNS.RBD, | ||
accessMode: VOLUME_ACCESS_MODES.RWO, | ||
}; | ||
await createNewPersistentVolumeClaim(testPvc, true); | ||
expect(pvcStatus.getText()).toEqual(PVC_STATUS.BOUND); | ||
await goToPersistentVolumeClaims(); | ||
await resourceRowsPresent(); | ||
await deletePersistentVolumeClaim('rbdpvc', NS); | ||
}); | ||
|
||
it('Test PVC size is rounded', async () => { | ||
// PVC size of 1.5 should be rounded to 2 | ||
// https://bugzilla.redhat.com/show_bug.cgi?id=1746156 | ||
const testPvc = { | ||
name: 'rbdpvc', | ||
namespace: NS, | ||
size: '1.5', | ||
sizeUnits: SIZE_UNITS.GI, | ||
storageClass: STORAGE_CLASS_PATTERNS.RBD, | ||
accessMode: VOLUME_ACCESS_MODES.RWO, | ||
}; | ||
await createNewPersistentVolumeClaim(testPvc, true); | ||
expect(pvcSize.getText()).toEqual('2Gi'); | ||
await goToPersistentVolumeClaims(); | ||
await resourceRowsPresent(); | ||
await deletePersistentVolumeClaim('rbdpvc', NS); | ||
}); | ||
|
||
it('Test cephFS PVC is created and gets bound', async () => { | ||
const testPvc = { | ||
name: 'cephfspvc', | ||
namespace: NS, | ||
size: '1', | ||
sizeUnits: SIZE_UNITS.TI, | ||
storageClass: STORAGE_CLASS_PATTERNS.FS, | ||
accessMode: VOLUME_ACCESS_MODES.RWO, | ||
}; | ||
await createNewPersistentVolumeClaim(testPvc, true); | ||
expect(pvcStatus.getText()).toEqual(PVC_STATUS.BOUND); | ||
await goToPersistentVolumeClaims(); | ||
await resourceRowsPresent(); | ||
await deletePersistentVolumeClaim('cephfspvc', NS); | ||
}); | ||
|
||
it('Test RWX RBD PVC is created and gets bound', async () => { | ||
const testPvc = { | ||
name: 'rwxrbdpvc', | ||
namespace: NS, | ||
size: '512', | ||
sizeUnits: SIZE_UNITS.MI, | ||
storageClass: STORAGE_CLASS_PATTERNS.RBD, | ||
accessMode: VOLUME_ACCESS_MODES.RWX, | ||
}; | ||
await createNewPersistentVolumeClaim(testPvc, true); | ||
expect(pvcStatus.getText()).toEqual(PVC_STATUS.BOUND); | ||
await goToPersistentVolumeClaims(); | ||
await resourceRowsPresent(); | ||
await deletePersistentVolumeClaim('rwxrbdpvc', NS); | ||
}); | ||
|
||
it('Test RWX CephFS PVC is created and gets bound', async () => { | ||
const testPvc = { | ||
name: 'rwxcephfspvc', | ||
namespace: NS, | ||
size: '5', | ||
sizeUnits: SIZE_UNITS.GI, | ||
storageClass: STORAGE_CLASS_PATTERNS.FS, | ||
accessMode: VOLUME_ACCESS_MODES.RWX, | ||
}; | ||
await createNewPersistentVolumeClaim(testPvc, true); | ||
expect(pvcStatus.getText()).toEqual(PVC_STATUS.BOUND); | ||
await goToPersistentVolumeClaims(); | ||
await resourceRowsPresent(); | ||
await deletePersistentVolumeClaim('rwxcephfspvc', NS); | ||
}); | ||
}); |
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
66 changes: 66 additions & 0 deletions
66
frontend/packages/ceph-storage-plugin/integration-tests/views/pvc.view.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,66 @@ | ||
import { $, $$, browser, ExpectedConditions as until } from 'protractor'; | ||
import * as crudView from '@console/internal-integration-tests/views/crud.view'; | ||
import * as sideNavView from '@console/internal-integration-tests/views/sidenav.view'; | ||
import { click } from '@console/shared/src/test-utils/utils'; | ||
import { PVC_STATUS } from '../utils/consts'; | ||
import { PvcType } from '../utils/helpers'; | ||
|
||
export const selectItemFromDropdown = async (item, dropdownElement) => { | ||
await click(dropdownElement); | ||
await click($(`#${item}-link`)); | ||
}; | ||
|
||
// create pvc | ||
export const namespaceDropdown = $$('[class="pf-c-dropdown__toggle pf-m-plain"]').get(0); | ||
export const storageclassDropdown = $('#storageclass-dropdown'); | ||
export const inputPVCName = $('#pvc-name'); | ||
export const selectAccessMode = (accessMode) => $(`input[value=${accessMode}]`); | ||
export const inputPVCSize = $('[name=requestSizeValue]'); | ||
export const sizeUnitsDropdown = $('[data-test-id=dropdown-button]'); | ||
|
||
// pvc details | ||
export const pvcName = $('[data-test-id=pvc-name]'); | ||
export const pvcStatus = $('[data-test-id=pvc-status]'); | ||
export const pvcSize = $('[data-test-id=pvc-capacity]'); | ||
export const pvcAccessMode = $('[data-test-id=pvc-access-mode]'); | ||
export const pvcVolumeMode = $('[data-test-id=pvc-volume-mode]'); | ||
export const pvcStorageClass = $('[data-test-id=pvc-storageclass]'); | ||
export const pvcPersistentVolume = $('[data-test-id=persistent-volume]'); | ||
export const actionsButton = $('[data-test-id=actions-menu-button]'); | ||
export const deletePvc = $('[data-test-action="Delete Persistent Volume Claim"]'); | ||
|
||
// list of PVCs | ||
export const nameInTable = (name) => $(`a[data-test-id=${name}]`); | ||
|
||
export const goToPersistentVolumeClaims = async () => { | ||
await sideNavView.clickNavLink(['Storage', 'Persistent Volume Claims']); | ||
await crudView.isLoaded(); | ||
}; | ||
|
||
export const createNewPersistentVolumeClaim = async (pvc: PvcType, waitForBinding: boolean) => { | ||
await goToPersistentVolumeClaims(); | ||
await selectItemFromDropdown(pvc.namespace, namespaceDropdown); | ||
await click(crudView.createYAMLButton); | ||
await browser.wait( | ||
until.textToBePresentInElement($('.co-m-pane__heading'), 'Create Persistent Volume Claim'), | ||
); | ||
await browser.wait(until.and(crudView.untilNoLoadersPresent)); | ||
await selectItemFromDropdown(pvc.storageClass, storageclassDropdown); | ||
await inputPVCName.sendKeys(pvc.name); | ||
await click(selectAccessMode(pvc.accessMode)); | ||
await inputPVCSize.sendKeys(pvc.size); | ||
// Units should be Mi, Gi or Ti | ||
await selectItemFromDropdown(pvc.sizeUnits, sizeUnitsDropdown); | ||
await click(crudView.saveChangesBtn); | ||
if (waitForBinding === true) | ||
await browser.wait(until.textToBePresentInElement(pvcStatus, PVC_STATUS.BOUND)); | ||
}; | ||
|
||
export const deletePersistentVolumeClaim = async (name: string, namespace: string) => { | ||
await goToPersistentVolumeClaims(); | ||
await selectItemFromDropdown(namespace, namespaceDropdown); | ||
await crudView.resourceRowsPresent(); | ||
await crudView.filterForName(name); | ||
await crudView.isLoaded(); | ||
await crudView.deleteRow('PersistentVolumeClaim')(name); | ||
ebondare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
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.
It would be a bit safer to
await isLoaded()
here.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.
isLoaded() function doesn't work here, because the page being loaded as default is Overview Dashboard, so I'd need dashboardIsLoaded()
But actually I wouldn't want the test to wait for the dashboard to be loaded, it might fail on https://bugzilla.redhat.com/show_bug.cgi?id=1753666 or just make the test run longer unnecessarily.
I do check that Persistent Volume Claims page is loaded at the beginning of each test as part of PVC creation function.
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.
ack