github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/test/integration_tests/run.sh (about)

     1  #!/bin/bash
     2  
     3  set -eu
     4  
     5  CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
     6  export DOCKER_COMPOSE_DIR=$(cd $CUR_DIR/../../../deployments/engine/docker-compose/ && pwd)
     7  export PATH=$PATH:$CUR_DIR/../utils
     8  export OUT_DIR=/tmp/tiflow_engine_test
     9  mkdir -p $OUT_DIR || true
    10  
    11  if [ "${1-}" = 'debug' ]; then
    12  	shift
    13  	if [[ $# -gt 0 ]]; then
    14  		cnf=$*
    15  	else
    16  		cnf="$DOCKER_COMPOSE_DIR/1m1e.yaml"
    17  		echo "got empty file, use default config: ${cnf}"
    18  	fi
    19  
    20  	TEST_NAME=debug
    21  	WORK_DIR=$OUT_DIR/$TEST_NAME
    22  	CONFIG=$(adjust_config $OUT_DIR $TEST_NAME $cnf)
    23  	trap "stop_engine_cluster $WORK_DIR $CONFIG" EXIT
    24  	start_engine_cluster $CONFIG
    25  
    26  	echo 'You may now debug from another terminal. Press [ENTER] to exit.'
    27  	read line
    28  	exit 0
    29  fi
    30  
    31  run_case() {
    32  	# cleanup test binaries and data, preserve logs, if we debug one case,
    33  	# these files will be preserved since no more case will be run.
    34  	find /tmp/tiflow_engine_test/*/* -type d | xargs rm -rf || true
    35  	local case=$1
    36  	local script=$2
    37  
    38  	# validate the case script
    39  	check_case.sh
    40  
    41  	echo "=================>> Running test $script... <<================="
    42  	PATH="$PATH:$CUR_DIR/../utils" \
    43  		OUT_DIR=$OUT_DIR \
    44  		TEST_NAME=$case \
    45  		DOCKER_COMPOSE_DIR=$DOCKER_COMPOSE_DIR \
    46  		bash "$script"
    47  }
    48  
    49  set +eu
    50  
    51  test_case=$1
    52  if [ -z "$test_case" ]; then
    53  	test_case="*"
    54  fi
    55  
    56  start_at=$2
    57  run_test="no"
    58  if [ -z "$start_at" ]; then
    59  	run_test="yes"
    60  else
    61  	test_case="*"
    62  fi
    63  
    64  set -eu
    65  if [ "$test_case" == "*" ]; then
    66  	for script in $CUR_DIR/*/run.sh; do
    67  		test_name="$(basename "$(dirname "$script")")"
    68  		if [ "$run_test" == "yes" ] || [ "$start_at" == "$test_name" ]; then
    69  			run_test="yes"
    70  			run_case $test_name $script
    71  		fi
    72  	done
    73  else
    74  	for name in $test_case; do
    75  		script="$CUR_DIR/$name/run.sh"
    76  		run_case $name $script
    77  	done
    78  fi
    79  
    80  # with color
    81  echo "\033[0;36m<<< Run all test success >>>\033[0m"