-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add service discovery config (#2081)
- Loading branch information
Showing
17 changed files
with
646 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
web/cypress/integration/route/create-route-with-service-discovery-upstream.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/* eslint-disable no-undef */ | ||
|
||
context('Create Route with Service Discovery Upstream', () => { | ||
const selector = { | ||
name: '#name', | ||
description: '#desc', | ||
discovery_type: '#discovery_type', | ||
service_name: '#service_name', | ||
upstreamSelector: '[data-cy=upstream_selector]', | ||
nameSelector: '[title=Name]', | ||
selectItem: '.ant-select-item-option-content', | ||
drawer: '.ant-drawer-content', | ||
monacoScroll: '.monaco-scrollable-element', | ||
input: ':input', | ||
deleteAlert: '.ant-modal-body', | ||
notification: '.ant-notification-notice-message', | ||
}; | ||
|
||
const data = { | ||
deleteRouteSuccess: 'Delete Route Successfully', | ||
submitSuccess: 'Submit Successfully', | ||
deleteUpstreamSuccess: 'Delete Upstream Successfully', | ||
weight: 1, | ||
description: 'desc_by_autotest', | ||
upstreamName: 'test_upstream', | ||
routeName: 'test_route', | ||
serviceName: 'test.cluster.local', | ||
}; | ||
|
||
beforeEach(() => { | ||
cy.login(); | ||
}); | ||
|
||
it('should create route with DNS service discovery upstream', function () { | ||
cy.visit('/'); | ||
cy.get('[role=menu]') | ||
.should('be.visible') | ||
.within(() => { | ||
cy.contains('Route').click(); | ||
}); | ||
cy.contains('Create').click(); | ||
|
||
cy.contains('Next').click().click(); | ||
cy.get(selector.name).type(data.routeName); | ||
cy.contains('Next').click(); | ||
|
||
// should enable Upstream input boxes after selecting Custom mode | ||
cy.get(selector.upstreamSelector).click(); | ||
cy.contains('.ant-select-item-option-content', 'Custom').click(); | ||
|
||
// set service discovery | ||
cy.get('[title="Node"]').click(); | ||
cy.get(selector.selectItem).within(() => { | ||
cy.contains('Service Discovery').click(); | ||
}); | ||
|
||
cy.get(selector.discovery_type).click(); | ||
cy.get(selector.selectItem).within(() => { | ||
cy.contains('DNS').click(); | ||
}); | ||
cy.get(selector.service_name).type(data.serviceName); | ||
|
||
cy.contains('Next').click(); | ||
cy.contains('Next').click(); | ||
cy.contains('Submit').click(); | ||
cy.contains(data.submitSuccess).should('be.visible'); | ||
cy.contains('Goto List').click(); | ||
cy.url().should('contains', 'routes/list'); | ||
|
||
// check if the service discovery have been saved | ||
cy.get(selector.nameSelector).type(data.routeName); | ||
cy.contains('Search').click(); | ||
|
||
cy.contains(data.routeName).siblings().contains('Configure').click(); | ||
// ensure it has already changed to edit page | ||
cy.get(selector.name).should('value', data.routeName); | ||
cy.contains('Next').click({ | ||
force: true, | ||
}); | ||
cy.get(selector.service_name).should('value', data.serviceName); | ||
}); | ||
|
||
it('should edit this route with Nacos Service Discovery upstream', function () { | ||
cy.visit('/'); | ||
cy.contains('Route').click(); | ||
cy.get(selector.nameSelector).type(data.routeName); | ||
|
||
cy.contains('Search').click(); | ||
cy.contains(data.routeName).siblings().contains('Configure').click(); | ||
|
||
cy.get(selector.name).should('value', data.routeName); | ||
cy.contains('Next').click({ | ||
force: true, | ||
}); | ||
|
||
cy.contains('DNS').should('exist'); | ||
|
||
// set another service discovery | ||
cy.get(selector.discovery_type).click({ force: true }); | ||
cy.get(selector.selectItem).within(() => { | ||
cy.contains('Nacos').click(); | ||
}); | ||
cy.get(selector.service_name).clear().type(`another.${data.serviceName}`); | ||
|
||
cy.contains('Next').click(); | ||
cy.contains('Next').click(); | ||
cy.contains('Submit').click(); | ||
cy.contains(data.submitSuccess).should('be.visible'); | ||
cy.contains('Goto List').click(); | ||
cy.url().should('contains', 'routes/list'); | ||
|
||
// check if the changes have been saved | ||
cy.get(selector.nameSelector).type(data.routeName); | ||
cy.contains('Search').click(); | ||
|
||
cy.contains(data.routeName).siblings().contains('Configure').click(); | ||
// ensure it has already changed to edit page | ||
cy.get(selector.name).should('value', data.routeName); | ||
cy.contains('Next').click({ | ||
force: true, | ||
}); | ||
cy.get(selector.service_name).should('value', `another.${data.serviceName}`); | ||
}); | ||
|
||
it('should view the test route', function () { | ||
cy.visit('/'); | ||
cy.contains('Route').click(); | ||
|
||
cy.get(selector.nameSelector).type(data.routeName); | ||
cy.contains('Search').click(); | ||
cy.contains(data.routeName).siblings().contains('More').click(); | ||
cy.contains('View').click(); | ||
cy.get(selector.drawer).should('be.visible'); | ||
|
||
cy.get(selector.monacoScroll).within(() => { | ||
cy.contains('service_name').should('exist'); | ||
cy.contains('discovery').should('exist'); | ||
}); | ||
}); | ||
|
||
it('should delete this test route and upstream', function () { | ||
cy.visit('/routes/list'); | ||
cy.get(selector.nameSelector).type(data.routeName); | ||
cy.contains('Search').click(); | ||
cy.contains(data.routeName).siblings().contains('More').click(); | ||
cy.contains('Delete').click(); | ||
cy.get(selector.deleteAlert) | ||
.should('be.visible') | ||
.within(() => { | ||
cy.contains('OK').click(); | ||
}); | ||
cy.get(selector.notification).should('contain', data.deleteRouteSuccess); | ||
}); | ||
}); |
126 changes: 126 additions & 0 deletions
126
web/cypress/integration/service/create-service-with-service-discovery-upstream.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/* eslint-disable no-undef */ | ||
|
||
context('Create and Edit Service with Custom CHash Key Upstream', () => { | ||
const selector = { | ||
name: '#name', | ||
description: '#desc', | ||
roundRobinSelect: '[title="Round Robin"]', | ||
upstreamTypeSelect: '[title="Node"]', | ||
discovery_type: '#discovery_type', | ||
service_name: '#service_name', | ||
upstreamType: '.ant-select-item-option-content', | ||
hashPosition: '.ant-select-item-option-content', | ||
discoveryTypeSelect: '.ant-select-item-option-content', | ||
chash_key: '#key', | ||
notification: '.ant-notification-notice-message', | ||
nameSearch: '[title=Name]', | ||
notificationCloseIcon: '.ant-notification-close-icon', | ||
drawer: '.ant-drawer-content', | ||
monacoScroll: '.monaco-scrollable-element', | ||
}; | ||
|
||
const data = { | ||
createServiceSuccess: 'Create Service Successfully', | ||
deleteServiceSuccess: 'Delete Service Successfully', | ||
editServiceSuccess: 'Configure Service Successfully', | ||
port: '80', | ||
weight: 1, | ||
description: 'desc_by_autotest', | ||
ip1: '127.0.0.1', | ||
port0: '7000', | ||
weight0: '1', | ||
custom_key: 'custom_key', | ||
new_key: 'new_key', | ||
serviceName: 'test.cluster.local', | ||
anotherServiceName: `another.test.cluster.local`, | ||
}; | ||
|
||
beforeEach(() => { | ||
cy.login(); | ||
}); | ||
|
||
it('should create a service with service discovery Upstream', function () { | ||
cy.visit('/'); | ||
cy.contains('Service').click(); | ||
cy.contains('Create').click(); | ||
cy.get(selector.name).type(data.serviceName); | ||
cy.get(selector.description).type(data.description); | ||
cy.get(selector.upstreamTypeSelect).click(); | ||
cy.get(selector.upstreamType).within(() => { | ||
cy.contains('Service Discovery').click(); | ||
}); | ||
cy.get(selector.discovery_type).click(); | ||
cy.get(selector.discoveryTypeSelect).within(() => { | ||
cy.contains('DNS').click(); | ||
}); | ||
cy.get(selector.service_name).type(data.serviceName); | ||
cy.contains('Next').click(); | ||
cy.contains('Next').click(); | ||
cy.contains('Submit').click(); | ||
cy.get(selector.notification).should('contain', data.createServiceSuccess); | ||
}); | ||
|
||
it('should edit the service', function () { | ||
cy.visit('/service/list'); | ||
|
||
cy.get(selector.nameSearch).type(data.serviceName); | ||
cy.contains('Search').click(); | ||
cy.contains(data.serviceName).siblings().contains('Configure').click(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.get(selector.name).clear().type(data.anotherServiceName); | ||
|
||
// set another service discovery | ||
cy.get(selector.discovery_type).click({ force: true }); | ||
cy.get(selector.discoveryTypeSelect).within(() => { | ||
cy.contains('Nacos').click(); | ||
}); | ||
cy.get(selector.service_name).clear().type(data.anotherServiceName); | ||
|
||
cy.contains('Next').click(); | ||
cy.contains('Next').click(); | ||
cy.contains('Submit').click(); | ||
cy.get(selector.notification).should('contain', data.editServiceSuccess); | ||
}); | ||
|
||
it('should view the test service', function () { | ||
cy.visit('/service/list'); | ||
|
||
cy.get(selector.nameSearch).type(data.anotherServiceName); | ||
cy.contains('Search').click(); | ||
cy.contains(data.anotherServiceName).siblings().contains('View').click(); | ||
cy.get(selector.drawer).should('be.visible'); | ||
|
||
cy.get(selector.monacoScroll).within(() => { | ||
cy.contains('service_name').should('exist'); | ||
cy.contains('discovery').should('exist'); | ||
}); | ||
}); | ||
|
||
it('should delete this service', function () { | ||
cy.visit('/service/list'); | ||
cy.get(selector.nameSearch).type(data.anotherServiceName); | ||
cy.contains('Search').click(); | ||
cy.contains(data.anotherServiceName).siblings().contains('Delete').click(); | ||
cy.contains('button', 'Confirm').click(); | ||
cy.get(selector.notification).should('contain', data.deleteServiceSuccess); | ||
cy.get(selector.notificationCloseIcon).click(); | ||
}); | ||
}); |
Oops, something went wrong.