You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/10/16 07:44:53 UTC
[dubbo-go-samples] branch master updated: # This is a combination
of 2 commits. (#259)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 1d66f92 # This is a combination of 2 commits. (#259)
1d66f92 is described below
commit 1d66f920f27892bfb081bb6373a75e66cfbb7683
Author: Jason Peng <lv...@gmail.com>
AuthorDate: Sat Oct 16 15:44:46 2021 +0800
# This is a combination of 2 commits. (#259)
# This is the 1st commit message:
[WIP]Ftr: 支持java go集成测试互通
# The commit message #2 will be skipped:
# 测试java测试的输出
---
build/Makefile | 10 +++-
generic/default/java-client/run.sh | 3 +-
generic/default/java-server/run.sh | 3 +-
helloworld/java-client/run.sh | 3 +-
.../com/apache/dubbo/sample/TestHelloWorld.java | 62 ++++++++++++++++++++++
helloworld/java-server/run.sh | 3 +-
integrate_test.sh | 21 ++++++--
integrate_test/helloworld/tests/java/run.sh | 11 ++++
rpc/dubbo/java-client/run.sh | 3 +-
rpc/dubbo/java-server/run.sh | 3 +-
rpc/triple/hessian2/java-client/run.sh | 3 +-
rpc/triple/hessian2/java-server/run.sh | 3 +-
rpc/triple/pb/dubbogo-java/java-client/run.sh | 3 +-
rpc/triple/pb/dubbogo-java/java-server/run.sh | 3 +-
waiting_launch.sh | 24 +++++++++
15 files changed, 133 insertions(+), 25 deletions(-)
diff --git a/build/Makefile b/build/Makefile
index 2053976..588da0c 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -155,4 +155,12 @@ integration: export DUBBO_GO_CONFIG_PATH ?= $(PROJECT_DIR)/go-client/conf/dubbog
integration:
$(info > Running integration test for application $(INTEGRATE_DIR))
@go clean -testcache
- @go test -tags integration -v $(INTEGRATE_DIR)/tests/integration/...
\ No newline at end of file
+ @go test -tags integration -v $(INTEGRATE_DIR)/tests/integration/...
+
+## integration-java: Integration java test (for client)
+.PHONY: integration-java
+integration-java:
+ @$(info > Running java test $(INTEGRATE_DIR), project name $(PROJECT_NAME))
+ @chmod +x $(INTEGRATE_DIR)/tests/java/run.sh
+ @$(shell )$(INTEGRATE_DIR)/tests/java/run.sh $(PROJECT_DIR)/java-client
+ @exit $(.SHELLSTATUS)
\ No newline at end of file
diff --git a/generic/default/java-client/run.sh b/generic/default/java-client/run.sh
index 14cebf9..6eac45d 100644
--- a/generic/default/java-client/run.sh
+++ b/generic/default/java-client/run.sh
@@ -1,2 +1 @@
-mvn install -DSkipTests
-mvn exec:java -Dexec.mainClass="org.apache.dubbo.ApiConsumer"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="org.apache.dubbo.ApiConsumer"
\ No newline at end of file
diff --git a/generic/default/java-server/run.sh b/generic/default/java-server/run.sh
index 6a421b1..7fbe2f2 100644
--- a/generic/default/java-server/run.sh
+++ b/generic/default/java-server/run.sh
@@ -1,2 +1 @@
-mvn install -DSkipTests
-mvn exec:java -Dexec.mainClass="org.apache.dubbo.ApiProvider"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="org.apache.dubbo.ApiProvider"
\ No newline at end of file
diff --git a/helloworld/java-client/run.sh b/helloworld/java-client/run.sh
index 5152f3a..db8c6f6 100644
--- a/helloworld/java-client/run.sh
+++ b/helloworld/java-client/run.sh
@@ -1,2 +1 @@
-mvn install -DSkipTests
-mvn exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiConsumer"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiConsumer"
\ No newline at end of file
diff --git a/helloworld/java-client/src/test/java/com/apache/dubbo/sample/TestHelloWorld.java b/helloworld/java-client/src/test/java/com/apache/dubbo/sample/TestHelloWorld.java
new file mode 100644
index 0000000..f417963
--- /dev/null
+++ b/helloworld/java-client/src/test/java/com/apache/dubbo/sample/TestHelloWorld.java
@@ -0,0 +1,62 @@
+/*
+ * 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 com.apache.dubbo.sample;
+
+import org.junit.Test;
+import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+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.sample.hello.Helloworld;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import com.apache.dubbo.sample.basic.*;
+
+public class TestHelloWorld {
+
+ @Test
+ public void testHelloWorld() throws Exception {
+ ReferenceConfig<IGreeter> ref = new ReferenceConfig<>();
+ ref.setInterface(IGreeter.class);
+ ref.setCheck(false);
+ ref.setProtocol(CommonConstants.TRIPLE);
+ ref.setLazy(true);
+ ref.setTimeout(100000);
+ ref.setApplication(new ApplicationConfig("demo-consumer"));
+ ref.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
+ final IGreeter iGreeter = ref.get();
+
+ System.out.println("dubbo ref started");
+ Helloworld.HelloRequest req = Helloworld.HelloRequest.newBuilder().setName("laurence").build();
+ try {
+ final Helloworld.User reply = iGreeter.sayHello(req);
+ TimeUnit.SECONDS.sleep(1);
+ System.out.println("Reply:" + reply);
+ TestCase.assertEquals(reply.getName(), "Hello laurence");
+ TestCase.assertEquals(reply.getId(), "12345");
+ TestCase.assertEquals(reply.getAge(), 21);
+ } catch (IllegalStateException t) {
+ t.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/helloworld/java-server/run.sh b/helloworld/java-server/run.sh
index 939b13d..7d411b7 100644
--- a/helloworld/java-server/run.sh
+++ b/helloworld/java-server/run.sh
@@ -1,2 +1 @@
-mvn install -DSkipTests
-mvn exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiProvider"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiProvider"
\ No newline at end of file
diff --git a/integrate_test.sh b/integrate_test.sh
index 89da2a4..c6e9258 100755
--- a/integrate_test.sh
+++ b/integrate_test.sh
@@ -32,20 +32,33 @@ INTEGRATE_DIR=$(pwd)/integrate_test/$1
sleep 5
# start server
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile start
+make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile start
# waiting for registry
sleep 5
# start integration
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile integration
+make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile integration
result=$?
# if fail print server log
if [ $result != 0 ];then
- make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile print-server-log
+ make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile print-server-log
fi
+JAVA_TEST_SHELL=$INTEGRATE_DIR/tests/java
+if [ -e $JAVA_TEST_SHELL ]; then
+ # run java test
+ make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile integration-java
+ result=$?
+
+ # if fail print server log
+ if [ $result != 0 ];then
+ make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile print-server-log
+ fi
+fi
+
+
# stop server
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile clean
+make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile clean
exit $((result))
\ No newline at end of file
diff --git a/integrate_test/helloworld/tests/java/run.sh b/integrate_test/helloworld/tests/java/run.sh
new file mode 100755
index 0000000..59e64c3
--- /dev/null
+++ b/integrate_test/helloworld/tests/java/run.sh
@@ -0,0 +1,11 @@
+# !/bin/bash
+
+if [ -z "$1" ]; then
+ echo "Provide test directory please, like : ./run.sh $(pwd)/helloworld/java-server"
+ exit
+fi
+
+cd $1
+set -e
+
+mvn test
\ No newline at end of file
diff --git a/rpc/dubbo/java-client/run.sh b/rpc/dubbo/java-client/run.sh
index 5ad39b2..e7a91d0 100644
--- a/rpc/dubbo/java-client/run.sh
+++ b/rpc/dubbo/java-client/run.sh
@@ -1,2 +1 @@
-mvn clean install -DSkipTests
-mvn -e exec:java -Dexec.mainClass="org.apache.dubbo.Consumer"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="org.apache.dubbo.Consumer"
\ No newline at end of file
diff --git a/rpc/dubbo/java-server/run.sh b/rpc/dubbo/java-server/run.sh
index 555d1b3..d24d248 100644
--- a/rpc/dubbo/java-server/run.sh
+++ b/rpc/dubbo/java-server/run.sh
@@ -1,2 +1 @@
-mvn clean install -DSkipTests
-mvn -e exec:java -Dexec.mainClass="java.org.apache.dubbo.Provider"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="org.apache.dubbo.Provider"
\ No newline at end of file
diff --git a/rpc/triple/hessian2/java-client/run.sh b/rpc/triple/hessian2/java-client/run.sh
index 946b97e..db8c6f6 100644
--- a/rpc/triple/hessian2/java-client/run.sh
+++ b/rpc/triple/hessian2/java-client/run.sh
@@ -1,2 +1 @@
-mvn clean install -DSkipTests
-mvn -e exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiConsumer"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiConsumer"
\ No newline at end of file
diff --git a/rpc/triple/hessian2/java-server/run.sh b/rpc/triple/hessian2/java-server/run.sh
index 939b13d..7d411b7 100644
--- a/rpc/triple/hessian2/java-server/run.sh
+++ b/rpc/triple/hessian2/java-server/run.sh
@@ -1,2 +1 @@
-mvn install -DSkipTests
-mvn exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiProvider"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiProvider"
\ No newline at end of file
diff --git a/rpc/triple/pb/dubbogo-java/java-client/run.sh b/rpc/triple/pb/dubbogo-java/java-client/run.sh
index 5152f3a..db8c6f6 100644
--- a/rpc/triple/pb/dubbogo-java/java-client/run.sh
+++ b/rpc/triple/pb/dubbogo-java/java-client/run.sh
@@ -1,2 +1 @@
-mvn install -DSkipTests
-mvn exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiConsumer"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiConsumer"
\ No newline at end of file
diff --git a/rpc/triple/pb/dubbogo-java/java-server/run.sh b/rpc/triple/pb/dubbogo-java/java-server/run.sh
index 939b13d..7d411b7 100755
--- a/rpc/triple/pb/dubbogo-java/java-server/run.sh
+++ b/rpc/triple/pb/dubbogo-java/java-server/run.sh
@@ -1,2 +1 @@
-mvn install -DSkipTests
-mvn exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiProvider"
\ No newline at end of file
+mvn -e clean compile exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiProvider"
\ No newline at end of file
diff --git a/waiting_launch.sh b/waiting_launch.sh
new file mode 100644
index 0000000..d43f8c8
--- /dev/null
+++ b/waiting_launch.sh
@@ -0,0 +1,24 @@
+# !/bin/bash
+
+if [ -z "$1" ]; then
+ echo "Provide log file please, like : ./waiting_launch.sh log.sh"
+ exit
+fi
+
+PREV_MD5=""
+MD5=""
+
+# wait 150s at most
+for ((i=1; i<=15; i++));
+do
+ sleep 10s
+ MD5=$(md5sum $1 | cut -d ' ' -f1)
+ if [ "$PREV_MD5" = "$MD5" ]; then
+ exit
+ fi
+ echo "waiting... log file md5: $MD5"
+ PREV_MD5=$MD5
+done
+
+echo "java-server is not launched properly, the launching log will be outputted at below: "
+cat $1
\ No newline at end of file