-
Notifications
You must be signed in to change notification settings - Fork 726
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: husharp <[email protected]>
- Loading branch information
Showing
16 changed files
with
409 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,19 @@ jobs: | |
strategy: | ||
fail-fast: true | ||
matrix: | ||
worker_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | ||
include: | ||
- worker_id: 1 | ||
name: 'Unit Test' | ||
- worker_id: 2 | ||
name: 'Tools Test' | ||
- worker_id: 3 | ||
name: 'Client Integration Test' | ||
- worker_id: 4 | ||
name: 'TSO Integration Test' | ||
- worker_id: 5 | ||
name: 'MicroService Integration Test' | ||
outputs: | ||
job-total: 13 | ||
job-total: 5 | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
|
@@ -43,15 +53,13 @@ jobs: | |
**/.tools | ||
**/.dashboard_download_cache | ||
key: ${{ runner.os }}-go-${{ matrix.worker_id }}-${{ hashFiles('**/go.sum') }} | ||
- name: Make Test | ||
- name: ${{ matrix.name }} | ||
env: | ||
WORKER_ID: ${{ matrix.worker_id }} | ||
WORKER_COUNT: 13 | ||
JOB_COUNT: 9 # 10 is tools test, 11, 12, 13 are for other integrations jobs | ||
WORKER_COUNT: 5 | ||
run: | | ||
make ci-test-job JOB_COUNT=$(($JOB_COUNT)) JOB_INDEX=$WORKER_ID | ||
make ci-test-job JOB_INDEX=$WORKER_ID | ||
mv covprofile covprofile_$WORKER_ID | ||
sed -i "/failpoint_binding/d" covprofile_$WORKER_ID | ||
- name: Upload coverage result ${{ matrix.worker_id }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
|
@@ -70,7 +78,11 @@ jobs: | |
- name: Merge | ||
env: | ||
TOTAL_JOBS: ${{needs.chunks.outputs.job-total}} | ||
run: for i in $(seq 1 $TOTAL_JOBS); do cat covprofile_$i >> covprofile; done | ||
run: | | ||
for i in $(seq 1 $TOTAL_JOBS); do cat covprofile_$i >> covprofile; done | ||
sed -i "/failpoint_binding/d" covprofile | ||
# only keep the first line(`mode: aomic`) of the coverage profile | ||
sed -i '2,${/mode: atomic/d;}' covprofile | ||
- name: Send coverage | ||
uses: codecov/[email protected] | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ./ci-subtask.sh <TOTAL_TASK_N> <TASK_INDEX> | ||
# ./ci-subtask.sh <TASK_INDEX> | ||
|
||
ROOT_PATH_COV=$(pwd)/covprofile | ||
|
||
if [[ $2 -gt 9 ]]; then | ||
# run tools tests | ||
if [[ $2 -eq 10 ]]; then | ||
# Currently, we only have 3 integration tests, so we can hardcode the task index. | ||
integrations_dir=$(pwd)/tests/integrations | ||
|
||
case $1 in | ||
1) | ||
# unit tests ignore `tests` | ||
./bin/pd-dev run --ignore tests --race --coverprofile $ROOT_PATH_COV || exit 1 | ||
# tools tests | ||
cd ./tools && make ci-test-job && cat covprofile >> $ROOT_PATH_COV || exit 1 | ||
exit | ||
fi | ||
|
||
# Currently, we only have 3 integration tests, so we can hardcode the task index. | ||
integrations_dir=$(pwd)/tests/integrations | ||
integrations_tasks=($(find "$integrations_dir" -mindepth 1 -maxdepth 1 -type d)) | ||
for t in "${integrations_tasks[@]}"; do | ||
if [[ "$t" = "$integrations_dir/client" && $2 -eq 11 ]]; then | ||
cd ./client && make ci-test-job && cat covprofile >> $ROOT_PATH_COV || exit 1 | ||
cd $integrations_dir && make ci-test-job test_name=client && cat ./client/covprofile >> $ROOT_PATH_COV || exit 1 | ||
elif [[ "$t" = "$integrations_dir/tso" && $2 -eq 12 ]]; then | ||
cd $integrations_dir && make ci-test-job test_name=tso && cat ./tso/covprofile >> $ROOT_PATH_COV || exit 1 | ||
elif [[ "$t" = "$integrations_dir/mcs" && $2 -eq 13 ]]; then | ||
cd $integrations_dir && make ci-test-job test_name=mcs && cat ./mcs/covprofile >> $ROOT_PATH_COV || exit 1 | ||
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 == "github.com/tikv/pd/server/api" ]] && return 30 | ||
[[ $1 == "github.com/tikv/pd/pkg/schedule" ]] && return 30 | ||
[[ $1 == "github.com/tikv/pd/pkg/core" ]] && return 30 | ||
[[ $1 == "github.com/tikv/pd/tests/server/api" ]] && return 30 | ||
[[ $1 =~ "pd/tests" ]] && return 5 | ||
return 1 | ||
} | ||
|
||
# Create an associative array to store the weight of each task. | ||
declare -A task_weights | ||
for t in ${tasks[@]}; do | ||
weight $t | ||
task_weights[$t]=$? | ||
done | ||
|
||
# Sort tasks by weight in descending order. | ||
tasks=($(printf "%s\n" "${tasks[@]}" | sort -rn)) | ||
|
||
scores=($(seq "$1" | xargs -I{} echo 0)) | ||
|
||
res=() | ||
for t in ${tasks[@]}; do | ||
min_i=0 | ||
for i in ${!scores[@]}; do | ||
[[ ${scores[i]} -lt ${scores[$min_i]} ]] && min_i=$i | ||
done | ||
scores[$min_i]=$((${scores[$min_i]} + ${task_weights[$t]})) | ||
[[ $(($min_i + 1)) -eq $2 ]] && res+=($t) | ||
done | ||
|
||
CGO_ENABLED=1 go test -timeout=15m -tags deadlock -race -cover -covermode=atomic -coverprofile=$ROOT_PATH_COV -coverpkg=./... ${res[@]} | ||
fi | ||
;; | ||
2) | ||
# unit tests only for `tests` | ||
./bin/pd-dev run tests --race --coverprofile $ROOT_PATH_COV || exit 1 | ||
;; | ||
3) | ||
# client tests | ||
cd ./client && make ci-test-job && cat covprofile >> $ROOT_PATH_COV || exit 1 | ||
# integration test client | ||
./bin/pd-dev it run client --race --coverprofile $ROOT_PATH_COV || exit 1 | ||
;; | ||
4) | ||
# integration test tso | ||
./bin/pd-dev it run tso --race --coverprofile $ROOT_PATH_COV || exit 1 | ||
;; | ||
5) | ||
# integration test mcs | ||
./bin/pd-dev it run mcs --race --coverprofile $ROOT_PATH_COV || exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.