-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add
integration2
for tools integration tests (#56486)
ref #56556
- Loading branch information
Showing
8 changed files
with
685 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# IntegrationTest | ||
|
||
IntegrationTest is a integration test command tool, also with some useful test cases for TiDB execute plan logic, we can run case via `run-tests.sh`. | ||
|
||
``` | ||
Usage: ./run-tests.sh [options] | ||
-h: Print this help message. | ||
-s <tidb-server-path>: Use tidb-server in <tidb-server-path> for testing. | ||
eg. "./run-tests.sh -s ./integrationtest_tidb-server" | ||
-b <y|Y|n|N>: "y" or "Y" for building test binaries [default "y" if this option is not specified]. | ||
"n" or "N" for not to build. | ||
The building of tidb-server will be skiped if "-s <tidb-server-path>" is provided. | ||
-r <test-name>|all: Run tests in file "t/<test-name>.test" and record result to file "r/<test-name>.result". | ||
"all" for running all tests and record their results. | ||
-t <test-name>: Run tests in file "t/<test-name>.test". | ||
This option will be ignored if "-r <test-name>" is provided. | ||
Run all tests if this option is not provided. | ||
-v <vendor-path>: Add <vendor-path> to $GOPATH. | ||
-p <portgenerator-path>: Use port generator in <portgenerator-path> for generating port numbers. | ||
``` | ||
|
||
## How it works | ||
|
||
IntegrationTest will read test case in `t/*.test`, and execute them in TiDB server with `s/*.json` stat, and compare integration result in `r/*.result`. | ||
|
||
For convenience, we can generate new `*.result` and `*.json` from execute by use `-r` parameter for `run-tests.sh` | ||
|
||
## Usage | ||
|
||
### Regression Execute Plan Modification | ||
|
||
After modify code and before commit, please run this command under TiDB root folder. | ||
|
||
```sh | ||
make dev | ||
``` | ||
|
||
or | ||
|
||
```sh | ||
make integrationtest | ||
``` | ||
|
||
It will identify execute plan change. | ||
|
||
### Generate New Result from Execute | ||
|
||
Add a new test file in `t/` folder, file name should ended with `.test`. Or add new test queries at the end of some files. Then run shell below, it will generate results based on last execution. | ||
|
||
```sh | ||
cd tests/integrationtest | ||
./run-tests.sh -r [casename] | ||
``` | ||
|
||
## How to debug integration test | ||
|
||
### Visual Studio Code | ||
|
||
1. Add or create a configuration to `.vscode/launch.json`, an example is shown below. If you want to change some configurations, such as using `TiKV` to run integration tests or others, you can modify `pkg/config/config.toml.example`. | ||
|
||
```json | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug TiDB With Default Config", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${fileWorkspaceFolder}/cmd/tidb-server", | ||
"args": ["--config=${fileWorkspaceFolder}/pkg/config/config.toml.example"] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
2. To run `TiDB-Server`, you could bring up **Run and Debug** view, select the **Run and Debug** icon in the **Activity Bar** on the side of VS Code. You can also use shortcut **F5**. | ||
|
||
3. Use any mysql client application you like to run SQLs in integration test, the default port is `4000` and default user is `root` without password. Taking `mysql` as an example, you can use `mysql --comments --host 127.0.0.1 --port 4000 -u root` command to do this. | ||
|
||
### Goland | ||
|
||
You could follow <https://pingcap.github.io/tidb-dev-guide/get-started/setup-an-ide.html#run-or-debug> to run a `TiDB-Server` with or without `TiKV`. Then use any mysql client application you like to run SQLs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2021 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, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
lease = "0" | ||
host = "127.0.0.1" | ||
new_collations_enabled_on_first_bootstrap = true | ||
enable-table-lock = true | ||
|
||
[status] | ||
status-host = "127.0.0.1" | ||
|
||
[performance] | ||
stats-lease = "0" | ||
|
||
[tikv-client.async-commit] | ||
safe-window = 0 | ||
allowed-clock-drift = 0 | ||
|
||
[experimental] | ||
enable-new-charset = true | ||
allow-expression-index = true |
104 changes: 104 additions & 0 deletions
104
tests/integrationtest2/download_integration_test_binaries.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 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, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# help | ||
# download some third party tools for br&lightning integration test | ||
# example: ./download_integration_test_binaries.sh master | ||
|
||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
|
||
# Specify which branch to be utilized for executing the test, which is | ||
# exclusively accessible when obtaining binaries from | ||
# http://fileserver.pingcap.net. | ||
branch=${1:-master} | ||
file_server_url=${2:-http://fileserver.pingcap.net} | ||
|
||
tikv_sha1_url="${file_server_url}/download/refs/pingcap/tikv/${branch}/sha1" | ||
pd_sha1_url="${file_server_url}/download/refs/pingcap/pd/${branch}/sha1" | ||
tiflash_sha1_url="${file_server_url}/download/refs/pingcap/tiflash/${branch}/sha1" | ||
ticdc_sha1_url="${file_server_url}/download/refs/pingcap/ticdc/${branch}/sha1" | ||
|
||
pd_sha1=$(curl "$pd_sha1_url") | ||
tikv_sha1=$(curl "$tikv_sha1_url") | ||
tiflash_sha1=$(curl "$tiflash_sha1_url") | ||
ticdc_sha1=$(curl "$ticdc_sha1_url") | ||
|
||
# download pd / tikv / tiflash binary build from tibuid multibranch pipeline | ||
pd_download_url="${file_server_url}/download/builds/pingcap/pd/${pd_sha1}/centos7/pd-server.tar.gz" | ||
tikv_download_url="${file_server_url}/download/builds/pingcap/tikv/${tikv_sha1}/centos7/tikv-server.tar.gz" | ||
tiflash_download_url="${file_server_url}/download/builds/pingcap/tiflash/${branch}/${tiflash_sha1}/centos7/tiflash.tar.gz" | ||
ticdc_download_url="${file_server_url}/download/builds/pingcap/ticdc/${ticdc_sha1}/centos7/ticdc-linux-amd64.tar.gz" | ||
|
||
set -o nounset | ||
|
||
# See https://misc.flogisoft.com/bash/tip_colors_and_formatting. | ||
color-green() { # Green | ||
echo -e "\x1B[1;32m${*}\x1B[0m" | ||
} | ||
|
||
function download() { | ||
local url=$1 | ||
local file_name=$2 | ||
local file_path=$3 | ||
if [[ -f "${file_path}" ]]; then | ||
echo "file ${file_name} already exists, skip download" | ||
return | ||
fi | ||
echo "download ${file_name} from ${url}" | ||
wget --no-verbose --retry-connrefused --waitretry=1 -t 3 -O "${file_path}" "${url}" | ||
} | ||
|
||
function main() { | ||
rm -rf third_bin | ||
rm -rf tmp | ||
mkdir third_bin | ||
mkdir tmp | ||
|
||
#PD server | ||
download "$pd_download_url" "pd-server.tar.gz" "tmp/pd-server.tar.gz" | ||
# tar -xzf tmp/pd-server.tar.gz -C third_bin --wildcards 'bin/*' | ||
tar -xzf tmp/pd-server.tar.gz -C third_bin | ||
mv third_bin/bin/* third_bin/ | ||
|
||
#TiKV server | ||
download "$tikv_download_url" "tikv-server.tar.gz" "tmp/tikv-server.tar.gz" | ||
# tar -xzf tmp/tikv-server.tar.gz -C third_bin --wildcards 'bin/*' | ||
tar -xzf tmp/tikv-server.tar.gz -C third_bin | ||
mv third_bin/bin/* third_bin/ | ||
|
||
#TiFlash | ||
download "$tiflash_download_url" "tiflash.tar.gz" "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 | ||
|
||
#TiCDC | ||
download "$ticdc_download_url" "ticdc-linux-amd64.tar.gz" "tmp/ticdc-linux-amd64.tar.gz" | ||
# tar -xzf tmp/ticdc-linux-amd64.tar.gz -C third_bin --wildcards '*/bin/*' | ||
tar -xzf tmp/ticdc-linux-amd64.tar.gz -C third_bin | ||
mv third_bin/ticdc-linux-amd64/bin/* third_bin/ | ||
|
||
chmod +x third_bin/* | ||
rm -rf tmp | ||
# rm -rf third_bin/bin | ||
ls -alh third_bin/ | ||
} | ||
|
||
main "$@" | ||
|
||
color-green "Download SUCCESS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE t1 (a INT PRIMARY KEY NONCLUSTERED AUTO_INCREMENT, b INT) AUTO_ID_CACHE = 100; | ||
INSERT INTO t1 (b) VALUES (1), (2), (3); | ||
SHOW TABLE t1 NEXT_ROW_ID; | ||
DB_NAME TABLE_NAME COLUMN_NAME NEXT_GLOBAL_ROW_ID ID_TYPE | ||
br_integration t1 _tidb_rowid 101 _TIDB_ROWID | ||
br_integration t1 _tidb_rowid 1 AUTO_INCREMENT | ||
SHOW TABLE tt1 NEXT_ROW_ID; | ||
DB_NAME TABLE_NAME COLUMN_NAME NEXT_GLOBAL_ROW_ID ID_TYPE | ||
br_integration tt1 _tidb_rowid 1 _TIDB_ROWID | ||
br_integration tt1 _tidb_rowid 1 AUTO_INCREMENT |
Oops, something went wrong.