github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/run.sh (about) 1 #!/bin/bash 2 3 set -eu 4 5 OUT_DIR=/tmp/tidb_cdc_test 6 CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 7 export PATH=$PATH:$CUR/_utils:$CUR/../bin:$CUR/../../bin:$CUR/../../scripts/bin 8 9 mkdir -p $OUT_DIR || true 10 11 if [ "${1-}" = '--debug' ]; then 12 WORK_DIR=$OUT_DIR/debug 13 trap stop_tidb_cluster EXIT 14 15 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 16 17 PATH="$CUR/../bin:$CUR/_utils:$PATH" \ 18 LD_LIBRARY_PATH="$CUR/../bin:$CUR/_utils:$PATH" \ 19 OUT_DIR=$OUT_DIR \ 20 TEST_NAME="debug" \ 21 start_tidb_cluster --workdir $WORK_DIR 22 23 cdc server --log-file $WORK_DIR/cdc.log --log-level debug --addr 127.0.0.1:8300 >$WORK_DIR/stdout.log 2>&1 & 24 sleep 1 25 cdc cli changefeed create --sink-uri="mysql://normal:123456@127.0.0.1:3306/" 26 27 echo 'You may now debug from another terminal. Press [ENTER] to exit.' 28 read line 29 exit 0 30 fi 31 32 run_case() { 33 # cleanup test binaries and data, preserve logs, if we debug one case, 34 # these files will be preserved since no more case will be run. 35 find /tmp/tidb_cdc_test/*/* -type d | xargs rm -rf || true 36 local case=$1 37 local script=$2 38 local sink_type=$3 39 echo "=================>> Running test $script using Sink-Type: $sink_type... <<=================" 40 PATH="$CUR/../bin:$CUR/_utils:$PATH" \ 41 LD_LIBRARY_PATH="$CUR/../bin:$CUR/_utils:$PATH" \ 42 OUT_DIR=$OUT_DIR \ 43 TEST_NAME=$case \ 44 bash "$script" "$sink_type" 45 } 46 47 sink_type=$1 48 49 set +eu 50 test_case=$2 51 52 if [ -z "$test_case" ]; then 53 test_case="*" 54 fi 55 56 start_at=$3 57 run_test="no" 58 if [ -z "$start_at" ]; then 59 run_test="yes" 60 else 61 test_case="*" 62 fi 63 64 # Print environment variables. 65 env 66 set -eu 67 68 if [ "$test_case" == "*" ]; then 69 for script in $CUR/*/run.sh; do 70 test_name="$(basename "$(dirname "$script")")" 71 if [ "$run_test" == "yes" ] || [ "$start_at" == "$test_name" ]; then 72 run_test="yes" 73 run_case $test_name $script $sink_type 74 fi 75 done 76 else 77 for name in $test_case; do 78 script="$CUR/$name/run.sh" 79 run_case $name $script $sink_type 80 done 81 fi 82 83 # with color 84 echo "\033[0;36m<<< Run all test success >>>\033[0m"