github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_shuffle_leader/run.sh (about) 1 #!/bin/sh 2 # 3 # Copyright 2019 PingCAP, Inc. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -eu 17 DB="$TEST_NAME" 18 TABLE="usertable" 19 20 run_sql "CREATE DATABASE $DB;" 21 22 go-ycsb load mysql -P tests/$TEST_NAME/workload -p mysql.host=$TIDB_IP -p mysql.port=$TIDB_PORT -p mysql.user=root -p mysql.db=$DB 23 24 row_count_ori=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') 25 26 # add shuffle leader scheduler 27 run_pd_ctl -u https://$PD_ADDR sched add shuffle-leader-scheduler 28 29 # backup with shuffle leader 30 echo "backup start..." 31 run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB" --db $DB -t $TABLE 32 33 run_sql "DROP TABLE $DB.$TABLE;" 34 35 # restore with shuffle leader 36 echo "restore start..." 37 run_br restore table --db $DB --table $TABLE -s "local://$TEST_DIR/$DB" --pd $PD_ADDR 38 39 # remove shuffle leader scheduler 40 run_pd_ctl -u https://$PD_ADDR sched remove shuffle-leader-scheduler 41 42 row_count_new=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') 43 44 echo "[original] row count: $row_count_ori, [after br] row count: $row_count_new" 45 46 if [ "$row_count_ori" -ne "$row_count_new" ];then 47 echo "TEST: [$TEST_NAME] failed!" 48 exit 1 49 fi 50 51 run_sql "DROP DATABASE $DB;"