From 4bb5c2398b9f5767d7b7a0abe15b43aa6e2258dd Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Tue, 20 Jun 2023 15:17:42 +0800 Subject: [PATCH] ci: split integrations test to speed up (#6626) ref tikv/pd#4399 Signed-off-by: lhy1024 --- .github/workflows/pd-tests.yaml | 9 +++++---- Makefile | 7 +++++-- scripts/ci-subtask.sh | 11 +++++------ tests/integrations/client/Makefile | 2 +- tests/integrations/mcs/Makefile | 2 +- tests/integrations/tso/Makefile | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pd-tests.yaml b/.github/workflows/pd-tests.yaml index 83d4651ca3a..1a9e353b21a 100644 --- a/.github/workflows/pd-tests.yaml +++ b/.github/workflows/pd-tests.yaml @@ -23,9 +23,9 @@ jobs: strategy: fail-fast: true matrix: - worker_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + worker_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] outputs: - job-total: 10 + job-total: 13 steps: - uses: actions/setup-go@v3 with: @@ -44,9 +44,10 @@ jobs: - name: Make Test env: WORKER_ID: ${{ matrix.worker_id }} - WORKER_COUNT: 10 + WORKER_COUNT: 13 + JOB_COUNT: 10 # 11, 12 13 are for other integrations jobs run: | - make ci-test-job JOB_COUNT=$(($WORKER_COUNT)) JOB_INDEX=$WORKER_ID + make ci-test-job JOB_COUNT=$(($JOB_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 84b7ce37ee0..f6879cf20d1 100644 --- a/Makefile +++ b/Makefile @@ -215,8 +215,11 @@ 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 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 + if [[ $(JOB_INDEX) -le 10 ]]; then \ + CGO_ENABLED=1 go test -timeout=15m -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=./... $(shell ./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX)); \ + else \ + for mod in $(shell ./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX)); do cd $$mod && $(MAKE) ci-test-job && cd $(ROOT_PATH) > /dev/null && cat $$mod/covprofile >> covprofile; done; \ + fi TSO_INTEGRATION_TEST_PKGS := $(PD_PKG)/tests/server/tso diff --git a/scripts/ci-subtask.sh b/scripts/ci-subtask.sh index 9628f2688c5..389d7f43341 100755 --- a/scripts/ci-subtask.sh +++ b/scripts/ci-subtask.sh @@ -1,21 +1,21 @@ #!/bin/bash -# ./ci-subtask.sh +# ./ci-subtask.sh -if [[ $3 ]]; then +if [[ $2 -gt 10 ]]; 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 + if [[ "$t" = "./tests/integrations/client" && "$2" = 11 ]]; then printf "%s " "$t" break - elif [[ "$t" = "./tests/integrations/tso" && "$2" = 7 ]]; then + elif [[ "$t" = "./tests/integrations/tso" && "$2" = 12 ]]; then printf "%s " "$t" break - elif [[ "$t" = "./tests/integrations/mcs" && "$2" = 2 ]]; then + elif [[ "$t" = "./tests/integrations/mcs" && "$2" = 13 ]]; then printf "%s " "$t" break fi @@ -45,6 +45,5 @@ else scores[$min_i]=$((${scores[$min_i]} + $?)) [[ $(($min_i + 1)) -eq $2 ]] && res+=($t) done - printf "%s " "${res[@]}" fi diff --git a/tests/integrations/client/Makefile b/tests/integrations/client/Makefile index e8c2f30e2fa..71f6297270c 100644 --- a/tests/integrations/client/Makefile +++ b/tests/integrations/client/Makefile @@ -32,7 +32,7 @@ test: failpoint-enable $(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 -v -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 f2481a8bbd2..2628ea9e437 100644 --- a/tests/integrations/mcs/Makefile +++ b/tests/integrations/mcs/Makefile @@ -32,7 +32,7 @@ test: failpoint-enable $(MAKE) failpoint-disable ci-test-job: - CGO_ENABLED=1 go test ./... -timeout=15m -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=$(ROOT_PATH)/... github.com/tikv/pd/tests/integrations/mcs + CGO_ENABLED=1 go test ./... -v -timeout=15m -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 820bbf33ccf..4573863039c 100644 --- a/tests/integrations/tso/Makefile +++ b/tests/integrations/tso/Makefile @@ -32,7 +32,7 @@ test: failpoint-enable $(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 -v -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