-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: add integration2
for tools integration tests
#56486
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
91 changes: 91 additions & 0 deletions
91
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,91 @@ | ||
#! /usr/bin/env bash | ||
|
||
# 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems a little bit unreasonable here.
If we want test it on local env, maybe tiup is a better choose. If we want test it on ci env, maybe add it to ci repo is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a copy of https://github.com/pingcap/tidb/blob/master/br/tests/download_integration_test_binaries.sh
This is used mainly by CI, but I want it available for local env, too.
Also, this script guarantees we always use latest builds for all components, which is hard to archive for TiUP nightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this shell always downloads centos7 image which can't work under MacOS env.
Using tiup means that users can manually set up the test environment through tiup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll refine it later to make it work in MacOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And better add
third_bin
path into.gitignore
file