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 c492a61 check transporter connected count for VersionServiceStarIT
(#379)
c492a61 is described below
commit c492a61fa8f1605d171b365184e6d55bd728801a
Author: zrlw <[email protected]>
AuthorDate: Sat Oct 9 15:50:08 2021 +0800
check transporter connected count for VersionServiceStarIT (#379)
* check transporter connected count for VersionServiceStarIT
* reset bootstrap before testing
* enlarge WAIT_TIMEOUT for test container
* change connected count type to AtomicInteger
* revert WAIT_TIMEOUT of port checking and increase timeout default value
---
.../dubbo/samples/version/MyNettyTransporter.java | 49 ++++++++++++++++++++++
.../samples/version/VersionServiceStarIT.java | 18 ++++++++
.../internal/org.apache.dubbo.remoting.Transporter | 1 +
.../resources/spring/version-consumer-star.xml | 2 +-
test/README.md | 6 +--
.../dubbo/scenario/builder/ConfigurationImpl.java | 2 +-
6 files changed, 73 insertions(+), 5 deletions(-)
diff --git
a/dubbo-samples-version/src/test/java/org/apache/dubbo/samples/version/MyNettyTransporter.java
b/dubbo-samples-version/src/test/java/org/apache/dubbo/samples/version/MyNettyTransporter.java
new file mode 100644
index 0000000..73cdb5e
--- /dev/null
+++
b/dubbo-samples-version/src/test/java/org/apache/dubbo/samples/version/MyNettyTransporter.java
@@ -0,0 +1,49 @@
+/*
+ * 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.version;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.remoting.ChannelHandler;
+import org.apache.dubbo.remoting.Client;
+import org.apache.dubbo.remoting.RemotingException;
+import org.apache.dubbo.remoting.transport.netty4.NettyTransporter;
+
+public class MyNettyTransporter extends NettyTransporter {
+
+ public static final String NAME = "myNetty";
+
+ private static AtomicInteger connectedCount = new AtomicInteger(0);
+
+ @Override
+ public Client connect(URL url, ChannelHandler handler) throws
RemotingException {
+ Client client = super.connect(url, handler);
+ if (client.isConnected()) {
+ connectedCount.incrementAndGet();
+ }
+ return client;
+ }
+
+ public static int getConnectedCount() {
+ return connectedCount.get();
+ }
+
+ public static void reset() {
+ connectedCount.set(0);
+ }
+}
diff --git
a/dubbo-samples-version/src/test/java/org/apache/dubbo/samples/version/VersionServiceStarIT.java
b/dubbo-samples-version/src/test/java/org/apache/dubbo/samples/version/VersionServiceStarIT.java
index dd1704e..331d8d4 100644
---
a/dubbo-samples-version/src/test/java/org/apache/dubbo/samples/version/VersionServiceStarIT.java
+++
b/dubbo-samples-version/src/test/java/org/apache/dubbo/samples/version/VersionServiceStarIT.java
@@ -17,9 +17,11 @@
package org.apache.dubbo.samples.version;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.samples.version.api.VersionService;
import org.junit.Assert;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,12 +34,28 @@ public class VersionServiceStarIT {
@Autowired
private VersionService service;
+ @BeforeClass
+ public static void setUp() {
+ DubboBootstrap.reset();
+ MyNettyTransporter.reset();
+ }
+
@Test
public void test() throws Exception {
+ for (int i = 0; i < 10; i++) {
+ System.out.println("transporter connected count: " +
MyNettyTransporter.getConnectedCount());
+ if (2 == MyNettyTransporter.getConnectedCount()) {
+ break;
+ }
+ Thread.sleep(200);
+ }
+ Assert.assertEquals(2, MyNettyTransporter.getConnectedCount());
+
boolean version1 = false;
boolean version2 = false;
for (int i = 0; i < 10; i++) {
String result = service.sayHello("dubbo");
+ System.out.println("result: " + result);
if (result.equals("hello, dubbo")) {
version1 = true;
}
diff --git
a/dubbo-samples-version/src/test/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Transporter
b/dubbo-samples-version/src/test/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Transporter
new file mode 100644
index 0000000..9e51393
--- /dev/null
+++
b/dubbo-samples-version/src/test/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.Transporter
@@ -0,0 +1 @@
+myNetty=org.apache.dubbo.samples.version.MyNettyTransporter
\ No newline at end of file
diff --git
a/dubbo-samples-version/src/test/resources/spring/version-consumer-star.xml
b/dubbo-samples-version/src/test/resources/spring/version-consumer-star.xml
index 35fdb52..03858a8 100644
--- a/dubbo-samples-version/src/test/resources/spring/version-consumer-star.xml
+++ b/dubbo-samples-version/src/test/resources/spring/version-consumer-star.xml
@@ -27,6 +27,6 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <dubbo:reference id="versionService"
interface="org.apache.dubbo.samples.version.api.VersionService" version="*"/>
+ <dubbo:reference id="versionService"
interface="org.apache.dubbo.samples.version.api.VersionService" version="*"
client="myNetty"/>
</beans>
diff --git a/test/README.md b/test/README.md
index 16ace77..cba7840 100644
--- a/test/README.md
+++ b/test/README.md
@@ -223,12 +223,12 @@ A scenario is a complete test environment, including
docker-compose.yml, scenari
* Scenario running timeout
- Default running timeout is 90s. Some test cases require more time, you can
modify it in the following way.
+ Default running timeout is 200s. Some test cases require more time, you can
modify it in the following way.
- Change timeout in `case-configuration.yml`:
+ Set timeout in `case-configuration.yml`:
```
- timeout: 120
+ timeout: 300
```
#### Logs
diff --git
a/test/dubbo-scenario-builder/src/main/java/org/apache/dubbo/scenario/builder/ConfigurationImpl.java
b/test/dubbo-scenario-builder/src/main/java/org/apache/dubbo/scenario/builder/ConfigurationImpl.java
index 5141cf2..1c9894d 100644
---
a/test/dubbo-scenario-builder/src/main/java/org/apache/dubbo/scenario/builder/ConfigurationImpl.java
+++
b/test/dubbo-scenario-builder/src/main/java/org/apache/dubbo/scenario/builder/ConfigurationImpl.java
@@ -72,7 +72,7 @@ public class ConfigurationImpl implements IConfiguration {
private String configBasedir;
private String scenarioName;
private final String scenarioLogDir;
- private int scenarioTimeout = 120;
+ private int scenarioTimeout = 200;
private int javaDebugPort = 20660;
private int debugTimeout = 36000;
private Set<Pattern> debugPatterns = new HashSet<>();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]