github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_common_handle/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 check_cluster_version 4 0 0 'local backend' || exit 0 17 18 # enable cluster index 19 run_sql 'set @@global.tidb_enable_clustered_index = 1' || exit 0 20 # wait for global variable cache invalid 21 sleep 2 22 23 set -euE 24 25 # Populate the mydumper source 26 DBPATH="$TEST_DIR/ch.mydump" 27 mkdir -p $DBPATH 28 echo 'CREATE DATABASE ch;' > "$DBPATH/ch-schema-create.sql" 29 # create table with non-integer primary key, so that cluster index will be used 30 echo "CREATE TABLE t(s varchar(32), i INT, j TINYINT, PRIMARY KEY(s, i));" > "$DBPATH/ch.t-schema.sql" 31 cat > "$DBPATH/ch.t.0.sql" << _EOF_ 32 INSERT INTO t (s, i, j) VALUES 33 ("this_is_test1", 1, 1), 34 ("this_is_test2", 2, 2), 35 ("this_is_test3", 3, 3), 36 ("this_is_test4", 4, 4), 37 ("this_is_test5", 5, 5); 38 _EOF_ 39 echo 'INSERT INTO t(s, i, j) VALUES ("another test case", 6, 6);' > "$DBPATH/ch.t.1.sql" 40 41 for BACKEND in local importer tidb; do 42 # Start importing the tables. 43 run_sql 'DROP DATABASE IF EXISTS ch' 44 45 run_lightning -d "$DBPATH" --backend $BACKEND 2> /dev/null 46 47 run_sql 'SELECT count(*), sum(i) FROM `ch`.t' 48 check_contains "count(*): 6" 49 check_contains "sum(i): 21" 50 51 # check table kv pairs. common hanle should have no extra index kv-paris 52 run_sql 'ADMIN CHECKSUM TABLE `ch`.t' 53 check_contains "Total_kvs: 6" 54 done 55 56 # restore global variables, other tests needs this to handle the _tidb_row_id column 57 run_sql 'set @@global.tidb_enable_clustered_index = 0' 58 # wait for global variable cache invalid 59 sleep 2