-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() {
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');
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
+ };
}
});
}
- @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);
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) {
});
}
- @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');
}
}
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)
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(() => {
});
}
- @PageHelper.restrictTo(pages.create.url)
addService(serviceType: string, exist?: boolean, count = '1') {
cy.get(`${this.pages.create.id}`).within(() => {
this.selectServiceType(serviceType);
});
}
- @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();
});
}
- @PageHelper.restrictTo(pages.index.url)
deleteService(serviceName: string) {
const getRow = this.getTableCell.bind(this, this.columnIndex.service_name);
getRow(serviceName).click();
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);
});
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);
});
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);
});
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');
});
});
});
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();
});
});
+++ /dev/null
-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);
- });
- });
-});
-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(() => {
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);
});
});
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');
});
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');
});
});
});
-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');
});
});
});
-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();
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');
});
});
});
it('should check default host name is present', () => {
- createCluster.check_for_host();
+ createClusterHostPage.check_for_host();
});
});
});
describe('when cluster creation is completed', () => {
const createCluster = new CreateClusterWizardHelper();
+ const services = new ServicesPageHelper();
+ const serviceName = 'rgw.foo';
beforeEach(() => {
cy.login();
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', () => {
});
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);
});
});
});
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.