From: Patrick Seidensal Date: Mon, 19 Aug 2019 11:54:15 +0000 (+0200) Subject: mgr/dashboard: migrate E2E crushmap to async/await X-Git-Tag: v15.1.0~1745^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6566a2c4c5c1369179aad5f1d2c29ced7359f631;p=ceph.git mgr/dashboard: migrate E2E crushmap to async/await Needed to adapt the backend to return the type of the tree nodes as the previous selector did not work reliably. Fixes: https://tracker.ceph.com/issues/40693 Signed-off-by: Patrick Seidensal --- diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.e2e-spec.ts index 0828e52c0ec2..6c98c0192dd8 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.e2e-spec.ts @@ -2,43 +2,43 @@ import { $, browser } from 'protractor'; import { Helper } from '../helper.po'; describe('CRUSH map page', () => { - let crushmap: Helper['crushmap']; + let crushmap: Helper['crushMap']; beforeAll(() => { - crushmap = new Helper().crushmap; + crushmap = new Helper().crushMap; }); - afterEach(() => { - Helper.checkConsole(); + afterEach(async () => { + await Helper.checkConsole(); }); describe('breadcrumb test', () => { - beforeAll(() => { - crushmap.navigateTo(); + beforeAll(async () => { + await crushmap.navigateTo(); }); - it('should open and show breadcrumb', () => { - expect(crushmap.getBreadcrumbText()).toEqual('CRUSH map'); + it('should open and show breadcrumb', async () => { + expect(await crushmap.getBreadcrumbText()).toEqual('CRUSH map'); }); }); describe('fields check', () => { - beforeAll(() => { - crushmap.navigateTo(); + beforeAll(async () => { + await crushmap.navigateTo(); }); - it('should check that title & table appears', () => { + it('should check that title & table appears', async () => { // Check that title (CRUSH map viewer) appears - expect(crushmap.getPageTitle()).toMatch('CRUSH map viewer'); + expect(await crushmap.getPageTitle()).toMatch('CRUSH map viewer'); // Check that title appears once OSD is clicked - crushmap.getCrushNode(1).click(); - const label = $('legend').getText(); // Get table label - expect(crushmap.getCrushNode(1).getText()).toEqual(label); + await crushmap.getCrushNode(1).click(); + + const label = await $('legend').getText(); // Get table label + expect(await crushmap.getCrushNode(1).getText()).toEqual(label); // Check that table appears once OSD is clicked - browser.wait(Helper.EC.visibilityOf($('.datatable-body'))).then(() => { - expect($('.datatable-body').isDisplayed()).toBe(true); - }); + await browser.wait(Helper.EC.visibilityOf($('.datatable-body'))); + expect(await $('.datatable-body').isDisplayed()).toBe(true); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts index 6e447e15db00..ac2f1587a3b9 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts @@ -9,6 +9,6 @@ export class CrushMapPageHelper extends PageHelper { } getCrushNode(idx) { - return $$('.node-name.ng-star-inserted').get(idx); + return $$('.node-name.type-osd').get(idx); } } diff --git a/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts index 5f734e0e5447..3a66896f5b36 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts @@ -1,6 +1,6 @@ import { browser } from 'protractor'; -import { Logs } from 'selenium-webdriver'; import { ImagesPageHelper } from './block/images.po'; +import { CrushMapPageHelper } from './cluster/crush-map.po'; import { HostsPageHelper } from './cluster/hosts.po'; import { LogsPageHelper } from './cluster/logs.po'; import { ManagerModulesPageHelper } from './cluster/mgr-modules.po'; @@ -34,6 +34,7 @@ export class Helper { mgrModules: ManagerModulesPageHelper; logs: LogsPageHelper; hosts: HostsPageHelper; + crushMap: CrushMapPageHelper; constructor() { this.pools = new PoolPageHelper(); @@ -52,6 +53,7 @@ export class Helper { this.mgrModules = new ManagerModulesPageHelper(); this.logs = new LogsPageHelper(); this.hosts = new HostsPageHelper(); + this.crushMap = new CrushMapPageHelper(); } /** diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.html index 0c3852502c43..67c5d391265b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.html @@ -16,6 +16,7 @@   diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts index 3f6cf763d8c6..025791b5e247 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts @@ -82,6 +82,7 @@ describe('CrushmapComponent', () => { static: true }, status: 'up', + type: 'osd', value: 'osd.0-2 (osd)' } ], @@ -90,6 +91,7 @@ describe('CrushmapComponent', () => { static: true }, status: undefined, + type: 'host', value: 'my-host-2 (host)' } ], @@ -98,6 +100,7 @@ describe('CrushmapComponent', () => { static: true }, status: undefined, + type: 'root', value: 'default-2 (root)' }, { @@ -110,6 +113,7 @@ describe('CrushmapComponent', () => { static: true }, status: 'up', + type: 'osd', value: 'osd.0 (osd)' }, { @@ -118,6 +122,7 @@ describe('CrushmapComponent', () => { static: true }, status: 'down', + type: 'osd', value: 'osd.1 (osd)' }, { @@ -126,6 +131,7 @@ describe('CrushmapComponent', () => { static: true }, status: 'up', + type: 'osd', value: 'osd.2 (osd)' } ], @@ -134,6 +140,7 @@ describe('CrushmapComponent', () => { static: true }, status: undefined, + type: 'host', value: 'my-host (host)' } ], @@ -142,6 +149,7 @@ describe('CrushmapComponent', () => { static: true }, status: undefined, + type: 'root', value: 'default (root)' } ]); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts index 37b56b52de5b..6f488f8932e4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts @@ -61,15 +61,16 @@ export class CrushmapComponent implements OnInit { const status: string = node.status; const children: any[] = []; + const resultNode = { value, status, settings, id, type: node.type }; if (node.children) { node.children.sort().forEach((childId) => { children.push(treeNodeMap[childId]); }); - return { value, status, settings, id, children }; + resultNode['children'] = children; } - return { value, status, settings, id }; + return resultNode; } onNodeSelected(e: NodeEvent) {