github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_shard_rowid/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 run_sql 'show variables like "%tidb_enable_clustered_index%";' 19 is_on=$(grep 'Value: \S+' "$TEST_DIR/sql_res.$TEST_NAME.txt" | awk '{print $2}') 20 21 # disable clustered index 22 if [ "$is_on" = "ON" ] || [ "$is_on" = "1" ]; then 23 run_sql "set @@global.tidb_enable_clustered_index = 'OFF'"; 24 sleep 2 25 fi 26 27 for backend in importer local; do 28 if [ "$backend" = 'local' ]; then 29 check_cluster_version 4 0 0 'local backend' || continue 30 fi 31 32 run_sql 'DROP DATABASE IF EXISTS shard_rowid;' 33 run_lightning --backend $backend 34 35 run_sql "SELECT count(*) from shard_rowid.shr" 36 check_contains "count(*): 16" 37 38 run_sql "SELECT count(distinct _tidb_rowid & b'000001111111111111111111111111111111111111111111111111111111111') as count FROM shard_rowid.shr" 39 check_contains "count: 16" 40 41 # since we use random to generate the shard bits, with 16 record, there maybe less than 8 distinct value, 42 # but it should be bigger than 4 43 run_sql 'SELECT count between 5 and 8 as correct from (SELECT count(distinct _tidb_rowid >> 60) as count from shard_rowid.shr) _' 44 check_contains "correct: 1" 45 done 46 47 if [ -n "$is_on" ]; then 48 run_sql "set @@global.tidb_enable_clustered_index = '$is_on'"; 49 sleep 2 50 fi