-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mgr/dashboard: E2E Test for RBD Mirroring and Images (ceph#29381)
mgr/dashboard: E2E Test for RBD Mirroring and Images Reviewed-by: Stephan Müller <[email protected]> Reviewed-by: Tiago Melo <[email protected]>
- Loading branch information
Showing
5 changed files
with
236 additions
and
7 deletions.
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
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,5 +1,92 @@ | ||
import { $, $$, browser, by, element } from 'protractor'; | ||
import { Helper } from '../helper.po'; | ||
import { PageHelper } from '../page-helper.po'; | ||
|
||
export class ImagesPageHelper extends PageHelper { | ||
pages = { index: '/#/block/rbd' }; | ||
pages = { | ||
index: '/#/block/rbd', | ||
create: '/#/block/rbd/create' | ||
}; | ||
|
||
// Creates a block image and fills in the name, pool, and size fields. Then checks | ||
// if the image is present in the Images table. | ||
createImage(name, pool, size) { | ||
this.navigateTo('create'); | ||
|
||
// Need the string '[value="<pool>"]' to find the pool in the dropdown menu | ||
const getPoolName = `[value="${pool}"]`; | ||
|
||
element(by.id('name')).sendKeys(name); // Enter in image name | ||
|
||
// Select image pool | ||
element(by.id('pool')).click(); | ||
element(by.cssContainingText('select[name=pool] option', pool)).click(); | ||
$(getPoolName).click(); | ||
expect(element(by.id('pool')).getAttribute('class')).toContain('ng-valid'); // check if selected | ||
|
||
// Enter in the size of the image | ||
element(by.id('size')).click(); | ||
element(by.id('size')).sendKeys(size); | ||
|
||
// Click the create button and wait for image to be made | ||
element(by.cssContainingText('button', 'Create RBD')) | ||
.click() | ||
.then(() => { | ||
browser.wait(Helper.EC.presenceOf(this.getTableCell(name)), Helper.TIMEOUT); | ||
}); | ||
} | ||
|
||
editImage(name, pool, newName, newSize) { | ||
const base_url = '/#/block/rbd/edit/'; | ||
const editURL = base_url | ||
.concat(pool) | ||
.concat('/') | ||
.concat(name); | ||
browser.get(editURL); | ||
|
||
element(by.id('name')).click(); // click name box and send new name | ||
element(by.id('name')).clear(); | ||
element(by.id('name')).sendKeys(newName); | ||
element(by.id('size')).click(); | ||
element(by.id('size')).clear(); | ||
element(by.id('size')).sendKeys(newSize); // click the size box and send new size | ||
|
||
element(by.cssContainingText('button', 'Edit RBD')) | ||
.click() | ||
.then(() => { | ||
this.navigateTo(); | ||
browser | ||
.wait(Helper.EC.elementToBeClickable(this.getTableCell(newName)), Helper.TIMEOUT) | ||
.then(() => { | ||
this.getTableCell(newName).click(); | ||
expect( | ||
element | ||
.all(by.css('.table.table-striped.table-bordered')) | ||
.first() | ||
.getText() | ||
).toMatch(newSize); | ||
}); // click edit button and wait to make sure new owner is present in table | ||
}); | ||
} | ||
|
||
deleteImage(name) { | ||
this.navigateTo(); | ||
|
||
// wait for table to load | ||
browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); | ||
this.getTableCell(name).click(); // click on the image you want to delete in the table | ||
$$('.table-actions button.dropdown-toggle') | ||
.first() | ||
.click(); // click toggle menu | ||
$('li.delete.ng-star-inserted').click(); // click delete | ||
// wait for pop-up to be visible (checks for title of pop-up) | ||
browser.wait(Helper.EC.visibilityOf($('.modal-body')), Helper.TIMEOUT).then(() => { | ||
$('.custom-control-label').click(); // click confirmation checkbox | ||
element(by.cssContainingText('button', 'Delete RBD')) | ||
.click() | ||
.then(() => { | ||
browser.wait(Helper.EC.stalenessOf(this.getTableCell(name)), Helper.TIMEOUT); | ||
}); | ||
}); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.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 |
---|---|---|
@@ -1,5 +1,50 @@ | ||
import { $, browser, by, element } from 'protractor'; | ||
import { Helper } from '../helper.po'; | ||
import { PageHelper } from '../page-helper.po'; | ||
|
||
export class MirroringPageHelper extends PageHelper { | ||
pages = { index: '/#/block/mirroring' }; | ||
|
||
// Goes to the mirroring page and edits a pool in the Pool table. Clicks on the | ||
// pool and chooses a option (either pool, image, or disabled) | ||
editMirror(name, option) { | ||
this.navigateTo(); | ||
// Clicks the pool in the table | ||
browser | ||
.wait(Helper.EC.elementToBeClickable(this.getFirstTableCellWithText(name)), Helper.TIMEOUT) | ||
.then(() => { | ||
this.getFirstTableCellWithText(name).click(); | ||
}); | ||
|
||
// Clicks the Edit Mode button | ||
const editModeButton = element(by.cssContainingText('button', 'Edit Mode')); | ||
browser.wait(Helper.EC.elementToBeClickable(editModeButton), Helper.TIMEOUT).then(() => { | ||
editModeButton.click(); | ||
}); | ||
// Clicks the drop down in the edit pop-up, then clicks the Update button | ||
browser.wait(Helper.EC.visibilityOf($('.modal-content')), Helper.TIMEOUT).then(() => { | ||
const mirrorDrop = element(by.id('mirrorMode')); | ||
this.moveClick(mirrorDrop); | ||
element(by.cssContainingText('select[name=mirrorMode] option', option)).click(); | ||
}); | ||
// Clicks update button and checks if the mode has been changed | ||
element(by.cssContainingText('button', 'Update')) | ||
.click() | ||
.then(() => { | ||
browser | ||
.wait( | ||
Helper.EC.stalenessOf( | ||
element(by.cssContainingText('.modal-dialog', 'Edit pool mirror mode')) | ||
), | ||
Helper.TIMEOUT | ||
) | ||
.then(() => { | ||
const val = option.toLowerCase(); // used since entries in table are lower case | ||
browser.wait( | ||
Helper.EC.visibilityOf(this.getFirstTableCellWithText(val)), | ||
Helper.TIMEOUT | ||
); | ||
}); | ||
}); | ||
} | ||
} |
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