]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: migrate E2E crushmap to async/await
authorPatrick Seidensal <pseidensal@suse.com>
Mon, 19 Aug 2019 11:54:15 +0000 (13:54 +0200)
committerPatrick Seidensal <pseidensal@suse.com>
Wed, 28 Aug 2019 07:38:48 +0000 (09:38 +0200)
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 <pseidensal@suse.com>
src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.po.ts
src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts

index 0828e52c0ec2729d026f38b8207c2522aa12eafb..6c98c0192dd80a572ca4418cb3d36336fbd83ec3 100644 (file)
@@ -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);
     });
   });
 });
index 6e447e15db00399de9f3e9322e46e25c2010bb69..ac2f1587a3b986bb3df5d95db43e8591c6f05cb8 100644 (file)
@@ -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);
   }
 }
index 5f734e0e544732a296d50c64523647f81f526e29..3a66896f5b368c58d58df0359785d5e94a52a37e 100644 (file)
@@ -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();
   }
 
   /**
index 0c3852502c438622538745e649c0197158fc603b..67c5d391265ba6fd8b35144990b9287e84aea2c9 100644 (file)
@@ -16,6 +16,7 @@
                 </span>
                 <span>&nbsp;</span>
                 <span class="node-name"
+                      [ngClass]="{'type-osd': node.type === 'osd'}"
                       [innerHTML]="node.value"></span>
               </ng-template>
             </tree>
index 3f6cf763d8c63e35d1697e58f7eef6f5c2663c17..025791b5e247c9c4c21b99ec448e5ab632048d2f 100644 (file)
@@ -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)'
           }
         ]);
index 37b56b52de5ba4c9678cbdb821c55f970f216e2b..6f488f8932e44686fbc45a5f42dcbc279ae334bb 100644 (file)
@@ -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) {