github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_table_partition/run.sh (about) 1 #!/usr/bin/env bash 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 TABLE_COUNT=16 20 PATH="tests/$TEST_NAME:bin:$PATH" 21 22 echo "load data..." 23 DB=$DB TABLE=$TABLE TABLE_COUNT=$TABLE_COUNT prepare.sh 24 25 declare -A row_count_ori 26 declare -A row_count_new 27 28 for i in $(seq $TABLE_COUNT) _Hash _List; do 29 row_count_ori[$i]=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE${i};" | awk '/COUNT/{print $2}') 30 done 31 32 # backup full 33 echo "backup start..." 34 run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/$DB" 35 36 run_sql "DROP DATABASE $DB;" 37 38 # restore full 39 echo "restore start..." 40 run_br restore full -s "local://$TEST_DIR/$DB" --pd $PD_ADDR 41 42 for i in $(seq $TABLE_COUNT) _Hash _List; do 43 run_sql "SHOW CREATE TABLE $DB.$TABLE${i};" | grep 'PARTITION' 44 row_count_new[$i]=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE${i};" | awk '/COUNT/{print $2}') 45 done 46 47 fail=false 48 for i in $(seq $TABLE_COUNT) _Hash _List; do 49 if [ "${row_count_ori[$i]}" != "${row_count_new[$i]}" ];then 50 fail=true 51 echo "TEST: [$TEST_NAME] fail on table $DB.$TABLE${i}" 52 fi 53 echo "table $DB.$TABLE${i} [original] row count: ${row_count_ori[$i]}, [after br] row count: ${row_count_new[$i]}" 54 done 55 56 if $fail; then 57 echo "TEST: [$TEST_NAME] failed!" 58 exit 1 59 fi 60 61 run_sql "DROP DATABASE $DB;"