github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_new_collation/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 'new collation' || { echo 'TiDB does not support new collation! skipping test'; exit 0; } 17 18 set -euE 19 20 cur=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 21 . $cur/../_utils/run_services 22 23 # restart cluster with new collation enabled 24 start_services --tidb-cfg $cur/tidb-new-collation.toml 25 26 # Populate the mydumper source 27 DBPATH="$TEST_DIR/nc.mydump" 28 mkdir -p $DBPATH 29 echo 'CREATE DATABASE nc;' > "$DBPATH/nc-schema-create.sql" 30 # create table with collate `utf8_general_ci`, the index key will be different between old/new collation 31 echo "CREATE TABLE t(i INT PRIMARY KEY, s varchar(32), j TINYINT, KEY s_j (s, i)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;" > "$DBPATH/nc.t-schema.sql" 32 cat > "$DBPATH/nc.t.0.sql" << _EOF_ 33 INSERT INTO t (s, i, j) VALUES 34 ("this_is_test1", 1, 1), 35 ("this_is_test2", 2, 2), 36 ("this_is_test3", 3, 3), 37 ("this_is_test4", 4, 4), 38 ("this_is_test5", 5, 5); 39 _EOF_ 40 echo 'INSERT INTO t(s, i, j) VALUES ("another test case", 6, 6);' > "$DBPATH/nc.t.1.sql" 41 42 for BACKEND in local importer tidb; do 43 # Start importing the tables. 44 run_sql 'DROP DATABASE IF EXISTS nc' 45 46 run_lightning -d "$DBPATH" --backend $BACKEND 2> /dev/null 47 48 run_sql 'SELECT count(*), sum(i) FROM `nc`.t' 49 check_contains "count(*): 6" 50 check_contains "sum(i): 21" 51 52 # run sql with index `s_j`, if lightning don't support new collation, no result will be returned. 53 run_sql "SELECT j FROM nc.t WHERE s = 'This_Is_Test4'"; 54 check_contains "j: 4" 55 56 done 57 58 # restart with original config 59 start_services