Skip to content

Commit

Permalink
br: update manual of integration tests (pingcap#52689)
Browse files Browse the repository at this point in the history
  • Loading branch information
RidRisR committed Apr 18, 2024
1 parent c385987 commit 09d676b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
22 changes: 16 additions & 6 deletions br/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,17 @@ This folder contains all tests which relies on external processes such as TiDB.
The versions must be ≥2.1.0.

What's more, there must be dynamic link library for TiFlash, see make target `bin` to learn more.
You can install most of dependencies by running `download_tools.sh`.
You can install most of dependencies by running following commands:

```sh
cd ${WORKSPACE}/tidb
rm -rf third_bin/
rm -rf bin/
br/tests/download_integration_test_binaries.sh
mkdir -p bin && mv third_bin/* bin/
rm -rf third_bin/
make #make tidb
```

2. The following programs must be installed:

Expand All @@ -57,6 +67,7 @@ This folder contains all tests which relies on external processes such as TiDB.
* `openssl`
* `wget`
* `lsof`
* `psmisc`

3. The user executing the tests must have permission to create the folder
`/tmp/backup_restore_test`. All test artifacts will be written into this folder.
Expand All @@ -66,13 +77,11 @@ If you have docker installed, you can skip step 1 and step 2 by running

## Running

Link `bin` directory by `cd br && ln -s ../bin bin` and run `make br_integration_test` to execute the integration tests.
This command will

1. Build `br`
1. Build `br.test` using `make build_for_br_integration_test`
2. Check that all 9 required executables and `br` executable exist
3. Select the tests to run using `export TEST_NAME="<test_name1> <test_name2> ..."`
3. Execute `tests/run.sh`
4. To start cluster with tiflash, please run `TIFLASH=1 tests/run.sh`
<!-- 4. To start cluster with tiflash, please run `TIFLASH=1 tests/run.sh` -->

If the first two steps are done before, you could also run `tests/run.sh` directly.
This script will
Expand All @@ -95,6 +104,7 @@ The script should exit with a nonzero error code on failure.
Several convenient commands are provided:

* `run_sql <SQL>` — Executes an SQL query on the TiDB database
* `run_br` - Executes `br.test` with necessary settings
* `run_lightning [CONFIG]` — Starts `tidb-lightning` using `tests/TEST_NAME/CONFIG.toml`
* `check_contains <TEXT>` — Checks if the previous `run_sql` result contains the given text
(in `-E` format)
Expand Down
25 changes: 20 additions & 5 deletions br/tests/download_integration_test_binaries.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,33 @@ function main() {
rm -rf tmp
mkdir third_bin
mkdir tmp

#PD server
download "$pd_download_url" "pd-server.tar.gz" "tmp/pd-server.tar.gz"
tar -xz -C third_bin 'bin/*' -f tmp/pd-server.tar.gz && mv third_bin/bin/* third_bin/
tar -xzf tmp/pd-server.tar.gz -C third_bin --wildcards 'bin/*'
mv third_bin/bin/* third_bin/

#TiKV server
download "$tikv_download_url" "tikv-server.tar.gz" "tmp/tikv-server.tar.gz"
tar -xz -C third_bin 'bin/*' -f tmp/tikv-server.tar.gz && mv third_bin/bin/* third_bin/
tar -xzf tmp/tikv-server.tar.gz -C third_bin --wildcards 'bin/*'
mv third_bin/bin/* third_bin/

#TiFlash
download "$tiflash_download_url" "tiflash.tar.gz" "tmp/tiflash.tar.gz"
tar -xz -C third_bin -f tmp/tiflash.tar.gz
tar -xzf tmp/tiflash.tar.gz -C third_bin
mv third_bin/tiflash third_bin/_tiflash
mv third_bin/_tiflash/* third_bin && rm -rf third_bin/_tiflash

#TiKV Importer
download "$tikv_importer_download_url" "importer.tar.gz" "tmp/importer.tar.gz"
tar -xz -C third_bin bin/tikv-importer -f tmp/importer.tar.gz && mv third_bin/bin/tikv-importer third_bin/
tar -xzf tmp/importer.tar.gz -C third_bin --wildcards 'bin/tikv-importer'
mv third_bin/bin/tikv-importer third_bin/

#TiCDC
download "$ticdc_download_url" "ticdc-linux-amd64.tar.gz" "tmp/ticdc-linux-amd64.tar.gz"
tar -xz -C third_bin -f tmp/ticdc-linux-amd64.tar.gz && mv third_bin/ticdc-linux-amd64/bin/* third_bin/ && rm -rf third_bin/ticdc-linux-amd64
tar -xzf tmp/ticdc-linux-amd64.tar.gz -C third_bin --wildcards '*/bin/*'
mv third_bin/ticdc-linux-amd64/bin/* third_bin/
rm -rf third_bin/ticdc-linux-amd64

download "$minio_url" "minio" "third_bin/minio"
download "$go_ycsb_url" "go-ycsb" "third_bin/go-ycsb"
Expand Down
10 changes: 5 additions & 5 deletions br/tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#

# Copyright 2019 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -38,8 +38,8 @@ rm -rf $TEST_DIR && mkdir -p $TEST_DIR
# Generate TLS certs
generate_certs &> /dev/null

SELECTED_TEST_NAME="${TEST_NAME-$(find tests -mindepth 2 -maxdepth 2 -name run.sh | cut -d/ -f2 | sort)}"

# Use the environment variable TEST_NAME if set, otherwise find all test cases
SELECTED_TEST_NAME="${TEST_NAME:-$(find "$CUR" -mindepth 2 -maxdepth 2 -name run.sh | awk -F'/' '{print $(NF-1)}' | sort)}"
trap stop_services EXIT
start_services $@

Expand All @@ -53,7 +53,7 @@ if [ "${1-}" = '--debug' ]; then
read line
fi

echo "selected test cases: $SELECTED_TEST_NAME"
echo "Selected test cases: $SELECTED_TEST_NAME"

run_case() {
local case=$1
Expand All @@ -75,7 +75,7 @@ run_case() {
bash "$script" && echo "TEST: [$case] success!"
}

# wait for global variable cache invalid
# Wait for global variable cache invalid
sleep 2

for casename in $SELECTED_TEST_NAME; do
Expand Down

0 comments on commit 09d676b

Please sign in to comment.