Skip to content

Commit

Permalink
Merge pull request #1189 from hanbingleixue/develop
Browse files Browse the repository at this point in the history
【enhancement】提交离群实例摘除插件的集成测试
  • Loading branch information
luanwenfei-venus authored Apr 14, 2023
2 parents 49b288e + 0226384 commit ee8c296
Show file tree
Hide file tree
Showing 37 changed files with 1,274 additions and 20 deletions.
15 changes: 15 additions & 0 deletions .github/actions/common/plugin-change-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ runs:
shell: bash
run: |
echo "sermantMqConsumerDenyChanged=${{ steps.changed-sermant-mq-consumer-deny.outputs.changed }}" >> $GITHUB_ENV
- uses: marceloprado/has-changed-path@v1
id: changed-sermant-removal
with:
paths: sermant-plugins/sermant-service-removal
- name: env sermant-sermant-service-removal
shell: bash
run: |
echo "sermantServiceRemovalChanged=${{ steps.changed-sermant-removal.outputs.changed }}" >> $GITHUB_ENV
- uses: marceloprado/has-changed-path@v1
id: changed-workflow-or-test
with:
Expand Down Expand Up @@ -164,6 +172,12 @@ runs:
${{ env.sermantSpringbootRegistryChanged }} == 'true' -o ${{ env.sermantServiceRegistryChanged }} == 'true' ];then
echo "enableSpringLane=true" >> $GITHUB_ENV
fi
# ==========removal is needed to test?==========
if [ ${{ env.sermantAgentCoreChanged }} == 'true' -o ${{ env.sermantServiceRemovalChanged }} == 'true' -o \
${{ env.sermantSpringbootRegistryChanged }} == 'true' -o ${{ env.sermantServiceRegistryChanged }} == 'true' ];then
echo "enableRemoval=true" >> $GITHUB_ENV
fi
# all workflow will trigger while workflow changed
if [ ${{ steps.changed-workflow-or-test.outputs.changed }} == 'true' -o ${{ env.triggerPushEvent }} == 'true' ];then
Expand All @@ -178,5 +192,6 @@ runs:
echo "enableVisibility=true" >> $GITHUB_ENV
echo "enableSpringLane=true" >> $GITHUB_ENV
echo "enableDubboLane=true" >> $GITHUB_ENV
echo "enableRemoval=true" >> $GITHUB_ENV
fi
91 changes: 91 additions & 0 deletions .github/actions/scenarios/dubbo/removal/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: "Dubbo Removal Test"
description: "Automated testing of outlier instance removal plug-in duddo scenario"
runs:
using: "composite"
steps:
- name: removal-entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/dubbo-removal
- name: package dubbo 2.5.x tests
shell: bash
if: matrix.dubbo-version == '2-5'
run: mvn package -Dalibaba.dubbo.version=2.5.${{ matrix.dubbo-versions }} -DskipTests -P260 --file sermant-integration-tests/dubbo-test/pom.xml
- name: package dubbo 2.6.0 tests
shell: bash
if: matrix.dubbo-version == '2-6' && matrix.dubbo-versions == '0'
run: mvn package -Dalibaba.dubbo.version=2.6.${{ matrix.dubbo-versions }} -DskipTests -P260 --file sermant-integration-tests/dubbo-test/pom.xml
- name: package dubbo 2.6.x tests
shell: bash
if: matrix.dubbo-version == '2-6' && matrix.dubbo-versions != '0'
run: mvn package -Dalibaba.dubbo.version=2.6.${{ matrix.dubbo-versions }} -DskipTests --file sermant-integration-tests/dubbo-test/pom.xml
- name: package dubbo 2.7.x tests
shell: bash
if: matrix.dubbo-version == '2-7'
run: mvn package -Ddubbo.version=2.7.${{ matrix.dubbo-versions }} -DskipTests --file sermant-integration-tests/dubbo-test/pom.xml
- name: start provider service
shell: bash
env:
TIMEOUT: 2000
SERVER_PORT: 28021
DUBBO_PROTOCOL_PORT: 28821
run: |
nohup java -jar sermant-integration-tests/dubbo-test/dubbo-${{ env.projectPath }}-integration-provider/target/dubbo-integration-provider.jar > ${{ env.logDir }}/removal-provider-28021.log 2>&1 &
- name: start provider service
shell: bash
env:
TIMEOUT: 0
SERVER_PORT: 28022
DUBBO_PROTOCOL_PORT: 28822
run: |
nohup java -jar sermant-integration-tests/dubbo-test/dubbo-${{ env.projectPath }}-integration-provider/target/dubbo-integration-provider.jar > ${{ env.logDir }}/removal-provider-28022.log 2>&1 &
- name: start provider service
shell: bash
env:
TIMEOUT: 0
SERVER_PORT: 28023
DUBBO_PROTOCOL_PORT: 28823
run: |
nohup java -jar sermant-integration-tests/dubbo-test/dubbo-${{ env.projectPath }}-integration-provider/target/dubbo-integration-provider.jar > ${{ env.logDir }}/removal-provider-28023.log 2>&1 &
- name: start consumer service
shell: bash
env:
REMOVAL_CONFIG_EXPIRE_TIMES: 60000
REMOVAL_CONFIG_EXCEPTIONS: "[com.alibaba.dubbo.remoting.TimeoutException, org.apache.dubbo.remoting.TimeoutException, java.util.concurrent.TimeoutException, java.net.SocketTimeoutException]"
REMOVAL_CONFIG_ENABLE_REMOVAL: true
REMOVAL_CONFIG_RECOVERY_TIMES: 30000
REMOVAL_CONFIG_WINDOWS_TIMES: 1000
REMOVAL_CONFIG_WINDOWS_NUM: 10
REMOVAL_CONFIG_RULES: "[{ scaleUpLimit: 0.6, minInstanceNum: 1, errorRate: 0.6 , key: default-rule}]"
SERVER_PORT: 28020
DUBBO_PROTOCOL_PORT: 28820
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=dubbo-integration-consumer -jar \
sermant-integration-tests/dubbo-test/dubbo-${{ env.projectPath }}-integration-consumer/target/dubbo-integration-consumer.jar > ${{ env.logDir }}/removal-consumer-28050.log 2>&1 &
- name: waiting for services start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:28020/actuator/health 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:28021/actuator/health 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:28022/actuator/health 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:28023/actuator/health 120
- name: removal test
shell: bash
env:
TEST_TYPE: removal
run: mvn test --file sermant-integration-tests/dubbo-test/pom.xml
- name: exit
if: always()
uses: ./.github/actions/common/exit
with:
processor-keyword: dubbo
- name: upload error log
uses: actions/upload-artifact@v3
if: ${{ failure() || cancelled() }}
with:
name: removal-(${{ matrix.dubbo-version }}-${{ matrix.dubbo-versions }})-logs
path: |
./*.log
./logs/**/*.log
if-no-files-found: warn
retention-days: 2
175 changes: 175 additions & 0 deletions .github/actions/scenarios/spring/removal/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
name: "Spring Removal Test"
description: "Auto test for spring removal for plugin sermant-removal"
runs:
using: "composite"
steps:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/spring-removal
- name: 1.5.x config
if: matrix.springBootVersion == '1.5.0.RELEASE' && matrix.springCloudVersion == 'Edgware.SR2'
shell: bash
run: |
echo "tailVersion=-1.5.x" >> $GITHUB_ENV
echo "healthApi=health" >> $GITHUB_ENV
- name: 2.x config
if: matrix.springBootVersion != '1.5.0.RELEASE'
shell: bash
run: |
echo "healthApi=actuator/health" >> $GITHUB_ENV
- name: package common demos
shell: bash
run: |
sed -i 's|<version>${{ env.projectSpringBootVersion }}</version>|<version>${{ matrix.springBootVersion }}</version>|g' sermant-integration-tests/spring-test/pom.xml
mvn package -Dspring.cloud.version=${{ matrix.springCloudVersion }} -Dspring.boot.version=${{ matrix.springBootVersion }} -DskipTests -P common-test${{ env.tailVersion }} --file sermant-integration-tests/spring-test/pom.xml
- name: post config
shell: bash
run: bash ./sermant-integration-tests/scripts/createStrategy.sh all
- name: start feign provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
NIWS_LOADBALANCER_AVAILABILITY_FILTERING_RULE_FILTER_CIRCUIT_TRIPPED: false
SERVER_PORT: 8013
SPRING_APPLICATION_NAME: removal-provider
TIMEOUT: 0
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider.log 2>&1 &
- name: start second feign provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
NIWS_LOADBALANCER_AVAILABILITY_FILTERING_RULE_FILTER_CIRCUIT_TRIPPED: false
SERVER_PORT: 8014
SPRING_APPLICATION_NAME: removal-provider
TIMEOUT: 0
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider2.log 2>&1 &
- name: start third feign provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
NIWS_LOADBALANCER_AVAILABILITY_FILTERING_RULE_FILTER_CIRCUIT_TRIPPED: false
SERVER_PORT: 8015
SPRING_APPLICATION_NAME: removal-provider
TIMEOUT: 2000
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider3.log 2>&1 &
- name: start fourth feign provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
NIWS_LOADBALANCER_AVAILABILITY_FILTERING_RULE_FILTER_CIRCUIT_TRIPPED: false
SERVER_PORT: 8016
SPRING_APPLICATION_NAME: removal-provider
TIMEOUT: 2000
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-provider${{ env.tailVersion }}/target/feign-provider${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-provider4.log 2>&1 &
- name: start feign consumer service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
REMOVAL_CONFIG_EXPIRE_TIMES: 60000
REMOVAL_CONFIG_EXCEPTIONS: "[com.alibaba.dubbo.remoting.TimeoutException, org.apache.dubbo.remoting.TimeoutException, java.util.concurrent.TimeoutException, java.net.SocketTimeoutException]"
REMOVAL_CONFIG_ENABLE_REMOVAL: true
REMOVAL_CONFIG_RECOVERY_TIMES: 30000
REMOVAL_CONFIG_WINDOWS_TIMES: 1000
REMOVAL_CONFIG_WINDOWS_NUM: 10
REMOVAL_CONFIG_RULES: "[{ scaleUpLimit: 0.6, minInstanceNum: 1, errorRate: 0.6 , key: default-rule}]"
NIWS_LOADBALANCER_AVAILABILITY_FILTERING_RULE_FILTER_CIRCUIT_TRIPPED: false
SERVER_PORT: 8017
SERMANT_SPRINGBOOT_REGISTRY_LB_MAXRETRY: 0
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-feign${{ env.tailVersion }}/feign-consumer${{ env.tailVersion }}/target/feign-consumer${{ env.tailVersion }}.jar > ${{ env.logDir }}/feign-consumer.log 2>&1 &
- name: start resttemplate provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
SERVER_PORT: 8018
TIMEOUT: 0
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider.log 2>&1 &
- name: start second resttemplate provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
SERVER_PORT: 8019
TIMEOUT: 0
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider2.log 2>&1 &
- name: start third resttemplate provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
SERVER_PORT: 8020
TIMEOUT: 0
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider3.log 2>&1 &
- name: start fourth resttemplate provider service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
SERVER_PORT: 8021
TIMEOUT: 2000
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-provider/target/rest-provider.jar > ${{ env.logDir }}/rest-provider4.log 2>&1 &
- name: start resttemplate consumer service
shell: bash
env:
SERMANT_SPRINGBOOT_REGISTRY_ENABLE_REGISTRY: true
REMOVAL_CONFIG_EXPIRE_TIMES: 60000
REMOVAL_CONFIG_EXCEPTIONS: "[com.alibaba.dubbo.remoting.TimeoutException, org.apache.dubbo.remoting.TimeoutException, java.util.concurrent.TimeoutException, java.net.SocketTimeoutException]"
REMOVAL_CONFIG_ENABLE_REMOVAL: true
REMOVAL_CONFIG_RECOVERY_TIMES: 30000
REMOVAL_CONFIG_WINDOWS_TIMES: 1000
REMOVAL_CONFIG_WINDOWS_NUM: 10
REMOVAL_CONFIG_RULES: "[{ scaleUpLimit: 0.6, minInstanceNum: 1, errorRate: 0.6 , key: default-rule}]"
NIWS_LOADBALANCER_AVAILABILITY_FILTERING_RULE_FILTER_CIRCUIT_TRIPPED: false
SERVER_PORT: 8022
SERMANT_SPRINGBOOT_REGISTRY_LB_MAXRETRY: 0
TIMEOUT: 1000
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar=appName=default -jar \
sermant-integration-tests/spring-test/spring-common-demos/spring-common-resttemplate/rest-consumer/target/rest-consumer.jar > ${{ env.logDir }}/rest-consumer.log 2>&1 &
- name: waiting for services start
shell: bash
run: |
ps -ef | grep java
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8013/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8014/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8015/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8016/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8017/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8018/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8019/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8020/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8021/${{ env.healthApi }} 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8022/${{ env.healthApi }} 120
- name: integration test module REMOVAL
shell: bash
run: mvn test -Dsermant.integration.test.type=REMOVAL --file sermant-integration-tests/spring-test/pom.xml
- name: exit
if: always()
uses: ./.github/actions/common/exit
with:
processor-keyword: feign|rest
- name: if failure then upload error log
uses: actions/upload-artifact@v3
if: ${{ failure() || cancelled() }}
with:
name: (${{ github.job }})-graceful-(${{ matrix.springBootVersion }}-${{ matrix.springCloudVersion }})-logs
path: |
./*.log
./logs/**
if-no-files-found: warn
retention-days: 2
3 changes: 3 additions & 0 deletions .github/workflows/dubbo_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,6 @@ jobs:
- name: (dubbo lane) test for ${{ matrix.dubbo-version }}-${{ matrix.dubbo-versions }}
if: env.enableDubboLane == 'true'
uses: ./.github/actions/scenarios/dubbo/lane
- name: removal test for ${{ matrix.dubbo-version }}-${{ matrix.dubbo-versions }}
if: env.enableRemoval == 'true'
uses: ./.github/actions/scenarios/dubbo/removal
3 changes: 3 additions & 0 deletions .github/workflows/spring_integration_test_1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@ jobs:
- name: visibility test for springboot=${{ matrix.springBootVersion }} springCloudVersion=${{ matrix.springCloudVersion }}
if: env.enableVisibility == 'true'
uses: ./.github/actions/scenarios/spring/visibility
- name: removal test for springboot=${{ matrix.springBootVersion }} springCloudVersion=${{ matrix.springCloudVersion }}
if: env.enableRemoval == 'true'
uses: ./.github/actions/scenarios/spring/removal
3 changes: 3 additions & 0 deletions .github/workflows/spring_integration_test_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,6 @@ jobs:
- name: (spring lane) test for springboot=${{ matrix.springBootVersion }} springCloudVersion=${{ matrix.springCloudVersion }}
if: env.enableSpringLane == 'true'
uses: ./.github/actions/scenarios/spring/lane
- name: removal test for springboot=${{ matrix.springBootVersion }} springCloudVersion=${{ matrix.springCloudVersion }}
if: env.enableRemoval == 'true'
uses: ./.github/actions/scenarios/spring/removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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.
*/

package com.huaweicloud.integration.controller;

import com.huaweicloud.integration.service.RemovalService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* 离群实例摘除测试接口
*
* @author zhp
* @since 2023-03-16
*/
@RestController
@RequestMapping("/removal")
public class RemovalController {
@Resource(name = "removalService")
private RemovalService removalService;

/**
* 测试离群实例摘除接口接口
*
* @return 测试信息
*/
@GetMapping("/testReq")
public String testReq() {
return removalService.getPort();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<dubbo:protocol name="dubbo" port="${dubbo.protocol.port}"/>

<dubbo:reference id="barService" check="false" interface="com.huaweicloud.integration.service.BarService"/>
<dubbo:reference id="removalService" check="false" interface="com.huaweicloud.integration.service.RemovalService"
timeout="1000"/>
<dubbo:reference id="bar2Service" check="false" interface="com.huaweicloud.integration.service.BarService"
group="bar2"/>
<dubbo:reference id="barGenericService" check="false" interface="com.huaweicloud.integration.service.BarService"
Expand Down
Loading

0 comments on commit ee8c296

Please sign in to comment.