Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2e test deregistration cascading #1634

Merged
merged 11 commits into from
Jul 20, 2023
62 changes: 39 additions & 23 deletions test/e2e/cypress/e2e/clusters_overview.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const clusterIdByName = (clusterName) =>
availableClusters.find(({ name }) => name === clusterName).id;

context('Clusters Overview', () => {
beforeEach(() => {
before(() => {
cy.visit('/clusters');
cy.url().should('include', '/clusters');
});
Expand Down Expand Up @@ -122,31 +122,47 @@ context('Clusters Overview', () => {
.should('have.class', 'fill-red-500');
});
});
});

describe('Clusters Tagging', () => {
before(() => {
cy.removeTagsFromView();
});
const clustersByMatchingPattern = (pattern) => (clusterName) =>
clusterName.includes(pattern);
const taggingRules = [
['hana_cluster_1', 'env1'],
['hana_cluster_2', 'env2'],
['hana_cluster_3', 'env3'],
];

taggingRules.forEach(([pattern, tag]) => {
describe(`Add tag '${tag}' to all clusters with '${pattern}' in the cluster name`, () => {
availableClusters
.map(({ name }) => name)
.filter(clustersByMatchingPattern(pattern))
.forEach((clusterName) => {
it(`should tag cluster '${clusterName}'`, () => {
cy.addTagByColumnValue(clusterName, tag);
});
describe('Clusters Tagging', () => {
before(() => {
cy.removeTagsFromView();
});
const clustersByMatchingPattern = (pattern) => (clusterName) =>
clusterName.includes(pattern);
const taggingRules = [
['hana_cluster_1', 'env1'],
['hana_cluster_2', 'env2'],
['hana_cluster_3', 'env3'],
];

taggingRules.forEach(([pattern, tag]) => {
describe(`Add tag '${tag}' to all clusters with '${pattern}' in the cluster name`, () => {
availableClusters
.map(({ name }) => name)
.filter(clustersByMatchingPattern(pattern))
.forEach((clusterName) => {
it(`should tag cluster '${clusterName}'`, () => {
cy.addTagByColumnValue(clusterName, tag);
});
});
});
});
});
});

describe('Deregistration', () => {
const hanaCluster1 = {
name: 'hana_cluster_1',
hosts: [
'13e8c25c-3180-5a9a-95c8-51ec38e50cfc',
'0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4',
],
};

it(`should not display '${hanaCluster1.name}' after deregistering all its nodes`, () => {
cy.deregisterHost(hanaCluster1.hosts[0]);
cy.deregisterHost(hanaCluster1.hosts[1]);
cy.contains(hanaCluster1.name).should('not.exist');
});
});
});
21 changes: 21 additions & 0 deletions test/e2e/cypress/e2e/databases_overview.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
context('Databases Overview', () => {
before(() => {
cy.visit('/databases');
cy.url().should('include', '/databases');
});

describe('Deregistration', () => {
const hdqDatabase = {
sid: 'HDQ',
hanaPrimary: {
name: 'vmhdbqas01',
id: '99cf8a3a-48d6-57a4-b302-6e4482227ab6',
},
};

it(`should not display DB ${hdqDatabase.sid} after deregistering the primary instance`, () => {
cy.deregisterHost(hdqDatabase.hanaPrimary.id);
cy.contains(hdqDatabase.sid).should('not.exist');
});
});
});
20 changes: 20 additions & 0 deletions test/e2e/cypress/e2e/hana_cluster_details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,24 @@ context('HANA cluster details', () => {
cy.get('li').first().contains(5000);
});
});

describe('Deregistration', () => {
const hostToDeregister = {
name: 'vmhdbprd02',
id: 'b767b3e9-e802-587e-a442-541d093b86b9',
sid: 'WDF',
};

before(() => {
cy.deregisterHost(hostToDeregister.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deregisterHost move to the test

cy.visit(`/clusters/${availableHanaCluster.id}`);
cy.url().should('include', `/clusters/${availableHanaCluster.id}`);
});

it(`should not include a working link to ${hostToDeregister.name} in the list of sites`, () => {
cy.get(`.tn-site-details-${hostToDeregister.sid}`)
.contains('a', hostToDeregister.name)
.should('not.exist');
});
});
});
10 changes: 10 additions & 0 deletions test/e2e/cypress/e2e/hana_database_details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,14 @@ context('HANA database details', () => {
});
});
});

