github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/test/integration_tests/dm_collation/run.sh (about)

     1  #!/bin/bash
     2  
     3  set -eu
     4  
     5  WORK_DIR=$OUT_DIR/$TEST_NAME
     6  CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
     7  
     8  CONFIG="$DOCKER_COMPOSE_DIR/3m3e_with_s3.yaml $DOCKER_COMPOSE_DIR/dm_databases.yaml"
     9  CONFIG=$(adjust_config $OUT_DIR $TEST_NAME $CONFIG)
    10  echo "using adjusted configs to deploy cluster: $CONFIG"
    11  TABLE_NUM=500
    12  
    13  function run() {
    14  	start_engine_cluster $CONFIG
    15  	wait_mysql_online.sh --port 3306
    16  	wait_mysql_online.sh --port 3307
    17  	wait_mysql_online.sh --port 4000
    18  
    19  	# change default charset and collation for MySQL 8.0
    20  	run_sql --port 3307 "set global character_set_server='utf8mb4';set global collation_server='utf8mb4_bin';"
    21  
    22  	# prepare data
    23  
    24  	run_sql_file $CUR_DIR/data/db1.prepare.sql
    25  	run_sql_file --port 3307 $CUR_DIR/data/db2.prepare.sql
    26  
    27  	# create job
    28  	job_id=$(create_job "DM" "$CUR_DIR/conf/job.yaml" "dm_collation")
    29  
    30  	# a table with utf8mb4_0900_as_cs collation will fail the test. After we manually
    31  	# create the table, task can be continued.
    32  	exec_with_retry --count 30 "curl \"http://127.0.0.1:10245/api/v1/jobs/$job_id/status\" | tee /dev/stderr | grep -q 'utf8mb4_0900_as_cs'"
    33  	run_sql --port 4000 "create table test_panic.t1 (id int PRIMARY KEY, name varchar(20) COLLATE utf8mb4_bin);"
    34  	# after a manually resume, the task can be continued.
    35  	# duplicate request is OK
    36  	curl -X PUT "http://127.0.0.1:10245/api/v1/jobs/$job_id/status" -H 'Content-Type: application/json' -d '{"op": "resume"}'
    37  	curl -X PUT "http://127.0.0.1:10245/api/v1/jobs/$job_id/status" -H 'Content-Type: application/json' -d '{"op": "resume"}'
    38  
    39  	# wait for dump and load finished
    40  
    41  	exec_with_retry --count 30 "curl \"http://127.0.0.1:10245/api/v1/jobs/$job_id/status\" | tee /dev/stderr | jq -e '.task_status.\"mysql-01\".status.unit == \"DMSyncTask\" and .task_status.\"mysql-02\".status.unit == \"DMSyncTask\"'"
    42  	curl http://127.0.0.1:10245/api/v1/jobs/$job_id/status | tee /dev/stderr | jq -e '.finished_unit_status."mysql-02"[1].Status.finishedBytes == 248'
    43  
    44  	# check data
    45  
    46  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation.t1 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    47  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation.t2 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    48  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation2.t1 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    49  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation2.t2 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    50  
    51  	# insert increment data
    52  
    53  	run_sql_file $CUR_DIR/data/db1.increment.sql
    54  	run_sql_file --port 3307 $CUR_DIR/data/db2.increment.sql
    55  
    56  	# check data
    57  
    58  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation_increment.t1 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    59  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation_increment.t2 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    60  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation_increment2.t1 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    61  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation_increment2.t2 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    62  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation_server.t1 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    63  	exec_with_retry 'run_sql --port 4000 "select count(1) from sync_collation_server2.t1 where name =' "'aa'" '\G" | grep -Fq "count(1): 2"'
    64  
    65  	curl -X POST "http://127.0.0.1:10245/api/v1/jobs/$job_id/cancel"
    66  	curl -X DELETE "http://127.0.0.1:10245/api/v1/jobs/$job_id"
    67  
    68  }
    69  
    70  trap "stop_engine_cluster $WORK_DIR $CONFIG" EXIT
    71  run $*
    72  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"