This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new c3cfcd71 Add test cases to verify apache/dubbo#11137 (#627)
c3cfcd71 is described below
commit c3cfcd71af2336072e052f6c9c19843b70405cd2
Author: Albumen Kevin <[email protected]>
AuthorDate: Fri Dec 16 12:36:32 2022 +0800
Add test cases to verify apache/dubbo#11137 (#627)
---
.../case-configuration.yml | 46 ++++++
.../dubbo-samples-test-11137/case-versions.conf | 24 +++
99-integration/dubbo-samples-test-11137/pom.xml | 157 +++++++++++++++++++
.../java/org/apache/dubbo/samples/FakeMain.java | 25 +++
.../org/apache/dubbo/samples/test/DemoService.java | 26 ++++
.../apache/dubbo/samples/test/DemoService2.java | 26 ++++
.../dubbo/samples/test/DemoService2Impl.java | 37 +++++
.../apache/dubbo/samples/test/DemoServiceImpl.java | 37 +++++
.../org/apache/dubbo/samples/test/NacosIT.java | 171 +++++++++++++++++++++
.../org/apache/dubbo/samples/test/ZookeeperIT.java | 171 +++++++++++++++++++++
.../src/test/resources/log4j.properties | 26 ++++
99-integration/pom.xml | 1 +
12 files changed, 747 insertions(+)
diff --git a/99-integration/dubbo-samples-test-11137/case-configuration.yml
b/99-integration/dubbo-samples-test-11137/case-configuration.yml
new file mode 100644
index 00000000..23fb6165
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11137/case-configuration.yml
@@ -0,0 +1,46 @@
+# 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.
+
+
+# local call through injvm, start test container only
+services:
+ zookeeper:
+ image: zookeeper:latest
+
+ nacos:
+ image: nacos/nacos-server:2.0.0
+ environment:
+ - PREFER_HOST_MODE=hostname
+ - MODE=standalone
+ - NACOS_AUTH_ENABLE=true
+ - JVM_XMS=350m
+ - JVM_XMX=350m
+ - JVM_XMN=150m
+
+ dubbo-samples-test-11096-test:
+ type: test
+ basedir: .
+ tests:
+ - "**/*IT.class"
+ systemProps:
+ - zookeeper.address=zookeeper
+ - nacos.address=nacos
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ - nacos:8848
+ depends_on:
+ - zookeeper
+ - nacos
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-test-11137/case-versions.conf
b/99-integration/dubbo-samples-test-11137/case-versions.conf
new file mode 100644
index 00000000..901e42fb
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11137/case-versions.conf
@@ -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.1.0 ]
+spring.version=4.*, 5.*
diff --git a/99-integration/dubbo-samples-test-11137/pom.xml
b/99-integration/dubbo-samples-test-11137/pom.xml
new file mode 100644
index 00000000..85678461
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11137/pom.xml
@@ -0,0 +1,157 @@
+<?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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>23</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-test-11137</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Dubbo Samples Test For Issue 11137</name>
+ <description>Dubbo Samples Test For Issue 11137</description>
+
+ <properties>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <dubbo.version>3.1.4-SNAPSHOT</dubbo.version>
+ <spring.version>4.3.16.RELEASE</spring.version>
+ <junit.version>4.12</junit.version>
+ <awaitility.version>4.2.0</awaitility.version>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-nacos-merge-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-framework-bom</artifactId>
+ <version>${spring.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ </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>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>${awaitility.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </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>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${source.level}</source>
+ <target>${target.level}</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git
a/99-integration/dubbo-samples-test-11137/src/main/java/org/apache/dubbo/samples/FakeMain.java
b/99-integration/dubbo-samples-test-11137/src/main/java/org/apache/dubbo/samples/FakeMain.java
new file mode 100644
index 00000000..acd29c76
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/main/java/org/apache/dubbo/samples/FakeMain.java
@@ -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.samples;
+
+public class FakeMain {
+ public static void main(String[] args) {
+
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService.java
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService.java
new file mode 100644
index 00000000..d61f54ab
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService.java
@@ -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.
+ *
+ */
+
+package org.apache.dubbo.samples.test;
+
+public interface DemoService {
+
+ String sayHello(String name);
+
+}
diff --git
a/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService2.java
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService2.java
new file mode 100644
index 00000000..7b02c778
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService2.java
@@ -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.
+ *
+ */
+
+package org.apache.dubbo.samples.test;
+
+public interface DemoService2 {
+
+ String sayHello(String name);
+
+}
diff --git
a/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService2Impl.java
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService2Impl.java
new file mode 100644
index 00000000..e8b5d85a
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoService2Impl.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.test;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class DemoService2Impl implements DemoService2 {
+
+ private final AtomicInteger atomicInteger = new AtomicInteger();
+
+ @Override
+ public String sayHello(String name) {
+ atomicInteger.incrementAndGet();
+ return "Hello " + name;
+ }
+
+ public AtomicInteger getAtomicInteger() {
+ return atomicInteger;
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java
new file mode 100644
index 00000000..138f7e8c
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.test;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class DemoServiceImpl implements DemoService {
+
+ private final AtomicInteger atomicInteger = new AtomicInteger();
+
+ @Override
+ public String sayHello(String name) {
+ atomicInteger.incrementAndGet();
+ return "Hello " + name;
+ }
+
+ public AtomicInteger getAtomicInteger() {
+ return atomicInteger;
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/NacosIT.java
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/NacosIT.java
new file mode 100644
index 00000000..aacfa60c
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/NacosIT.java
@@ -0,0 +1,171 @@
+/*
+ *
+ * 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.test;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.awaitility.Awaitility.await;
+
+public class NacosIT {
+ private static final String nacosAddress = "nacos://" +
System.getProperty("nacos.address", "127.0.0.1") +
":8848?namingLoadCacheAtStart=false&username=nacos&password=nacos";
+ private static final String providerNamePrefix = "provider" +
System.currentTimeMillis();
+
+ @Test
+ public void test() {
+ FrameworkModel frameworkModel1 = new FrameworkModel();
+ FrameworkModel frameworkModel2 = new FrameworkModel();
+ FrameworkModel frameworkModel3 = new FrameworkModel();
+ FrameworkModel frameworkModel4 = new FrameworkModel();
+
+ DemoServiceImpl demoService11 = new DemoServiceImpl();
+ DemoServiceImpl demoService12 = new DemoServiceImpl();
+ DemoServiceImpl demoService13 = new DemoServiceImpl();
+
+ DemoService2Impl demoService21 = new DemoService2Impl();
+ DemoService2Impl demoService22 = new DemoService2Impl();
+ DemoService2Impl demoService23 = new DemoService2Impl();
+
+ ServiceConfig<DemoService> serviceConfig11 = new ServiceConfig<>();
+ serviceConfig11.setInterface(DemoService.class);
+ serviceConfig11.setRef(demoService11);
+
+ ServiceConfig<DemoService2> serviceConfig21 = new ServiceConfig<>();
+ serviceConfig21.setInterface(DemoService2.class);
+ serviceConfig21.setRef(demoService21);
+
+ ApplicationConfig applicationConfig1 = new ApplicationConfig();
+ applicationConfig1.setName(providerNamePrefix + "-1");
+ applicationConfig1.setRegisterMode("instance");
+
+ DubboBootstrap.getInstance(frameworkModel1.newApplication())
+ .application(applicationConfig1)
+ .protocol(new ProtocolConfig("dubbo", 20881))
+ .service(serviceConfig11)
+ .service(serviceConfig21)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ ReferenceConfig<DemoService> referenceConfig1 = new
ReferenceConfig<>();
+ referenceConfig1.setInterface(DemoService.class);
+ referenceConfig1.setScope("remote");
+ ReferenceConfig<DemoService2> referenceConfig2 = new
ReferenceConfig<>();
+ referenceConfig2.setInterface(DemoService2.class);
+ referenceConfig2.setScope("remote");
+
+ DubboBootstrap.getInstance(frameworkModel2.newApplication())
+ .application("consumer")
+ .reference(referenceConfig1)
+ .reference(referenceConfig2)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ DemoService demoService1 = referenceConfig1.get();
+ Assert.assertEquals("Hello world", demoService1.sayHello("world"));
+
+ DemoService2 demoService2 = referenceConfig2.get();
+ Assert.assertEquals("Hello world", demoService2.sayHello("world"));
+
+ Assert.assertEquals(1, demoService11.getAtomicInteger().get());
+ Assert.assertEquals(1, demoService21.getAtomicInteger().get());
+
+ ServiceConfig<DemoService> serviceConfig12 = new ServiceConfig<>();
+ serviceConfig12.setInterface(DemoService.class);
+ serviceConfig12.setRef(demoService12);
+
+ ServiceConfig<DemoService2> serviceConfig22 = new ServiceConfig<>();
+ serviceConfig22.setInterface(DemoService2.class);
+ serviceConfig22.setRef(demoService22);
+
+ ApplicationConfig applicationConfig2 = new ApplicationConfig();
+ applicationConfig2.setName(providerNamePrefix + "-2");
+ applicationConfig2.setRegisterMode("instance");
+
+ DubboBootstrap.getInstance(frameworkModel3.newApplication())
+ .application(applicationConfig2)
+ .protocol(new ProtocolConfig("dubbo", 20882))
+ .service(serviceConfig12)
+ .service(serviceConfig22)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService1.sayHello("world");
+ }
+ return demoService12.getAtomicInteger().get() > 0;
+ });
+
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService2.sayHello("world");
+ }
+ return demoService22.getAtomicInteger().get() > 0;
+ });
+
+
+ ServiceConfig<DemoService> serviceConfig13 = new ServiceConfig<>();
+ serviceConfig13.setInterface(DemoService.class);
+ serviceConfig13.setRef(demoService13);
+
+ ServiceConfig<DemoService2> serviceConfig23 = new ServiceConfig<>();
+ serviceConfig23.setInterface(DemoService2.class);
+ serviceConfig23.setRef(demoService23);
+
+ ApplicationConfig applicationConfig3 = new ApplicationConfig();
+ applicationConfig3.setName(providerNamePrefix + "-1");
+ applicationConfig3.setRegisterMode("instance");
+
+ DubboBootstrap.getInstance(frameworkModel1.newApplication())
+ .application(applicationConfig3)
+ .protocol(new ProtocolConfig("dubbo", 20883))
+ .service(serviceConfig13)
+ .service(serviceConfig23)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService1.sayHello("world");
+ }
+ return demoService13.getAtomicInteger().get() > 0;
+ });
+
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService2.sayHello("world");
+ }
+ return demoService23.getAtomicInteger().get() > 0;
+ });
+
+ frameworkModel2.destroy();
+ frameworkModel1.destroy();
+ frameworkModel3.destroy();
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/ZookeeperIT.java
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/ZookeeperIT.java
new file mode 100644
index 00000000..7d6ad7ca
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/test/java/org/apache/dubbo/samples/test/ZookeeperIT.java
@@ -0,0 +1,171 @@
+/*
+ *
+ * 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.test;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.awaitility.Awaitility.await;
+
+public class ZookeeperIT {
+ private static final String nacosAddress = "zookeeper://" +
System.getProperty("zookeeper.address", "127.0.0.1") + ":2181";
+ private static final String providerNamePrefix = "provider" +
System.currentTimeMillis();
+
+ @Test
+ public void test() {
+ FrameworkModel frameworkModel1 = new FrameworkModel();
+ FrameworkModel frameworkModel2 = new FrameworkModel();
+ FrameworkModel frameworkModel3 = new FrameworkModel();
+ FrameworkModel frameworkModel4 = new FrameworkModel();
+
+ DemoServiceImpl demoService11 = new DemoServiceImpl();
+ DemoServiceImpl demoService12 = new DemoServiceImpl();
+ DemoServiceImpl demoService13 = new DemoServiceImpl();
+
+ DemoService2Impl demoService21 = new DemoService2Impl();
+ DemoService2Impl demoService22 = new DemoService2Impl();
+ DemoService2Impl demoService23 = new DemoService2Impl();
+
+ ServiceConfig<DemoService> serviceConfig11 = new ServiceConfig<>();
+ serviceConfig11.setInterface(DemoService.class);
+ serviceConfig11.setRef(demoService11);
+
+ ServiceConfig<DemoService2> serviceConfig21 = new ServiceConfig<>();
+ serviceConfig21.setInterface(DemoService2.class);
+ serviceConfig21.setRef(demoService21);
+
+ ApplicationConfig applicationConfig1 = new ApplicationConfig();
+ applicationConfig1.setName(providerNamePrefix + "-1");
+ applicationConfig1.setRegisterMode("instance");
+
+ DubboBootstrap.getInstance(frameworkModel1.newApplication())
+ .application(applicationConfig1)
+ .protocol(new ProtocolConfig("dubbo", 20881))
+ .service(serviceConfig11)
+ .service(serviceConfig21)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ ReferenceConfig<DemoService> referenceConfig1 = new
ReferenceConfig<>();
+ referenceConfig1.setInterface(DemoService.class);
+ referenceConfig1.setScope("remote");
+ ReferenceConfig<DemoService2> referenceConfig2 = new
ReferenceConfig<>();
+ referenceConfig2.setInterface(DemoService2.class);
+ referenceConfig2.setScope("remote");
+
+ DubboBootstrap.getInstance(frameworkModel2.newApplication())
+ .application("consumer")
+ .reference(referenceConfig1)
+ .reference(referenceConfig2)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ DemoService demoService1 = referenceConfig1.get();
+ Assert.assertEquals("Hello world", demoService1.sayHello("world"));
+
+ DemoService2 demoService2 = referenceConfig2.get();
+ Assert.assertEquals("Hello world", demoService2.sayHello("world"));
+
+ Assert.assertEquals(1, demoService11.getAtomicInteger().get());
+ Assert.assertEquals(1, demoService21.getAtomicInteger().get());
+
+ ServiceConfig<DemoService> serviceConfig12 = new ServiceConfig<>();
+ serviceConfig12.setInterface(DemoService.class);
+ serviceConfig12.setRef(demoService12);
+
+ ServiceConfig<DemoService2> serviceConfig22 = new ServiceConfig<>();
+ serviceConfig22.setInterface(DemoService2.class);
+ serviceConfig22.setRef(demoService22);
+
+ ApplicationConfig applicationConfig2 = new ApplicationConfig();
+ applicationConfig2.setName(providerNamePrefix + "-2");
+ applicationConfig2.setRegisterMode("instance");
+
+ DubboBootstrap.getInstance(frameworkModel3.newApplication())
+ .application(applicationConfig2)
+ .protocol(new ProtocolConfig("dubbo", 20882))
+ .service(serviceConfig12)
+ .service(serviceConfig22)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService1.sayHello("world");
+ }
+ return demoService12.getAtomicInteger().get() > 0;
+ });
+
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService2.sayHello("world");
+ }
+ return demoService22.getAtomicInteger().get() > 0;
+ });
+
+
+ ServiceConfig<DemoService> serviceConfig13 = new ServiceConfig<>();
+ serviceConfig13.setInterface(DemoService.class);
+ serviceConfig13.setRef(demoService13);
+
+ ServiceConfig<DemoService2> serviceConfig23 = new ServiceConfig<>();
+ serviceConfig23.setInterface(DemoService2.class);
+ serviceConfig23.setRef(demoService23);
+
+ ApplicationConfig applicationConfig3 = new ApplicationConfig();
+ applicationConfig3.setName(providerNamePrefix + "-1");
+ applicationConfig3.setRegisterMode("instance");
+
+ DubboBootstrap.getInstance(frameworkModel1.newApplication())
+ .application(applicationConfig3)
+ .protocol(new ProtocolConfig("dubbo", 20883))
+ .service(serviceConfig13)
+ .service(serviceConfig23)
+ .registry(new RegistryConfig(nacosAddress))
+ .start();
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService1.sayHello("world");
+ }
+ return demoService13.getAtomicInteger().get() > 0;
+ });
+
+
+ await().until(()->{
+ for (int i = 0; i < 10; i++) {
+ demoService2.sayHello("world");
+ }
+ return demoService23.getAtomicInteger().get() > 0;
+ });
+
+ frameworkModel2.destroy();
+ frameworkModel1.destroy();
+ frameworkModel3.destroy();
+ }
+}
diff --git
a/99-integration/dubbo-samples-test-11137/src/test/resources/log4j.properties
b/99-integration/dubbo-samples-test-11137/src/test/resources/log4j.properties
new file mode 100644
index 00000000..d6ecd5ce
--- /dev/null
+++
b/99-integration/dubbo-samples-test-11137/src/test/resources/log4j.properties
@@ -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=info, 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
\ No newline at end of file
diff --git a/99-integration/pom.xml b/99-integration/pom.xml
index ed019a25..abf1e74c 100644
--- a/99-integration/pom.xml
+++ b/99-integration/pom.xml
@@ -43,5 +43,6 @@
<module>dubbo-samples-test-9806</module>
<module>dubbo-samples-test-10704</module>
<module>dubbo-samples-test-11096</module>
+ <module>dubbo-samples-test-11137</module>
</modules>
</project>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]