From 871e5995cbbafaa980f6df383e375359b4364428 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Wed, 12 May 2021 15:37:40 +0530 Subject: [PATCH] mgr/dashboard: Fix test_error force maintenance dashboard check Fixes: https://tracker.ceph.com/issues/50771 Signed-off-by: Nizamudeen A --- .../01-hosts-force-maintenance.e2e-spec.ts | 12 +++++++++++- .../app/ceph/cluster/hosts/hosts.component.spec.ts | 6 +++--- .../src/app/ceph/cluster/hosts/hosts.component.ts | 6 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts-force-maintenance.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts-force-maintenance.e2e-spec.ts index ac00e2f2903e7..9a176e6e8ee98 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts-force-maintenance.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts-force-maintenance.e2e-spec.ts @@ -17,6 +17,10 @@ describe('Hosts page', () => { it('should force enter host into maintenance', function () { const hostname = Cypress._.sample(this.hosts).name; + const hostnameList = new Array(); + this.hosts.array.forEach((host: any) => { + hostnameList.push(host.hostname); + }); const serviceList = new Array(); this.services.forEach((service: any) => { if (hostname === service.hostname) { @@ -25,8 +29,14 @@ describe('Hosts page', () => { }); let enterMaintenance = true; + + // Force maintenance might throw out error if host are less than 3. + if (hostnameList.length < 3) { + enterMaintenance = false; + } + serviceList.forEach((service: string) => { - if (service === 'mgr' || service === 'alertmanager') { + if (service !== 'rgw' && (service === 'mgr' || service === 'alertmanager')) { enterMaintenance = false; } }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts index c92188ed05411..f4d400f3230c8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts @@ -31,7 +31,7 @@ class MockShowForceMaintenanceModal { msg.includes('WARNING') && !msg.includes('It is NOT safe to stop') && !msg.includes('ALERT') && - !msg.includes('unable to stop') + !msg.includes('unsafe to stop') ) { this.showModal = true; } @@ -143,8 +143,8 @@ describe('HostsComponent', () => { expect(showForceMaintenanceModal.showModal).toBeFalsy(); }); - it('should not show force maintenance modal when it is unable to stop host', () => { - const errorMsg = 'unable to stop osd.0 because of some unknown reason'; + it('should not show force maintenance modal when it is unsafe to stop host', () => { + const errorMsg = 'unsafe to stop osd.0 because of some unknown reason'; showForceMaintenanceModal.showModalDialog(errorMsg); expect(showForceMaintenanceModal.showModal).toBeFalsy(); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts index e4f042699eb39..8c559a748b05d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts @@ -247,9 +247,9 @@ export class HostsComponent extends ListWithDetails implements OnInit { error.error['detail'].includes('WARNING') && !error.error['detail'].includes('It is NOT safe to stop') && !error.error['detail'].includes('ALERT') && - !error.error['detail'].includes('unable to stop') + !error.error['detail'].includes('unsafe to stop') ) { - const modalVarialbes = { + const modalVariables = { titleText: $localize`Warning`, buttonText: $localize`Continue`, warning: true, @@ -264,7 +264,7 @@ export class HostsComponent extends ListWithDetails implements OnInit { ); } }; - this.modalRef = this.modalService.show(ConfirmationModalComponent, modalVarialbes); + this.modalRef = this.modalService.show(ConfirmationModalComponent, modalVariables); } else { this.notificationService.show( NotificationType.error, -- 2.39.5