Skip to content

Commit

Permalink
feat: cluster scope adds hostnames (#356)
Browse files Browse the repository at this point in the history
Signed-off-by: zhaoxinxin <[email protected]>
  • Loading branch information
Liam-Zhao authored Feb 21, 2024
1 parent ac60432 commit 8bee0cf
Show file tree
Hide file tree
Showing 17 changed files with 477 additions and 165 deletions.
8 changes: 8 additions & 0 deletions cypress/e2e/clusters/cluster.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ describe('Cluster', () => {
cy.get('.MuiDialogContent-root').should('be.visible').and('contain', '10.0.0.0/8');

cy.get('body').click('topLeft');

cy.get(':nth-child(4) > .MuiPaper-root > .information_cidrsTags__4sKxa')
.should('be.visible')
.and('contain', 'cluster-1');
});

it('can display config', () => {
Expand Down Expand Up @@ -373,6 +377,7 @@ describe('Cluster', () => {
).click();

cy.get('.information_clusterContainer__l8H8p > :nth-child(1) > .MuiTypography-subtitle1')
.scrollIntoView()
.should('be.visible')
.and('contain', 'cluster-10');

Expand Down Expand Up @@ -444,6 +449,7 @@ describe('Cluster', () => {
).click();

cy.get('.information_clusterContainer__l8H8p > :nth-child(1) > .MuiTypography-subtitle1')
.scrollIntoView()
.should('be.visible')
.and('contain', 'cluster-1');

Expand Down Expand Up @@ -516,6 +522,7 @@ describe('Cluster', () => {
).click();

cy.get('.information_clusterContainer__l8H8p > :nth-child(1) > .MuiTypography-subtitle1')
.scrollIntoView()
.should('be.visible')
.and('contain', 'cluster-10');

Expand Down Expand Up @@ -565,6 +572,7 @@ describe('Cluster', () => {
).click();

cy.get('.information_clusterContainer__l8H8p > :nth-child(1) > .MuiTypography-subtitle1')
.scrollIntoView()
.should('be.visible')
.and('contain', 'cluster-10');

Expand Down
17 changes: 17 additions & 0 deletions cypress/e2e/clusters/create-cluster.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ describe('Create cluster', () => {
it('try to verify scopes', () => {
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
const location = _.times(101, () => _.sample(characters)).join('');
const hostnames = _.times(31, () => _.sample(characters)).join('');

// Name is a required attribute.
cy.get('#name').type('cluster-12');
Expand Down Expand Up @@ -323,6 +324,22 @@ describe('Create cluster', () => {

// Verification passed.
cy.get('#cidrs-helper-text').should('not.exist');

// Should display cidrs the validation error message.
cy.get(':nth-child(4) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root').type('sigma');
cy.get('#save').click();
cy.url().should('include', '/clusters/new');
cy.get('#hostnames-helper-text')
.should('be.visible')
.and('contain', `Please press ENTER to end the Hostnames creation.`);
cy.get(':nth-child(4) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root').type(
'hostname{enter}',
);
cy.get(':nth-child(4) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root').type(hostnames);

cy.get('#hostnames-helper-text')
.should('be.visible')
.and('contain', `Fill in the characters, the length is 1-30.`);
});

it('try to verify config', () => {
Expand Down
21 changes: 21 additions & 0 deletions cypress/e2e/clusters/update-cluster.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ describe('Update cluster', () => {
.and('contain', '192.168.0.0/16')
.and('contain', '172.16.0.0/12');

cy.get(':nth-child(4) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root')
.should('contain', 'cluster-1')
.and('contain', 'cluster-2')
.and('contain', 'cluster-3');

// Show config.
cy.get('#seedPeerLoadLimit').should('have.value', 300);
cy.get('#peerLoadLimit').should('have.value', 51);
Expand Down Expand Up @@ -332,6 +337,22 @@ describe('Update cluster', () => {
'192.168.40.0/24{enter}',
);
cy.get('#cidrs-helper-text').should('not.exist');

// Should display hostnames the validation error message.
cy.get(':nth-child(4) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root').type('cluster-2');

cy.get('#save').click();
cy.url().should('include', '/clusters/1/edit');

// Show verification error message.
cy.get('#hostnames-helper-text')
.should('be.visible')
.and('contain', `Please press ENTER to end the Hostnames creation.`);

cy.get(':nth-child(4) > .MuiAutocomplete-root > .MuiFormControl-root > .MuiInputBase-root').type(
'cluster-1{enter}',
);
cy.get('#hostnames-helper-text').should('not.exist');
});

it('try to verify config', () => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/job/preheats/create-preheat.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ describe('Create preheat', () => {
// Incorrect header value entered.
cy.get('.new_headersValueInput__zn-9E > .MuiInputBase-root').type(value);

// Show header value verification error message.
// Show header value verification error message.
cy.get('.new_headersValueInput__zn-9E > .MuiFormHelperText-root')
.should('be.visible')
.and('have.text', 'Fill in the characters, the length is 1-1000.');

// Show header value verification error message.
// Show header value verification error message.
cy.get('.new_headersValueInput__zn-9E > .MuiFormHelperText-root')
.should('be.visible')
.and('have.text', 'Fill in the characters, the length is 1-1000.');
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/seed-peers/seed-peers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('Seed peers', () => {

describe('pagination', () => {
it('pagination updates results and page number', () => {
cy.get('#seed-peer-table').should('be.visible');
cy.get('#seed-peer-table').scrollIntoView().should('be.visible');

// Check number of pagination.
cy.get('#seed-peer-pagination > .MuiPagination-ul').children().should('have.length', 5);
Expand Down Expand Up @@ -470,6 +470,8 @@ describe('Seed peers', () => {
.should('be.visible')
.and('contain', 'Inactive');

cy.get(':nth-child(5) > :nth-child(9) > .MuiButtonBase-root').click();

cy.intercept({ method: 'DELETE', url: '/api/v1/seed-peers/9' }, (req) => {
req.reply({
statusCode: 200,
Expand All @@ -488,8 +490,6 @@ describe('Seed peers', () => {
},
);

cy.get(':nth-child(5) > :nth-child(9) > .MuiButtonBase-root').click();

cy.get('#deleteSeedPeer').click();

// Delete success message.
Expand Down
3 changes: 2 additions & 1 deletion cypress/fixtures/clusters/cluster/cluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scopes": {
"idc": "Hangzhou|Shanghai|Beijing",
"location": "China|Hang|Zhou",
"cidrs": ["10.0.0.0/8", "192.168.0.0/16", "172.16.0.0/12"]
"cidrs": ["10.0.0.0/8", "192.168.0.0/16", "172.16.0.0/12"],
"hostnames": ["cluster-1", "cluster-2", "cluster-3"]
},
"scheduler_cluster_id": 1,
"seed_peer_cluster_id": 1,
Expand Down
3 changes: 2 additions & 1 deletion cypress/fixtures/clusters/cluster/update-cluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scopes": {
"idc": "Hangzhou|Shanghai",
"location": "China|Shang|Hai",
"cidrs": ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "192.168.20.2"]
"cidrs": ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "192.168.20.2"],
"hostnames": ["cluster-1"]
},
"scheduler_cluster_id": 1,
"seed_peer_cluster_id": 1,
Expand Down
33 changes: 22 additions & 11 deletions cypress/fixtures/clusters/create-cluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"scopes": {
"idc": "",
"location": "",
"cidrs": []
"cidrs": [],
"hostnames": []
},
"scheduler_cluster_id": 2,
"seed_peer_cluster_id": 2,
Expand All @@ -56,7 +57,8 @@
"scopes": {
"idc": "Korea",
"location": "Seoul|Korea",
"cidrs": ["192.168.0.0/16", "172.16.0.0/12"]
"cidrs": ["192.168.0.0/16", "172.16.0.0/12"],
"hostnames": []
},
"scheduler_cluster_id": 3,
"seed_peer_cluster_id": 3,
Expand All @@ -81,7 +83,8 @@
"scopes": {
"idc": "hz|dl",
"location": "China|Hang|Zhou",
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"]
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"],
"hostnames": []
},
"scheduler_cluster_id": 4,
"seed_peer_cluster_id": 4,
Expand All @@ -106,7 +109,8 @@
"scopes": {
"idc": "cq|cd",
"location": "China|Chong|Qing",
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"]
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"],
"hostnames": []
},
"scheduler_cluster_id": 5,
"seed_peer_cluster_id": 5,
Expand All @@ -131,7 +135,8 @@
"scopes": {
"idc": "cq|cd",
"location": "China|Chong|Du",
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"]
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"],
"hostnames": []
},
"scheduler_cluster_id": 6,
"seed_peer_cluster_id": 6,
Expand All @@ -156,7 +161,8 @@
"scopes": {
"idc": "cd",
"location": "China|Cheng|Du",
"cidrs": ["10.0.0.0/8", "172.16.0.0/19"]
"cidrs": ["10.0.0.0/8", "172.16.0.0/19"],
"hostnames": []
},
"scheduler_cluster_id": 7,
"seed_peer_cluster_id": 7,
Expand All @@ -181,7 +187,8 @@
"scopes": {
"idc": "js",
"location": "China|Jiang|Su",
"cidrs": ["10.0.0.0/5", "172.16.0.0/19"]
"cidrs": ["10.0.0.0/5", "172.16.0.0/19"],
"hostnames": []
},
"scheduler_cluster_id": 8,
"seed_peer_cluster_id": 8,
Expand All @@ -206,7 +213,8 @@
"scopes": {
"idc": "hz|hf",
"location": "China|Hang|Zhou",
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"]
"cidrs": ["10.0.0.0/8", "192.168.0.0/16"],
"hostnames": []
},
"scheduler_cluster_id": 9,
"seed_peer_cluster_id": 9,
Expand All @@ -231,7 +239,8 @@
"scopes": {
"idc": "London",
"location": "London|England",
"cidrs": ["192.168.255.255"]
"cidrs": ["192.168.255.255"],
"hostnames": []
},
"scheduler_cluster_id": 10,
"seed_peer_cluster_id": 10,
Expand All @@ -256,7 +265,8 @@
"scopes": {
"idc": "Paris",
"location": "Paris|France",
"cidrs": ["192.168.0.0", "10.0.0.0"]
"cidrs": ["192.168.0.0", "10.0.0.0"],
"hostnames": []
},
"scheduler_cluster_id": 11,
"seed_peer_cluster_id": 11,
Expand All @@ -281,7 +291,8 @@
"scopes": {
"idc": "hz|sh",
"location": "China|Hang|Zhou",
"cidrs": ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
"cidrs": ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"],
"hostnames": []
},
"scheduler_cluster_id": 12,
"seed_peer_cluster_id": 12,
Expand Down
9 changes: 8 additions & 1 deletion public/icons/cluster/cidrs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion public/icons/cluster/hostname.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/icons/cluster/hostnames.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8bee0cf

Please sign in to comment.