Skip to content

Commit

Permalink
Try to break up all tests into the chunks
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Mar 24, 2023
1 parent 19f7dd9 commit c5a767b
Show file tree
Hide file tree
Showing 49 changed files with 83 additions and 81 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pd-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 11 additions & 4 deletions scripts/ci-subtask.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/bash

# ./ci-subtask.sh <TOTAL_TASK_N> <TASK_INDEX>
# ./ci-subtask.sh <TOTAL_TASK_N> <TASK_INDEX> <IS_INTEGRATION_TEST>

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
Expand Down
30 changes: 14 additions & 16 deletions tests/client/Makefile → tests/integrations/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions tests/client/go.mod → tests/integrations/client/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
File renamed without changes.
File renamed without changes.
25 changes: 13 additions & 12 deletions tests/mcs/Makefile → tests/integrations/mcs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
18 changes: 9 additions & 9 deletions tests/mcs/go.mod → tests/integrations/mcs/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
25 changes: 13 additions & 12 deletions tests/tso/Makefile → tests/integrations/tso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
10 changes: 5 additions & 5 deletions tests/tso/go.mod → tests/integrations/tso/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
File renamed without changes.

0 comments on commit c5a767b

Please sign in to comment.