From 550c952aacf26d57b3f7bb4976be244ebbd4e3fb Mon Sep 17 00:00:00 2001 From: husharp Date: Sun, 7 Apr 2024 11:21:33 +0800 Subject: [PATCH 1/4] fix ci Signed-off-by: husharp --- client/Makefile | 19 ++++++++++++++----- scripts/ci-subtask.sh | 4 ++-- tools/Makefile | 5 ++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/client/Makefile b/client/Makefile index dae53222d92..d97156e5618 100644 --- a/client/Makefile +++ b/client/Makefile @@ -12,20 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. +ROOT_PATH := .. GO_TOOLS_BIN_PATH := $(shell pwd)/../.tools/bin PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) default: static tidy test -test: - CGO_ENABLE=1 go test ./... -race -cover +test: failpoint-enable + CGO_ENABLE=1 go test ./... -race -cover || { $(MAKE) failpoint-disable && exit 1; } + $(MAKE) failpoint-disable -basic-test: - CGO_ENABLE=1 go test ./... +basic-test: failpoint-enable + CGO_ENABLE=1 go test ./... || { $(MAKE) failpoint-disable && exit 1; } + $(MAKE) failpoint-disable ci-test-job: - CGO_ENABLED=1 go test ./... -race -covermode=atomic -coverprofile=covprofile -coverpkg=../... github.com/tikv/pd/client + CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=covprofile -coverpkg=../... + +failpoint-enable: + cd $(ROOT_PATH) && $(MAKE) failpoint-enable + +failpoint-disable: + cd $(ROOT_PATH) && $(MAKE) failpoint-disable install-tools: cd .. && $(MAKE) install-tools diff --git a/scripts/ci-subtask.sh b/scripts/ci-subtask.sh index b9006dda503..31185909122 100755 --- a/scripts/ci-subtask.sh +++ b/scripts/ci-subtask.sh @@ -7,7 +7,7 @@ ROOT_PATH=../../ if [[ $2 -gt 9 ]]; then # run tools tests if [[ $2 -eq 10 ]]; then - cd ./tools && make ci-test-job && cd .. && cat ./covprofile >> covprofile || exit 1 + cd ./tools && make ci-test-job && cat covprofile >> ../covprofile && cd .. || exit 1 exit fi @@ -16,7 +16,7 @@ if [[ $2 -gt 9 ]]; then integrations_tasks=($(find "$integrations_dir" -mindepth 1 -maxdepth 1 -type d)) for t in "${integrations_tasks[@]}"; do if [[ "$t" = "$integrations_dir/client" && $2 -eq 11 ]]; then - cd ./client && make ci-test-job && cd .. && cat ./covprofile >> covprofile || exit 1 + cd ./client && make ci-test-job && cat covprofile >> ../covprofile && cd .. || exit 1 cd $integrations_dir && make ci-test-job test_name=client && cat ./client/covprofile >> "$ROOT_PATH/covprofile" || exit 1 elif [[ "$t" = "$integrations_dir/tso" && $2 -eq 12 ]]; then cd $integrations_dir && make ci-test-job test_name=tso && cat ./tso/covprofile >> "$ROOT_PATH/covprofile" || exit 1 diff --git a/tools/Makefile b/tools/Makefile index 052f8573b62..ba463a9d622 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -33,9 +33,8 @@ tidy: git diff go.mod go.sum | cat git diff --quiet go.mod go.sum -ci-test-job: failpoint-enable - CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } - $(MAKE) failpoint-disable +ci-test-job: + CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=covprofile -coverpkg=../... failpoint-enable: cd $(ROOT_PATH) && $(MAKE) failpoint-enable From f1d200a1264f3c73f597d2dd3087255a34a943e3 Mon Sep 17 00:00:00 2001 From: husharp Date: Sun, 7 Apr 2024 15:36:31 +0800 Subject: [PATCH 2/4] support test for tools Signed-off-by: husharp --- client/Makefile | 2 +- tests/integrations/Makefile | 2 +- tools/Makefile | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/Makefile b/client/Makefile index d97156e5618..9e76cfd61d3 100644 --- a/client/Makefile +++ b/client/Makefile @@ -20,7 +20,7 @@ SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) default: static tidy test test: failpoint-enable - CGO_ENABLE=1 go test ./... -race -cover || { $(MAKE) failpoint-disable && exit 1; } + CGO_ENABLE=1 go test ./... -v -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } $(MAKE) failpoint-disable basic-test: failpoint-enable diff --git a/tests/integrations/Makefile b/tests/integrations/Makefile index 43b5945baca..2542cd3bcf1 100644 --- a/tests/integrations/Makefile +++ b/tests/integrations/Makefile @@ -35,7 +35,7 @@ test: failpoint-enable $(MAKE) failpoint-disable ci-test-job: - CGO_ENABLED=1 go test ./$(value test_name)/... -v -tags deadlock -race -covermode=atomic -coverprofile=./$(value test_name)/covprofile -coverpkg=$(ROOT_PATH)/... + CGO_ENABLED=1 go test ./$(value test_name)/... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=./$(value test_name)/covprofile -coverpkg=$(ROOT_PATH)/... install-tools: cd $(ROOT_PATH) && $(MAKE) install-tools diff --git a/tools/Makefile b/tools/Makefile index ba463a9d622..c5649359330 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -33,6 +33,10 @@ tidy: git diff go.mod go.sum | cat git diff --quiet go.mod go.sum +test: failpoint-enable + CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } + $(MAKE) failpoint-disable + ci-test-job: CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=covprofile -coverpkg=../... From aaff8025cdb17bcb5b3e265c8bbca2fb72baa5ea Mon Sep 17 00:00:00 2001 From: husharp Date: Mon, 8 Apr 2024 14:59:38 +0800 Subject: [PATCH 3/4] address comment Signed-off-by: husharp --- client/Makefile | 2 +- scripts/ci-subtask.sh | 8 ++++---- tests/integrations/Makefile | 2 +- tests/integrations/realcluster/Makefile | 2 +- tools/Makefile | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/Makefile b/client/Makefile index 9e76cfd61d3..715aea09cd4 100644 --- a/client/Makefile +++ b/client/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ROOT_PATH := .. +ROOT_PATH := $(shell pwd)/.. GO_TOOLS_BIN_PATH := $(shell pwd)/../.tools/bin PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) diff --git a/scripts/ci-subtask.sh b/scripts/ci-subtask.sh index 31185909122..67c8549a5e6 100755 --- a/scripts/ci-subtask.sh +++ b/scripts/ci-subtask.sh @@ -2,7 +2,7 @@ # ./ci-subtask.sh -ROOT_PATH=../../ +ROOT_PATH_COV=$(pwd)/covprofile if [[ $2 -gt 9 ]]; then # run tools tests @@ -17,11 +17,11 @@ if [[ $2 -gt 9 ]]; then for t in "${integrations_tasks[@]}"; do if [[ "$t" = "$integrations_dir/client" && $2 -eq 11 ]]; then cd ./client && make ci-test-job && cat covprofile >> ../covprofile && cd .. || exit 1 - cd $integrations_dir && make ci-test-job test_name=client && cat ./client/covprofile >> "$ROOT_PATH/covprofile" || exit 1 + cd $integrations_dir && make ci-test-job test_name=client && cat ./client/covprofile >> $ROOT_PATH_COV || exit 1 elif [[ "$t" = "$integrations_dir/tso" && $2 -eq 12 ]]; then - cd $integrations_dir && make ci-test-job test_name=tso && cat ./tso/covprofile >> "$ROOT_PATH/covprofile" || exit 1 + cd $integrations_dir && make ci-test-job test_name=tso && cat ./tso/covprofile >> $ROOT_PATH_COV || exit 1 elif [[ "$t" = "$integrations_dir/mcs" && $2 -eq 13 ]]; then - cd $integrations_dir && make ci-test-job test_name=mcs && cat ./mcs/covprofile >> "$ROOT_PATH/covprofile" || exit 1 + cd $integrations_dir && make ci-test-job test_name=mcs && cat ./mcs/covprofile >> $ROOT_PATH_COV || exit 1 fi done else diff --git a/tests/integrations/Makefile b/tests/integrations/Makefile index 2542cd3bcf1..e487c8c7d0b 100644 --- a/tests/integrations/Makefile +++ b/tests/integrations/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ROOT_PATH := ../.. +ROOT_PATH := $(shell pwd)/../.. GO_TOOLS_BIN_PATH := $(ROOT_PATH)/.tools/bin PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) diff --git a/tests/integrations/realcluster/Makefile b/tests/integrations/realcluster/Makefile index 4817b94b5da..278f585feaa 100644 --- a/tests/integrations/realcluster/Makefile +++ b/tests/integrations/realcluster/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ROOT_PATH := ../../.. +ROOT_PATH := $(shell pwd)/../../.. GO_TOOLS_BIN_PATH := $(ROOT_PATH)/.tools/bin PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) diff --git a/tools/Makefile b/tools/Makefile index c5649359330..3e95d4d76a9 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ROOT_PATH := .. +ROOT_PATH := $(shell pwd)/.. GO_TOOLS_BIN_PATH := $(ROOT_PATH)/.tools/bin PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) From 146b99fb1ab1b0ce6d79ed834acf33e5c68dd5d9 Mon Sep 17 00:00:00 2001 From: husharp Date: Mon, 8 Apr 2024 15:45:03 +0800 Subject: [PATCH 4/4] refine covprofile Signed-off-by: husharp --- client/Makefile | 1 + scripts/ci-subtask.sh | 6 +++--- tests/integrations/Makefile | 1 + tools/Makefile | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/Makefile b/client/Makefile index 715aea09cd4..89c4936d179 100644 --- a/client/Makefile +++ b/client/Makefile @@ -28,6 +28,7 @@ basic-test: failpoint-enable $(MAKE) failpoint-disable ci-test-job: + if [ -f covprofile ]; then rm covprofile; fi CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=covprofile -coverpkg=../... failpoint-enable: diff --git a/scripts/ci-subtask.sh b/scripts/ci-subtask.sh index 67c8549a5e6..effd250965f 100755 --- a/scripts/ci-subtask.sh +++ b/scripts/ci-subtask.sh @@ -7,7 +7,7 @@ ROOT_PATH_COV=$(pwd)/covprofile if [[ $2 -gt 9 ]]; then # run tools tests if [[ $2 -eq 10 ]]; then - cd ./tools && make ci-test-job && cat covprofile >> ../covprofile && cd .. || exit 1 + cd ./tools && make ci-test-job && cat covprofile >> $ROOT_PATH_COV || exit 1 exit fi @@ -16,7 +16,7 @@ if [[ $2 -gt 9 ]]; then integrations_tasks=($(find "$integrations_dir" -mindepth 1 -maxdepth 1 -type d)) for t in "${integrations_tasks[@]}"; do if [[ "$t" = "$integrations_dir/client" && $2 -eq 11 ]]; then - cd ./client && make ci-test-job && cat covprofile >> ../covprofile && cd .. || exit 1 + cd ./client && make ci-test-job && cat covprofile >> $ROOT_PATH_COV && cd .. || exit 1 cd $integrations_dir && make ci-test-job test_name=client && cat ./client/covprofile >> $ROOT_PATH_COV || exit 1 elif [[ "$t" = "$integrations_dir/tso" && $2 -eq 12 ]]; then cd $integrations_dir && make ci-test-job test_name=tso && cat ./tso/covprofile >> $ROOT_PATH_COV || exit 1 @@ -61,5 +61,5 @@ else [[ $(($min_i + 1)) -eq $2 ]] && res+=($t) done - CGO_ENABLED=1 go test -timeout=15m -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=./... ${res[@]} + CGO_ENABLED=1 go test -timeout=15m -tags deadlock -race -covermode=atomic -coverprofile=$ROOT_PATH_COV -coverpkg=./... ${res[@]} fi diff --git a/tests/integrations/Makefile b/tests/integrations/Makefile index e487c8c7d0b..b43ecabce7e 100644 --- a/tests/integrations/Makefile +++ b/tests/integrations/Makefile @@ -35,6 +35,7 @@ test: failpoint-enable $(MAKE) failpoint-disable ci-test-job: + if [ -f covprofile ]; then rm ./$(value test_name)/covprofile; fi CGO_ENABLED=1 go test ./$(value test_name)/... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=./$(value test_name)/covprofile -coverpkg=$(ROOT_PATH)/... install-tools: diff --git a/tools/Makefile b/tools/Makefile index 3e95d4d76a9..336cc536949 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -38,6 +38,7 @@ test: failpoint-enable $(MAKE) failpoint-disable ci-test-job: + if [ -f covprofile ]; then rm covprofile; fi CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=covprofile -coverpkg=../... failpoint-enable: