summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts
blob: aca36ade192198a7faef4396c5f47d5b4103da50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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 not add an exsiting host', function () {
      const hostname = Cypress._.sample(this.hosts).name;
      hosts.navigateTo('add');
      hosts.add(hostname, true);
    });

    it('should drain and remove a host and then add it back', function () {
      const hostname = Cypress._.last(this.hosts)['name'];

      // should drain the host first before deleting
      hosts.drain(hostname);
      hosts.remove(hostname);

      // add it back
      hosts.navigateTo('add');
      hosts.add(hostname);
      hosts.checkExist(hostname, true);
    });

    it('should display inventory', function () {
      for (const host of this.hosts) {
        hosts.clickTab('cd-host-details', host.name, 'Physical Disks');
        cy.get('cd-host-details').within(() => {
          hosts.expectTableCount('total', host.devices.length);
        });
      }
    });

    it('should display daemons', function () {
      for (const host of this.hosts) {
        hosts.clickTab('cd-host-details', host.name, 'Daemons');
        cy.get('cd-host-details').within(() => {
          hosts.getTableCount('total').should('be.gte', 0);
        });
      }
    });

    it('should edit host labels', function () {
      const hostname = Cypress._.sample(this.hosts).name;
      const labels = ['foo', 'bar'];
      hosts.editLabels(hostname, labels, true);
      hosts.editLabels(hostname, labels, false);
    });

    it('should enter host into maintenance', function () {
      const hostname = Cypress._.sample(this.hosts).name;
      const serviceList = new Array();
      this.services.forEach((service: any) => {
        if (hostname === service.hostname) {
          serviceList.push(service.daemon_type);
        }
      });
      let enterMaintenance = true;
      serviceList.forEach((service: string) => {
        if (service === 'mgr' || service === 'alertmanager') {
          enterMaintenance = false;
        }
      });
      if (enterMaintenance) {
        hosts.maintenance(hostname);
      }
    });

    it('should exit host from maintenance', function () {
      const hostname = Cypress._.sample(this.hosts).name;
      hosts.maintenance(hostname, true);
    });
  });
});