github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_incremental/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 18 check_cluster_version 4 0 0 "incremental restore" || exit 0 19 20 DB_NAME=incr 21 22 for backend in importer local; do 23 run_sql "DROP DATABASE IF EXISTS incr;" 24 run_lightning --backend $backend 25 26 for tbl in auto_random pk_auto_inc rowid_uk_inc uk_auto_inc; do 27 run_sql "SELECT count(*) from incr.$tbl" 28 check_contains "count(*): 3" 29 done 30 31 for tbl in auto_random pk_auto_inc rowid_uk_inc uk_auto_inc; do 32 if [ "$tbl" = "auto_random" ]; then 33 run_sql "SELECT id & b'000001111111111111111111111111111111111111111111111111111111111' as inc FROM incr.$tbl" 34 else 35 run_sql "SELECT id as inc FROM incr.$tbl" 36 fi 37 check_contains 'inc: 1' 38 check_contains 'inc: 2' 39 check_contains 'inc: 3' 40 done 41 42 for tbl in pk_auto_inc rowid_uk_inc; do 43 run_sql "SELECT group_concat(v) from incr.$tbl group by 'all';" 44 check_contains "group_concat(v): a,b,c" 45 done 46 47 run_sql "SELECT sum(pk) from incr.uk_auto_inc;" 48 check_contains "sum(pk): 6" 49 50 # incrementally import all data in data1 51 run_lightning --backend $backend -d "tests/$TEST_NAME/data1" 52 53 for tbl in auto_random pk_auto_inc rowid_uk_inc uk_auto_inc; do 54 run_sql "SELECT count(*) from incr.$tbl" 55 check_contains "count(*): 6" 56 done 57 58 for tbl in auto_random pk_auto_inc rowid_uk_inc uk_auto_inc; do 59 if [ "$tbl" = "auto_random" ]; then 60 run_sql "SELECT id & b'000001111111111111111111111111111111111111111111111111111111111' as inc FROM incr.$tbl" 61 else 62 run_sql "SELECT id as inc FROM incr.$tbl" 63 fi 64 check_contains 'inc: 4' 65 check_contains 'inc: 5' 66 check_contains 'inc: 6' 67 done 68 69 for tbl in pk_auto_inc rowid_uk_inc; do 70 run_sql "SELECT group_concat(v) from incr.$tbl group by 'all';" 71 check_contains "group_concat(v): a,b,c,d,e,f" 72 done 73 74 run_sql "SELECT sum(pk) from incr.uk_auto_inc;" 75 check_contains "sum(pk): 21" 76 done