diff --git a/tests/br_db_gcs/run.sh b/tests/br_db_gcs/run.sh new file mode 100755 index 000000000..018dfbc16 --- /dev/null +++ b/tests/br_db_gcs/run.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Copyright 2019 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu +DB="$TEST_NAME" + +run_sql "CREATE DATABASE $DB;" + +run_sql "CREATE TABLE $DB.usertable1 ( \ + YCSB_KEY varchar(64) NOT NULL, \ + FIELD0 varchar(1) DEFAULT NULL, \ + PRIMARY KEY (YCSB_KEY) \ +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" + +run_sql "INSERT INTO $DB.usertable1 VALUES (\"a\", \"b\");" +run_sql "INSERT INTO $DB.usertable1 VALUES (\"aa\", \"b\");" + +run_sql "CREATE TABLE $DB.usertable2 ( \ + YCSB_KEY varchar(64) NOT NULL, \ + FIELD0 varchar(1) DEFAULT NULL, \ + PRIMARY KEY (YCSB_KEY) \ +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" + +run_sql "INSERT INTO $DB.usertable2 VALUES (\"c\", \"d\");" + +# TODO: use backup db, once it is supported. +# backup full +echo "backup start..." +echo "TEST_GCS_BUCKET: ${TEST_GCS_BUCKET}" +echo "TEST_GCS_CREDENTIALS: ${TEST_GCS_CREDENTIALS}" +run_br --pd $PD_ADDR backup full -s "gcs://${TEST_GCS_BUCKET}/$DB" --ratelimit 5 --concurrency 4 --fastchecksum true --only-meta --gcs.credentials_file "${TEST_GCS_CREDENTIALS}" --gcs.predefined_acl "bucketOwnerRead" --gcs.storage_class "NEARLINE" + +run_sql "DROP DATABASE $DB;" + +# restore db +echo "restore start..." +run_br restore db --db $DB -s "gcs://${TEST_GCS_BUCKET}/$DB" --pd $PD_ADDR --only-meta --gcs.credentials_file "${TEST_GCS_CREDENTIALS}" + +run_sql "DROP DATABASE $DB;" diff --git a/tests/run.sh b/tests/run.sh index 3cedc7093..1792f4d8f 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -98,10 +98,12 @@ start_services if [ "${1-}" = '--debug' ]; then echo 'You may now debug from another terminal. Press [ENTER] to continue.' read line + shift fi -for script in tests/*/run.sh; do - echo "*===== Running test $script... =====*" +run_one() +{ + echo "*===== Running test $1... =====*" TEST_DIR="$TEST_DIR" \ PD_ADDR="$PD_ADDR" \ TIDB_IP="$TIDB_IP" \ @@ -110,6 +112,15 @@ for script in tests/*/run.sh; do TIDB_STATUS_ADDR="$TIDB_STATUS_ADDR" \ TIKV_ADDR="$TIKV_ADDR" \ PATH="tests/_utils:bin:$PATH" \ - TEST_NAME="$(basename "$(dirname "$script")")" \ - sh "$script" -done + TEST_NAME="$(basename "$(dirname "$1")")" \ + sh "$1" +} + +if [ $# -eq 0 ] +then + for script in tests/*/run.sh; do + run_one "$script" + done +else + run_one "tests/$1/run.sh" +fi