Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #366 from guohao/add-dubbo-samples-migration
[ISSUE-365] Add dubbo-samples-migration
- Loading branch information
Showing
23 changed files
with
943 additions
and
30 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
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
@@ -0,0 +1,34 @@ | ||
## Compatibility Testing Scenario Usage | ||
Pre-requirements: Both provider and consumer can not use the same `POM`, because you cannot guarantee that all the codes you write Dubbo 2.0 and 3.0 support at the same time, they must be divided into two independent projects. This is also applicable in daily business compatibility testing | ||
|
||
Add new grammar to `case-versions.conf`: | ||
```yaml | ||
# 原常规配置 | ||
# dubbo.version=2.7*, 3.* | ||
spring.version=4.*, 5.* | ||
# 支持不同的 servcie 应用,配置不同的 dubbo 版本依赖,与 dubbo.version 二选一 | ||
# 为防止构建用例倍级增长,不建议配置多个版本 | ||
# dubbo.{service}.verison 中的 service 可以任意自定义 | ||
dubbo.provider.version=3.* | ||
dubbo.consumer.version=2.7.* | ||
``` | ||
And then in each consumer and provider project, you can configure `POM`'s properties as follows: | ||
```xml | ||
# consumer side | ||
<properties> | ||
<dubbo.consumer.version>2.7.13</dubbo.consumer.version> | ||
</properties> | ||
|
||
# provider side | ||
<properties> | ||
<dubbo.provider.version>2.7.13</dubbo.provider.version> | ||
</properties> | ||
``` | ||
|
||
When the Integration Tests trigger, these properties will be overwritten by maven, for example: | ||
```shell | ||
mvn -Ddubbo.provider.version=3.0.3-SNAPSHOT -Ddubbo.consumer.version=2.7.13 -Dspring.version=4.3.16.RELEASE | ||
``` | ||
|
||
|
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
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-samples-migration-api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
|
||
</project> |
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
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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.migration.api; | ||
|
||
public interface GreeterService { | ||
|
||
/** | ||
* Sends a greeting | ||
*/ | ||
HelloReply sayHello(HelloRequest request); | ||
} |
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
@@ -0,0 +1,18 @@ | ||
package org.apache.dubbo.migration.api; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* HelloReply | ||
*/ | ||
public class HelloReply implements Serializable { | ||
private String message; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
} |
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
@@ -0,0 +1,18 @@ | ||
package org.apache.dubbo.migration.api; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* HelloRequest | ||
*/ | ||
public class HelloRequest implements Serializable { | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
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
@@ -0,0 +1,50 @@ | ||
# 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. | ||
|
||
props: | ||
app_provider: dubbo-samples-migration-provider | ||
app_provider_main_class: org.apache.dubbo.migration.provider.ApiProvider | ||
app_consumer: dubbo-samples-migration-consumer | ||
zookeeper_port: 2181 | ||
dubbo_port: 20880 | ||
|
||
services: | ||
${app_provider}: | ||
type: app | ||
basedir: ../${app_provider} | ||
mainClass: ${app_provider_main_class} | ||
systemProps: | ||
- dubbo.current.protocol=dubbo | ||
- zookeeper.address=${app_provider} | ||
- dubbo.application.register-mode=all | ||
checkPorts: | ||
- ${zookeeper_port} | ||
- ${dubbo_port} | ||
checkLog: "dubbo service started" | ||
|
||
${app_consumer}-test: | ||
type: test | ||
basedir: ../${app_consumer} | ||
tests: | ||
- "**/*IT.class" | ||
systemProps: | ||
- dubbo.current.protocol=dubbo | ||
- zookeeper.address=${app_provider} | ||
waitPortsBeforeRun: | ||
- ${app_provider}:${zookeeper_port} | ||
- ${app_provider}:${dubbo_port} | ||
depends_on: | ||
- ${app_provider} |
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
@@ -0,0 +1,26 @@ | ||
# | ||
# | ||
# 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 | ||
spring.version=4.*, 5.* | ||
|
||
# Support Compatibility test | ||
dubbo.provider.version=3.* | ||
dubbo.consumer.version=2.7.* |
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
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>dubbo-samples-migration-case-default</artifactId> | ||
<groupId>org.apache.dubbo</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>../dubbo-samples-migration-api</module> | ||
<module>../dubbo-samples-migration-provider</module> | ||
<module>../dubbo-samples-migration-consumer</module> | ||
</modules> | ||
</project> |
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
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>dubbo-samples-migration-consumer</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<dubbo.consumer.version>2.7.13</dubbo.consumer.version> | ||
<junit.version>4.12</junit.version> | ||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version> | ||
<source.level>1.8</source.level> | ||
<target.level>1.8</target.level> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-bom</artifactId> | ||
<version>${dubbo.consumer.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-dependencies-zookeeper</artifactId> | ||
<version>${dubbo.consumer.version}</version> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-dependencies-bom</artifactId> | ||
<version>${dubbo.consumer.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-dependencies-zookeeper</artifactId> | ||
<type>pom</type> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-samples-migration-api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<!-- For jdk 11 above JavaEE annotation --> | ||
<profile> | ||
<id>javax.annotation</id> | ||
<activation> | ||
<jdk>[1.11,)</jdk> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
<version>1.3.2</version> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
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
@@ -0,0 +1,26 @@ | ||
# | ||
# | ||
# 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. | ||
# | ||
# | ||
|
||
###set log levels### | ||
log4j.rootLogger=debug, stdout | ||
###output to the 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 |
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
@@ -0,0 +1,44 @@ | ||
package org.apache.dubbo.migration.consumer; | ||
|
||
import org.apache.dubbo.common.constants.CommonConstants; | ||
import org.apache.dubbo.config.ApplicationConfig; | ||
import org.apache.dubbo.config.ReferenceConfig; | ||
import org.apache.dubbo.config.RegistryConfig; | ||
import org.apache.dubbo.config.bootstrap.DubboBootstrap; | ||
import org.apache.dubbo.migration.api.GreeterService; | ||
import org.apache.dubbo.migration.api.HelloReply; | ||
import org.apache.dubbo.migration.api.HelloRequest; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Consumer test side | ||
*/ | ||
public class ApiConsumerIT { | ||
@Test | ||
public void consumeInvoke() { | ||
String curProtocol = System.getProperty("dubbo.current.protocol", CommonConstants.DUBBO); | ||
String zookeeperAddress = System.getProperty("zookeeper.address", "127.0.0.1"); | ||
|
||
ReferenceConfig<GreeterService> referenceConfig = new ReferenceConfig<>(); | ||
referenceConfig.setInterface(GreeterService.class); | ||
referenceConfig.setCheck(false); | ||
referenceConfig.setProtocol(curProtocol); | ||
referenceConfig.setLazy(true); | ||
referenceConfig.setTimeout(100000); | ||
|
||
DubboBootstrap bootstrap = DubboBootstrap.getInstance(); | ||
bootstrap.application(new ApplicationConfig("dubbo-samples-migration-consumer")) | ||
.registry(new RegistryConfig("zookeeper://" + zookeeperAddress + ":2181")) | ||
.reference(referenceConfig) | ||
.start(); | ||
|
||
GreeterService greeterService = referenceConfig.get(); | ||
HelloRequest helloRequest = new HelloRequest(); | ||
helloRequest.setName(curProtocol); | ||
final HelloReply reply = greeterService.sayHello(helloRequest); | ||
|
||
Assert.assertEquals("Hello " + curProtocol, reply.getMessage()); | ||
} | ||
} |
Oops, something went wrong.