From e1a0b550b77eb754fcf25f564eda22280bdea5f7 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 19 May 2022 23:48:15 +0800 Subject: [PATCH] fix: delete layotto's dependency on go-sdk (#461) --- .gitignore | 2 +- Makefile | 2 +- configs/integrate_config.json | 2 +- etc/script/report.sh | 2 +- go.mod | 1 - go.sum | 2 -- make/ci.mk | 4 ++-- make/common.mk | 7 +++++-- make/golang.mk | 2 +- sdk/go-sdk/go.mod | 1 + sdk/go-sdk/go.sum | 1 + {test => sdk/go-sdk/test}/runtime/integrate_test.sh | 5 ++--- .../test}/runtime/other_component_integrate_test.go | 0 {test => sdk/go-sdk/test}/runtime/redis_integrate_test.go | 8 ++++---- 14 files changed, 20 insertions(+), 19 deletions(-) rename {test => sdk/go-sdk/test}/runtime/integrate_test.sh (89%) rename {test => sdk/go-sdk/test}/runtime/other_component_integrate_test.go (100%) rename {test => sdk/go-sdk/test}/runtime/redis_integrate_test.go (93%) diff --git a/.gitignore b/.gitignore index 3c76b32ef5..6ac94b0225 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,4 @@ demo/state/common/client etc/script/mdx etcd layotto_wasmer -nohup.out +nohup.out \ No newline at end of file diff --git a/Makefile b/Makefile index 4b4ddd3673..d4a483484a 100644 --- a/Makefile +++ b/Makefile @@ -284,4 +284,4 @@ help: Makefile @echo -e "Commands below are used in Development 💻 and GitHub workflow 🌊.\n" @echo -e "Usage: make ...\n\nCOMMANDS:" @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' - @echo "$$USAGE_OPTIONS" + @echo "$$USAGE_OPTIONS" \ No newline at end of file diff --git a/configs/integrate_config.json b/configs/integrate_config.json index e53eb0e0a0..91cdd53512 100644 --- a/configs/integrate_config.json +++ b/configs/integrate_config.json @@ -6,7 +6,7 @@ "listeners": [ { "name": "grpc", - "address": "0.0.0.0:34904", + "address": "0.0.0.0:11104", "bind_port": true, "filter_chains": [ { diff --git a/etc/script/report.sh b/etc/script/report.sh index 2209940344..e779d51e9a 100644 --- a/etc/script/report.sh +++ b/etc/script/report.sh @@ -17,6 +17,6 @@ cd .. cd sdk/go-sdk echo "" > cover.out echo "test go-sdk" -go test -count=1 -failfast -timeout 120s ./... -coverprofile cover.out -covermode=atomic +go test -count=1 -failfast -timeout 120s $(go list ./... | grep -v runtime) -coverprofile cover.out -covermode=atomic cat cover.out >> ../../cover.out cd ../.. diff --git a/go.mod b/go.mod index c341efb839..e3d5fdce5e 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,6 @@ require ( google.golang.org/protobuf v1.27.1 mosn.io/api v1.0.0 mosn.io/layotto/components v0.0.0-20220413092851-55c58dbb1a23 - mosn.io/layotto/sdk/go-sdk v0.0.0-20220422112241-cd96c75e590f mosn.io/layotto/spec v0.0.0-20220413092851-55c58dbb1a23 mosn.io/mosn v1.0.1 mosn.io/pkg v1.0.0 diff --git a/go.sum b/go.sum index 351c614fb7..a622e2eb1f 100644 --- a/go.sum +++ b/go.sum @@ -2121,8 +2121,6 @@ mosn.io/api v0.0.0-20211217011300-b851d129be01/go.mod h1:TBv4bz2f2RbpgdohbVAFRFV mosn.io/api v1.0.0 h1:EK5jHRaqeszV3tKzgNKX1NZf1JdPU9QTF6E276xQHPk= mosn.io/api v1.0.0/go.mod h1:TBv4bz2f2RbpgdohbVAFRFVOoN8YyEUiLH3jAh752Qc= mosn.io/holmes v1.0.1/go.mod h1:pZjPamcZk4Z16xlZySG1rU9psLUCOx6MVNuj/3bfkEk= -mosn.io/layotto/sdk/go-sdk v0.0.0-20220422112241-cd96c75e590f h1:YlTX+AVcE1IoRhHrl56rJnO0zhwyNwPqsHexYWJgSW8= -mosn.io/layotto/sdk/go-sdk v0.0.0-20220422112241-cd96c75e590f/go.mod h1:mMrIBDCM2kTSCFC5a7rog00FPxCVCSh5Qtq81X4f9f8= mosn.io/mosn v0.25.1-0.20211217125944-69b50c40af81/go.mod h1:JwLkls6oMaap0+P1uZ1d1ccdLPigdK8xH8gDSm3SEq4= mosn.io/mosn v1.0.1 h1:3X2Sh7B6K2PD/4cKZ72GtXohG+jeubojJBbArXQ/ZqI= mosn.io/mosn v1.0.1/go.mod h1:NtUWYhOSHgC+yRlLLFGSD1zUbEXKm4XhvLwAbCh1F8U= diff --git a/make/ci.mk b/make/ci.mk index db06d52647..d73468186e 100644 --- a/make/ci.mk +++ b/make/ci.mk @@ -58,7 +58,7 @@ integration.wasm: app.image.linux_amd64.faas $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) $(eval BUILD_IMAGE := $(REGISTRY_PREFIX)/faas-$(ARCH):$(VERSION)) $(eval WORKDIR := -w /go/src/${PROJECT_NAME} ) - $(eval INTEGRATE_SUFFIX := -v $(ROOT_DIR):/go/src/${PROJECT_NAME} -v ${TEST_DIR}/wasm/wasm_test.sh:/go/src/${PROJECT_NAME}/wasm_test.sh $(WORKDIR)) + $(eval INTEGRATE_SUFFIX := -v $(ROOT_DIR):/go/src/${PROJECT_NAME} -v ${TEST_WASM_DIR}/wasm/wasm_test.sh:/go/src/${PROJECT_NAME}/wasm_test.sh $(WORKDIR)) $(DOCKER) run --rm $(INTEGRATE_SUFFIX) $(BUILD_IMAGE) $(ACTION) .PHONY: integration.runtime @@ -68,5 +68,5 @@ integration.runtime: app.image.linux_amd64.integrate $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) $(eval BUILD_IMAGE := $(REGISTRY_PREFIX)/integrate-$(ARCH):$(VERSION)) $(eval WORKDIR := -w /go/src/${PROJECT_NAME} ) - $(eval INTEGRATE_SUFFIX := -v $(ROOT_DIR):/go/src/${PROJECT_NAME} -v ${TEST_DIR}/runtime/integrate_test.sh:/go/src/${PROJECT_NAME}/integrate_test.sh $(WORKDIR)) + $(eval INTEGRATE_SUFFIX := -v $(ROOT_DIR):/go/src/${PROJECT_NAME} -v ${TEST_RUNTIME_DIR}/runtime/integrate_test.sh:/go/src/${PROJECT_NAME}/integrate_test.sh $(WORKDIR)) $(DOCKER) run --rm $(INTEGRATE_SUFFIX) ${BUILD_IMAGE} $(ACTION) diff --git a/make/common.mk b/make/common.mk index 8a30ec62a0..ce6f63136b 100644 --- a/make/common.mk +++ b/make/common.mk @@ -32,8 +32,11 @@ endif ifeq ($(origin DOCS_DIR),undefined) DOCS_DIR := $(ROOT_DIR)/docs endif -ifeq ($(origin TEST_DIR),undefined) -TEST_DIR := $(ROOT_DIR)/test +ifeq ($(origin TEST_WASM_DIR),undefined) +TEST_WASM_DIR := $(ROOT_DIR)/test +endif +ifeq ($(origin TEST_RUNTIME_DIR),undefined) +TEST_RUNTIME_DIR := $(ROOT_DIR)/sdk/go-sdk/test endif ifeq ($(origin DEMO_DIR),undefined) DEMO_DIR := $(ROOT_DIR)/demo diff --git a/make/golang.mk b/make/golang.mk index 629c2019f2..07145ccde1 100644 --- a/make/golang.mk +++ b/make/golang.mk @@ -105,7 +105,7 @@ go.test: go.test.verify @echo "===========> Run unit test in diagnostics" $(GO) test -count=1 -timeout=10m -short -v `go list ./diagnostics/...` @echo "===========> Run unit test in sdk/go-sdk" - @cd sdk/go-sdk && $(GO) test -count=1 -timeout=10m -short -v `go list ./...` + @cd sdk/go-sdk && $(GO) test -count=1 -timeout=10m -short -v `go list ./... | grep -v runtime` @echo "===========> Run unit test in components" @cd components/ && $(GO) test -count=1 -timeout=10m -short -v `go list ./...` @echo "===========> Run unit test in pkg" diff --git a/sdk/go-sdk/go.mod b/sdk/go-sdk/go.mod index 35224da897..d685a85bfe 100644 --- a/sdk/go-sdk/go.mod +++ b/sdk/go-sdk/go.mod @@ -4,6 +4,7 @@ go 1.14 require ( github.com/golang/protobuf v1.5.0 + github.com/google/uuid v1.1.2 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 google.golang.org/grpc v1.37.0 diff --git a/sdk/go-sdk/go.sum b/sdk/go-sdk/go.sum index aa5bc4e378..f63b65b4ce 100644 --- a/sdk/go-sdk/go.sum +++ b/sdk/go-sdk/go.sum @@ -29,6 +29,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/test/runtime/integrate_test.sh b/sdk/go-sdk/test/runtime/integrate_test.sh similarity index 89% rename from test/runtime/integrate_test.sh rename to sdk/go-sdk/test/runtime/integrate_test.sh index 7bdfab1293..03e25551da 100644 --- a/test/runtime/integrate_test.sh +++ b/sdk/go-sdk/test/runtime/integrate_test.sh @@ -17,6 +17,5 @@ go build ./cmd/layotto nohup redis-server & nohup ./layotto start -c ./configs/integrate_config.json & -go get mosn.io/layotto/sdk/go-sdk/client -go test -p 1 -v ./test/runtime/... - +cd sdk/go-sdk/test/runtime +go test -p 1 -v ./... \ No newline at end of file diff --git a/test/runtime/other_component_integrate_test.go b/sdk/go-sdk/test/runtime/other_component_integrate_test.go similarity index 100% rename from test/runtime/other_component_integrate_test.go rename to sdk/go-sdk/test/runtime/other_component_integrate_test.go diff --git a/test/runtime/redis_integrate_test.go b/sdk/go-sdk/test/runtime/redis_integrate_test.go similarity index 93% rename from test/runtime/redis_integrate_test.go rename to sdk/go-sdk/test/runtime/redis_integrate_test.go index 8da61b8909..cffdf7df17 100644 --- a/test/runtime/redis_integrate_test.go +++ b/sdk/go-sdk/test/runtime/redis_integrate_test.go @@ -31,7 +31,7 @@ import ( var componentName = "redis" func TestHelloApi(t *testing.T) { - cli, err := client.NewClientWithAddress("127.0.0.1:34904") + cli, err := client.NewClientWithAddress("127.0.0.1:11104") if err != nil { t.Fatal(err) } @@ -48,7 +48,7 @@ func TestHelloApi(t *testing.T) { } func TestStateApi(t *testing.T) { - cli, err := client.NewClientWithAddress("127.0.0.1:34904") + cli, err := client.NewClientWithAddress("127.0.0.1:11104") if err != nil { t.Fatal(err) } @@ -67,7 +67,7 @@ func TestStateApi(t *testing.T) { } func TestLockApi(t *testing.T) { - cli, err := client.NewClientWithAddress("127.0.0.1:34904") + cli, err := client.NewClientWithAddress("127.0.0.1:11104") if err != nil { t.Fatal(err) } @@ -138,7 +138,7 @@ func TestLockApi(t *testing.T) { } func TestSequencerApi(t *testing.T) { - cli, err := client.NewClientWithAddress("127.0.0.1:34904") + cli, err := client.NewClientWithAddress("127.0.0.1:11104") if err != nil { t.Fatal(err) }