github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/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 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 set -eu 56 57 if [ "$test_case" == "*" ]; then 58 for script in $CUR/*/run.sh; do 59 test_name="$(basename "$(dirname "$script")")" 60 run_case $test_name $script $sink_type 61 done 62 else 63 for name in $test_case; do 64 script="$CUR/$name/run.sh" 65 run_case $name $script $sink_type 66 done 67 fi 68 69 # with color 70 echo "\033[0;36m<<< Run all test success >>>\033[0m"