From 3c3d8822d432186f6be9cb2d2603de7611aa0abb Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Fri, 12 Nov 2021 13:44:51 +0530 Subject: [PATCH] mgr/dashboard: Edit a service feature Fixes: https://tracker.ceph.com/issues/53077 Signed-off-by: Nizamudeen A --- .../integration/cluster/services.po.ts | 20 +++ .../orchestrator/05-services.e2e-spec.ts | 9 +- ...create-cluster-create-services.e2e-spec.ts | 12 +- .../cypress/integration/page-helper.po.ts | 6 +- .../frontend/src/app/app-routing.module.ts | 5 + .../create-cluster.component.html | 2 +- .../service-form/service-form.component.html | 4 +- .../service-form.component.spec.ts | 17 +++ .../service-form/service-form.component.ts | 114 ++++++++++++++++-- .../cluster/services/services.component.ts | 55 +++++++-- .../app/shared/models/orchestrator.enum.ts | 1 + .../app/shared/models/service.interface.ts | 28 +++++ .../shared/services/task-message.service.ts | 3 + .../mgr/dashboard/services/orchestrator.py | 1 + 14 files changed, 251 insertions(+), 26 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/services.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/services.po.ts index 457b759ead3..50bd6121ce5 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/services.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/services.po.ts @@ -70,6 +70,16 @@ export class ServicesPageHelper extends PageHelper { } } + editService(name: string, count: string) { + this.navigateEdit(name, true, false); + cy.get(`${this.pages.create.id}`).within(() => { + cy.get('#service_type').should('be.disabled'); + cy.get('#service_id').should('be.disabled'); + cy.get('#count').clear().type(count); + cy.get('cd-submit-button').click(); + }); + } + checkServiceStatus(daemon: string) { this.getTableCell(this.serviceDetailColumnIndex.daemonType, daemon) .parent() @@ -80,6 +90,16 @@ export class ServicesPageHelper extends PageHelper { }); } + expectPlacementCount(serviceName: string, expectedCount: string) { + this.getTableCell(this.columnIndex.service_name, serviceName) + .parent() + .find(`datatable-body-cell:nth-child(${this.columnIndex.placement})`) + .should(($ele) => { + const running = $ele.text().split(';'); + expect(running).to.include(`count:${expectedCount}`); + }); + } + checkExist(serviceName: string, exist: boolean) { this.getTableCell(this.columnIndex.service_name, serviceName).should(($elements) => { const services = $elements.map((_, el) => el.textContent).get(); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/05-services.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/05-services.e2e-spec.ts index 9f5e8ceda86..fb5e6ac8923 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/05-services.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/05-services.e2e-spec.ts @@ -2,6 +2,7 @@ import { ServicesPageHelper } from '../cluster/services.po'; describe('Services page', () => { const services = new ServicesPageHelper(); + const serviceName = 'rgw.foo'; beforeEach(() => { cy.login(); @@ -14,7 +15,13 @@ describe('Services page', () => { services.navigateTo('create'); services.addService('rgw'); - services.checkExist('rgw.foo', true); + services.checkExist(serviceName, true); + }); + + it('should edit a service', () => { + const count = '2'; + services.editService(serviceName, count); + services.expectPlacementCount(serviceName, count); }); it('should create and delete an ingress service', () => { diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/04-create-cluster-create-services.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/04-create-cluster-create-services.e2e-spec.ts index 5060a22649b..aec174a99cd 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/04-create-cluster-create-services.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/04-create-cluster-create-services.e2e-spec.ts @@ -20,11 +20,19 @@ describe('Create cluster create services page', () => { }); describe('when Orchestrator is available', () => { + const serviceName = 'rgw.foo'; + it('should create an rgw service', () => { cy.get('.btn.btn-accent').first().click({ force: true }); - createClusterServicePage.addService('rgw', false, '3'); - createClusterServicePage.checkExist('rgw.foo', true); + createClusterServicePage.addService('rgw', false, '2'); + createClusterServicePage.checkExist(serviceName, true); + }); + + it('should edit a service', () => { + const count = '3'; + createClusterServicePage.editService(serviceName, count); + createClusterServicePage.expectPlacementCount(serviceName, count); }); it('should create and delete an ingress service', () => { diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/page-helper.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/page-helper.po.ts index 176bca5a147..85a536f05a9 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/page-helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/page-helper.po.ts @@ -52,14 +52,16 @@ export abstract class PageHelper { /** * Navigates to the edit page */ - navigateEdit(name: string, select = true) { + navigateEdit(name: string, select = true, breadcrumb = true) { if (select) { this.navigateTo(); this.getFirstTableCell(name).click(); } cy.contains('Creating...').should('not.exist'); cy.contains('button', 'Edit').click(); - this.expectBreadcrumbText('Edit'); + if (breadcrumb) { + this.expectBreadcrumbText('Edit'); + } } /** diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts index e1eb456ee8a..959cb376997 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts @@ -139,6 +139,11 @@ const routes: Routes = [ path: URLVerbs.CREATE, component: ServiceFormComponent, outlet: 'modal' + }, + { + path: `${URLVerbs.EDIT}/:type/:name`, + component: ServiceFormComponent, + outlet: 'modal' } ] }, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html index 5394dc1d33b..4a4bb109472 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html @@ -65,7 +65,7 @@ + [routedModal]="false">
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html index 99c0903dacf..5582d300dda 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html @@ -215,10 +215,10 @@ - -