Skip to content
Permalink
Browse files
Merge remote-tracking branch 'origin/master'
  • Loading branch information
chickenlj committed Jul 15, 2021
2 parents 417d88a + b6b3599 commit b6d089f8c46611c6d126bbafd3b85cfdc20cd961
Showing 62 changed files with 1,476 additions and 141 deletions.
@@ -29,7 +29,7 @@ Dubbo integration test base on docker container, and relies on an image used to

Integration test leverages [docker](https://docs.docker.com/get-started/) to setup test environment, more accurately, to start dubbo provider instance, and any other supporting systems like registry center if necessary, in docker.

Please install `docker` and `docker-compose` first, then build the test image `dubb/sample-test`.
Please install `docker` and `docker-compose` first, then build the test image `dubbo/sample-test`.

```bash
cd dubbo-samples
@@ -52,9 +52,9 @@ Then we use the `run-tests.sh` script to run the test cases.
cd dubbo-samples
./test/run-tests.sh <project.basedir>
```

For example, run the `dubbo-samples-annotation` test case:

```
./test/run-tests.sh dubbo-samples-annotation
```
@@ -1,3 +1,21 @@
/*
*
* 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.
*
*/
package org.apache.dubbo.samples.governance;

import org.apache.dubbo.rpc.RpcContext;
@@ -41,7 +41,7 @@
<skip_maven_deploy>true</skip_maven_deploy>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<spring.version>4.3.16.RELEASE</spring.version>
<dubbo.version>3.0.0-SNAPSHOT</dubbo.version>
<dubbo.version>3.0.0</dubbo.version>
<junit.version>4.12</junit.version>
</properties>

@@ -0,0 +1,65 @@
# 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.

timeout: 240

services:
zookeeper:
image: zookeeper:latest

servicediscovery-migration-provider1:
type: app
basedir: dubbo-servicediscovery-migration-provider1
mainClass: org.apache.dubbo.demo.provider.Application
systemProps:
- zookeeper.address=zookeeper
waitPortsBeforeRun:
- zookeeper:2181
checkPorts:
- 20881
checkLog: "dubbo service started"
depends_on:
- zookeeper

servicediscovery-migration-provider2:
type: app
basedir: dubbo-servicediscovery-migration-provider2
mainClass: org.apache.dubbo.demo.provider.Application
systemProps:
- zookeeper.address=zookeeper
waitPortsBeforeRun:
- zookeeper:2181
checkPorts:
- 20882
checkLog: "dubbo service started"
depends_on:
- zookeeper

servicediscovery-migration-consumer-test:
type: test
basedir: dubbo-servicediscovery-migration-consumer
tests:
- "**/*IT.class"
systemProps:
- zookeeper.address=zookeeper
waitPortsBeforeRun:
- zookeeper:2181
- servicediscovery-migration-provider1:20881
- servicediscovery-migration-provider2:20882
depends_on:
- zookeeper
- servicediscovery-migration-provider1
- servicediscovery-migration-provider2
@@ -0,0 +1,24 @@
#
#
# 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.
#


# Supported component versions of the test case

# Spring app
dubbo.version=3.*
spring.version=4.*, 5.*
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dubbo-servicediscovery-migration</artifactId>
<groupId>org.apache.dubbo</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-servicediscovery-migration-api</artifactId>

<packaging>jar</packaging>
<name>${project.artifactId}</name>

<properties>
<skip_maven_deploy>true</skip_maven_deploy>
</properties>

</project>
@@ -0,0 +1,23 @@
/*
* 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.
*/
package org.apache.dubbo.demo;

public interface DemoService {

String sayHello(String name);

}
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dubbo-servicediscovery-migration</artifactId>
<groupId>org.apache.dubbo</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-servicediscovery-migration-consumer</artifactId>

<packaging>jar</packaging>
<name>${project.artifactId}</name>

<properties>
<skip_maven_deploy>true</skip_maven_deploy>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-servicediscovery-migration-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
@@ -0,0 +1,48 @@
/*
* 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.
*/
package org.apache.dubbo.demo.consumer;

import org.apache.dubbo.demo.DemoService;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Application {
public static void main(String[] args) throws InterruptedException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
context.start();

UpgradeUtil.writeForceInterfaceRule();
Thread.sleep(5000);

call(context);

UpgradeUtil.writeApplicationFirstRule(100);
Thread.sleep(5000);

call(context);

}

private static void call(ClassPathXmlApplicationContext context) {
DemoService demoServiceFromNormal = context.getBean("demoServiceFromNormal", DemoService.class);
System.out.println("result: " + demoServiceFromNormal.sayHello("name"));
DemoService demoServiceFromService = context.getBean("demoServiceFromService", DemoService.class);
System.out.println("result: " + demoServiceFromService.sayHello("name"));
DemoService demoServiceFromDual = context.getBean("demoServiceFromDual", DemoService.class);
System.out.println("result: " + demoServiceFromDual.sayHello("name"));
}
}
@@ -0,0 +1,52 @@
/*
* 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.
*/
package org.apache.dubbo.demo.consumer;

import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.rpc.model.ApplicationModel;

public class UpgradeUtil {
private static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "DUBBO_SERVICEDISCOVERY_MIGRATION";

public static void writeApplicationFirstRule(int proportion) {
String content = "step: APPLICATION_FIRST\r\n" +
"proportion: " + proportion;

String RULE_KEY = ApplicationModel.getName() + ".migration";
DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
}

public static void writeForceInterfaceRule() {
String content = "step: FORCE_INTERFACE\r\n" +
"force: true";

String RULE_KEY = ApplicationModel.getName() + ".migration";
DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
}

public static void writeForceApplicationRule() {
String content = "step: FORCE_APPLICATION\r\n" +
"force: true";

String RULE_KEY = ApplicationModel.getName() + ".migration";
DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
}

}
@@ -0,0 +1 @@
dubbo.application.qos.port=33333
@@ -0,0 +1,7 @@
###set log levels###
log4j.rootLogger=info, stdout
###output to console###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n

0 comments on commit b6d089f

Please sign in to comment.