github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_incompatible_tidb_config/run.sh (about) 1 #!/bin/bash 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 -eux 17 18 cur=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 19 source $cur/../_utils/run_services 20 21 DB="$TEST_NAME" 22 23 # prepare database 24 echo "Restart cluster with max-index-length=12288" 25 start_services --tidb-cfg $cur/config/tidb-max-index-length.toml 26 27 run_sql "drop schema if exists $DB;" 28 run_sql "create schema $DB;" 29 30 # test alter pk issue https://github.com/pingcap/br/issues/215 31 TABLE="t1" 32 INCREMENTAL_TABLE="t1inc" 33 34 run_sql "create table $DB.$TABLE (a int primary key nonclustered, b int unique);" 35 run_sql "insert into $DB.$TABLE values (42, 42);" 36 37 # backup 38 run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$TEST_DIR/$DB$TABLE" 39 40 run_sql "create table $DB.$INCREMENTAL_TABLE (a int primary key nonclustered, b int unique);" 41 run_sql "insert into $DB.$INCREMENTAL_TABLE values (42, 42);" 42 43 # drop pk 44 run_sql "alter table $DB.$INCREMENTAL_TABLE drop primary key" 45 run_sql "drop table $DB.$INCREMENTAL_TABLE" 46 run_sql "create table $DB.$INCREMENTAL_TABLE like $DB.$TABLE" 47 run_sql "insert into $DB.$INCREMENTAL_TABLE values (42, 42);" 48 49 # incremental backup 50 run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$TEST_DIR/$DB$INCREMENTAL_TABLE" 51 52 # restore 53 run_sql "drop schema $DB;" 54 55 run_br --pd $PD_ADDR restore db --db "$DB" -s "local://$TEST_DIR/$DB$TABLE" 56 57 run_br --pd $PD_ADDR restore db --db "$DB" -s "local://$TEST_DIR/$DB$INCREMENTAL_TABLE" 58 59 run_sql "drop schema $DB;" 60 run_sql "create schema $DB;" 61 62 # test max-index-length issue https://github.com/pingcap/br/issues/217 63 TABLE="t2" 64 run_sql "create table $DB.$TABLE (a varchar(3072) primary key);" 65 run_sql "insert into $DB.$TABLE values ('42');" 66 67 # backup 68 run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$TEST_DIR/$DB$TABLE" 69 70 # restore 71 run_sql "drop schema $DB;" 72 run_br --pd $PD_ADDR restore db --db "$DB" -s "local://$TEST_DIR/$DB$TABLE" 73 74 run_sql "drop schema $DB;" 75 76 # test auto random issue https://github.com/pingcap/br/issues/228 77 TABLE="t3" 78 INCREMENTAL_TABLE="t3inc" 79 run_sql "create schema $DB;" 80 run_sql "create table $DB.$TABLE (a bigint(11) NOT NULL /*T!30100 AUTO_RANDOM(5) */, PRIMARY KEY (a) clustered)" 81 run_sql "insert into $DB.$TABLE values ('42');" 82 83 # Full backup 84 run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$TEST_DIR/$DB$TABLE" 85 86 run_sql "create table $DB.$INCREMENTAL_TABLE (a bigint(11) NOT NULL /*T!30100 AUTO_RANDOM(5) */, PRIMARY KEY (a) clustered)" 87 run_sql "insert into $DB.$INCREMENTAL_TABLE values ('42');" 88 89 # incremental backup test for execute DDL 90 last_backup_ts=$(run_br validate decode --field="end-version" -s "local://$TEST_DIR/$DB$TABLE" | grep -oE "^[0-9]+") 91 run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$TEST_DIR/$DB$INCREMENTAL_TABLE" --lastbackupts $last_backup_ts 92 93 run_sql "drop schema $DB;" 94 95 # full restore 96 run_br --pd $PD_ADDR restore db --db "$DB" -s "local://$TEST_DIR/$DB$TABLE" 97 # incremental restore 98 run_br --pd $PD_ADDR restore db --db "$DB" -s "local://$TEST_DIR/$DB$INCREMENTAL_TABLE" 99 100 run_sql "drop schema $DB;" 101 102 # test auto random issue https://github.com/pingcap/br/issues/241 103 TABLE="t4" 104 run_sql "create schema $DB;" 105 run_sql "create table $DB.$TABLE(a bigint key clustered auto_random(5));" 106 run_sql "insert into $DB.$TABLE values (),(),(),(),();" 107 108 # Table backup 109 run_br --pd $PD_ADDR backup table --db "$DB" --table "$TABLE" -s "local://$TEST_DIR/$DB$TABLE" 110 run_sql "drop schema $DB;" 111 112 # Table restore, restore normally without Duplicate entry 113 run_br --pd $PD_ADDR restore table --db "$DB" --table "$TABLE" -s "local://$TEST_DIR/$DB$TABLE" 114 115 # run insert after restore 116 run_sql "insert into $DB.$TABLE values (),(),(),(),();" 117 118 row_count=$(run_sql "select a & b'0000011111111111111111111111111' from $DB.$TABLE;" | grep -v "a" | grep -v "-" | sort -u | wc -l) 119 if [ "$row_count" -ne "10" ];then 120 echo "TEST: [$TEST_NAME] failed!, because auto_random didn't rebase" 121 exit 1 122 fi 123 124 echo "Restart service with normal" 125 start_services