From c5a767b6721083c85b74cc8799ad61d3619c2d28 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 21 Mar 2023 14:44:42 +0800 Subject: [PATCH] Try to break up all tests into the chunks Signed-off-by: JmPotato --- .github/workflows/pd-tests.yaml | 3 +- Makefile | 8 ++--- scripts/ci-subtask.sh | 15 +++++++--- tests/{ => integrations}/client/Makefile | 30 +++++++++---------- .../client/cert-expired/ca-config.json | 0 .../client/cert-expired/ca-csr.json | 0 .../client/cert-expired/ca-key.pem | 0 .../client/cert-expired/ca.csr | 0 .../client/cert-expired/ca.pem | 0 .../client/cert-expired/client-key.pem | 0 .../client/cert-expired/client.csr | 0 .../client/cert-expired/client.pem | 0 .../client/cert-expired/gencerts.sh | 0 .../client/cert-expired/pd-server-key.pem | 0 .../client/cert-expired/pd-server.csr | 0 .../client/cert-expired/pd-server.pem | 0 .../client/cert/ca-config.json | 0 .../client/cert/ca-csr.json | 0 .../{ => integrations}/client/cert/ca-key.pem | 0 tests/{ => integrations}/client/cert/ca.csr | 0 tests/{ => integrations}/client/cert/ca.pem | 0 .../client/cert/client-key.pem | 0 .../{ => integrations}/client/cert/client.csr | 0 .../{ => integrations}/client/cert/client.pem | 0 .../client/cert/gencerts.sh | 0 .../client/cert/pd-server-key.pem | 0 .../client/cert/pd-server.csr | 0 .../client/cert/pd-server.pem | 0 .../{ => integrations}/client/client_test.go | 0 .../client/client_tls_test.go | 0 .../client/global_config_test.go | 0 tests/{ => integrations}/client/go.mod | 18 +++++------ tests/{ => integrations}/client/go.sum | 0 .../client/keyspace_test.go | 0 tests/{ => integrations}/mcs/Makefile | 25 ++++++++-------- .../mcs/discovery/register_test.go | 2 +- tests/{ => integrations}/mcs/go.mod | 18 +++++------ tests/{ => integrations}/mcs/go.sum | 0 .../resource_manager/resource_manager_test.go | 0 .../mcs/resource_manager/server_test.go | 2 +- tests/{ => integrations}/mcs/testutil.go | 0 .../{ => integrations}/mcs/tso/server_test.go | 2 +- tests/{ => integrations}/tso/Makefile | 25 ++++++++-------- tests/{ => integrations}/tso/client_test.go | 2 +- .../tso/consistency_test.go | 2 +- tests/{ => integrations}/tso/go.mod | 10 +++---- tests/{ => integrations}/tso/go.sum | 0 tests/{ => integrations}/tso/server_test.go | 2 +- tests/{ => integrations}/tso/testutil.go | 0 49 files changed, 83 insertions(+), 81 deletions(-) rename tests/{ => integrations}/client/Makefile (59%) rename tests/{ => integrations}/client/cert-expired/ca-config.json (100%) rename tests/{ => integrations}/client/cert-expired/ca-csr.json (100%) rename tests/{ => integrations}/client/cert-expired/ca-key.pem (100%) rename tests/{ => integrations}/client/cert-expired/ca.csr (100%) rename tests/{ => integrations}/client/cert-expired/ca.pem (100%) rename tests/{ => integrations}/client/cert-expired/client-key.pem (100%) rename tests/{ => integrations}/client/cert-expired/client.csr (100%) rename tests/{ => integrations}/client/cert-expired/client.pem (100%) rename tests/{ => integrations}/client/cert-expired/gencerts.sh (100%) rename tests/{ => integrations}/client/cert-expired/pd-server-key.pem (100%) rename tests/{ => integrations}/client/cert-expired/pd-server.csr (100%) rename tests/{ => integrations}/client/cert-expired/pd-server.pem (100%) rename tests/{ => integrations}/client/cert/ca-config.json (100%) rename tests/{ => integrations}/client/cert/ca-csr.json (100%) rename tests/{ => integrations}/client/cert/ca-key.pem (100%) rename tests/{ => integrations}/client/cert/ca.csr (100%) rename tests/{ => integrations}/client/cert/ca.pem (100%) rename tests/{ => integrations}/client/cert/client-key.pem (100%) rename tests/{ => integrations}/client/cert/client.csr (100%) rename tests/{ => integrations}/client/cert/client.pem (100%) rename tests/{ => integrations}/client/cert/gencerts.sh (100%) rename tests/{ => integrations}/client/cert/pd-server-key.pem (100%) rename tests/{ => integrations}/client/cert/pd-server.csr (100%) rename tests/{ => integrations}/client/cert/pd-server.pem (100%) rename tests/{ => integrations}/client/client_test.go (100%) rename tests/{ => integrations}/client/client_tls_test.go (100%) rename tests/{ => integrations}/client/global_config_test.go (100%) rename tests/{ => integrations}/client/go.mod (98%) rename tests/{ => integrations}/client/go.sum (100%) rename tests/{ => integrations}/client/keyspace_test.go (100%) rename tests/{ => integrations}/mcs/Makefile (68%) rename tests/{ => integrations}/mcs/discovery/register_test.go (99%) rename tests/{ => integrations}/mcs/go.mod (98%) rename tests/{ => integrations}/mcs/go.sum (100%) rename tests/{ => integrations}/mcs/resource_manager/resource_manager_test.go (100%) rename tests/{ => integrations}/mcs/resource_manager/server_test.go (98%) rename tests/{ => integrations}/mcs/testutil.go (100%) rename tests/{ => integrations}/mcs/tso/server_test.go (99%) rename tests/{ => integrations}/tso/Makefile (68%) rename tests/{ => integrations}/tso/client_test.go (99%) rename tests/{ => integrations}/tso/consistency_test.go (99%) rename tests/{ => integrations}/tso/go.mod (97%) rename tests/{ => integrations}/tso/go.sum (100%) rename tests/{ => integrations}/tso/server_test.go (99%) rename tests/{ => integrations}/tso/testutil.go (100%) diff --git a/.github/workflows/pd-tests.yaml b/.github/workflows/pd-tests.yaml index f2f3b0f43e0..83d4651ca3a 100644 --- a/.github/workflows/pd-tests.yaml +++ b/.github/workflows/pd-tests.yaml @@ -46,8 +46,7 @@ jobs: WORKER_ID: ${{ matrix.worker_id }} WORKER_COUNT: 10 run: | - [ $WORKER_ID -ne $WORKER_COUNT ] && make ci-test-job JOB_COUNT=$(($WORKER_COUNT-1)) JOB_INDEX=$WORKER_ID - [ $WORKER_ID -eq $WORKER_COUNT ] && make ci-test-job-submod + make ci-test-job JOB_COUNT=$(($WORKER_COUNT)) JOB_INDEX=$WORKER_ID mv covprofile covprofile_$WORKER_ID sed -i "/failpoint_binding/d" covprofile_$WORKER_ID - name: Upload coverage result ${{ matrix.worker_id }} diff --git a/Makefile b/Makefile index 14de2eb5263..640cad2b0c7 100644 --- a/Makefile +++ b/Makefile @@ -216,12 +216,8 @@ basic-test: install-tools ci-test-job: install-tools dashboard-ui @$(FAILPOINT_ENABLE) CGO_ENABLED=1 go test -timeout=15m -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=./... $(shell ./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX)) - @$(FAILPOINT_DISABLE) - -ci-test-job-submod: install-tools dashboard-ui - @$(FAILPOINT_ENABLE) - @ for mod in $(SUBMODULES); do cd $$mod && $(MAKE) ci-test-job && cd $(ROOT_PATH) > /dev/null && cat $$mod/covprofile >> covprofile; done - @$(FAILPOINT_DISABLE) + @ for pkg in $(shell ./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX) 1); do cd $$pkg && $(MAKE) ci-test-job && cd $(ROOT_PATH) > /dev/null && cat $$mod/covprofile >> covprofile; done + # @$(FAILPOINT_DISABLE) TSO_INTEGRATION_TEST_PKGS := $(PD_PKG)/tests/server/tso diff --git a/scripts/ci-subtask.sh b/scripts/ci-subtask.sh index 6a2ebc0248a..746a9a37bf6 100755 --- a/scripts/ci-subtask.sh +++ b/scripts/ci-subtask.sh @@ -1,10 +1,17 @@ #!/bin/bash -# ./ci-subtask.sh +# ./ci-subtask.sh -packages=(`go list ./...`) -dirs=(`find . -iname "*_test.go" -exec dirname {} \; | sort -u | sed -e "s/^\./github.com\/tikv\/pd/"`) -tasks=($(comm -12 <(printf "%s\n" "${packages[@]}") <(printf "%s\n" "${dirs[@]}"))) +tasks=() +if [[ $3 ]]; then + makefile_dirs=(`find . -iname "Makefile" -exec dirname {} \; | sort -u`) + submod_dirs=(`find . -iname "go.mod" -exec dirname {} \; | sort -u`) + tasks=$(comm -12 <(printf "%s\n" "${makefile_dirs[@]}") <(printf "%s\n" "${submod_dirs[@]}") | grep "./tests/integrations/*") +else + packages=(`go list ./...`) + dirs=(`find . -iname "*_test.go" -exec dirname {} \; | sort -u | sed -e "s/^\./github.com\/tikv\/pd/"`) + tasks=($(comm -12 <(printf "%s\n" "${packages[@]}") <(printf "%s\n" "${dirs[@]}"))) +fi weight () { [[ $1 == "github.com/tikv/pd/server/api" ]] && return 30 diff --git a/tests/client/Makefile b/tests/integrations/client/Makefile similarity index 59% rename from tests/client/Makefile rename to tests/integrations/client/Makefile index 5663a2f3b45..5b6bc42f85f 100644 --- a/tests/client/Makefile +++ b/tests/integrations/client/Makefile @@ -12,37 +12,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -GO_TOOLS_BIN_PATH := $(shell pwd)/../../.tools/bin +ROOT_PATH := ../../.. +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) static: install-tools @ gofmt -s -l -d . 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }' @ golangci-lint run ./... - @ revive -formatter friendly -config ../../revive.toml . + @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml . tidy: @ go mod tidy git diff go.mod go.sum | cat git diff --quiet go.mod go.sum -test: enable-codegen - CGO_ENABLED=1 go test -v -tags deadlock -race -cover || { $(MAKE) disable-codegen && exit 1; } - $(MAKE) disable-codegen +test: failpoint-enable + CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } + $(MAKE) failpoint-disable -basic-test: - # skip - -ci-test-job: enable-codegen - CGO_ENABLED=1 go test -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=../../... github.com/tikv/pd/tests/client +ci-test-job: + CGO_ENABLED=1 go test ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/client install-tools: - cd ../../ && $(MAKE) install-tools + cd $(ROOT_PATH) && $(MAKE) install-tools -enable-codegen: - cd ../../ && $(MAKE) failpoint-enable +failpoint-enable: + cd $(ROOT_PATH) && $(MAKE) failpoint-enable go mod tidy -disable-codegen: - cd ../../ && $(MAKE) failpoint-disable - go mod tidy +failpoint-disable: + cd $(ROOT_PATH) && $(MAKE) failpoint-disable + go mod tidy \ No newline at end of file diff --git a/tests/client/cert-expired/ca-config.json b/tests/integrations/client/cert-expired/ca-config.json similarity index 100% rename from tests/client/cert-expired/ca-config.json rename to tests/integrations/client/cert-expired/ca-config.json diff --git a/tests/client/cert-expired/ca-csr.json b/tests/integrations/client/cert-expired/ca-csr.json similarity index 100% rename from tests/client/cert-expired/ca-csr.json rename to tests/integrations/client/cert-expired/ca-csr.json diff --git a/tests/client/cert-expired/ca-key.pem b/tests/integrations/client/cert-expired/ca-key.pem similarity index 100% rename from tests/client/cert-expired/ca-key.pem rename to tests/integrations/client/cert-expired/ca-key.pem diff --git a/tests/client/cert-expired/ca.csr b/tests/integrations/client/cert-expired/ca.csr similarity index 100% rename from tests/client/cert-expired/ca.csr rename to tests/integrations/client/cert-expired/ca.csr diff --git a/tests/client/cert-expired/ca.pem b/tests/integrations/client/cert-expired/ca.pem similarity index 100% rename from tests/client/cert-expired/ca.pem rename to tests/integrations/client/cert-expired/ca.pem diff --git a/tests/client/cert-expired/client-key.pem b/tests/integrations/client/cert-expired/client-key.pem similarity index 100% rename from tests/client/cert-expired/client-key.pem rename to tests/integrations/client/cert-expired/client-key.pem diff --git a/tests/client/cert-expired/client.csr b/tests/integrations/client/cert-expired/client.csr similarity index 100% rename from tests/client/cert-expired/client.csr rename to tests/integrations/client/cert-expired/client.csr diff --git a/tests/client/cert-expired/client.pem b/tests/integrations/client/cert-expired/client.pem similarity index 100% rename from tests/client/cert-expired/client.pem rename to tests/integrations/client/cert-expired/client.pem diff --git a/tests/client/cert-expired/gencerts.sh b/tests/integrations/client/cert-expired/gencerts.sh similarity index 100% rename from tests/client/cert-expired/gencerts.sh rename to tests/integrations/client/cert-expired/gencerts.sh diff --git a/tests/client/cert-expired/pd-server-key.pem b/tests/integrations/client/cert-expired/pd-server-key.pem similarity index 100% rename from tests/client/cert-expired/pd-server-key.pem rename to tests/integrations/client/cert-expired/pd-server-key.pem diff --git a/tests/client/cert-expired/pd-server.csr b/tests/integrations/client/cert-expired/pd-server.csr similarity index 100% rename from tests/client/cert-expired/pd-server.csr rename to tests/integrations/client/cert-expired/pd-server.csr diff --git a/tests/client/cert-expired/pd-server.pem b/tests/integrations/client/cert-expired/pd-server.pem similarity index 100% rename from tests/client/cert-expired/pd-server.pem rename to tests/integrations/client/cert-expired/pd-server.pem diff --git a/tests/client/cert/ca-config.json b/tests/integrations/client/cert/ca-config.json similarity index 100% rename from tests/client/cert/ca-config.json rename to tests/integrations/client/cert/ca-config.json diff --git a/tests/client/cert/ca-csr.json b/tests/integrations/client/cert/ca-csr.json similarity index 100% rename from tests/client/cert/ca-csr.json rename to tests/integrations/client/cert/ca-csr.json diff --git a/tests/client/cert/ca-key.pem b/tests/integrations/client/cert/ca-key.pem similarity index 100% rename from tests/client/cert/ca-key.pem rename to tests/integrations/client/cert/ca-key.pem diff --git a/tests/client/cert/ca.csr b/tests/integrations/client/cert/ca.csr similarity index 100% rename from tests/client/cert/ca.csr rename to tests/integrations/client/cert/ca.csr diff --git a/tests/client/cert/ca.pem b/tests/integrations/client/cert/ca.pem similarity index 100% rename from tests/client/cert/ca.pem rename to tests/integrations/client/cert/ca.pem diff --git a/tests/client/cert/client-key.pem b/tests/integrations/client/cert/client-key.pem similarity index 100% rename from tests/client/cert/client-key.pem rename to tests/integrations/client/cert/client-key.pem diff --git a/tests/client/cert/client.csr b/tests/integrations/client/cert/client.csr similarity index 100% rename from tests/client/cert/client.csr rename to tests/integrations/client/cert/client.csr diff --git a/tests/client/cert/client.pem b/tests/integrations/client/cert/client.pem similarity index 100% rename from tests/client/cert/client.pem rename to tests/integrations/client/cert/client.pem diff --git a/tests/client/cert/gencerts.sh b/tests/integrations/client/cert/gencerts.sh similarity index 100% rename from tests/client/cert/gencerts.sh rename to tests/integrations/client/cert/gencerts.sh diff --git a/tests/client/cert/pd-server-key.pem b/tests/integrations/client/cert/pd-server-key.pem similarity index 100% rename from tests/client/cert/pd-server-key.pem rename to tests/integrations/client/cert/pd-server-key.pem diff --git a/tests/client/cert/pd-server.csr b/tests/integrations/client/cert/pd-server.csr similarity index 100% rename from tests/client/cert/pd-server.csr rename to tests/integrations/client/cert/pd-server.csr diff --git a/tests/client/cert/pd-server.pem b/tests/integrations/client/cert/pd-server.pem similarity index 100% rename from tests/client/cert/pd-server.pem rename to tests/integrations/client/cert/pd-server.pem diff --git a/tests/client/client_test.go b/tests/integrations/client/client_test.go similarity index 100% rename from tests/client/client_test.go rename to tests/integrations/client/client_test.go diff --git a/tests/client/client_tls_test.go b/tests/integrations/client/client_tls_test.go similarity index 100% rename from tests/client/client_tls_test.go rename to tests/integrations/client/client_tls_test.go diff --git a/tests/client/global_config_test.go b/tests/integrations/client/global_config_test.go similarity index 100% rename from tests/client/global_config_test.go rename to tests/integrations/client/global_config_test.go diff --git a/tests/client/go.mod b/tests/integrations/client/go.mod similarity index 98% rename from tests/client/go.mod rename to tests/integrations/client/go.mod index 7e12db678e0..5a2d09be935 100644 --- a/tests/client/go.mod +++ b/tests/integrations/client/go.mod @@ -1,7 +1,15 @@ -module github.com/tikv/pd/tests/client +module github.com/tikv/pd/tests/integrations/client go 1.20 +replace ( + github.com/tikv/pd => ../../../ + github.com/tikv/pd/client => ../../../client +) + +// reset grpc and protobuf deps in order to import client and server at the same time +replace google.golang.org/grpc v1.51.0 => google.golang.org/grpc v1.26.0 + require ( github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 github.com/pingcap/kvproto v0.0.0-20230317010544-b47a4830141f @@ -163,11 +171,3 @@ require ( moul.io/zapgorm2 v1.1.0 // indirect sigs.k8s.io/yaml v1.2.0 // indirect ) - -replace ( - github.com/tikv/pd => ../../ - github.com/tikv/pd/client => ../../client -) - -// reset grpc and protobuf deps in order to import client and server at the same time -replace google.golang.org/grpc v1.51.0 => google.golang.org/grpc v1.26.0 diff --git a/tests/client/go.sum b/tests/integrations/client/go.sum similarity index 100% rename from tests/client/go.sum rename to tests/integrations/client/go.sum diff --git a/tests/client/keyspace_test.go b/tests/integrations/client/keyspace_test.go similarity index 100% rename from tests/client/keyspace_test.go rename to tests/integrations/client/keyspace_test.go diff --git a/tests/mcs/Makefile b/tests/integrations/mcs/Makefile similarity index 68% rename from tests/mcs/Makefile rename to tests/integrations/mcs/Makefile index 86dc5f58bd2..080925939d9 100644 --- a/tests/mcs/Makefile +++ b/tests/integrations/mcs/Makefile @@ -12,34 +12,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -GO_TOOLS_BIN_PATH := $(shell pwd)/../../.tools/bin +ROOT_PATH := ../../.. +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) static: install-tools @ gofmt -s -l -d . 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }' @ golangci-lint run ./... - @ revive -formatter friendly -config ../../revive.toml . + @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml . tidy: @ go mod tidy git diff go.mod go.sum | cat git diff --quiet go.mod go.sum -test: enable-codegen - CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) disable-codegen && exit 1; } - $(MAKE) disable-codegen +test: failpoint-enable + CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } + $(MAKE) failpoint-disable -ci-test-job: enable-codegen - CGO_ENABLED=1 go test ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=../../... github.com/tikv/pd/tests/mcs +ci-test-job: + CGO_ENABLED=1 go test ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/mcs install-tools: - cd ../../ && $(MAKE) install-tools + cd $(ROOT_PATH) && $(MAKE) install-tools -enable-codegen: - cd ../../ && $(MAKE) failpoint-enable +failpoint-enable: + cd $(ROOT_PATH) && $(MAKE) failpoint-enable go mod tidy -disable-codegen: - cd ../../ && $(MAKE) failpoint-disable +failpoint-disable: + cd $(ROOT_PATH) && $(MAKE) failpoint-disable go mod tidy diff --git a/tests/mcs/discovery/register_test.go b/tests/integrations/mcs/discovery/register_test.go similarity index 99% rename from tests/mcs/discovery/register_test.go rename to tests/integrations/mcs/discovery/register_test.go index a658d5ef4e4..09d53289c03 100644 --- a/tests/mcs/discovery/register_test.go +++ b/tests/integrations/mcs/discovery/register_test.go @@ -25,7 +25,7 @@ import ( "github.com/tikv/pd/pkg/utils/tempurl" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/tests" - "github.com/tikv/pd/tests/mcs" + "github.com/tikv/pd/tests/integrations/mcs" "go.uber.org/goleak" ) diff --git a/tests/mcs/go.mod b/tests/integrations/mcs/go.mod similarity index 98% rename from tests/mcs/go.mod rename to tests/integrations/mcs/go.mod index d5eda55e6e5..cefac1b9797 100644 --- a/tests/mcs/go.mod +++ b/tests/integrations/mcs/go.mod @@ -1,7 +1,15 @@ -module github.com/tikv/pd/tests/mcs +module github.com/tikv/pd/tests/integrations/mcs go 1.20 +replace ( + github.com/tikv/pd => ../../../ + github.com/tikv/pd/client => ../../../client +) + +// reset grpc and protobuf deps in order to import client and server at the same time +replace google.golang.org/grpc v1.51.0 => google.golang.org/grpc v1.26.0 + require ( github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 github.com/pingcap/kvproto v0.0.0-20230317010544-b47a4830141f @@ -163,11 +171,3 @@ require ( moul.io/zapgorm2 v1.1.0 // indirect sigs.k8s.io/yaml v1.2.0 // indirect ) - -replace ( - github.com/tikv/pd => ../../ - github.com/tikv/pd/client => ../../client -) - -// reset grpc and protobuf deps in order to import client and server at the same time -replace google.golang.org/grpc v1.51.0 => google.golang.org/grpc v1.26.0 diff --git a/tests/mcs/go.sum b/tests/integrations/mcs/go.sum similarity index 100% rename from tests/mcs/go.sum rename to tests/integrations/mcs/go.sum diff --git a/tests/mcs/resource_manager/resource_manager_test.go b/tests/integrations/mcs/resource_manager/resource_manager_test.go similarity index 100% rename from tests/mcs/resource_manager/resource_manager_test.go rename to tests/integrations/mcs/resource_manager/resource_manager_test.go diff --git a/tests/mcs/resource_manager/server_test.go b/tests/integrations/mcs/resource_manager/server_test.go similarity index 98% rename from tests/mcs/resource_manager/server_test.go rename to tests/integrations/mcs/resource_manager/server_test.go index dbc2dcb400e..7547e5c009c 100644 --- a/tests/mcs/resource_manager/server_test.go +++ b/tests/integrations/mcs/resource_manager/server_test.go @@ -27,7 +27,7 @@ import ( "github.com/tikv/pd/client/grpcutil" "github.com/tikv/pd/pkg/utils/tempurl" "github.com/tikv/pd/tests" - "github.com/tikv/pd/tests/mcs" + "github.com/tikv/pd/tests/integrations/mcs" ) func TestResourceManagerServer(t *testing.T) { diff --git a/tests/mcs/testutil.go b/tests/integrations/mcs/testutil.go similarity index 100% rename from tests/mcs/testutil.go rename to tests/integrations/mcs/testutil.go diff --git a/tests/mcs/tso/server_test.go b/tests/integrations/mcs/tso/server_test.go similarity index 99% rename from tests/mcs/tso/server_test.go rename to tests/integrations/mcs/tso/server_test.go index 39a6265474e..882ef3db56a 100644 --- a/tests/mcs/tso/server_test.go +++ b/tests/integrations/mcs/tso/server_test.go @@ -36,7 +36,7 @@ import ( "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/tsoutil" "github.com/tikv/pd/tests" - "github.com/tikv/pd/tests/mcs" + "github.com/tikv/pd/tests/integrations/mcs" "go.etcd.io/etcd/clientv3" "go.uber.org/goleak" "google.golang.org/grpc" diff --git a/tests/tso/Makefile b/tests/integrations/tso/Makefile similarity index 68% rename from tests/tso/Makefile rename to tests/integrations/tso/Makefile index 655cc0e62d1..c10dada9bd7 100644 --- a/tests/tso/Makefile +++ b/tests/integrations/tso/Makefile @@ -12,34 +12,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -GO_TOOLS_BIN_PATH := $(shell pwd)/../../.tools/bin +ROOT_PATH := ../../.. +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) static: install-tools @ gofmt -s -l -d . 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }' @ golangci-lint run ./... - @ revive -formatter friendly -config ../../revive.toml . + @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml . tidy: @ go mod tidy git diff go.mod go.sum | cat git diff --quiet go.mod go.sum -test: enable-codegen - CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) disable-codegen && exit 1; } - $(MAKE) disable-codegen +test: failpoint-enable + CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } + $(MAKE) failpoint-disable -ci-test-job: enable-codegen - CGO_ENABLED=1 go test ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=../../... github.com/tikv/pd/tests/tso +ci-test-job: + CGO_ENABLED=1 go test ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/tso install-tools: - cd ../../ && $(MAKE) install-tools + cd $(ROOT_PATH) && $(MAKE) install-tools -enable-codegen: - cd ../../ && $(MAKE) failpoint-enable +failpoint-enable: + cd $(ROOT_PATH) && $(MAKE) failpoint-enable go mod tidy -disable-codegen: - cd ../../ && $(MAKE) failpoint-disable +failpoint-disable: + cd $(ROOT_PATH) && $(MAKE) failpoint-disable go mod tidy diff --git a/tests/tso/client_test.go b/tests/integrations/tso/client_test.go similarity index 99% rename from tests/tso/client_test.go rename to tests/integrations/tso/client_test.go index 8e38e0fce1b..a79ed60b66d 100644 --- a/tests/tso/client_test.go +++ b/tests/integrations/tso/client_test.go @@ -29,7 +29,7 @@ import ( "github.com/tikv/pd/pkg/utils/tempurl" "github.com/tikv/pd/pkg/utils/tsoutil" "github.com/tikv/pd/tests" - "github.com/tikv/pd/tests/mcs" + "github.com/tikv/pd/tests/integrations/mcs" ) type tsoClientTestSuite struct { diff --git a/tests/tso/consistency_test.go b/tests/integrations/tso/consistency_test.go similarity index 99% rename from tests/tso/consistency_test.go rename to tests/integrations/tso/consistency_test.go index b4222ff6abb..70000d2abd4 100644 --- a/tests/tso/consistency_test.go +++ b/tests/integrations/tso/consistency_test.go @@ -30,7 +30,7 @@ import ( pd "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/tsoutil" "github.com/tikv/pd/tests" - "github.com/tikv/pd/tests/mcs" + "github.com/tikv/pd/tests/integrations/mcs" "google.golang.org/grpc" ) diff --git a/tests/tso/go.mod b/tests/integrations/tso/go.mod similarity index 97% rename from tests/tso/go.mod rename to tests/integrations/tso/go.mod index e3bc0f9511c..b35bddd5e5c 100644 --- a/tests/tso/go.mod +++ b/tests/integrations/tso/go.mod @@ -1,11 +1,11 @@ -module github.com/tikv/pd/tests/tso +module github.com/tikv/pd/tests/integrations/tso go 1.20 replace ( - github.com/tikv/pd => ../../ - github.com/tikv/pd/client => ../../client - github.com/tikv/pd/tests/mcs => ../mcs + github.com/tikv/pd => ../../../ + github.com/tikv/pd/client => ../../../client + github.com/tikv/pd/tests/integrations/mcs => ../mcs ) // reset grpc and protobuf deps in order to import client and server at the same time @@ -17,7 +17,7 @@ require ( github.com/stretchr/testify v1.8.2 github.com/tikv/pd v0.0.0-00010101000000-000000000000 github.com/tikv/pd/client v0.0.0-00010101000000-000000000000 - github.com/tikv/pd/tests/mcs v0.0.0-20230320064440-220dbed05897 + github.com/tikv/pd/tests/integrations/mcs v0.0.0-00010101000000-000000000000 google.golang.org/grpc v1.51.0 ) diff --git a/tests/tso/go.sum b/tests/integrations/tso/go.sum similarity index 100% rename from tests/tso/go.sum rename to tests/integrations/tso/go.sum diff --git a/tests/tso/server_test.go b/tests/integrations/tso/server_test.go similarity index 99% rename from tests/tso/server_test.go rename to tests/integrations/tso/server_test.go index 3b33253a424..1a73db2ff43 100644 --- a/tests/tso/server_test.go +++ b/tests/integrations/tso/server_test.go @@ -28,7 +28,7 @@ import ( "github.com/tikv/pd/pkg/utils/tempurl" pd "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/tests" - "github.com/tikv/pd/tests/mcs" + "github.com/tikv/pd/tests/integrations/mcs" "google.golang.org/grpc" ) diff --git a/tests/tso/testutil.go b/tests/integrations/tso/testutil.go similarity index 100% rename from tests/tso/testutil.go rename to tests/integrations/tso/testutil.go