From e33d9e15b92f922d3c5c40475cf493c238e91d75 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Tue, 17 Aug 2021 22:26:52 +0530 Subject: [PATCH] mgr/dashboard: Move force maintenance test to the workflow test suite Fixes: https://tracker.ceph.com/issues/52276 Signed-off-by: Nizamudeen A --- qa/workunits/cephadm/test_dashboard_e2e.sh | 13 ----- .../dashboard/ci/cephadm/bootstrap-cluster.sh | 2 +- .../integration/cluster/services.po.ts | 40 +++++++++++---- .../01-hosts-force-maintenance.e2e-spec.ts | 49 ------------------- .../orchestrator/05-services.e2e-spec.ts | 2 +- .../workflow/01-hosts.e2e-spec.ts | 36 +++++++++++++- 6 files changed, 67 insertions(+), 75 deletions(-) delete mode 100644 src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts-force-maintenance.e2e-spec.ts diff --git a/qa/workunits/cephadm/test_dashboard_e2e.sh b/qa/workunits/cephadm/test_dashboard_e2e.sh index 3d9a798398187..60719aa4ed56f 100755 --- a/qa/workunits/cephadm/test_dashboard_e2e.sh +++ b/qa/workunits/cephadm/test_dashboard_e2e.sh @@ -87,23 +87,10 @@ find cypress # List all specs cypress_run "orchestrator/01-hosts.e2e-spec.ts" -ceph orch apply rgw foo --placement=3 -sleep 15 -ceph orch device ls --refresh -ceph orch ps --refresh -sleep 10 # the previous call is asynchronous -ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json -ceph orch ps --format=json | tee cypress/fixtures/orchestrator/services.json - -cypress_run "orchestrator/01-hosts-force-maintenance.e2e-spec.ts" - # Hosts are removed and added in the previous step. Do a refresh again. -ceph orch rm rgw.foo ceph orch device ls --refresh -ceph orch ps --refresh sleep 10 ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json -ceph orch ps --format=json | tee cypress/fixtures/orchestrator/services.json cypress_run "orchestrator/02-hosts-inventory.e2e-spec.ts" cypress_run "orchestrator/03-inventory.e2e-spec.ts" diff --git a/src/pybind/mgr/dashboard/ci/cephadm/bootstrap-cluster.sh b/src/pybind/mgr/dashboard/ci/cephadm/bootstrap-cluster.sh index 4bad63bc5973c..10a060a9bceb6 100755 --- a/src/pybind/mgr/dashboard/ci/cephadm/bootstrap-cluster.sh +++ b/src/pybind/mgr/dashboard/ci/cephadm/bootstrap-cluster.sh @@ -8,7 +8,7 @@ chmod +x /root/bin/cephadm mkdir -p /etc/ceph mon_ip=$(ifconfig eth0 | grep 'inet ' | awk '{ print $2}') -cephadm bootstrap --mon-ip $mon_ip --initial-dashboard-password {{ admin_password }} --allow-fqdn-hostname --dashboard-password-noupdate --shared_ceph_folder /mnt/{{ ceph_dev_folder }} +cephadm bootstrap --mon-ip $mon_ip --initial-dashboard-password {{ admin_password }} --allow-fqdn-hostname --skip-monitoring-stack --dashboard-password-noupdate --shared_ceph_folder /mnt/{{ ceph_dev_folder }} fsid=$(cat /etc/ceph/ceph.conf | grep fsid | awk '{ print $3}') 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 55763285e290e..e28a8fbd57c26 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 @@ -16,6 +16,12 @@ export class ServicesPageHelper extends PageHelper { last_refresh: 6 }; + serviceDetailColumnIndex = { + hostname: 1, + daemonType: 2, + status: 8 + }; + check_for_service() { this.getTableCount('total').should('not.be.eq', 0); } @@ -24,16 +30,24 @@ export class ServicesPageHelper extends PageHelper { return this.selectOption('service_type', serviceType); } + @PageHelper.restrictTo(pages.index.url) + clickServiceTab(serviceName: string, tabName: string) { + this.getExpandCollapseElement(serviceName).click(); + cy.get('cd-service-details').within(() => { + this.getTab(tabName).click(); + }); + } + @PageHelper.restrictTo(pages.create.url) - addService(serviceType: string, exist?: boolean) { + addService(serviceType: string, exist?: boolean, count = '1') { cy.get(`${this.pages.create.id}`).within(() => { this.selectServiceType(serviceType); if (serviceType === 'rgw') { - cy.get('#service_id').type('rgw.foo'); - cy.get('#count').type('1'); + cy.get('#service_id').type('foo'); + cy.get('#count').type(count); } else if (serviceType === 'ingress') { - this.selectOption('backend_service', 'rgw.rgw.foo'); - cy.get('#service_id').should('have.value', 'rgw.rgw.foo'); + this.selectOption('backend_service', 'rgw.foo'); + cy.get('#service_id').should('have.value', 'rgw.foo'); cy.get('#virtual_ip').type('192.168.20.1/24'); cy.get('#frontend_port').type('8081'); cy.get('#monitor_port').type('8082'); @@ -49,6 +63,16 @@ export class ServicesPageHelper extends PageHelper { } } + checkServiceStatus(daemon: string) { + this.getTableCell(this.serviceDetailColumnIndex.daemonType, daemon) + .parent() + .find(`datatable-body-cell:nth-child(${this.serviceDetailColumnIndex.status}) .badge`) + .should(($ele) => { + const status = $ele.toArray().map((v) => v.innerText); + expect(status).to.include('running'); + }); + } + @PageHelper.restrictTo(pages.index.url) checkExist(serviceName: string, exist: boolean) { this.getTableCell(this.columnIndex.service_name, serviceName).should(($elements) => { @@ -62,7 +86,7 @@ export class ServicesPageHelper extends PageHelper { } @PageHelper.restrictTo(pages.index.url) - deleteService(serviceName: string, wait: number) { + deleteService(serviceName: string) { const getRow = this.getTableCell.bind(this, this.columnIndex.service_name); getRow(serviceName).click(); @@ -75,10 +99,6 @@ export class ServicesPageHelper extends PageHelper { // Wait for modal to close cy.get('cd-modal').should('not.exist'); - - // wait for delete operation to complete: tearing down the service daemons - cy.wait(wait); - this.checkExist(serviceName, false); } } 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 deleted file mode 100644 index 9a176e6e8ee98..0000000000000 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts-force-maintenance.e2e-spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { HostsPageHelper } from '../cluster/hosts.po'; - -describe('Hosts page', () => { - const hosts = new HostsPageHelper(); - - beforeEach(() => { - cy.login(); - Cypress.Cookies.preserveOnce('token'); - hosts.navigateTo(); - }); - - describe('when Orchestrator is available', () => { - beforeEach(function () { - cy.fixture('orchestrator/inventory.json').as('hosts'); - cy.fixture('orchestrator/services.json').as('services'); - }); - - 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) { - serviceList.push(service.daemon_type); - } - }); - - 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 !== 'rgw' && (service === 'mgr' || service === 'alertmanager')) { - enterMaintenance = false; - } - }); - - if (enterMaintenance) { - hosts.maintenance(hostname, true, true); - } - }); - }); -}); 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 dec84d73562d8..d36ffc17eed16 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 @@ -23,7 +23,7 @@ describe('Services page', () => { services.checkExist('ingress.rgw.rgw.foo', true); - services.deleteService('ingress.rgw.rgw.foo', 5000); + services.deleteService('ingress.rgw.rgw.foo'); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-hosts.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-hosts.e2e-spec.ts index b1c8ad0bbc015..7dd0c1104334c 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-hosts.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-hosts.e2e-spec.ts @@ -1,8 +1,16 @@ import { HostsPageHelper } from 'cypress/integration/cluster/hosts.po'; +import { ServicesPageHelper } from 'cypress/integration/cluster/services.po'; describe('Hosts page', () => { const hosts = new HostsPageHelper(); - const hostnames = ['ceph-node-00.cephlab.com', 'ceph-node-01.cephlab.com']; + const services = new ServicesPageHelper(); + + const serviceName = 'rgw.foo'; + const hostnames = [ + 'ceph-node-00.cephlab.com', + 'ceph-node-01.cephlab.com', + 'ceph-node-02.cephlab.com' + ]; const addHost = (hostname: string, exist?: boolean, maintenance?: boolean) => { hosts.navigateTo('create'); hosts.add(hostname, exist, maintenance); @@ -16,6 +24,10 @@ describe('Hosts page', () => { }); describe('when Orchestrator is available', () => { + it('should add a host', () => { + addHost(hostnames[2], false, false); + }); + it('should display inventory', function () { hosts.clickHostTab(hostnames[0], 'Physical Disks'); cy.get('cd-host-details').within(() => { @@ -53,5 +65,27 @@ describe('Hosts page', () => { it('should exit host from maintenance', function () { hosts.maintenance(hostnames[1], true); }); + + it('should check if mon service is running', () => { + hosts.clickHostTab(hostnames[1], 'Daemons'); + cy.get('cd-host-details').within(() => { + services.checkServiceStatus('mon'); + }); + }); + + it('should create rgw services', () => { + services.navigateTo('create'); + services.addService('rgw', false, '3'); + services.checkExist(serviceName, true); + hosts.navigateTo(); + hosts.clickHostTab(hostnames[1], 'Daemons'); + cy.get('cd-host-details').within(() => { + services.checkServiceStatus('rgw'); + }); + }); + + it('should force maintenance', () => { + hosts.maintenance(hostnames[1], true, true); + }); }); }); -- 2.39.5