github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_s3/run.sh (about) 1 #!/bin/bash 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 -eux 17 DB="s3_test" 18 TABLE="tbl" 19 20 check_cluster_version 4 0 0 'local backend' || exit 0 21 22 set -euE 23 24 # Populate the mydumper source 25 DBPATH="$TEST_DIR/s3.mydump" 26 27 # start the s3 server 28 export MINIO_ACCESS_KEY=s3accesskey 29 export MINIO_SECRET_KEY=s3secretkey 30 export MINIO_BROWSER=off 31 export S3_ENDPOINT=127.0.0.1:9900 32 rm -rf "$TEST_DIR/$DB" 33 mkdir -p "$TEST_DIR/$DB" 34 bin/minio server --address $S3_ENDPOINT "$DBPATH" & 35 i=0 36 while ! curl -o /dev/null -v -s "http://$S3_ENDPOINT/"; do 37 i=$(($i+1)) 38 if [ $i -gt 30 ]; then 39 echo 'Failed to start minio' 40 exit 1 41 fi 42 sleep 2 43 done 44 45 BUCKET=test-bucket 46 DATA_PATH=$DBPATH/$BUCKET 47 mkdir -p $DATA_PATH 48 echo 'CREATE DATABASE s3_test;' > "$DATA_PATH/$DB-schema-create.sql" 49 echo "CREATE TABLE t(i INT, s varchar(32));" > "$DATA_PATH/$DB.$TABLE-schema.sql" 50 echo 'INSERT INTO tbl (i, s) VALUES (1, "1"),(2, "test2"), (3, "qqqtest");' > "$DATA_PATH/$DB.$TABLE.sql" 51 cat > "$DATA_PATH/$DB.$TABLE.0.csv" << _EOF_ 52 i,s 53 100,"test100" 54 101,"\"" 55 102,"😄😄😄😄😄" 56 104,"" 57 _EOF_ 58 59 # Fill in the database 60 # Start importing the tables. 61 run_sql "DROP DATABASE IF EXISTS $DB;" 62 run_sql "DROP TABLE IF EXISTS $DB.$TABLE;" 63 64 SOURCE_DIR="s3://$BUCKET/?endpoint=http%3A//127.0.0.1%3A9900&access_key=$MINIO_ACCESS_KEY&secret_access_key=$MINIO_SECRET_KEY&force_path_style=true" 65 run_lightning -d $SOURCE_DIR --backend local 2> /dev/null 66 run_sql "SELECT count(*), sum(i) FROM \`$DB\`.$TABLE" 67 check_contains "count(*): 7" 68 check_contains "sum(i): 413"