github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/_utils/check_changefeed_state (about)

     1  #!/bin/bash
     2  
     3  set -eux
     4  
     5  # parameter 1: pd endpoints
     6  # parameter 2: changefeed id
     7  # parameter 3: expected state
     8  # parameter 4: error msg
     9  # parameter last: tls dir
    10  
    11  endpoints=${1}
    12  changefeed_id=${2}
    13  expected_state=${3}
    14  error_msg=${4}
    15  tls_dir=${!#}
    16  
    17  if [[ "$endpoints" =~ "https" ]]; then
    18  	info=$(cdc cli changefeed query --ca="${tls_dir}/ca.pem" --cert="${tls_dir}/client.pem" --key="${tls_dir}/client-key.pem" --pd=$endpoints -c $changefeed_id -s)
    19  else
    20  	info=$(cdc cli changefeed query --pd=$endpoints -c $changefeed_id -s)
    21  fi
    22  
    23  echo "$info"
    24  
    25  state=$(echo $info | jq -r '.state')
    26  if [[ ! "$state" == "$expected_state" ]]; then
    27  	echo "changefeed state $state does not equal to $expected_state"
    28  	exit 1
    29  fi
    30  
    31  message=$(echo $info | jq -r '.error.message')
    32  if [[ ! "$message" =~ "$error_msg" ]]; then
    33  	echo "error message '$message' is not as expected '$error_msg'"
    34  	exit 1
    35  fi