github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_skip_checksum/run.sh (about) 1 #!/bin/sh 2 # 3 # Copyright 2020 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 DB_COUNT=3 20 21 for i in $(seq $DB_COUNT); do 22 run_sql "CREATE DATABASE $DB${i};" 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${i} 24 done 25 26 for i in $(seq $DB_COUNT); do 27 row_count_ori[${i}]=$(run_sql "SELECT COUNT(*) FROM $DB${i}.$TABLE;" | awk '/COUNT/{print $2}') 28 done 29 30 # backup full, skipping generate checksum. 31 echo "backup start..." 32 run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/$DB" --checksum=false 33 34 for i in $(seq $DB_COUNT); do 35 run_sql "DROP DATABASE $DB${i};" 36 done 37 38 # restore full, skipping genreate checksum. 39 echo "restore start..." 40 run_br restore full -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --ratelimit 1024 --checksum=false 41 42 for i in $(seq $DB_COUNT); do 43 row_count_new[${i}]=$(run_sql "SELECT COUNT(*) FROM $DB${i}.$TABLE;" | awk '/COUNT/{print $2}') 44 done 45 46 fail=false 47 for i in $(seq $DB_COUNT); do 48 if [ "${row_count_ori[i]}" != "${row_count_new[i]}" ];then 49 fail=true 50 echo "TEST: [$TEST_NAME] fail on database $DB${i}" 51 fi 52 echo "database $DB${i} [original] row count: ${row_count_ori[i]}, [after br] row count: ${row_count_new[i]}" 53 done 54 55 if $fail; then 56 echo "TEST: [$TEST_NAME] failed on restore with skipping checksum!" 57 exit 1 58 fi 59 60 # Let drop it again. Try to restore without disable checksum. 61 for i in $(seq $DB_COUNT); do 62 run_sql "DROP DATABASE $DB${i};" 63 done 64 echo "restore(with checksum) start..." 65 run_br restore full -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --ratelimit 1024 66 67 for i in $(seq $DB_COUNT); do 68 row_count_new[${i}]=$(run_sql "SELECT COUNT(*) FROM $DB${i}.$TABLE;" | awk '/COUNT/{print $2}') 69 done 70 71 for i in $(seq $DB_COUNT); do 72 if [ "${row_count_ori[i]}" != "${row_count_new[i]}" ];then 73 fail=true 74 echo "TEST: [$TEST_NAME] fail on database $DB${i}" 75 fi 76 echo "database $DB${i} [original] row count: ${row_count_ori[i]}, [after br] row count: ${row_count_new[i]}" 77 done 78 79 if $fail; then 80 echo "TEST: [$TEST_NAME] failed on restore without skipping checksum!" 81 exit 1 82 fi 83 84 for i in $(seq $DB_COUNT); do 85 run_sql "DROP DATABASE $DB${i};" 86 done