github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/_utils/run_cdc_server (about)

     1  #!/bin/bash
     2  
     3  # --workdir: work directory
     4  # --tlsdir: work directory
     5  # --cert-allowed-cn: cert allowed cn
     6  # --binary: path to cdc test binary
     7  # --logsuffix: log suffix
     8  # --addr: address
     9  # --pd: pd address
    10  
    11  set -e
    12  
    13  workdir=
    14  tls=
    15  certcn=
    16  binary=
    17  logsuffix=
    18  addr=
    19  pd_addr=
    20  pwd=$pwd
    21  log_level=debug
    22  restart=
    23  failpoint=$GO_FAILPOINTS
    24  config_path=
    25  data_dir=
    26  
    27  while [[ ${1} ]]; do
    28      case "${1}" in
    29          --workdir)
    30              workdir=${2}
    31              shift
    32              ;;
    33          --tlsdir)
    34              tls="--ca ${2}/ca.pem --cert ${2}/server.pem --key ${2}/server-key.pem"
    35              shift
    36              ;;
    37          --cert-allowed-cn)
    38              certcn="--cert-allowed-cn ${2}"
    39              shift
    40              ;;
    41          --binary)
    42              binary=${2}
    43              shift
    44              ;;
    45          --logsuffix)
    46              logsuffix=${2}
    47              shift
    48              ;;
    49          --addr)
    50              addr="--addr ${2}"
    51              shift
    52              ;;
    53          --pd)
    54              pd_addr="--pd ${2}"
    55              shift
    56              ;;
    57          --loglevel)
    58              log_level=${2}
    59              shift
    60              ;;
    61          --restart)
    62              restart=${2}
    63              shift
    64              ;;
    65          --failpoint)
    66              failpoint=${2}
    67              shift
    68              ;;
    69          --config)
    70              config_path="--config ${2}"
    71              shift
    72              ;;
    73          --data-dir)
    74              data_dir=${2}
    75              shift
    76              ;;
    77          *)
    78              echo "Unknown parameter: ${1}" >&2
    79              exit 1
    80      esac
    81  
    82      if ! shift; then
    83          echo 'Missing parameter argument.' >&2
    84          exit 1
    85      fi
    86  done
    87  
    88  if [ -z "$data_dir" ]; then
    89      data_dir=${workdir}/cdc_data${logsuffix}
    90  fi
    91  
    92  echo "[$(date)] <<<<<< START cdc server in $TEST_NAME case >>>>>>"
    93  cd $workdir
    94  pid=$(ps -C run_cdc_server -o pid=|tr -d '[:space:]')
    95  # Uncomment to turn on grpc versbose log.
    96  # GRPC_GO_LOG_VERBOSITY_LEVEL=99 GRPC_GO_LOG_SEVERITY_LEVEL=debug \
    97  
    98  if [[ "$restart" == "true" ]]; then
    99    while true; do
   100        GO_FAILPOINTS=$failpoint $binary -test.coverprofile="$OUT_DIR/cov.$TEST_NAME.$pid.out" server \
   101          --log-file $workdir/cdc$logsuffix.log \
   102          --log-level $log_level \
   103          --sorter-num-workerpool-goroutine 4 \
   104          --data-dir "$data_dir" \
   105          $config_path \
   106          $tls \
   107          $certcn \
   108          $addr \
   109          $pd_addr &>> $workdir/stdout$logsuffix.log
   110        if [ $? -eq 143 ]; then
   111          break
   112        fi
   113        sleep 1
   114    done &
   115  else
   116    GO_FAILPOINTS=$failpoint $binary -test.coverprofile="$OUT_DIR/cov.$TEST_NAME.$pid.out" server \
   117      --log-file $workdir/cdc$logsuffix.log \
   118      --log-level $log_level \
   119      --sorter-num-workerpool-goroutine 4 \
   120      --data-dir "$data_dir" \
   121      $config_path \
   122      $tls \
   123      $certcn \
   124      $addr \
   125      $pd_addr &>> $workdir/stdout$log_suffix.log &
   126  fi
   127  
   128  cd $pwd
   129  
   130