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

【UT】add ut for spring cloud router plugin #758

Merged
merged 3 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 61 additions & 28 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dubbo-version: [ '2-6','2-7' ]
dubbo-versions: [ '0','1','3','5','6','7','8','9','10','11','12' ]
dubbo-version: ['2-6','2-7']
dubbo-versions: ['0','1','3','5','6','7','8','9','10','11','12']
include:
- dubbo-version: '2-6'
dubbo-versions: '2'
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
tar -zxf apache-zookeeper-3.8.0-bin.tar.gz
bash apache-zookeeper-3.8.0-bin/bin/zkServer.sh start apache-zookeeper-3.8.0-bin/conf/zoo_sample.cfg
- name: package agent
run: mvn package -DskipTests -Pagent --file pom.xml
run: sed -i '/sermant-backend/d' pom.xml & mvn package -DskipTests -Pagent --file pom.xml
- name: package dubbo 2.6.0 tests
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
Expand All @@ -65,44 +65,77 @@ jobs:
servicecomb.service.enableDubboRegister: true
servicecomb.service.enableSpringRegister: true
servicecomb.service.openMigration: false
service.meta.environment: testing
server.port: 38020
dubbo.protocol.port: 38820
run: nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-provider -jar sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar &
SERVICE_META_ENVIRONMENT: testing
SERVER_PORT: 38020
DUBBO_PROTOCOL_PORT: 38820
run: |
nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-provider -jar \
sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar > spring-and-dubbo-provider.log 2>&1 &
- name: start second spring and dubbo provider service
env:
servicecomb.service.enableDubboRegister: true
servicecomb.service.enableSpringRegister: true
servicecomb.service.openMigration: false
service.meta.environment: testing
server.port: 38021
dubbo.protocol.port: 38821
run: nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-provider -jar sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar &
- name: start spring and dubbo consumer service
env:
servicecomb.service.enableDubboRegister: true
servicecomb.service.enableSpringRegister: true
servicecomb.service.openMigration: false
service.meta.environment: testing
server.port: 38022
dubbo.protocol.port: 38822
run: nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-consumer -jar sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-consumer/target/dubbo-integration-consumer.jar &
SERVICE_META_ENVIRONMENT: testing
SERVER_PORT: 38021
DUBBO_PROTOCOL_PORT: 38821
run: |
nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-provider -jar \
sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar > spring-and-dubbo-provider2.log 2>&1 &
- name: start provider service
env:
servicecomb.service.enableDubboRegister: true
servicecomb.service.openMigration: false
run: nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-provider -jar sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar &
run: |
nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-provider -jar \
sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar > dubbo-provider.log 2>&1 &
- name: start zookeeper provider service
env:
server.port: 48021
dubbo.protocol.port: 48821
run: nohup java -jar sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar &
SERVER_PORT: 48021
DUBBO_PROTOCOL_PORT: 48821
run: |
nohup java -jar sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-provider/target/dubbo-integration-provider.jar > dubbo-zk-provider.log 2>&1 &
- name: waiting for providers start
run: |
ps -ef | grep java
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:48021/ping 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:28021/ping 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:38021/ping 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:38020/ping 120
ps -ef | grep java
- name: start spring and dubbo consumer service
env:
servicecomb.service.enableDubboRegister: true
servicecomb.service.enableSpringRegister: true
servicecomb.service.openMigration: false
SERVICE_META_ENVIRONMENT: testing
SERVER_PORT: 38022
DUBBO_PROTOCOL_PORT: 38822
run: |
nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-consumer -jar \
sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-consumer/target/dubbo-integration-consumer.jar > spring-and-dubbo-consumer.log 2>&1 &
- name: start consumer service
env:
servicecomb.service.enableDubboRegister: true
servicecomb.service.openMigration: true
run: nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-consumer -jar sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-consumer/target/dubbo-integration-consumer.jar &
- name: waiting for services start
run: sleep 60s
run: |
nohup java -javaagent:sermant-agent-1.0.0/agent/sermant-agent.jar=appName=dubbo-integration-consumer -jar \
sermant-integration-tests/dubbo-test/dubbo-${{ matrix.dubbo-version }}-integration-consumer/target/dubbo-integration-consumer.jar > dubbo-consumer.log 2>&1 &
- name: waiting for consumers start
run: |
ps -ef | grep java
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:38022/ping 120
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:28820/ping 120
ps -ef | grep java
- name: integration test
run: mvn -Dcontroller.port=38022 test --file sermant-integration-tests/dubbo-test/pom.xml
run: mvn -Dcontroller.port=38022 test --file sermant-integration-tests/dubbo-test/pom.xml
- name: if failure then upload error log
uses: actions/upload-artifact@v3
if: failure()
with:
name: (test-for-dubbo)-(${{ matrix.dubbo-version }}-${{ matrix.dubbo-versions }})-logs
path: |
./*.log
./logs/**/*.log
if-no-files-found: warn
retention-days: 5
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ server:
port: 28021
dubbo:
protocol:
port: 28821
port: ${DUBBO_PROTOCOL_PORT:28821}

