]>
Commit | Line | Data |
---|---|---|
b3b6e05e TL |
1 | import { HostsPageHelper } from '../cluster/hosts.po'; |
2 | ||
3 | describe('Hosts page', () => { | |
4 | const hosts = new HostsPageHelper(); | |
5 | ||
6 | beforeEach(() => { | |
7 | cy.login(); | |
8 | Cypress.Cookies.preserveOnce('token'); | |
9 | hosts.navigateTo(); | |
10 | }); | |
11 | ||
12 | describe('when Orchestrator is available', () => { | |
13 | beforeEach(function () { | |
14 | cy.fixture('orchestrator/inventory.json').as('hosts'); | |
15 | cy.fixture('orchestrator/services.json').as('services'); | |
16 | }); | |
17 | ||
18 | it('should force enter host into maintenance', function () { | |
19 | const hostname = Cypress._.sample(this.hosts).name; | |
522d829b TL |
20 | const hostnameList = new Array(); |
21 | this.hosts.array.forEach((host: any) => { | |
22 | hostnameList.push(host.hostname); | |
23 | }); | |
b3b6e05e TL |
24 | const serviceList = new Array(); |
25 | this.services.forEach((service: any) => { | |
26 | if (hostname === service.hostname) { | |
27 | serviceList.push(service.daemon_type); | |
28 | } | |
29 | }); | |
30 | ||
31 | let enterMaintenance = true; | |
522d829b TL |
32 | |
33 | // Force maintenance might throw out error if host are less than 3. | |
34 | if (hostnameList.length < 3) { | |
35 | enterMaintenance = false; | |
36 | } | |
37 | ||
b3b6e05e | 38 | serviceList.forEach((service: string) => { |
522d829b | 39 | if (service !== 'rgw' && (service === 'mgr' || service === 'alertmanager')) { |
b3b6e05e TL |
40 | enterMaintenance = false; |
41 | } | |
42 | }); | |
43 | ||
44 | if (enterMaintenance) { | |
45 | hosts.maintenance(hostname, true, true); | |
46 | } | |
47 | }); | |
48 | }); | |
49 | }); |