Skip to content

Commit

Permalink
Ascs ers type frontend (#1398)
Browse files Browse the repository at this point in the history
* Add ascs/ers cluster type to the frontend

* Improve e2e testing of the clusters view
  • Loading branch information
arbulu89 authored and rtorrero committed Jun 16, 2023
1 parent 10dac6c commit 3a4e870
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 31 deletions.
2 changes: 2 additions & 0 deletions assets/js/components/ClustersList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const getClusterTypeLabel = (type) => {
return 'HANA Scale Up';
case 'hana_scale_out':
return 'HANA Scale Out';
case 'ascs_ers':
return 'ASCS/ERS';
default:
return 'Unknown';
}
Expand Down
5 changes: 3 additions & 2 deletions assets/js/components/ClustersList.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ describe('ClustersList component', () => {
},
{
filter: 'Type',
options: ['hana_scale_up'],
options: ['hana_scale_up', 'ascs_ers'],
state: {
...cleanInitialState,
clustersList: {
clusters: [].concat(
clusterFactory.buildList(2, { type: 'unknown' }),
clusterFactory.buildList(2, { type: 'hana_scale_up' })
clusterFactory.buildList(2, { type: 'hana_scale_up' }),
clusterFactory.buildList(2, { type: 'ascs_ers' })
),
},
},
Expand Down
43 changes: 33 additions & 10 deletions test/e2e/cypress/e2e/clusters_overview.cy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
allClusterNames,
clusterIdByName,
availableClusters,
healthyClusterScenario,
unhealthyClusterScenario,
} from '../fixtures/clusters-overview/available_clusters';

const clusterIdByName = (clusterName) =>
availableClusters.find(({ name }) => name === clusterName).id;

context('Clusters Overview', () => {
const availableClusters = allClusterNames();
beforeEach(() => {
cy.visit('/clusters');
cy.url().should('include', '/clusters');
Expand All @@ -21,14 +22,35 @@ context('Clusters Overview', () => {
it('should have 1 pages', () => {
cy.get('.tn-page-item').its('length').should('eq', 1);
});
describe('Discovered clusternames are the expected ones', () => {
availableClusters.forEach((clusterName) => {
it(`should have a cluster named ${clusterName}`, () => {
cy.get('.tn-clustername').each(($link) => {
const displayedClusterName = $link.text().trim();
expect(availableClusters).to.include(displayedClusterName);
it('should show the expected clusters data', () => {
cy.get('.container').eq(0).as('clustersTable');
availableClusters.forEach((cluster, index) => {
cy.get('@clustersTable')
.find('tr')
.eq(index + 1)
.find('td')
.as('clusterRow');

cy.get('@clustersTable')
.contains('th', 'Name')
.invoke('index')
.then((i) => {
cy.get('@clusterRow').eq(i).should('contain', cluster.name);
});

cy.get('@clustersTable')
.contains('th', 'SID')
.invoke('index')
.then((i) => {
cy.get('@clusterRow').eq(i).should('contain', cluster.sid);
});

cy.get('@clustersTable')
.contains('th', 'Type')
.invoke('index')
.then((i) => {
cy.get('@clusterRow').eq(i).should('contain', cluster.type);
});
});
});
});
describe('Unnamed cluster', () => {
Expand Down Expand Up @@ -116,6 +138,7 @@ context('Clusters Overview', () => {
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}'`, () => {
Expand Down
74 changes: 55 additions & 19 deletions test/e2e/cypress/fixtures/clusters-overview/available_clusters.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,60 @@
const availableClusters = [
['8a66f8fb-5fe9-51b3-a34c-24321271a4e3', 'drbd_cluster'],
['6bd7ec60-8cb1-5c6b-a892-29e1fd2f8380', 'drbd_cluster'],
['c7a1e943-bf46-590b-bd26-bfc7c78def97', 'drbd_cluster'],
['7965f822-0254-5858-abca-f6e8b4c27714', 'hana_cluster_1'],
['fa0d74a3-9240-5d9e-99fa-61c4137acf81', 'hana_cluster_2'],
['469e7be5-4e20-5007-b044-c6f540a87493', 'hana_cluster_3'],
['5284f376-c1f4-5178-8966-d490df3dab4f', 'netweaver_cluster'],
['fb861bce-d212-56b5-8786-74afd6eb58cb', 'netweaver_cluster'],
['0eac831a-aa66-5f45-89a4-007fbd2c5714', 'netweaver_cluster'],
export const availableClusters = [
{
id: '8a66f8fb-5fe9-51b3-a34c-24321271a4e3',
name: 'drbd_cluster',
sid: '',
type: 'Unknown',
},
{
id: '6bd7ec60-8cb1-5c6b-a892-29e1fd2f8380',
name: 'drbd_cluster',
sid: '',
type: 'Unknown',
},
{
id: 'c7a1e943-bf46-590b-bd26-bfc7c78def97',
name: 'drbd_cluster',
sid: '',
type: 'Unknown',
},
{
id: '7965f822-0254-5858-abca-f6e8b4c27714',
name: 'hana_cluster_1',
sid: 'HDD',
type: 'HANA Scale Up',
},
{
id: 'fa0d74a3-9240-5d9e-99fa-61c4137acf81',
name: 'hana_cluster_2',
sid: 'HDQ',
type: 'HANA Scale Up',
},
{
id: '469e7be5-4e20-5007-b044-c6f540a87493',
name: 'hana_cluster_3',
sid: 'HDP',
type: 'HANA Scale Up',
},
{
id: '5284f376-c1f4-5178-8966-d490df3dab4f',
name: 'netweaver_cluster',
sid: '',
type: 'ASCS/ERS',
},
{
id: 'fb861bce-d212-56b5-8786-74afd6eb58cb',
name: 'netweaver_cluster',
sid: '',
type: 'ASCS/ERS',
},
{
id: '0eac831a-aa66-5f45-89a4-007fbd2c5714',
name: 'netweaver_cluster',
sid: '',
type: 'ASCS/ERS',
},
];

export const allClusterNames = () =>
availableClusters.map(([_, clusterName]) => clusterName);
export const allClusterIds = () =>
availableClusters.map(([clusterId, _]) => clusterId);
export const clusterIdByName = (clusterName) =>
availableClusters.find(([, name]) => name === clusterName)[0];
export const clusterNameById = (clusterId) =>
availableClusters.find(([id]) => id === clusterId)[1];

export const healthyClusterScenario = {
clusterName: 'hana_cluster_2',
checks: ['156F64'],
Expand Down

0 comments on commit 3a4e870

Please sign in to comment.