mgr/dashboard: Move force maintenance test to the workflow test suite

Fixes: https://tracker.ceph.com/issues/52276
Signed-off-by: Nizamudeen A <nia@redhat.com>
This commit is contained in:
Nizamudeen A 2021-08-17 22:26:52 +05:30
parent 99f1f0f4c0
commit e33d9e15b9
6 changed files with 67 additions and 75 deletions

View File

@ -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"

View File

@ -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}')

View File

@ -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);
}
}

View File

@ -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);
}
});
});
});

View File

@ -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');
});
});
});

View File

@ -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);
});
});
});