Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: divide all tests into the CI chunks including submodule tests #6198

Merged
merged 8 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +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))
@$(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 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
Copy link
Member

@HuSharp HuSharp Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need @$(FAILPOINT_DISABLE) or just by clean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This task is only used for the CI enviroment, so there is no need to do the clean-up work.


TSO_INTEGRATION_TEST_PKGS := $(PD_PKG)/tests/server/tso

Expand Down
6 changes: 3 additions & 3 deletions pd.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/grpcutil/grpcutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
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
28 changes: 13 additions & 15 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 -v -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to enable the failpoint?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be enabled by the root Makefile, so we don't need to enable it here again.

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
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.
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.
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 ./... -v -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 -v -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.