From: Patrick Seidensal Date: Mon, 19 Aug 2019 11:07:05 +0000 (+0200) Subject: mgr/dashboard: migrate E2E hosts to async/await X-Git-Tag: v15.1.0~1745^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bdaf0a89f28d7a8fd2bc4527e2f75fa6e420d62a;p=ceph.git mgr/dashboard: migrate E2E hosts to async/await Fixes: https://tracker.ceph.com/issues/40693 Signed-off-by: Patrick Seidensal --- diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts index f3137366eff4..db385ed6a3e1 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts @@ -7,39 +7,39 @@ describe('Hosts page', () => { hosts = new Helper().hosts; }); - afterEach(() => { - Helper.checkConsole(); + afterEach(async () => { + await Helper.checkConsole(); }); describe('breadcrumb and tab tests', () => { - beforeAll(() => { - hosts.navigateTo(); + beforeAll(async () => { + await hosts.navigateTo(); }); - it('should open and show breadcrumb', () => { - expect(hosts.getBreadcrumbText()).toEqual('Hosts'); + it('should open and show breadcrumb', async () => { + expect(await hosts.getBreadcrumbText()).toEqual('Hosts'); }); - it('should show two tabs', () => { - expect(hosts.getTabsCount()).toEqual(2); + it('should show two tabs', async () => { + expect(await hosts.getTabsCount()).toEqual(2); }); - it('should show hosts list tab at first', () => { - expect(hosts.getTabText(0)).toEqual('Hosts List'); + it('should show hosts list tab at first', async () => { + expect(await hosts.getTabText(0)).toEqual('Hosts List'); }); - it('should show overall performance as a second tab', () => { - expect(hosts.getTabText(1)).toEqual('Overall Performance'); + it('should show overall performance as a second tab', async () => { + expect(await hosts.getTabText(1)).toEqual('Overall Performance'); }); }); describe('services link test', () => { - it('should check at least one host is present', () => { - hosts.check_for_host(); + it('should check at least one host is present', async () => { + await hosts.check_for_host(); }); - it('should check services link(s) work for first host', () => { - hosts.check_services_links(); + it('should check services link(s) work for first host', async () => { + await hosts.check_services_links(); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts index c628be7ef162..0d0b8f1090d4 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts @@ -4,49 +4,40 @@ import { PageHelper } from '../page-helper.po'; export class HostsPageHelper extends PageHelper { pages = { index: '/#/hosts' }; - check_for_host() { - this.navigateTo(); + async check_for_host() { + await this.navigateTo(); - this.getTableCount() - .getText() - .then((hostcount) => { - expect(hostcount.includes('0 total')).toBe(false); - }); + const hostcount = await this.getTableCount().getText(); + expect(await hostcount.includes('0 total')).toBe(false); } // function that checks all services links work for first // host in table - check_services_links() { - this.navigateTo(); + async check_services_links() { + await this.navigateTo(); let links_tested = 0; // grab services column for first host const services = element.all(by.css('.datatable-body-cell')).get(1); // check is any services links are present - services - .getText() - .then((txt) => { - // check that text (links) is present in services box - expect(txt.length).toBeGreaterThan(0, 'No services links exist on first host'); - if (txt.length === 0) { - return; - } - const links = services.all(by.css('a.ng-star-inserted')); - links.count().then((num_links) => { - for (let i = 0; i < num_links; i++) { - // click link, check it worked by looking for changed breadcrumb, - // navigate back to hosts page, repeat until all links checked - links.get(i).click(); - expect(this.getBreadcrumbText()).toEqual('Performance Counters'); - this.navigateTo(); - expect(this.getBreadcrumbText()).toEqual('Hosts'); - links_tested++; - } - }); - }) - .then(() => { - // check if any links were actually tested - expect(links_tested > 0).toBe(true, 'No links were tested. Test failed'); - }); + const txt = await services.getText(); + // check that text (links) is present in services box + expect(txt.length).toBeGreaterThan(0, 'No services links exist on first host'); + if (txt.length === 0) { + return; + } + const links = services.all(by.css('a.service-link')); + const num_links = await links.count(); + for (let i = 0; i < num_links; i++) { + // click link, check it worked by looking for changed breadcrumb, + // navigate back to hosts page, repeat until all links checked + await links.get(i).click(); + expect(await this.getBreadcrumbText()).toEqual('Performance Counters'); + await this.navigateTo(); + expect(await this.getBreadcrumbText()).toEqual('Hosts'); + links_tested++; + } + // check if any links were actually tested + expect(links_tested > 0).toBe(true, 'No links were tested. Test failed'); } } diff --git a/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts index bb2c3f0c7dc3..5f734e0e5447 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts @@ -1,6 +1,7 @@ import { browser } from 'protractor'; import { Logs } from 'selenium-webdriver'; import { ImagesPageHelper } from './block/images.po'; +import { HostsPageHelper } from './cluster/hosts.po'; import { LogsPageHelper } from './cluster/logs.po'; import { ManagerModulesPageHelper } from './cluster/mgr-modules.po'; import { MonitorsPageHelper } from './cluster/monitors.po'; @@ -32,6 +33,7 @@ export class Helper { monitors: MonitorsPageHelper; mgrModules: ManagerModulesPageHelper; logs: LogsPageHelper; + hosts: HostsPageHelper; constructor() { this.pools = new PoolPageHelper(); @@ -49,6 +51,7 @@ export class Helper { this.monitors = new MonitorsPageHelper(); this.mgrModules = new ManagerModulesPageHelper(); this.logs = new LogsPageHelper(); + this.hosts = new HostsPageHelper(); } /** diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html index 39dcedb313ed..799af3e471e3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html @@ -9,7 +9,8 @@ (updateSelection)="updateSelection($event)"> - {{ service.type }}.{{ service.id }}