github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_db_skip/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 19 run_sql "CREATE DATABASE $DB;" 20 21 run_sql "CREATE TABLE $DB.usertable1 ( \ 22 YCSB_KEY varchar(64) NOT NULL, \ 23 FIELD0 varchar(1) DEFAULT NULL, \ 24 PRIMARY KEY (YCSB_KEY) \ 25 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" 26 27 run_sql "INSERT INTO $DB.usertable1 VALUES (\"a\", \"b\");" 28 run_sql "INSERT INTO $DB.usertable1 VALUES (\"aa\", \"b\");" 29 30 # backup db 31 echo "backup start..." 32 run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$TEST_DIR/$DB" 33 34 run_sql "DROP DATABASE $DB;" 35 36 run_sql "CREATE DATABASE $DB;" 37 # restore db with skip-create-sql must failed 38 echo "restore start but must failed" 39 fail=false 40 run_br restore db --db $DB -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --no-schema=true || fail=true 41 if $fail; then 42 # Error: [schema:1146]Table 'br_db_skip.usertable1' doesn't exist 43 echo "TEST: [$TEST_NAME] restore $DB with no-schema must failed" 44 else 45 echo "TEST: [$TEST_NAME] restore $DB with no-schema not failed" 46 exit 1 47 fi 48 49 50 run_sql "CREATE TABLE $DB.usertable1 ( \ 51 YCSB_KEY varchar(64) NOT NULL, \ 52 FIELD0 varchar(1) DEFAULT NULL, \ 53 PRIMARY KEY (YCSB_KEY) \ 54 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" 55 56 echo "restore start must succeed" 57 fail=false 58 run_br restore db --db $DB -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --no-schema=true || fail=true 59 if $fail; then 60 echo "TEST: [$TEST_NAME] restore $DB with no-schema failed" 61 exit 1 62 else 63 echo "TEST: [$TEST_NAME] restore $DB with no-schema succeed" 64 fi 65 66 table_count=$(run_sql "use $DB; show tables;" | grep "Tables_in" | wc -l) 67 if [ "$table_count" -ne "1" ];then 68 echo "TEST: [$TEST_NAME] failed!" 69 exit 1 70 fi 71 72 run_sql "DROP DATABASE $DB;"