|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# This script split the integration tests into 9 groups to support parallel group tests execution. |
| 4 | +# all the integration tests are located in br/tests directory. only the directories |
| 5 | +# containing run.sh will be considered as valid br integration tests. the script will print the total case number |
| 6 | + |
| 7 | +set -eo pipefail |
| 8 | + |
| 9 | +# Step 1 |
| 10 | +CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) |
| 11 | +group=$1 |
| 12 | +export COV_DIR="/tmp/group_cover" |
| 13 | +rm -rf $COV_DIR |
| 14 | +mkdir -p $COV_DIR |
| 15 | + |
| 16 | +# Define groups |
| 17 | +# Note: If new group is added, the group name must also be added to CI |
| 18 | +# * https://github.com/PingCAP-QE/ci/blob/main/pipelines/pingcap/tidb/latest/pull_br_integration_test.groovy |
| 19 | +# Each group of tests consumes as much time as possible, thus reducing CI waiting time. |
| 20 | +# Putting multiple light tests together and heavy tests in a separate group. |
| 21 | +declare -A groups |
| 22 | +groups=( |
| 23 | + ["G00"]="br_300_small_tables br_backup_empty br_backup_version br_cache_table br_case_sensitive br_charset_gbk br_check_new_collocation_enable br_history br_gcs br_rawkv br_tidb_placement_policy" |
| 24 | + ["G01"]="br_autoid br_crypter2 br_db br_check_dup_table br_db_online br_db_online_newkv br_db_skip br_debug_meta br_ebs br_foreign_key br_full br_table_partition br_full_ddl br_tiflash" |
| 25 | + ["G02"]="br_full_cluster_restore br_full_index br_incremental_ddl br_pitr_failpoint br_pitr_gc_safepoint br_other br_pitr_long_running_schema_loading" |
| 26 | + ["G03"]='br_incompatible_tidb_config br_incremental br_incremental_index br_incremental_only_ddl br_incremental_same_table br_insert_after_restore br_key_locked br_log_test br_move_backup br_mv_index' |
| 27 | + ["G04"]='br_range br_replica_read br_restore_TDE_enable br_restore_log_task_enable br_s3 br_shuffle_leader br_shuffle_region br_single_table ' |
| 28 | + ["G05"]='br_skip_checksum br_split_region_fail br_systables br_table_filter br_txn br_stats br_clustered_index br_crypter br_partition_add_index' |
| 29 | + ["G06"]='br_tikv_outage br_tikv_outage3 br_restore_checkpoint br_encryption' |
| 30 | + ["G07"]='br_pitr' |
| 31 | + ["G08"]='br_tikv_outage2 br_ttl br_views_and_sequences br_z_gc_safepoint br_autorandom br_file_corruption br_tiflash_conflict' |
| 32 | +) |
| 33 | + |
| 34 | +# Get other cases not in groups, to avoid missing any case |
| 35 | +others=() |
| 36 | +for script in "$CUR"/*/run.sh; do |
| 37 | + test_name="$(basename "$(dirname "$script")")" |
| 38 | + if [[ $test_name != br* ]]; then |
| 39 | + continue |
| 40 | + fi |
| 41 | + # shellcheck disable=SC2076 |
| 42 | + if [[ ! " ${groups[*]} " =~ " ${test_name} " ]]; then |
| 43 | + others=("${others[@]} ${test_name}") |
| 44 | + fi |
| 45 | +done |
| 46 | + |
| 47 | +# enable local encryption for all tests |
| 48 | +ENABLE_ENCRYPTION=true |
| 49 | +export ENABLE_ENCRYPTION |
| 50 | + |
| 51 | +if [[ "$group" == "others" ]]; then |
| 52 | + if [[ -z $others ]]; then |
| 53 | + echo "All br integration test cases have been added to groups" |
| 54 | + exit 0 |
| 55 | + fi |
| 56 | + echo "Error: "$others" is not added to any group in br/tests/run_group_br_tests.sh" |
| 57 | + exit 1 |
| 58 | +elif [[ " ${!groups[*]} " =~ " ${group} " ]]; then |
| 59 | + test_names="${groups[${group}]}" |
| 60 | + # Run test cases |
| 61 | + if [[ -n $test_names ]]; then |
| 62 | + echo "" |
| 63 | + echo "Run cases: ${test_names}" |
| 64 | + for case_name in $test_names; do |
| 65 | + echo "Run cases: ${case_name}" |
| 66 | + rm -rf /tmp/backup_restore_test |
| 67 | + mkdir -p /tmp/backup_restore_test |
| 68 | + TEST_NAME=${case_name} ${CUR}/run.sh |
| 69 | + done |
| 70 | + fi |
| 71 | +else |
| 72 | + echo "Error: invalid group name: ${group}" |
| 73 | + exit 1 |
| 74 | +fi |
0 commit comments