Skip to content

Commit d29d3eb

Browse files
committed
# This is a combination of 2 commits.
# This is the 1st commit message: [WIP]Ftr: 支持java go集成测试互通 # The commit message #2 will be skipped: # 测试java测试的输出
1 parent 863cbac commit d29d3eb

File tree

7 files changed

+113
-32
lines changed

7 files changed

+113
-32
lines changed

build/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,11 @@ integration: export DUBBO_GO_CONFIG_PATH ?= $(PROJECT_DIR)/go-client/conf/dubbog
156156
integration:
157157
$(info > Running integration test for application $(INTEGRATE_DIR))
158158
@go clean -testcache
159-
@go test -tags integration -v $(INTEGRATE_DIR)/tests/integration/...
159+
@go test -tags integration -v $(INTEGRATE_DIR)/tests/integration/...
160+
161+
## integration-java: Integration java test (for client)
162+
.PHONY: integration-java
163+
integration-java:
164+
@$(info > Running java test $(INTEGRATE_DIR), project name $(PROJECT_NAME))
165+
@chmod +x $(INTEGRATE_DIR)/tests/java/run.sh
166+
@$(shell )$(INTEGRATE_DIR)/tests/java/run.sh

helloworld/java-server/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
mvn install -DSkipTests
1+
mvn install -DSkipTests
22
mvn exec:java -Dexec.mainClass="com.apache.dubbo.sample.basic.ApiProvider"

integrate_test.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,34 @@ INTEGRATE_DIR=$(pwd)/integrate_test/$1
3232
sleep 5
3333

3434
# start server
35-
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile start
35+
make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile start
3636
# waiting for registry
3737
sleep 5
3838

3939
# start integration
40-
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile integration
40+
make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile integration
4141
result=$?
4242

4343
# if fail print server log
4444
if [ $result != 0 ];then
45-
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile print-server-log
45+
make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile print-server-log
4646
fi
4747

48+
JAVA_TEST_SHELL=$INTEGRATE_DIR/tests/java
49+
if [ -e $JAVA_TEST_SHELL ]; then
50+
echo "JAVA TEST"
51+
# run java test
52+
make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile integration-java
53+
result=$?
54+
55+
# if fail print server log
56+
if [ $result != 0 ];then
57+
make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile print-server-log
58+
fi
59+
fi
60+
61+
4862
# stop server
49-
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile clean
63+
make PROJECT_DIR=$P_DIR PROJECT_NAME=$(basename $P_DIR) INTEGRATE_DIR=$INTEGRATE_DIR -f build/Makefile clean
5064

5165
exit $((result))
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package java
19+
20+
import (
21+
"errors"
22+
"fmt"
23+
"github.com/stretchr/testify/assert"
24+
"os"
25+
"testing"
26+
)
27+
28+
func TestStart(t *testing.T) {
29+
assert.Nil(t, errors.New("test"))
30+
fmt.Println("hello world")
31+
os.Exit(1)
32+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# !/bin/bash
2+
3+
go test -tags java -v $INTEGRATE_DIR/tests/java/java_test.go
4+
exit 1

start_integrate_test.sh

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@
1818
array=("helloworld")
1919

2020
# direct
21-
array+=("direct")
22-
23-
# context
24-
array+=("context/dubbo")
25-
26-
# config-api
27-
array+=("config-api/rpc/triple")
28-
array+=("config-api/configcenter/nacos")
29-
array+=("config-api/configcenter/zookeeper")
30-
31-
# registry
32-
array+=("registry/zookeeper")
33-
array+=("registry/nacos")
34-
array+=("registry/etcd")
35-
36-
# generic
37-
array+=("generic/default")
38-
39-
# rpc
40-
array+=("rpc/dubbo")
41-
array+=("rpc/triple/codec-extension")
42-
array+=("rpc/triple/hessian2")
43-
array+=("rpc/triple/msgpack")
44-
array+=("rpc/triple/pb/dubbogo-grpc")
45-
array+=("rpc/grpc")
46-
array+=("rpc/jsonrpc")
21+
#array+=("direct")
22+
#
23+
## context
24+
#array+=("context/dubbo")
25+
#
26+
## config-api
27+
#array+=("config-api/rpc/triple")
28+
#array+=("config-api/configcenter/nacos")
29+
#array+=("config-api/configcenter/zookeeper")
30+
#
31+
## registry
32+
#array+=("registry/zookeeper")
33+
#array+=("registry/nacos")
34+
#array+=("registry/etcd")
35+
#
36+
## generic
37+
#array+=("generic/default")
38+
#
39+
## rpc
40+
#array+=("rpc/dubbo")
41+
#array+=("rpc/triple/codec-extension")
42+
#array+=("rpc/triple/hessian2")
43+
#array+=("rpc/triple/msgpack")
44+
#array+=("rpc/triple/pb/dubbogo-grpc")
45+
#array+=("rpc/grpc")
46+
#array+=("rpc/jsonrpc")
4747

4848

4949
DOCKER_DIR=$(pwd)/integrate_test/dockercompose

waiting_launch.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ]; then
4+
echo "Provide log file please, like : ./waiting_launch.sh log.sh"
5+
exit
6+
fi
7+
8+
PREV_MD5=""
9+
MD5=""
10+
11+
# wait 150s at most
12+
for ((i=1; i<=15; i++));
13+
do
14+
sleep 10s
15+
MD5=$(md5sum $1 | cut -d ' ' -f1)
16+
if [ "$PREV_MD5" = "$MD5" ]; then
17+
exit
18+
fi
19+
echo "waiting... log file md5: $MD5"
20+
PREV_MD5=$MD5
21+
done
22+
23+
echo "java-server is not launched properly, the launching log will be outputted at below: "
24+
cat $1

0 commit comments

Comments
 (0)