spring:
application:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dubbo:
application:
name: dubbo-integration-provider
protocol:
port: 28821
port: ${DUBBO_PROTOCOL_PORT:28821}
name: dubbo
registry:
# 模拟存量dubbo应用注册到zookeeper的情况,新开发的应用建议配置为 sc://127.0.0.1:30100
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2022-2022 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 org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* PingController
*
* @author provenceee
* @since 2022-09-13
*/
@RestController
@Lazy
public class PingController {
/**
* 测试方法
*
* @return msg
*/
@GetMapping("ping")
public String ping() {
return "ok";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
* 测试dubbo接口
Expand Down Expand Up @@ -87,14 +88,15 @@ public void testTag() {
* 测试多注册中心
*/
@Test
public void testMultipleRegistry() {
public void testMultipleRegistry() throws InterruptedException {
// 因为多注册中心是随机选择一个注册中心的节点进行访问,所以这里访问100次,这个用例失败并不一定真的失败,需要详细分析
Set<String> set = new HashSet<>();
for (int i = 0; i <= 100; i++) {
set.add(REST_TEMPLATE.getForObject(BASE_URL + "getRegistryProtocol", String.class));
if (set.size() >= 2) {
break;
}
TimeUnit.SECONDS.sleep(1);
}
Assertions.assertTrue(set.size() >= 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.huaweicloud.sermant.core.plugin.agent.matcher.ClassMatcher;

/**
* 增强AbstractDirectory的子类的doList方法,筛选灰度应用的地址
* 增强AbstractDirectory的子类的doList方法,筛选标签应用的地址
*
* @author provenceee
* @since 2021-06-28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.huaweicloud.sermant.router.dubbo.service.AbstractDirectoryService;

/**
* 增强AbstractDirectory的子类的doList方法,筛选灰度应用的地址
* 增强AbstractDirectory的子类的doList方法,筛选标签应用的地址
*
* @author provenceee
* @since 2021-06-28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public interface AbstractDirectoryService extends PluginService {
/**
* 筛选灰度invoker
* 筛选标签invoker
*
* @param obj RegistryDirectory
* @param arguments 参数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public interface ApplicationConfigService extends PluginService {
/**
* 获取dubbo服务名,并设置灰度参数
* 获取dubbo服务名,并设置标签
*
* @param obj 增强的类
* @see com.alibaba.dubbo.config.ApplicationConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public interface ClusterService extends PluginService {
/**
* 从url中缓存接口与下游服务名的映射关系,从map中删除灰度发布相关的参数
* 从url中缓存接口与下游服务名的映射关系,从map中删除标签相关的参数
*
* @param arguments 请求参数
*/
Expand Down
Loading