github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/_utils/check_changefeed_status (about) 1 #!/bin/bash 2 3 set -ex 4 5 # parameter 1: cdc endpoint 6 # parameter 2: changefeed id 7 # parameter 3: expected state 8 # parameter 4: last_warning or last_error 9 # parameter 5: error msg pattern 10 11 endpoint=${1} 12 changefeed_id=${2} 13 expected_state=${3} 14 field=${4} 15 error_pattern=${5} 16 17 info=$(curl $endpoint/api/v2/changefeeds/$changefeed_id/status) 18 echo "$info" 19 20 state=$(echo $info | jq -r '.state') 21 if [[ ! "$state" == "$expected_state" ]]; then 22 echo "changefeed state $state does not equal to $expected_state" 23 exit 1 24 fi 25 26 if [[ -z $field ]]; then 27 error_msg=$(echo $info | jq -r ".last_error") 28 if [[ ! $error_msg == "null" ]]; then 29 echo "last_error should be empty as expected" 30 exit 1 31 fi 32 error_msg=$(echo $info | jq -r ".last_warning") 33 if [[ ! $error_msg == "null" ]]; then 34 echo "last_warning should be empty as expected" 35 exit 1 36 fi 37 exit 0 38 fi 39 40 error_msg=$(echo $info | jq -r ".$field.message") 41 if [[ ! "$error_msg" =~ "$error_pattern" ]]; then 42 echo "error message '$error_msg' is not as expected '$error_pattern'" 43 exit 1 44 fi