Skip to content

Commit

Permalink
mgr/dashboard: migrate E2E logs to async/await
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/40693

Signed-off-by: Patrick Seidensal <[email protected]>
  • Loading branch information
p-se committed Aug 28, 2019
1 parent 5de247e commit fa959e1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 67 deletions.
65 changes: 32 additions & 33 deletions src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,65 @@ describe('Logs page', () => {
configuration = new Helper().configuration;
});

afterEach(() => {
Helper.checkConsole();
afterEach(async () => {
await Helper.checkConsole();
});

describe('breadcrumb and tab tests', () => {
beforeAll(() => {
logs.navigateTo();
beforeAll(async () => {
await logs.navigateTo();
});

it('should open and show breadcrumb', () => {
expect(logs.getBreadcrumbText()).toEqual('Logs');
it('should open and show breadcrumb', async () => {
expect(await logs.getBreadcrumbText()).toEqual('Logs');
});

it('should show two tabs', () => {
expect(logs.getTabsCount()).toEqual(2);
it('should show two tabs', async () => {
expect(await logs.getTabsCount()).toEqual(2);
});

it('should show cluster logs tab at first', () => {
expect(logs.getTabText(0)).toEqual('Cluster Logs');
it('should show cluster logs tab at first', async () => {
expect(await logs.getTabText(0)).toEqual('Cluster Logs');
});

it('should show audit logs as a second tab', () => {
expect(logs.getTabText(1)).toEqual('Audit Logs');
it('should show audit logs as a second tab', async () => {
expect(await logs.getTabText(1)).toEqual('Audit Logs');
});
});

describe('audit logs respond to pool creation and deletion test', () => {
it('should create pool and check audit logs reacted', () => {
pools.navigateTo('create');
pools.create(poolname, 8);
it('should create pool and check audit logs reacted', async () => {
await pools.navigateTo('create');
await pools.create(poolname, 8);

pools.navigateTo();
pools.exist(poolname, true);
await pools.navigateTo();
await pools.exist(poolname, true);

logs.navigateTo();
logs.checkAuditForPoolFunction(poolname, 'create', hour, minute);
await logs.checkAuditForPoolFunction(poolname, 'create', hour, minute);
});

it('should delete pool and check audit logs reacted', () => {
pools.navigateTo();
pools.delete(poolname);
it('should delete pool and check audit logs reacted', async () => {
await pools.navigateTo();
await pools.delete(poolname);

pools.navigateTo();
pools.exist(poolname, false);
await pools.navigateTo();
await pools.exist(poolname, false);

logs.navigateTo();
logs.checkAuditForPoolFunction(poolname, 'delete', hour, minute);
await logs.navigateTo();
await logs.checkAuditForPoolFunction(poolname, 'delete', hour, minute);
});
});

describe('audit logs respond to editing configuration setting test', () => {
it('should change config settings and check audit logs reacted', () => {
configuration.navigateTo();
configuration.edit(configname, ['global', '5']);
it('should change config settings and check audit logs reacted', async () => {
await configuration.navigateTo();
await configuration.edit(configname, ['global', '5']);

logs.navigateTo();
logs.checkAuditForConfigChange(configname, 'global', hour, minute);
await logs.navigateTo();
await logs.checkAuditForConfigChange(configname, 'global', hour, minute);

configuration.navigateTo();
configuration.configClear(configname);
await configuration.navigateTo();
await configuration.configClear(configname);
});
});
});
68 changes: 34 additions & 34 deletions src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,124 +7,124 @@ browser.ignoreSynchronization = true;
export class LogsPageHelper extends PageHelper {
pages = { index: '/#/logs' };

checkAuditForPoolFunction(poolname, poolfunction, hour, minute) {
this.navigateTo();
async checkAuditForPoolFunction(poolname, poolfunction, hour, minute) {
await this.navigateTo();

// sometimes the modal from deleting pool is still present at this point.
// This wait makes sure it isn't
browser.wait(
await browser.wait(
Helper.EC.stalenessOf(element(by.cssContainingText('.modal-dialog', 'Delete Pool'))),
Helper.TIMEOUT
);

// go to audit logs tab
element(by.cssContainingText('.nav-link', 'Audit Logs')).click();
await element(by.cssContainingText('.nav-link', 'Audit Logs')).click();

// Enter an earliest time so that no old messages with the same pool name show up
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys(protractor.Key.BACK_SPACE);
if (hour < 10) {
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys('0');
}
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys(hour);

$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys(protractor.Key.BACK_SPACE);
if (minute < 10) {
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys('0');
}
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys(minute);

// Enter the pool name into the filter box
$$('input.form-control.ng-valid')
await $$('input.form-control.ng-valid')
.first()
.click();
$$('input.form-control.ng-valid')
await $$('input.form-control.ng-valid')
.first()
.clear();
$$('input.form-control.ng-valid')
await $$('input.form-control.ng-valid')
.first()
.sendKeys(poolname);

const audit_logs_tab = $('.tab-pane.active');
const audit_logs_body = audit_logs_tab.element(by.css('.card-body'));
const logs = audit_logs_body.all(by.cssContainingText('.ng-star-inserted', poolname));

expect(logs.getText()).toMatch(poolname);
expect(logs.getText()).toMatch(`pool ${poolfunction}`);
expect(await logs.getText()).toMatch(poolname);
expect(await logs.getText()).toMatch(`pool ${poolfunction}`);
}

checkAuditForConfigChange(configname, setting, hour, minute) {
this.navigateTo();
async checkAuditForConfigChange(configname, setting, hour, minute) {
await this.navigateTo();

// go to audit logs tab
element(by.cssContainingText('.nav-link', 'Audit Logs')).click();
await element(by.cssContainingText('.nav-link', 'Audit Logs')).click();

// Enter an earliest time so that no old messages with the same config name show up
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys(protractor.Key.BACK_SPACE);
if (hour < 10) {
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys('0');
}
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(0)
.sendKeys(hour);

$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys(protractor.Key.BACK_SPACE);
if (minute < 10) {
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys('0');
}
$$('.bs-timepicker-field')
await $$('.bs-timepicker-field')
.get(1)
.sendKeys(minute);

// Enter the config name into the filter box
$$('input.form-control.ng-valid')
await $$('input.form-control.ng-valid')
.first()
.click();
$$('input.form-control.ng-valid')
await $$('input.form-control.ng-valid')
.first()
.clear();
$$('input.form-control.ng-valid')
await $$('input.form-control.ng-valid')
.first()
.sendKeys(configname);

const audit_logs_tab = $('.tab-pane.active');
const audit_logs_body = audit_logs_tab.element(by.css('.card-body'));
const logs = audit_logs_body.all(by.cssContainingText('.ng-star-inserted', configname));

browser.wait(Helper.EC.presenceOf(logs.first()), Helper.TIMEOUT);
await browser.wait(Helper.EC.presenceOf(logs.first()), Helper.TIMEOUT);

expect(logs.getText()).toMatch(configname);
expect(logs.getText()).toMatch(setting);
expect(await logs.getText()).toMatch(configname);
expect(await logs.getText()).toMatch(setting);
}
}
4 changes: 4 additions & 0 deletions src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { browser } from 'protractor';
import { Logs } from 'selenium-webdriver';
import { ImagesPageHelper } from './block/images.po';
import { LogsPageHelper } from './cluster/logs.po';
import { ManagerModulesPageHelper } from './cluster/mgr-modules.po';
import { MonitorsPageHelper } from './cluster/monitors.po';
import { OSDsPageHelper } from './cluster/osds.po';
Expand Down Expand Up @@ -29,6 +31,7 @@ export class Helper {
osds: OSDsPageHelper;
monitors: MonitorsPageHelper;
mgrModules: ManagerModulesPageHelper;
logs: LogsPageHelper;

constructor() {
this.pools = new PoolPageHelper();
Expand All @@ -45,6 +48,7 @@ export class Helper {
this.osds = new OSDsPageHelper();
this.monitors = new MonitorsPageHelper();
this.mgrModules = new ManagerModulesPageHelper();
this.logs = new LogsPageHelper();
}

/**
Expand Down

0 comments on commit fa959e1

Please sign in to comment.