You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2021/09/01 01:20:10 UTC

[dubbo-go-samples] branch config-enhance updated: Ftr: support new integrate_test in new dubbo samples (#215)

This is an automated email from the ASF dual-hosted git repository.

laurence pushed a commit to branch config-enhance
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git


The following commit(s) were added to refs/heads/config-enhance by this push:
     new cee9d7d  Ftr: support new integrate_test in new dubbo samples (#215)
cee9d7d is described below

commit cee9d7d85fbe5374798fd019270d690a66864082
Author: Jason Peng <lv...@gmail.com>
AuthorDate: Wed Sep 1 09:20:06 2021 +0800

    Ftr: support new integrate_test in new dubbo samples (#215)
    
    * Ftr: support new integrate_test in new dubbo samples
    
    * delete useless comment
---
 build/Makefile                                     |  48 ++-----
 integrate_test.sh                                  |  20 +--
 .../helloworld/docker/docker-health-check.sh       |  10 ++
 .../tests/integration/userprovider_test.go         |   2 +-
 start_integrate_test.sh                            | 147 +++++++++++----------
 5 files changed, 110 insertions(+), 117 deletions(-)

diff --git a/build/Makefile b/build/Makefile
index 124ab7c..6bebcc0 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -16,10 +16,9 @@
 PROJECT_NAME = $(shell basename "$(PWD)")
 PID = /tmp/.$(PROJECT_NAME).pid
 PROJECT_DIR=$(shell pwd)
-BASE_DIR := $(PROJECT_DIR)/dist
+BASE_DIR := $(PROJECT_DIR)/go-server/dist
 
-
-SOURCES = $(wildcard $(PROJECT_DIR)/cmd/*.go)
+SOURCES = $(wildcard $(PROJECT_DIR)/go-server/cmd/*.go)
 
 export GO111MODULE ?= on
 export GOPROXY ?= https://goproxy.io,direct
@@ -69,43 +68,30 @@ help: $(realpath $(firstword $(MAKEFILE_LIST)))
 
 ## build: Build application's binaries
 .PHONY: build
-build: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) config
+build: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME)
 
 .PHONY: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME)
 $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME):
 	$(info   >  Buiding application binary: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME))
 	@CGO_ENABLED=$(CGO) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -i -o $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) $(SOURCES)
 
-
-## config: Setup config files
-.PHONY: config
-config:
-	$(info   >  Setting up config files)
-	@mkdir -p $(OUT_DIR)/conf
-	@-test -f $(PROJECT_DIR)/conf/log.yml && cat $(PROJECT_DIR)/conf/log.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/conf/log.yml && echo "  > $(OUT_DIR)/conf/log.yml"
-	@-test -f $(PROJECT_DIR)/conf/server.yml && cat $(PROJECT_DIR)/conf/server.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/conf/server.yml && echo "  > $(OUT_DIR)/conf/server.yml"
-	@-test -f $(PROJECT_DIR)/conf/client.yml && cat $(PROJECT_DIR)/conf/client.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/conf/client.yml && echo "  > $(OUT_DIR)/conf/client.yml"
-	@-test -f $(PROJECT_DIR)/conf/router_config.yml && cat $(PROJECT_DIR)/conf/router_config.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/conf/router_config.yml && echo "  > $(OUT_DIR)/conf/router_config.yml"
-	@-test -f $(PROJECT_DIR)/conf/virtual_service.yml && cat $(PROJECT_DIR)/conf/virtual_service.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/conf/virtual_service.yml && echo "  > $(OUT_DIR)/conf/virtual_service.yml"
-	@-test -f $(PROJECT_DIR)/conf/dest_rule.yml && cat $(PROJECT_DIR)/conf/dest_rule.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/conf/dest_rule.yml && echo "  > $(OUT_DIR)/conf/dest_rule.yml"
-
 ## docker-health-check: check services health on docker
 .PHONY: docker-health-check
 docker-health-check:
-	$(info   >  run docker health check with $(PROJECT_DIR)/docker/docker-health-check.sh)
-	@-test -f $(PROJECT_DIR)/docker/docker-health-check.sh && bash -f $(PROJECT_DIR)/docker/docker-health-check.sh
+	$(info   >  run docker health check with $(INTEGRATE_DIR)/docker/docker-health-check.sh)
+	@-test -f $(INTEGRATE_DIR)/docker/docker-health-check.sh && bash -f $(INTEGRATE_DIR)/docker/docker-health-check.sh
 
 ## docker-up: Shutdown dependency services on docker
 .PHONY: docker-up
 docker-up:
-	$(info   >  Starting dependency services with $(PROJECT_DIR)/docker/docker-compose.yml)
-	@docker-compose -f $(PROJECT_DIR)/docker/docker-compose.yml up -d
+	$(info   >  Starting dependency services with $(INTEGRATE_DIR)/docker/docker-compose.yml)
+	@docker-compose -f $(INTEGRATE_DIR)/docker/docker-compose.yml up -d
 
 ## docker-down: Shutdown dependency services on docker
 .PHONY: docker-down
 docker-down:
-	$(info   >  Stopping dependency services with $(PROJECT_DIR)/docker/docker-compose.yml)
-	@docker-compose -f $(PROJECT_DIR)/docker/docker-compose.yml down
+	$(info   >  Stopping dependency services with $(INTEGRATE_DIR)/docker/docker-compose.yml)
+	@docker-compose -f $(INTEGRATE_DIR)/docker/docker-compose.yml down
 
 ## clean: Clean up the output and the binary of the application
 .PHONY: clean
@@ -116,9 +102,10 @@ clean: stop
 
 ## start: Start the application (for server)
 .PHONY: start
-start: export CONF_PROVIDER_FILE_PATH ?= $(OUT_DIR)/conf/server.yml
+start: export DUBBO_GO_CONFIG_PATH ?= $(PROJECT_DIR)/go-server/conf/dubbogo.yml
 start: build
 	$(info   >  Starting application $(PROJECT_NAME), output is redirected to $(LOG_FILE))
+	@ls $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME)
 	@-$(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) > $(LOG_FILE) 2>&1 & echo $$! > $(PID)
 	@cat $(PID) | sed "/^/s/^/  \>  PID: /"
 
@@ -130,10 +117,6 @@ print-server-log:
 
 ## run: Run the application (for client)
 .PHONY: run
-run: export CONF_CONSUMER_FILE_PATH ?= $(OUT_DIR)/conf/client.yml
-run: export CONF_ROUTER_FILE_PATH ?= $(OUT_DIR)/conf/router_config.yml
-run: export CONF_DEST_RULE_FILE_PATH ?= $(OUT_DIR)/conf/dest_rule.yml
-run: export CONF_VIRTUAL_SERVICE_FILE_PATH ?= $(OUT_DIR)/conf/virtual_service.yml
 run: build
 	$(info   >  Running application $(PROJECT_NAME), output is redirected to $(LOG_FILE))
 	@-$(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) 2>&1 | tee $(LOG_FILE)
@@ -147,11 +130,8 @@ stop:
 
 ## integration: Run integration test for this application
 .PHONY: integration
-integration: export CONF_CONSUMER_FILE_PATH ?= $(OUT_DIR)/conf/client.yml
-integration: export CONF_ROUTER_FILE_PATH ?= $(OUT_DIR)/conf/router_config.yml
-integration: export CONF_DEST_RULE_FILE_PATH ?= $(OUT_DIR)/conf/dest_rule.yml
-integration: export CONF_VIRTUAL_SERVICE_FILE_PATH ?= $(OUT_DIR)/conf/virtual_service.yml
+integration: export DUBBO_GO_CONFIG_PATH ?= $(PROJECT_DIR)/go-client/conf/dubbogo.yml
 integration:
-	$(info   >  Running integration test for application $(PROJECT_NAME))
+	$(info   >  Running integration test for application $(INTEGRATE_DIR))
 	@go clean -testcache
-	@go test -tags integration -v $(PROJECT_DIR)/tests/...
\ No newline at end of file
+	@go test -tags integration -v $(INTEGRATE_DIR)/tests/integration/...
\ No newline at end of file
diff --git a/integrate_test.sh b/integrate_test.sh
index 78eb52e..8894871 100755
--- a/integrate_test.sh
+++ b/integrate_test.sh
@@ -15,37 +15,39 @@
 #  limitations under the License.
 
 if [ -z "$1" ]; then
-  echo "Provide test directory please, like : ./integrate_test.sh $(pwd)/helloworld/go-server ."
+  echo "Provide test directory please, like : ./integrate_test.sh helloworld"
   exit
 fi
 
 P_DIR=$(pwd)/$1
-
 if [ -f "$P_DIR"/build/test.sh ]; then
     "$P_DIR"/build/test.sh "$P_DIR"
     result=$?
     exit $((result))
 fi
 
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile docker-up
+INTEGRATE_DIR=$(pwd)/integrate_test/$1
+
+make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile docker-up
 
 # check docker health
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile docker-health-check
+make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile docker-health-check
 
 # start server
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile start
+make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile start
+
 # start integration
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -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")" BASE_DIR="$P_DIR"/dist -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
 
 # stop server
-make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile clean
+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")" BASE_DIR="$P_DIR"/dist -f build/Makefile docker-down
+make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" INTEGRATE_DIR="$INTEGRATE_DIR" -f build/Makefile docker-down
 
 exit $((result))
\ No newline at end of file
diff --git a/integrate_test/helloworld/docker/docker-health-check.sh b/integrate_test/helloworld/docker/docker-health-check.sh
new file mode 100644
index 0000000..2cc32c2
--- /dev/null
+++ b/integrate_test/helloworld/docker/docker-health-check.sh
@@ -0,0 +1,10 @@
+curl 127.0.0.1:2181
+res=$?
+passCode=52
+while [ "$res" != "$passCode" ];do
+  sleep 5
+  curl 127.0.0.1:2181
+  res=$?
+done
+
+sleep 5
diff --git a/integrate_test/helloworld/tests/integration/userprovider_test.go b/integrate_test/helloworld/tests/integration/userprovider_test.go
index 992c55d..1daa809 100644
--- a/integrate_test/helloworld/tests/integration/userprovider_test.go
+++ b/integrate_test/helloworld/tests/integration/userprovider_test.go
@@ -42,7 +42,7 @@ func TestSayHello(t *testing.T) {
 	ctx := context.Background()
 	ctx = context.WithValue(ctx, "tri-req-id", "test_value_XXXXXXXX")
 
-	err := greeterProvider.SayHello(ctx, req, reply)
+	reply, err := greeterProvider.SayHello(ctx, req)
 
 	assert.Nil(t, err)
 	assert.Equal(t, "Hello laurence", reply.Name)
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index c672b48..b539384 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -15,79 +15,80 @@
 #  limitations under the License.
 
 # tracing integrate test
-array=("tracing/dubbo/go-server")
-
-# async
-array+=("async/go-server")
-array+=("attachment/go-server")
-array+=("config-api/go-server")
-array+=("chain")
-# config center
-array+=("configcenter/apollo/go-server")
-array+=("configcenter/nacos/go-server")
-array+=("configcenter/zookeeper/go-server")
-
-# context
-array+=("context/go-server")
-
-# direct
-array+=("direct/go-server")
-
-# filter
-array+=("filter/custom/go-server")
-array+=("filter/tpslimit/go-server")
-array+=("filter/sentinel/go-server")
-
-# game
-array+=("game/go-server-game")
-array+=("game/go-server-gate")
-
-# general-dubbo
-array+=("general/dubbo/go-server")
-
-# general-dubbo3(triple)
-array+=("general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server")
-array+=("general/dubbo3/pb/dubbogo-java/go-server")
-array+=("general/dubbo3/hessian2/go-server")
-array+=("general/dubbo3/msgpack/go-server")
-array+=("general/dubbo3/codec-extension/go-server")
-
-# general-grpc
-array+=("general/grpc/go-server")
-
-# generic invocation
-array+=("generic/default/go-server")
-#array+=("generic/protobufjson/go-server")
-
-# group
-array+=("group/go-server-group-a")
-array+=("group/go-server-group-b")
-
-# hello world
-array+=("helloworld/go-server")
-
-# metric
-array+=("metric/go-server")
-
-# multi-registry
-array+=("multi-registry/go-server")
-
-# multi-zone
-array+=("multi-zone")
-
-# registry
-array+=("registry/zookeeper/go-server")
-array+=("registry/etcd/go-server")
-array+=("registry/nacos/go-server")
-
-# registry/servicediscovery (app level serivce discovery)
-array+=("registry/servicediscovery/zookeeper/go-server")
-array+=("registry/servicediscovery/nacos/go-server")
-
-# router integrate test can only confirm the program build success,
-# the test of router logic would be fixed later
-array+=("router/uniform-router/file/go-server")
-array+=("router/uniform-router/file/go-server2")
+#array=("tracing/dubbo/go-server")
+#
+## async
+#array+=("async/go-server")
+#array+=("attachment/go-server")
+#array+=("config-api/go-server")
+#array+=("chain")
+## config center
+#array+=("configcenter/apollo/go-server")
+#array+=("configcenter/nacos/go-server")
+#array+=("configcenter/zookeeper/go-server")
+#
+## context
+#array+=("context/go-server")
+#
+## direct
+#array+=("direct/go-server")
+#
+## filter
+#array+=("filter/custom/go-server")
+#array+=("filter/tpslimit/go-server")
+#array+=("filter/sentinel/go-server")
+#
+## game
+#array+=("game/go-server-game")
+#array+=("game/go-server-gate")
+#
+## general-dubbo
+#array+=("general/dubbo/go-server")
+#
+## general-dubbo3(triple)
+#array+=("general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server")
+#array+=("general/dubbo3/pb/dubbogo-java/go-server")
+#array+=("general/dubbo3/hessian2/go-server")
+#array+=("general/dubbo3/msgpack/go-server")
+#array+=("general/dubbo3/codec-extension/go-server")
+#
+## general-grpc
+#array+=("general/grpc/go-server")
+#
+## generic invocation
+#array+=("generic/default/go-server")
+##array+=("generic/protobufjson/go-server")
+#
+## group
+#array+=("group/go-server-group-a")
+#array+=("group/go-server-group-b")
+#
+## hello world
+#array+=("helloworld/go-server")
+#
+## metric
+#array+=("metric/go-server")
+#
+## multi-registry
+#array+=("multi-registry/go-server")
+#
+## multi-zone
+#array+=("multi-zone")
+#
+## registry
+#array+=("registry/zookeeper/go-server")
+#array+=("registry/etcd/go-server")
+#array+=("registry/nacos/go-server")
+#
+## registry/servicediscovery (app level serivce discovery)
+#array+=("registry/servicediscovery/zookeeper/go-server")
+#array+=("registry/servicediscovery/nacos/go-server")
+#
+## router integrate test can only confirm the program build success,
+## the test of router logic would be fixed later
+#array+=("router/uniform-router/file/go-server")
+#array+=("router/uniform-router/file/go-server2")
+array+=("helloworld")
 
 for((i=0;i<${#array[*]};i++))
 do