describe('Deregistration', () => {
before(() => {
cy.deregisterHost(attachedHosts[0].AgentId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to the test

});

it(`should not include host ${attachedHosts[0].Name} in the list of hosts`, () => {
cy.contains(attachedHosts[0].Name).should('not.exist');
});
});
});
17 changes: 17 additions & 0 deletions test/e2e/cypress/e2e/sap_system_details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,21 @@ context('SAP system details', () => {
});
});
});

describe('Deregistration', () => {
const hostToDeregister = {
name: 'vmnwdev02',
id: 'fb2c6b8a-9915-5969-a6b7-8b5a42de1971',
};

before(() => {
cy.visit(`/sap_systems/${selectedSystem.Id}`);
cy.url().should('include', `/sap_systems/${selectedSystem.Id}`);
});

it(`should not include ${hostToDeregister.name} in the list of hosts`, () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could improve this test (or add a new) to check that the SAP instance belonging to this SAP system is not there. @abravosuse reported some potential issue on this?

cy.deregisterHost(hostToDeregister.id);
cy.contains(hostToDeregister.name).should('not.exist');
});
});
});
48 changes: 48 additions & 0 deletions test/e2e/cypress/e2e/sap_systems_overview.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,52 @@ context('SAP Systems Overview', () => {
cy.get('table.table-fixed').should('not.contain', 'DAA');
});
});

describe('Deregistration', () => {
const sapSystemNwp = {
sid: 'NWP',
hanaPrimary: {
name: 'vmhdbprd01',
id: '9cd46919-5f19-59aa-993e-cf3736c71053',
},
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss a test here where we check that the SAP system is deregistered when the ASCS or PAS instances are deregistered

const sapSystemNwq = {
sid: 'NWQ',
messageserverInstance: {
name: 'vmnwqas01',
id: '25677e37-fd33-5005-896c-9275b1284534',
},
};

const sapSystemNwd = {
sid: 'NWD',
applicationInstances: [
{
name: 'vmnwdev03',
id: '9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f',
},
{
name: 'vmnwdev04',
id: '1b0e9297-97dd-55d6-9874-8efde4d84c90',
},
],
};

it(`should not display SAP System ${sapSystemNwp.sid} after deregistering the primary instance`, () => {
arbulu89 marked this conversation as resolved.
Show resolved Hide resolved
cy.deregisterHost(sapSystemNwp.hanaPrimary.id);
cy.contains(sapSystemNwp.sid).should('not.exist');
});

it(`should not display SAP System ${sapSystemNwq.sid} after deregistering the instance running the messageserver`, () => {
cy.deregisterHost(sapSystemNwq.messageserverInstance.id);
cy.contains(sapSystemNwq.sid).should('not.exist');
});

it(`should not display SAP System ${sapSystemNwd.sid} after deregistering both application instances`, () => {
cy.deregisterHost(sapSystemNwd.applicationInstances[0].id);
cy.deregisterHost(sapSystemNwd.applicationInstances[1].id);
cy.contains(sapSystemNwd.sid).should('not.exist');
});
});
});
23 changes: 23 additions & 0 deletions test/e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,26 @@ Cypress.Commands.add('requestChecksExecution', (clusterId) => {
});
});
});

Cypress.Commands.add('deregisterHost', (hostId) => {
const [webAPIHost, webAPIPort] = [
Cypress.env('web_api_host'),
Cypress.env('web_api_port'),
];

const headers = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have this headers in a default constant.
Maybe food for a tech debt

'Content-Type': 'application/json;charset=UTF-8',
};

apiLogin().then(({ accessToken }) => {
const url = `http://${webAPIHost}:${webAPIPort}/api/v1/hosts/${hostId}`;
cy.request({
method: 'DELETE',
url: url,
headers: headers,
auth: {
bearer: accessToken,
},
});
});
});
Loading