github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_source_linkfile/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 # test source dir that contains soft/hard link files 17 18 set -euE 19 20 # Populate the mydumper source 21 DBPATH="$TEST_DIR/sf.mydump" 22 RAW_PATH="${DBPATH}_tmp" 23 24 mkdir -p $DBPATH $TEST_DIR/sf.mydump_tmp 25 DB=linkfiles 26 27 ROW_COUNT=1000 28 29 echo "CREATE DATABASE $DB;" > "$RAW_PATH/$DB-schema-create.sql" 30 echo "CREATE TABLE t(s varchar(64), i INT, j TINYINT, PRIMARY KEY(s, i));" > "$RAW_PATH/$DB.t-schema.sql" 31 echo "CREATE TABLE t2(i INT PRIMARY KEY, s varchar(32));" > "$RAW_PATH/$DB.t2-schema.sql" 32 33 echo "s,i,j" > "$RAW_PATH/$DB.t.0.csv" 34 for i in $(seq "$ROW_COUNT"); do 35 echo "\"thisisastringvalues_line$i\",$i,$i" >> "$RAW_PATH/$DB.t.0.csv" 36 done 37 38 echo "i,s" > "$RAW_PATH/$DB.t2.0.csv" 39 for i in $(seq $ROW_COUNT); do 40 echo "$i,\"test123ataettaet$i\"" >> "$RAW_PATH/$DB.t2.0.csv" 41 done 42 43 # link source files to source dir 44 ls $RAW_PATH | xargs -I{} ln -s $RAW_PATH/{} $DBPATH/{} 45 46 for BACKEND in tidb local; do 47 if [ "$BACKEND" = 'local' ]; then 48 check_cluster_version 4 0 0 'local backend' || continue 49 fi 50 51 # Start importing the tables. 52 run_sql "DROP DATABASE IF EXISTS $DB" 53 54 run_lightning -d "$DBPATH" --backend $BACKEND 2> /dev/null 55 run_sql "SELECT count(*) FROM $DB.t" 56 check_contains "count(*): $ROW_COUNT" 57 58 run_sql "SELECT count(*) FROM $DB.t2" 59 check_contains "count(*): $ROW_COUNT" 60 done