From 3276147049511a9a8d45d84c95154a4ec014cd83 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Fri, 17 Sep 2021 18:43:01 +0530 Subject: [PATCH] mgr/dashboard: Cluster expansion e2e cleanups Fixes: https://tracker.ceph.com/issues/52645 Signed-off-by: Nizamudeen A --- .../integration/cluster/create-cluster.po.ts | 179 +++--------------- .../cypress/integration/cluster/hosts.po.ts | 16 +- .../integration/cluster/services.po.ts | 4 - .../orchestrator/01-hosts.e2e-spec.ts | 4 +- .../02-hosts-inventory.e2e-spec.ts | 2 +- .../orchestrator/05-services.e2e-spec.ts | 6 +- ...01-create-cluster-welcome-page.e2e-spec.ts | 4 +- .../workflow/01-hosts.e2e-spec.ts | 91 --------- .../02-create-cluster-add-host.e2e-spec.ts | 35 ++-- .../03-create-cluster-create-osds.e2e-spec.ts | 15 +- ...create-cluster-create-services.e2e-spec.ts | 26 +-- .../05-create-cluster-review.e2e-spec.ts | 16 +- .../workflow/06-cluster-check.e2e-spec.ts | 39 ++-- .../cypress/integration/page-helper.po.ts | 13 ++ 14 files changed, 133 insertions(+), 317 deletions(-) delete mode 100644 src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-hosts.e2e-spec.ts diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/create-cluster.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/create-cluster.po.ts index a528c0fc12e..52be703af28 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/create-cluster.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/create-cluster.po.ts @@ -1,26 +1,18 @@ -import { PageHelper } from '../page-helper.po'; -import { NotificationSidebarPageHelper } from '../ui/notification.po'; +import { HostsPageHelper } from 'cypress/integration/cluster/hosts.po'; +import { ServicesPageHelper } from 'cypress/integration/cluster/services.po'; +import { PageHelper } from 'cypress/integration/page-helper.po'; +import { NotificationSidebarPageHelper } from 'cypress/integration/ui/notification.po'; const pages = { index: { url: '#/expand-cluster', id: 'cd-create-cluster' } }; - export class CreateClusterWizardHelper extends PageHelper { pages = pages; - columnIndex = { - hostname: 1, - labels: 2, - status: 3 - }; - - serviceColumnIndex = { - service_name: 1, - placement: 2 - }; createCluster() { cy.get('cd-create-cluster').should('contain.text', 'Please expand your cluster first'); cy.get('[name=expand-cluster]').click(); + cy.get('cd-wizard').should('exist'); } doSkip() { @@ -33,91 +25,6 @@ export class CreateClusterWizardHelper extends PageHelper { notification.getNotifications().should('contain', 'Cluster expansion skipped by user'); } - check_for_host() { - this.getTableCount('total').should('not.be.eq', 0); - } - - clickHostTab(hostname: string, tabName: string) { - this.getExpandCollapseElement(hostname).click(); - cy.get('cd-host-details').within(() => { - this.getTab(tabName).click(); - }); - } - - add(hostname: string, exist?: boolean, maintenance?: boolean) { - cy.get('.btn.btn-accent').first().click({ force: true }); - cy.get('cd-modal').should('exist'); - cy.get('cd-modal').within(() => { - cy.get('#hostname').type(hostname); - if (maintenance) { - cy.get('label[for=maintenance]').click(); - } - if (exist) { - cy.get('#hostname').should('have.class', 'ng-invalid'); - } - cy.get('cd-submit-button').click(); - }); - // back to host list - cy.get(`${this.pages.index.id}`); - } - - checkExist(hostname: string, exist: boolean) { - this.clearTableSearchInput(); - this.getTableCell(this.columnIndex.hostname, hostname).should(($elements) => { - const hosts = $elements.map((_, el) => el.textContent).get(); - if (exist) { - expect(hosts).to.include(hostname); - } else { - expect(hosts).to.not.include(hostname); - } - }); - } - - delete(hostname: string) { - super.delete(hostname, this.columnIndex.hostname, 'hosts'); - } - - // Add or remove labels on a host, then verify labels in the table - editLabels(hostname: string, labels: string[], add: boolean) { - this.getTableCell(this.columnIndex.hostname, hostname).click(); - this.clickActionButton('edit'); - - // add or remove label badges - if (add) { - cy.get('cd-modal').find('.select-menu-edit').click(); - for (const label of labels) { - cy.contains('cd-modal .badge', new RegExp(`^${label}$`)).should('not.exist'); - cy.get('.popover-body input').type(`${label}{enter}`); - } - } else { - for (const label of labels) { - cy.contains('cd-modal .badge', new RegExp(`^${label}$`)) - .find('.badge-remove') - .click(); - } - } - cy.get('cd-modal cd-submit-button').click(); - this.checkLabelExists(hostname, labels, add); - } - - checkLabelExists(hostname: string, labels: string[], add: boolean) { - // Verify labels are added or removed from Labels column - // First find row with hostname, then find labels in the row - this.getTableCell(this.columnIndex.hostname, hostname) - .parent() - .find(`datatable-body-cell:nth-child(${this.columnIndex.labels}) .badge`) - .should(($ele) => { - const newLabels = $ele.toArray().map((v) => v.innerText); - for (const label of labels) { - if (add) { - expect(newLabels).to.include(label); - } else { - expect(newLabels).to.not.include(label); - } - } - }); - } - createOSD(deviceType: 'hdd' | 'ssd') { // Click Primary devices Add button cy.get('cd-osd-devices-selection-groups[name="Primary"]').as('primaryGroups'); @@ -131,59 +38,33 @@ export class CreateClusterWizardHelper extends PageHelper { cy.get('@addButton').click(); }); } +} - private selectServiceType(serviceType: string) { - return this.selectOption('service_type', serviceType); - } - - addService(serviceType: string) { - cy.get('.btn.btn-accent').first().click({ force: true }); - cy.get('cd-modal').should('exist'); - cy.get('cd-modal').within(() => { - this.selectServiceType(serviceType); - if (serviceType === 'rgw') { - cy.get('#service_id').type('rgw'); - cy.get('#count').type('1'); - } else if (serviceType === 'ingress') { - this.selectOption('backend_service', 'rgw.rgw'); - cy.get('#service_id').should('have.value', 'rgw.rgw'); - cy.get('#virtual_ip').type('192.168.20.1/24'); - cy.get('#frontend_port').type('8081'); - cy.get('#monitor_port').type('8082'); - } - - cy.get('cd-submit-button').click(); - }); - } - - checkServiceExist(serviceName: string, exist: boolean) { - this.getTableCell(this.serviceColumnIndex.service_name, serviceName).should(($elements) => { - const services = $elements.map((_, el) => el.textContent).get(); - if (exist) { - expect(services).to.include(serviceName); - } else { - expect(services).to.not.include(serviceName); - } - }); - } - - deleteService(serviceName: string, wait: number) { - const getRow = this.getTableCell.bind(this, this.serviceColumnIndex.service_name); - getRow(serviceName).click(); - - // Clicks on table Delete button - this.clickActionButton('delete'); - - // Confirms deletion - cy.get('cd-modal .custom-control-label').click(); - cy.contains('cd-modal button', 'Delete').click(); +export class CreateClusterHostPageHelper extends HostsPageHelper { + pages = { + index: { url: '#/expand-cluster', id: 'cd-wizard' }, + add: { url: '', id: 'cd-host-form' } + }; - // Wait for modal to close - cy.get('cd-modal').should('not.exist'); + columnIndex = { + hostname: 1, + labels: 2, + status: 3, + services: 0 + }; +} - // wait for delete operation to complete: tearing down the service daemons - cy.wait(wait); +export class CreateClusterServicePageHelper extends ServicesPageHelper { + pages = { + index: { url: '#/expand-cluster', id: 'cd-wizard' }, + create: { url: '', id: 'cd-service-form' } + }; - this.checkServiceExist(serviceName, false); - } + columnIndex = { + service_name: 1, + placement: 2, + running: 0, + size: 0, + last_refresh: 0 + }; } diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts index 5f3d39dcedc..c615b945a5d 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts @@ -41,15 +41,6 @@ export class HostsPageHelper extends PageHelper { }); } - @PageHelper.restrictTo(pages.index.url) - clickHostTab(hostname: string, tabName: string) { - this.getExpandCollapseElement(hostname).click(); - cy.get('cd-host-details').within(() => { - this.getTab(tabName).click(); - }); - } - - @PageHelper.restrictTo(pages.add.url) add(hostname: string, exist?: boolean, maintenance?: boolean) { cy.get(`${this.pages.add.id}`).within(() => { cy.get('#hostname').type(hostname); @@ -65,8 +56,8 @@ export class HostsPageHelper extends PageHelper { cy.get(`${this.pages.index.id}`); } - @PageHelper.restrictTo(pages.index.url) checkExist(hostname: string, exist: boolean) { + this.clearTableSearchInput(); this.getTableCell(this.columnIndex.hostname, hostname).should(($elements) => { const hosts = $elements.map((_, el) => el.textContent).get(); if (exist) { @@ -77,13 +68,11 @@ export class HostsPageHelper extends PageHelper { }); } - @PageHelper.restrictTo(pages.index.url) delete(hostname: string) { super.delete(hostname, this.columnIndex.hostname, 'hosts'); } // Add or remove labels on a host, then verify labels in the table - @PageHelper.restrictTo(pages.index.url) editLabels(hostname: string, labels: string[], add: boolean) { this.getTableCell(this.columnIndex.hostname, hostname).click(); this.clickActionButton('edit'); @@ -103,7 +92,10 @@ export class HostsPageHelper extends PageHelper { } } cy.get('cd-modal cd-submit-button').click(); + this.checkLabelExists(hostname, labels, add); + } + checkLabelExists(hostname: string, labels: string[], add: boolean) { // Verify labels are added or removed from Labels column // First find row with hostname, then find labels in the row this.getTableCell(this.columnIndex.hostname, hostname) 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 0a943d4b055..4265329db04 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 @@ -30,7 +30,6 @@ 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(() => { @@ -38,7 +37,6 @@ export class ServicesPageHelper extends PageHelper { }); } - @PageHelper.restrictTo(pages.create.url) addService(serviceType: string, exist?: boolean, count = '1') { cy.get(`${this.pages.create.id}`).within(() => { this.selectServiceType(serviceType); @@ -73,7 +71,6 @@ export class ServicesPageHelper extends PageHelper { }); } - @PageHelper.restrictTo(pages.index.url) checkExist(serviceName: string, exist: boolean) { this.getTableCell(this.columnIndex.service_name, serviceName).should(($elements) => { const services = $elements.map((_, el) => el.textContent).get(); @@ -85,7 +82,6 @@ export class ServicesPageHelper extends PageHelper { }); } - @PageHelper.restrictTo(pages.index.url) deleteService(serviceName: string) { const getRow = this.getTableCell.bind(this, this.columnIndex.service_name); getRow(serviceName).click(); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts index 6c79a74662d..ffc5fa83ab4 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts @@ -33,7 +33,7 @@ describe('Hosts page', () => { it('should display inventory', function () { for (const host of this.hosts) { - hosts.clickHostTab(host.name, 'Physical Disks'); + hosts.clickTab('cd-host-details', host.name, 'Physical Disks'); cy.get('cd-host-details').within(() => { hosts.getTableCount('total').should('be.gte', 0); }); @@ -42,7 +42,7 @@ describe('Hosts page', () => { it('should display daemons', function () { for (const host of this.hosts) { - hosts.clickHostTab(host.name, 'Daemons'); + hosts.clickTab('cd-host-details', host.name, 'Daemons'); cy.get('cd-host-details').within(() => { hosts.getTableCount('total').should('be.gte', 0); }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/02-hosts-inventory.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/02-hosts-inventory.e2e-spec.ts index 43e8aee595d..f26228510f5 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/02-hosts-inventory.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/02-hosts-inventory.e2e-spec.ts @@ -16,7 +16,7 @@ describe('Hosts page', () => { it('should display correct inventory', function () { for (const host of this.hosts) { - hosts.clickHostTab(host.name, 'Physical Disks'); + hosts.clickTab('cd-host-details', host.name, 'Physical Disks'); cy.get('cd-host-details').within(() => { hosts.getTableCount('total').should('be.eq', host.devices.length); }); 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 d36ffc17eed..9f5e8ceda86 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 @@ -14,16 +14,16 @@ describe('Services page', () => { services.navigateTo('create'); services.addService('rgw'); - services.checkExist('rgw.rgw.foo', true); + services.checkExist('rgw.foo', true); }); it('should create and delete an ingress service', () => { services.navigateTo('create'); services.addService('ingress'); - services.checkExist('ingress.rgw.rgw.foo', true); + services.checkExist('ingress.rgw.foo', true); - services.deleteService('ingress.rgw.rgw.foo'); + services.deleteService('ingress.rgw.foo'); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-create-cluster-welcome-page.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-create-cluster-welcome-page.e2e-spec.ts index d776a210a57..02ebb184b39 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-create-cluster-welcome-page.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-create-cluster-welcome-page.e2e-spec.ts @@ -9,11 +9,11 @@ describe('Create cluster page', () => { createCluster.navigateTo(); }); - it('should fail to create cluster', () => { + it('should open the wizard when Expand Cluster is clicked', () => { createCluster.createCluster(); }); - it('should skip to dashboard landing page', () => { + it('should skip to dashboard landing page when Skip is clicked', () => { createCluster.doSkip(); }); }); 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 deleted file mode 100644 index e8dea8e3008..00000000000 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/01-hosts.e2e-spec.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { HostsPageHelper } from 'cypress/integration/cluster/hosts.po'; -import { ServicesPageHelper } from 'cypress/integration/cluster/services.po'; - -describe('Hosts page', () => { - const hosts = new HostsPageHelper(); - 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('add'); - hosts.add(hostname, exist, maintenance); - hosts.checkExist(hostname, true); - }; - - beforeEach(() => { - cy.login(); - Cypress.Cookies.preserveOnce('token'); - hosts.navigateTo(); - }); - - 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(() => { - hosts.getTableCount('total').should('be.gte', 0); - }); - }); - - it('should display daemons', function () { - hosts.clickHostTab(hostnames[0], 'Daemons'); - cy.get('cd-host-details').within(() => { - hosts.getTableCount('total').should('be.gte', 0); - }); - }); - - it('should edit host labels', function () { - const labels = ['foo', 'bar']; - hosts.editLabels(hostnames[0], labels, true); - hosts.editLabels(hostnames[0], labels, false); - }); - - it('should not add an existing host', function () { - hosts.navigateTo('add'); - hosts.add(hostnames[0], true); - }); - - it('should add a host in maintenance mode', function () { - addHost(hostnames[1], false, true); - }); - - it('should delete a host and add it back', function () { - hosts.delete(hostnames[1]); - addHost(hostnames[1], false, true); - }); - - 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); - }); - }); -}); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/02-create-cluster-add-host.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/02-create-cluster-add-host.e2e-spec.ts index 3b64c2987c9..a35bd6c1074 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/02-create-cluster-add-host.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/02-create-cluster-add-host.e2e-spec.ts @@ -1,15 +1,20 @@ -import { CreateClusterWizardHelper } from 'cypress/integration/cluster/create-cluster.po'; +import { + CreateClusterHostPageHelper, + CreateClusterWizardHelper +} from 'cypress/integration/cluster/create-cluster.po'; describe('Create cluster add host page', () => { const createCluster = new CreateClusterWizardHelper(); + const createClusterHostPage = new CreateClusterHostPageHelper(); const hostnames = [ 'ceph-node-00.cephlab.com', 'ceph-node-01.cephlab.com', 'ceph-node-02.cephlab.com' ]; const addHost = (hostname: string, exist?: boolean) => { - createCluster.add(hostname, exist, false); - createCluster.checkExist(hostname, true); + cy.get('.btn.btn-accent').first().click({ force: true }); + createClusterHostPage.add(hostname, exist, false); + createClusterHostPage.checkExist(hostname, true); }; beforeEach(() => { @@ -19,35 +24,37 @@ describe('Create cluster add host page', () => { createCluster.createCluster(); }); - it('should check if nav-link and title contains Add Hosts', () => { + it('should check if title contains Add Hosts', () => { cy.get('.nav-link').should('contain.text', 'Add Hosts'); cy.get('.title').should('contain.text', 'Add Hosts'); }); it('should check existing host and add new hosts', () => { - createCluster.checkExist(hostnames[0], true); + createClusterHostPage.checkExist(hostnames[0], true); addHost(hostnames[1], false); addHost(hostnames[2], false); }); + it('should delete a host and add it back', () => { + createClusterHostPage.delete(hostnames[1]); + addHost(hostnames[1], false); + }); + it('should verify "_no_schedule" label is added', () => { - createCluster.checkLabelExists(hostnames[1], ['_no_schedule'], true); - createCluster.checkLabelExists(hostnames[2], ['_no_schedule'], true); + createClusterHostPage.checkLabelExists(hostnames[1], ['_no_schedule'], true); + createClusterHostPage.checkLabelExists(hostnames[2], ['_no_schedule'], true); }); it('should not add an existing host', () => { - createCluster.add(hostnames[0], true); + cy.get('.btn.btn-accent').first().click({ force: true }); + createClusterHostPage.add(hostnames[0], true); }); it('should edit host labels', () => { const labels = ['foo', 'bar']; - createCluster.editLabels(hostnames[0], labels, true); - createCluster.editLabels(hostnames[0], labels, false); - }); - - it('should delete a host', () => { - createCluster.delete(hostnames[1]); + createClusterHostPage.editLabels(hostnames[0], labels, true); + createClusterHostPage.editLabels(hostnames[0], labels, false); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/03-create-cluster-create-osds.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/03-create-cluster-create-osds.e2e-spec.ts index ee272bcf943..c8d93b47962 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/03-create-cluster-create-osds.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/03-create-cluster-create-osds.e2e-spec.ts @@ -11,12 +11,10 @@ describe('Create cluster create osds page', () => { Cypress.Cookies.preserveOnce('token'); createCluster.navigateTo(); createCluster.createCluster(); - cy.get('button[aria-label="Next"]').click(); + cy.get('.nav-link').contains('Create OSDs').click(); }); - it('should check if nav-link and title contains Create OSDs', () => { - cy.get('.nav-link').should('contain.text', 'Create OSDs'); - + it('should check if title contains Create OSDs', () => { cy.get('.title').should('contain.text', 'Create OSDs'); }); @@ -27,13 +25,16 @@ describe('Create cluster create osds page', () => { createCluster.navigateTo(); createCluster.createCluster(); - cy.get('button[aria-label="Next"]').click(); + cy.get('.nav-link').contains('Create OSDs').click(); createCluster.createOSD('hdd'); + // Go to the Review section and Expand the cluster + // because the drive group spec is only stored + // in frontend and will be lost when refreshed + cy.get('.nav-link').contains('Review').click(); cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); + cy.get('cd-dashboard').should('exist'); }); }); }); 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 0a95474c91d..5060a22649b 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 @@ -1,36 +1,38 @@ -import { CreateClusterWizardHelper } from 'cypress/integration/cluster/create-cluster.po'; +import { + CreateClusterServicePageHelper, + CreateClusterWizardHelper +} from 'cypress/integration/cluster/create-cluster.po'; describe('Create cluster create services page', () => { const createCluster = new CreateClusterWizardHelper(); + const createClusterServicePage = new CreateClusterServicePageHelper(); beforeEach(() => { cy.login(); Cypress.Cookies.preserveOnce('token'); createCluster.navigateTo(); createCluster.createCluster(); - cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); + cy.get('.nav-link').contains('Create Services').click(); }); - it('should check if nav-link and title contains Create Services', () => { - cy.get('.nav-link').should('contain.text', 'Create Services'); - + it('should check if title contains Create Services', () => { cy.get('.title').should('contain.text', 'Create Services'); }); describe('when Orchestrator is available', () => { it('should create an rgw service', () => { - createCluster.addService('rgw'); + cy.get('.btn.btn-accent').first().click({ force: true }); - createCluster.checkExist('rgw.rgw', true); + createClusterServicePage.addService('rgw', false, '3'); + createClusterServicePage.checkExist('rgw.foo', true); }); it('should create and delete an ingress service', () => { - createCluster.addService('ingress'); - - createCluster.checkExist('ingress.rgw.rgw', true); + cy.get('.btn.btn-accent').first().click({ force: true }); - createCluster.deleteService('ingress.rgw.rgw', 60000); + createClusterServicePage.addService('ingress'); + createClusterServicePage.checkExist('ingress.rgw.foo', true); + createClusterServicePage.deleteService('ingress.rgw.foo'); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/05-create-cluster-review.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/05-create-cluster-review.e2e-spec.ts index 29fd3a27f8e..41152229025 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/05-create-cluster-review.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/05-create-cluster-review.e2e-spec.ts @@ -1,7 +1,11 @@ -import { CreateClusterWizardHelper } from 'cypress/integration/cluster/create-cluster.po'; +import { + CreateClusterHostPageHelper, + CreateClusterWizardHelper +} from 'cypress/integration/cluster/create-cluster.po'; describe('Create Cluster Review page', () => { const createCluster = new CreateClusterWizardHelper(); + const createClusterHostPage = new CreateClusterHostPageHelper(); beforeEach(() => { cy.login(); @@ -9,14 +13,12 @@ describe('Create Cluster Review page', () => { createCluster.navigateTo(); createCluster.createCluster(); - cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); + cy.get('.nav-link').contains('Review').click(); }); describe('navigation link test', () => { - it('should check if nav-link contains Review', () => { - cy.get('.nav-link').should('contain.text', 'Review'); + it('should check if active nav-link is of Review section', () => { + cy.get('.nav-link.active').should('contain.text', 'Review'); }); }); @@ -68,7 +70,7 @@ describe('Create Cluster Review page', () => { }); it('should check default host name is present', () => { - createCluster.check_for_host(); + createClusterHostPage.check_for_host(); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/06-cluster-check.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/06-cluster-check.e2e-spec.ts index a5b54786b87..ac21714d321 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/06-cluster-check.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/06-cluster-check.e2e-spec.ts @@ -5,6 +5,8 @@ import { ServicesPageHelper } from 'cypress/integration/cluster/services.po'; describe('when cluster creation is completed', () => { const createCluster = new CreateClusterWizardHelper(); + const services = new ServicesPageHelper(); + const serviceName = 'rgw.foo'; beforeEach(() => { cy.login(); @@ -15,40 +17,53 @@ describe('when cluster creation is completed', () => { createCluster.navigateTo(); createCluster.createCluster(); + cy.get('.nav-link').contains('Review').click(); cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); - cy.get('button[aria-label="Next"]').click(); - cy.get('cd-dashboard').should('exist'); }); describe('Hosts page', () => { const hosts = new HostsPageHelper(); - const hostnames = ['ceph-node-00.cephlab.com', 'ceph-node-02.cephlab.com']; + const hostnames = [ + 'ceph-node-00.cephlab.com', + 'ceph-node-01.cephlab.com', + 'ceph-node-02.cephlab.com' + ]; beforeEach(() => { hosts.navigateTo(); }); + it('should have removed "_no_schedule" label', () => { - for (let host = 0; host < hostnames.length; host++) { - cy.get('datatable-row-wrapper').should('not.have.text', '_no_schedule'); + for (const hostname of hostnames) { + hosts.checkLabelExists(hostname, ['_no_schedule'], false); } }); it('should display inventory', () => { - hosts.clickHostTab(hostnames[1], 'Physical Disks'); + hosts.clickTab('cd-host-details', hostnames[1], 'Physical Disks'); cy.get('cd-host-details').within(() => { hosts.getTableCount('total').should('be.gte', 0); }); }); it('should display daemons', () => { - hosts.clickHostTab(hostnames[1], 'Daemons'); + hosts.clickTab('cd-host-details', hostnames[1], 'Daemons'); cy.get('cd-host-details').within(() => { hosts.getTableCount('total').should('be.gte', 0); }); }); + + it('should check if rgw service is running', () => { + hosts.clickTab('cd-host-details', hostnames[1], 'Daemons'); + cy.get('cd-host-details').within(() => { + services.checkServiceStatus('rgw'); + }); + }); + + it('should force maintenance and exit', { retries: 1 }, () => { + hosts.maintenance(hostnames[1], true, true); + }); }); describe('OSDs page', () => { @@ -59,19 +74,17 @@ describe('when cluster creation is completed', () => { }); it('should check if osds are created', { retries: 1 }, () => { - osds.expectTableCount('total', 2); + osds.getTableCount('total').should('be.gte', 1); }); }); describe('Services page', () => { - const services = new ServicesPageHelper(); - beforeEach(() => { services.navigateTo(); }); it('should check if services are created', () => { - services.checkExist('rgw.rgw', true); + services.checkExist(serviceName, true); }); }); }); 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 5405da94f01..6395128c947 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 @@ -85,6 +85,19 @@ export abstract class PageHelper { return this.getTabs().its('length'); } + /** + * Helper method to navigate/click a tab inside the expanded table row. + * @param selector The selector of the expanded table row. + * @param name The name of the row which should expand. + * @param tabName Name of the tab to be navigated/clicked. + */ + clickTab(selector: string, name: string, tabName: string) { + this.getExpandCollapseElement(name).click(); + cy.get(selector).within(() => { + this.getTab(tabName).click(); + }); + } + /** * Helper method to select an option inside a select element. * This method will also expect that the option was set. -- 2.39.5