github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_tiflash/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 # before v4.0.5 tiflash doesn't support tls, so we should skip this test then 17 (check_cluster_version 4 0 5 'TiFlash' && [ -n "$TIFLASH" ]) || exit 0 18 19 set -euE 20 # Populate the mydumper source 21 DBPATH="$TEST_DIR/tiflash.mydump" 22 mkdir -p $DBPATH 23 DB=test_tiflash 24 25 cat > "$DBPATH/$DB.t1.0.sql" << _EOF_ 26 INSERT INTO t1 (s, i, j) VALUES 27 ("this_is_test1", 1, 1), 28 ("this_is_test2", 2, 2), 29 ("this_is_test3", 3, 3), 30 ("this_is_test4", 4, 4), 31 ("this_is_test5", 5, 5); 32 _EOF_ 33 34 echo "INSERT INTO t2 VALUES (1, 1), (2, 2)" > "$DBPATH/$DB.t2.0.sql" 35 echo "INSERT INTO t2 VALUES (3, 3), (4, 4)" > "$DBPATH/$DB.t2.1.sql" 36 37 tiflash_replica_ready() { 38 i=0 39 run_sql "select sum(AVAILABLE) from information_schema.tiflash_replica WHERE TABLE_NAME = \"$1\"" 40 while ! check_contains "sum(AVAILABLE): 1" check; do 41 i=$((i+1)) 42 if [ "$i" -gt 100 ]; then 43 echo "wait tiflash replica ready timeout" 44 return 1 45 fi 46 sleep 3 47 run_sql "select sum(AVAILABLE) from information_schema.tiflash_replica WHERE TABLE_NAME = \"$1\"" 48 done 49 } 50 51 for BACKEND in importer tidb local; do 52 run_sql "DROP DATABASE IF EXISTS $DB" 53 run_sql "CREATE DATABASE $DB" 54 run_sql "CREATE TABLE $DB.t1 (i INT, j INT, s varchar(32), PRIMARY KEY(s, i));" 55 run_sql "ALTER TABLE $DB.t1 SET TIFLASH REPLICA 1;" 56 tiflash_replica_ready t1 57 run_sql "CREATE TABLE $DB.t2 (i INT, j TINYINT);" 58 run_sql "ALTER TABLE $DB.t2 SET TIFLASH REPLICA 1;" 59 tiflash_replica_ready t2 60 61 run_lightning -d "$DBPATH" --backend $BACKEND 2> /dev/null 62 63 run_sql "SELECT /*+ read_from_storage(tiflash[t1]) */ count(*), sum(i) FROM \`$DB\`.t1" 64 check_contains "count(*): 5" 65 check_contains "sum(i): 15" 66 67 run_sql "SELECT /*+ read_from_storage(tiflash[t2]) */ count(*), sum(i) FROM \`$DB\`.t2" 68 check_contains "count(*): 4" 69 check_contains "sum(i): 10" 70 71 done