github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/consistent_replicate_nfs/run.sh (about) 1 #!/bin/bash 2 3 set -eu 4 5 CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 6 source $CUR/../_utils/test_prepare 7 WORK_DIR=$OUT_DIR/$TEST_NAME 8 CDC_BINARY=cdc.test 9 SINK_TYPE=$1 10 11 stop() { 12 # to distinguish whether the test failed in the DML synchronization phase or the DDL synchronization phase 13 echo $(mysql -h${DOWN_TIDB_HOST} -P${DOWN_TIDB_PORT} -uroot -e "select count(*) from consistent_replicate_nfs.usertable;") 14 stop_tidb_cluster 15 } 16 17 function run() { 18 # we only support eventually consistent replication with MySQL sink 19 if [ "$SINK_TYPE" != "mysql" ]; then 20 return 21 fi 22 23 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 24 25 start_tidb_cluster --workdir $WORK_DIR 26 27 cd $WORK_DIR 28 29 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY 30 31 SINK_URI="mysql://normal:123456@127.0.0.1:3306/" 32 changefeed_id=$(cdc cli changefeed create --sink-uri="$SINK_URI" --config="$CUR/conf/changefeed.toml" 2>&1 | tail -n2 | head -n1 | awk '{print $2}') 33 34 run_sql "CREATE DATABASE consistent_replicate_nfs;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 35 go-ycsb load mysql -P $CUR/conf/workload -p mysql.host=${UP_TIDB_HOST} -p mysql.port=${UP_TIDB_PORT} -p mysql.user=root -p mysql.db=consistent_replicate_nfs 36 check_table_exists "consistent_replicate_nfs.usertable" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 37 38 cleanup_process $CDC_BINARY 39 # to ensure row changed events have been replicated to TiCDC 40 sleep 10 41 42 storage_path="nfs://$WORK_DIR/nfs/redo" 43 tmp_download_path=$WORK_DIR/cdc_data/redo/$changefeed_id 44 rts=$(cdc redo meta --storage="$storage_path" --tmp-dir="$tmp_download_path" | grep -oE "resolved-ts:[0-9]+" | awk -F: '{print $2}') 45 46 sed "s/<placeholder>/$rts/g" $CUR/conf/diff_config.toml >$WORK_DIR/diff_config.toml 47 48 cat $WORK_DIR/diff_config.toml 49 cdc redo apply --tmp-dir="$tmp_download_path/apply" --storage="$storage_path" --sink-uri="mysql://normal:123456@127.0.0.1:3306/" 50 check_sync_diff $WORK_DIR $WORK_DIR/diff_config.toml 51 } 52 53 trap stop EXIT 54 run $* 55 check_logs $WORK_DIR 56 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"