github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_file_routing/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 set -euE 17 18 # Populate the mydumper source 19 DBPATH="$TEST_DIR/fr.mydump" 20 21 mkdir -p $DBPATH $DBPATH/fr $DBPATH/ff 22 echo 'CREATE DATABASE fr;' > "$DBPATH/fr/schema.sql" 23 echo "CREATE TABLE tbl(i TINYINT PRIMARY KEY, j INT);" > "$DBPATH/fr/tbl-table.sql" 24 # the column orders in data file is different from table schema order. 25 echo "INSERT INTO tbl (i, j) VALUES (1, 1),(2, 2);" > "$DBPATH/fr/tbl1.sql.0" 26 echo "INSERT INTO tbl (i, j) VALUES (3, 3),(4, 4);" > "$DBPATH/fr/tbl2.sql.0" 27 echo "INSERT INTO tbl (i, j) VALUES (5, 5);" > "$DBPATH/fr/tbl.sql" 28 echo "INSERT INTO tbl (i, j) VALUES (6, 6), (7, 7), (8, 8), (9, 9);" > "$DBPATH/tbl1.sql.1" 29 echo "INSERT INTO tbl (i, j) VALUES (10, 10);" > "$DBPATH/ff/test.SQL" 30 echo "INSERT INTO tbl (i, j) VALUES (11, 11);" > "$DBPATH/fr/tbl-noused.sql" 31 32 # view schema 33 echo "CREATE TABLE v(i TINYINT);" > "$DBPATH/fr/v-table.sql" 34 cat > "$DBPATH/fr/v-view.sql" << '_EOF_' 35 /*!40101 SET NAMES binary*/; 36 DROP TABLE IF EXISTS `v`; 37 DROP VIEW IF EXISTS `v`; 38 SET @PREV_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; 39 SET @PREV_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; 40 SET @PREV_COLLATION_CONNECTION=@@COLLATION_CONNECTION; 41 SET character_set_client = utf8; 42 SET character_set_results = utf8; 43 SET collation_connection = utf8_general_ci; 44 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`192.168.198.178` SQL SECURITY DEFINER VIEW `v` (`i`) AS SELECT `i` FROM `fr`.`tbl` WHERE i <= 5; 45 SET character_set_client = @PREV_CHARACTER_SET_CLIENT; 46 SET character_set_results = @PREV_CHARACTER_SET_RESULTS; 47 SET collation_connection = @PREV_COLLATION_CONNECTION; 48 _EOF_ 49 50 for BACKEND in local importer; do 51 if [ "$BACKEND" = 'local' ]; then 52 check_cluster_version 4 0 0 'local backend' || continue 53 fi 54 55 run_sql 'DROP DATABASE IF EXISTS fr' 56 57 # Start importing the tables. 58 run_lightning -d "$DBPATH" --backend $BACKEND 2> /dev/null 59 60 run_sql 'SELECT count(*) FROM `fr`.tbl' 61 check_contains "count(*): 10" 62 run_sql 'SELECT sum(j) FROM `fr`.tbl' 63 check_contains "sum(j): 55" 64 65 run_sql 'SELECT sum(i), count(*) FROM `fr`.v' 66 check_contains "sum(i): 15" 67 check_contains "count(*): 5" 68 done