Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions tests/br_db_gcs/run.sh
Original file line number Diff line number Diff line change
@@ -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;"
21 changes: 16 additions & 5 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -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