Skip to content

Commit

Permalink
ci: split integrations test to speed up (tikv#6626)
Browse files Browse the repository at this point in the history
ref tikv#4399

Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 authored Jun 20, 2023
1 parent 3bdfef1 commit 4bb5c23
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/pd-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

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

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
Expand Down Expand Up @@ -45,6 +45,5 @@ else
scores[$min_i]=$((${scores[$min_i]} + $?))
[[ $(($min_i + 1)) -eq $2 ]] && res+=($t)
done

printf "%s " "${res[@]}"
fi
2 changes: 1 addition & 1 deletion tests/integrations/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/mcs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/tso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4bb5c23

Please sign in to comment.