github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_key_locked/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 18 DB="$TEST_NAME" 19 TABLE="usertable" 20 21 run_sql "CREATE DATABASE $DB;" 22 23 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 24 25 row_count_ori=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') 26 27 # put locks with TTL 10s, we assume a normal backup finishs within 10s, so it will meet locks. 28 bin/locker \ 29 -tidb $TIDB_STATUS_ADDR \ 30 -pd $PD_ADDR \ 31 -ca "$TEST_DIR/certs/ca.pem" \ 32 -cert "$TEST_DIR/certs/br.pem" \ 33 -key "$TEST_DIR/certs/br.key" \ 34 -db $DB -table $TABLE -lock-ttl "10s" -run-timeout "3s" 35 36 # backup table 37 echo "backup start..." 38 run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB" --db $DB -t $TABLE 39 40 run_sql "DROP TABLE $DB.$TABLE;" 41 42 # restore table 43 echo "restore start..." 44 run_br restore table --db $DB --table $TABLE -s "local://$TEST_DIR/$DB" --pd $PD_ADDR 45 46 row_count_new=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') 47 48 echo "[original] row count: $row_count_ori, [after br] row count: $row_count_new" 49 50 if [ "$row_count_ori" -ne "$row_count_new" ];then 51 echo "TEST: [$TEST_NAME] failed!" 52 exit 1 53 fi 54 55 run_sql "DROP DATABASE $DB;"