]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: show daemon count instead of services in host page 46201/head
authorNizamudeen A <nia@redhat.com>
Mon, 9 May 2022 08:43:19 +0000 (14:13 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 10 May 2022 06:44:33 +0000 (12:14 +0530)
Fixes: https://tracker.ceph.com/issues/47218
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts

index c1935a7838319940027b7b919e36cbc2db5979f1..e4f9936c3e36f962222f8df1b0995e1ffe07f724 100644 (file)
@@ -31,9 +31,5 @@ describe('Hosts page', () => {
     it('should check at least one host is present', () => {
       hosts.check_for_host();
     });
-
-    it('should check services link(s) work for first host', () => {
-      hosts.check_services_links();
-    });
   });
 });
index ffac83ba67bfc5553db1a3db35f9410001b2f44d..0682b01c6deb086affd5715006ad0eb6b856dbbc 100644 (file)
@@ -19,28 +19,6 @@ export class HostsPageHelper extends PageHelper {
     this.getTableCount('total').should('not.be.eq', 0);
   }
 
-  // function that checks all services links work for first
-  // host in table
-  check_services_links() {
-    // check that text (links) is present in services box
-    let links_tested = 0;
-
-    cy.get('cd-hosts a.service-link')
-      .should('have.length.greaterThan', 0)
-      .then(($elems) => {
-        $elems.each((_i, $el) => {
-          // click link, check it worked by looking for changed breadcrumb,
-          // navigate back to hosts page, repeat until all links checked
-          cy.contains('a', $el.innerText).should('exist').click();
-          this.expectBreadcrumbText('Performance Counters');
-          this.navigateTo();
-          links_tested++;
-        });
-        // check if any links were actually tested
-        expect(links_tested).gt(0);
-      });
-  }
-
   add(hostname: string, exist?: boolean, maintenance?: boolean, labels: string[] = []) {
     cy.get(`${this.pages.add.id}`).within(() => {
       cy.get('#hostname').type(hostname);
index 5f2da41496493c273f454784a3410379e1023fdd..b41ecfa8663302264a2a0246701838930040d36f 100644 (file)
 
 <ng-template #servicesTpl
              let-value="value">
-  <span *ngFor="let service of value; last as isLast">
-    <a class="service-link"
-       [routerLink]="[service.cdLink]"
-       [queryParams]="cdParams"
-       *ngIf="service.canRead">{{ service.type }}.{{ service.id }}</a>
-    <span *ngIf="!service.canRead">
-      {{ service.type }}.{{ service.id }}
-    </span>
-    <ng-container *ngIf="!isLast">, </ng-container>
+  <span *ngFor="let instance of value; last as isLast">
+    <span class="badge badge-background-primary" >{{ instance }}</span>
+    <ng-container *ngIf="!isLast">&nbsp;</ng-container>
   </span>
 </ng-template>
 
index f91a8ff83768054d4fda068d8f71c212024a952d..0d691f62acfd826d19541182b228709e3ee4aaa3 100644 (file)
@@ -117,6 +117,56 @@ describe('HostsComponent', () => {
     expect(spans[0].textContent).toBe(hostname);
   });
 
+  it('should show the exact count of the repeating daemons', () => {
+    const hostname = 'ceph.dev';
+    const payload = [
+      {
+        services: [
+          {
+            type: 'mgr',
+            id: 'x'
+          },
+          {
+            type: 'mgr',
+            id: 'y'
+          },
+          {
+            type: 'osd',
+            id: '0'
+          },
+          {
+            type: 'osd',
+            id: '1'
+          },
+          {
+            type: 'osd',
+            id: '2'
+          },
+          {
+            type: 'rgw',
+            id: 'rgw'
+          }
+        ],
+        hostname: hostname,
+        labels: ['foo', 'bar']
+      }
+    ];
+
+    OrchestratorHelper.mockStatus(false);
+    hostListSpy.and.callFake(() => of(payload));
+    fixture.detectChanges();
+
+    component.getHosts(new CdTableFetchDataContext(() => undefined));
+    fixture.detectChanges();
+
+    const spans = fixture.debugElement.nativeElement.querySelectorAll(
+      '.datatable-body-cell-label span span.badge.badge-background-primary'
+    );
+    expect(spans[0].textContent).toContain('mgr: 2');
+    expect(spans[1].textContent).toContain('osd: 3');
+    expect(spans[2].textContent).toContain('rgw: 1');
+  });
+
   it('should test if host facts are tranformed correctly if orch available', () => {
     const features = [OrchestratorFeature.HOST_FACTS];
     const payload = [
index f7df997c37b0d04a77acd01a4207463b7b6557e2..60cedf853c9ce6037268592c0c9967e88c570f76 100644 (file)
@@ -197,9 +197,9 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
         flexGrow: 1
       },
       {
-        name: $localize`Services`,
-        prop: 'services',
-        flexGrow: 2,
+        name: $localize`Service Instances`,
+        prop: 'service_instances',
+        flexGrow: 1,
         cellTemplate: this.servicesTpl
       },
       {
@@ -483,15 +483,6 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
     if (this.isLoadingHosts) {
       return;
     }
-    const typeToPermissionKey = {
-      mds: 'cephfs',
-      mon: 'monitor',
-      osd: 'osd',
-      rgw: 'rgw',
-      'rbd-mirror': 'rbdMirroring',
-      mgr: 'manager',
-      'tcmu-runner': 'iscsi'
-    };
     this.isLoadingHosts = true;
     this.sub = this.orchService
       .status()
@@ -503,11 +494,13 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
         }),
         map((hostList: object[]) =>
           hostList.map((host) => {
+            const counts = {};
+            host['service_instances'] = new Set<string>();
+            host['services'].forEach((service: any) => {
+              counts[service.type] = (counts[service.type] || 0) + 1;
+            });
             host['services'].map((service: any) => {
-              service.cdLink = `/perf_counters/${service.type}/${encodeURIComponent(service.id)}`;
-              const permission = this.permissions[typeToPermissionKey[service.type]];
-              service.canRead = permission ? permission.read : false;
-              return service;
+              host['service_instances'].add(`${service.type}: ${counts[service.type]}`);
             });
             return host;
           })