github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/run.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright 2019 PingCAP, Inc.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -eu
    17  export PATH="tests/_utils:bin:$PATH"
    18  export TEST_DIR=/tmp/backup_restore_test
    19  
    20  # Reset TEST_DIR
    21  rm -rf $TEST_DIR && mkdir -p $TEST_DIR
    22  
    23  # Generate TLS certs
    24  tests/_utils/generate_certs &> /dev/null
    25  
    26  SELECTED_TEST_NAME="${TEST_NAME-$(find tests -mindepth 2 -maxdepth 2 -name run.sh | cut -d/ -f2 | sort)}"
    27  source tests/_utils/run_services
    28  
    29  trap stop_services EXIT
    30  start_services
    31  
    32  # Intermediate file needed because read can be used as a pipe target.
    33  # https://stackoverflow.com/q/2746553/
    34  run_curl "https://$PD_ADDR/pd/api/v1/version" | grep -o 'v[0-9.]\+' > "$TEST_DIR/cluster_version.txt"
    35  IFS='.' read CLUSTER_VERSION_MAJOR CLUSTER_VERSION_MINOR CLUSTER_VERSION_REVISION < "$TEST_DIR/cluster_version.txt"
    36  
    37  if [ "${1-}" = '--debug' ]; then
    38      echo 'You may now debug from another terminal. Press [ENTER] to continue.'
    39      read line
    40  fi
    41  
    42  echo "selected test cases: $SELECTED_TEST_NAME"
    43  
    44  # wait for global variable cache invalid
    45  sleep 2
    46  
    47  for casename in $SELECTED_TEST_NAME; do
    48      script=tests/$casename/run.sh
    49      echo "*===== Running test $script... =====*"
    50      INTEGRATION_TEST=1 \
    51      TEST_DIR="$TEST_DIR" \
    52      TEST_NAME="$casename" \
    53      CLUSTER_VERSION_MAJOR="${CLUSTER_VERSION_MAJOR#v}" \
    54      CLUSTER_VERSION_MINOR="$CLUSTER_VERSION_MINOR" \
    55      CLUSTER_VERSION_REVISION="$CLUSTER_VERSION_REVISION" \
    56      PD_ADDR="$PD_ADDR" \
    57      TIDB_IP="$TIDB_IP" \
    58      TIDB_PORT="$TIDB_PORT" \
    59      TIDB_ADDR="$TIDB_ADDR" \
    60      TIDB_STATUS_ADDR="$TIDB_STATUS_ADDR" \
    61      TIKV_ADDR="$TIKV_ADDR" \
    62      BR_LOG_TO_TERM=1 \
    63      bash "$script" && echo "TEST: [$casename] success!"
    64  done