From c5a767b6721083c85b74cc8799ad61d3619c2d28 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 21 Mar 2023 14:44:42 +0800 Subject: [PATCH 1/7] 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 From 63179ff03eb0b54ccf6c883f2e4fc9907ca511a7 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Fri, 24 Mar 2023 11:02:22 +0800 Subject: [PATCH 2/7] Fix Makefile Signed-off-by: JmPotato --- Makefile | 1 - tests/integrations/client/Makefile | 4 ++-- tests/integrations/mcs/Makefile | 4 ++-- tests/integrations/tso/Makefile | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 640cad2b0c7..2081f428ae9 100644 --- a/Makefile +++ b/Makefile @@ -217,7 +217,6 @@ 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)) @ 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/tests/integrations/client/Makefile b/tests/integrations/client/Makefile index 5b6bc42f85f..b9574b253ec 100644 --- a/tests/integrations/client/Makefile +++ b/tests/integrations/client/Makefile @@ -28,11 +28,11 @@ tidy: git diff --quiet go.mod go.sum test: failpoint-enable - CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } + 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 ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/client + 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 $(ROOT_PATH) && $(MAKE) install-tools diff --git a/tests/integrations/mcs/Makefile b/tests/integrations/mcs/Makefile index 080925939d9..80b001fbdaf 100644 --- a/tests/integrations/mcs/Makefile +++ b/tests/integrations/mcs/Makefile @@ -28,11 +28,11 @@ tidy: git diff --quiet go.mod go.sum test: failpoint-enable - CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } + 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 ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/mcs + 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 $(ROOT_PATH) && $(MAKE) install-tools diff --git a/tests/integrations/tso/Makefile b/tests/integrations/tso/Makefile index c10dada9bd7..820bbf33ccf 100644 --- a/tests/integrations/tso/Makefile +++ b/tests/integrations/tso/Makefile @@ -28,11 +28,11 @@ tidy: git diff --quiet go.mod go.sum test: failpoint-enable - CGO_ENABLED=1 go test ./... -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; } + 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 ./... -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/tso + 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 $(ROOT_PATH) && $(MAKE) install-tools From b1ba01d05d89c2a8456d409add9ac9ab7a161f3b Mon Sep 17 00:00:00 2001 From: JmPotato Date: Fri, 24 Mar 2023 11:10:54 +0800 Subject: [PATCH 3/7] Fix the path Signed-off-by: JmPotato --- pd.code-workspace | 6 +++--- pkg/utils/grpcutil/grpcutil_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pd.code-workspace b/pd.code-workspace index 6a5d85d60fe..c4603084a93 100644 --- a/pd.code-workspace +++ b/pd.code-workspace @@ -10,15 +10,15 @@ }, { "name": "pd-client-tests", - "path": "tests/client" + "path": "tests/integrations/client" }, { "name": "mcs-tests", - "path": "tests/mcs" + "path": "tests/integrations/mcs" }, { "name": "tso-tests", - "path": "tests/tso" + "path": "tests/integrations/tso" }, { "name": "pd-tso-bench", diff --git a/pkg/utils/grpcutil/grpcutil_test.go b/pkg/utils/grpcutil/grpcutil_test.go index ac3ba3da3fc..ea1de4fb681 100644 --- a/pkg/utils/grpcutil/grpcutil_test.go +++ b/pkg/utils/grpcutil/grpcutil_test.go @@ -24,9 +24,9 @@ func TestToTLSConfig(t *testing.T) { t.Parallel() re := require.New(t) tlsConfig := TLSConfig{ - KeyPath: "../../../tests/client/cert/pd-server-key.pem", - CertPath: "../../../tests/client/cert/pd-server.pem", - CAPath: "../../../tests/client/cert/ca.pem", + KeyPath: "../../../tests/integrations/client/cert/pd-server-key.pem", + CertPath: "../../../tests/integrations/client/cert/pd-server.pem", + CAPath: "../../../tests/integrations/client/cert/ca.pem", } // test without bytes _, err := tlsConfig.ToTLSConfig() From 371157f447f895de6f4db03491abb601cb4d300f Mon Sep 17 00:00:00 2001 From: JmPotato Date: Fri, 24 Mar 2023 11:19:32 +0800 Subject: [PATCH 4/7] Fix the mcs tests Signed-off-by: JmPotato --- tests/integrations/client/Makefile | 2 +- tests/integrations/mcs/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integrations/client/Makefile b/tests/integrations/client/Makefile index b9574b253ec..e8c2f30e2fa 100644 --- a/tests/integrations/client/Makefile +++ b/tests/integrations/client/Makefile @@ -43,4 +43,4 @@ failpoint-enable: failpoint-disable: cd $(ROOT_PATH) && $(MAKE) failpoint-disable - go mod tidy \ No newline at end of file + go mod tidy diff --git a/tests/integrations/mcs/Makefile b/tests/integrations/mcs/Makefile index 80b001fbdaf..8be9ad22429 100644 --- a/tests/integrations/mcs/Makefile +++ b/tests/integrations/mcs/Makefile @@ -28,11 +28,11 @@ tidy: 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; } + 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 -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/mcs + 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 $(ROOT_PATH) && $(MAKE) install-tools From 4f264cfb6c3c001ac4a0c13e0cfec3c0ec9439fc Mon Sep 17 00:00:00 2001 From: JmPotato Date: Fri, 24 Mar 2023 11:29:04 +0800 Subject: [PATCH 5/7] Fix the covprofile path Signed-off-by: JmPotato --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2081f428ae9..84b7ce37ee0 100644 --- a/Makefile +++ b/Makefile @@ -216,7 +216,7 @@ 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)) - @ 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 + @ for mod in $(shell ./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX) 1); do cd $$mod && $(MAKE) ci-test-job && cd $(ROOT_PATH) > /dev/null && cat $$mod/covprofile >> covprofile; done TSO_INTEGRATION_TEST_PKGS := $(PD_PKG)/tests/server/tso From e4320bdbc3dc0a6e23486a37858efd61d18f3e62 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Fri, 24 Mar 2023 12:05:41 +0800 Subject: [PATCH 6/7] Refine the CI subtask Signed-off-by: JmPotato --- scripts/ci-subtask.sh | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/scripts/ci-subtask.sh b/scripts/ci-subtask.sh index 746a9a37bf6..705ca12567f 100755 --- a/scripts/ci-subtask.sh +++ b/scripts/ci-subtask.sh @@ -1,19 +1,20 @@ #!/bin/bash -# ./ci-subtask.sh +# ./ci-subtask.sh -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 +# Get package test list. +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[@]}"))) +# Get integration test list. +makefile_dirs=(`find . -iname "Makefile" -exec dirname {} \; | sort -u`) +submod_dirs=(`find . -iname "go.mod" -exec dirname {} \; | sort -u`) +integration_tasks=$(comm -12 <(printf "%s\n" "${makefile_dirs[@]}") <(printf "%s\n" "${submod_dirs[@]}") | grep "./tests/integrations/*") + +all_tasks=("${tasks[@]}" "${integration_tasks[@]}") weight () { + [[ $1 =~ "tests/integrations" ]] && return 50 [[ $1 == "github.com/tikv/pd/server/api" ]] && return 30 [[ $1 == "github.com/tikv/pd/pkg/schedule" ]] && return 30 [[ $1 =~ "pd/tests" ]] && return 5 @@ -23,14 +24,21 @@ weight () { scores=(`seq "$1" | xargs -I{} echo 0`) res=() -for t in ${tasks[@]}; do +for t in ${all_tasks[@]}; do min_i=0 for i in ${!scores[@]}; do [[ ${scores[i]} -lt ${scores[$min_i]} ]] && min_i=$i done weight $t scores[$min_i]=$((${scores[$min_i]} + $?)) - [[ $(($min_i+1)) -eq $2 ]] && res+=($t) + if [[ $(($min_i+1)) -eq $2 ]]; then + # Integration test only. + if [[ $3 && "$t" =~ "tests/integrations" ]]; then + res+=($t) + elif [[ ! $3 && "$t" =~ "github.com/tikv/pd" ]]; then + res+=($t) + fi + fi done printf "%s " "${res[@]}" From 45e7c68b9bf23722deb84aa974c1a9b8941f44a0 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Fri, 24 Mar 2023 13:31:21 +0800 Subject: [PATCH 7/7] Hardcode the index Signed-off-by: JmPotato --- scripts/ci-subtask.sh | 76 +++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/scripts/ci-subtask.sh b/scripts/ci-subtask.sh index 705ca12567f..9628f2688c5 100755 --- a/scripts/ci-subtask.sh +++ b/scripts/ci-subtask.sh @@ -2,43 +2,49 @@ # ./ci-subtask.sh -# Get package test list. -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[@]}"))) -# Get integration test list. -makefile_dirs=(`find . -iname "Makefile" -exec dirname {} \; | sort -u`) -submod_dirs=(`find . -iname "go.mod" -exec dirname {} \; | sort -u`) -integration_tasks=$(comm -12 <(printf "%s\n" "${makefile_dirs[@]}") <(printf "%s\n" "${submod_dirs[@]}") | grep "./tests/integrations/*") - -all_tasks=("${tasks[@]}" "${integration_tasks[@]}") +if [[ $3 ]]; then + # Get integration test list. + makefile_dirs=($(find . -iname "Makefile" -exec dirname {} \; | sort -u)) + submod_dirs=($(find . -iname "go.mod" -exec dirname {} \; | sort -u)) + integration_tasks=$(comm -12 <(printf "%s\n" "${makefile_dirs[@]}") <(printf "%s\n" "${submod_dirs[@]}") | grep "./tests/integrations/*") + # Currently, we only have 3 integration tests, so we can hardcode the task index. + for t in ${integration_tasks[@]}; do + if [[ "$t" = "./tests/integrations/client" && "$2" = 9 ]]; then + printf "%s " "$t" + break + elif [[ "$t" = "./tests/integrations/tso" && "$2" = 7 ]]; then + printf "%s " "$t" + break + elif [[ "$t" = "./tests/integrations/mcs" && "$2" = 2 ]]; then + printf "%s " "$t" + break + fi + done +else + # Get package test list. + 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[@]}"))) -weight () { - [[ $1 =~ "tests/integrations" ]] && return 50 - [[ $1 == "github.com/tikv/pd/server/api" ]] && return 30 - [[ $1 == "github.com/tikv/pd/pkg/schedule" ]] && return 30 - [[ $1 =~ "pd/tests" ]] && return 5 - return 1 -} + weight() { + [[ $1 == "github.com/tikv/pd/server/api" ]] && return 30 + [[ $1 == "github.com/tikv/pd/pkg/schedule" ]] && return 30 + [[ $1 =~ "pd/tests" ]] && return 5 + return 1 + } -scores=(`seq "$1" | xargs -I{} echo 0`) + scores=($(seq "$1" | xargs -I{} echo 0)) -res=() -for t in ${all_tasks[@]}; do - min_i=0 - for i in ${!scores[@]}; do - [[ ${scores[i]} -lt ${scores[$min_i]} ]] && min_i=$i + res=() + for t in ${tasks[@]}; do + min_i=0 + for i in ${!scores[@]}; do + [[ ${scores[i]} -lt ${scores[$min_i]} ]] && min_i=$i + done + weight $t + scores[$min_i]=$((${scores[$min_i]} + $?)) + [[ $(($min_i + 1)) -eq $2 ]] && res+=($t) done - weight $t - scores[$min_i]=$((${scores[$min_i]} + $?)) - if [[ $(($min_i+1)) -eq $2 ]]; then - # Integration test only. - if [[ $3 && "$t" =~ "tests/integrations" ]]; then - res+=($t) - elif [[ ! $3 && "$t" =~ "github.com/tikv/pd" ]]; then - res+=($t) - fi - fi -done -printf "%s " "${res[@]}" + printf "%s " "${res[@]}" +fi