Skip to content

Commit

Permalink
get started: add some docs for tidb's integration test (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros authored Aug 1, 2024
1 parent 8c11565 commit b284a0e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/get-started/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Let's start your TiDB journey! There's a lot to learn, but every journey starts
* [Setup an IDE](setup-an-ide.md)
* [Write and run unit tests](write-and-run-unit-tests.md)
* [Debug and profile](debug-and-profile.md)
* [Run and debug integration tests](run-and-debug-integration-tests.md)
* [Commit code and submit a pull request](commit-code-and-submit-a-pull-request.md)
41 changes: 41 additions & 0 deletions src/get-started/run-and-debug-integration-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Run and debug integration tests

TiDB now has some integration tests inside the folder `tests/integrationtest`. Those tests are simply organized as SQL files. The test inputs are put in the folder `t/` and the pre-stored result files are in the folder `r/`.

# How to run integration tests

Once you have built a TiDB binary. You can go to the folder `tests/integrationtest` and run `./run-tests.sh -s ../../bin/tidb-server` to run all the integration tests.

And you can use `-t` to specify a test file to test. If you run `./run-tests.sh -s ../../bin/tidb-server -t executor/simple`, the scripts will run the tests inside the file `t/executor/simple.test`.(It's corresponding result file is `r/executor/simple.result`)

If you find out that the changes of tests are expected, you can pass `-r` to re-generate the result file. If you run `./run-tests.sh -s ../../bin/tidb-server -r executor/simple`, it will overwirte the `r/executor/simple.test` by the new binary.

# How to debug integration tests

Sometimes you will need to debug the test when you find out that some changes are not expected. You will need to do some preparation before attach to `dlv` if you prefer to use `dlv` to do live debugging.

We use some build tags to inject some check in the testing environment. Those tags are `intest,deadlock,integrationtest`, so you need to pass `--tags intest,deadlock,integrationtest` when you're building the binary. Or you can directly run `make server_check` to build the needed binary and then use `dlv` to do the debugging.

After you build the correct binary, you can follow the descriptions in [Use delve for debugging](./debug-and-profile.md#use-delve-for-debugging) to debug TiDB.

## How to use IDE to debug

If you're using IDEs, you'll need to create a special build file for it.

### Visual Studio Code

Find the `Run and Debug` in the left sidebar. If you haven't created any config, click the `create a launch.json file.`

![VS Code create debug file](../img/vscode-go-to-edit.png)

And then you are able to create different run&debug configurations.

![VS Code config sample](../img/vscode-debug-config.png)

The above image shows some samples of the configuration. And the `tidb-on-2432-integration-test` is the one enabling build tags.

Then you just need to click the run button, VS Code will build the binary and then use `dlv` to attach on it.

![VS Code begin debugging](../img/vscode-debug-binary.png)

You can find more about VS Code's debugging on its official documents.
1 change: 1 addition & 0 deletions src/get-started/write-and-run-unit-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,4 @@ If a test case takes longer, its failure report looks like:
[2021-08-09T03:33:57.661Z] PASS: tidb_test.go:874: tidbTestSerialSuite.TestTLS 7.388s
[2021-08-09T03:33:57.661Z] --- PASS: TestCluster (5.20s)
```
And for integration tests, please refer to [Run and debug integration tests](./run-and-debug-integration-tests.md)
Binary file added src/img/vscode-debug-binary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/vscode-debug-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/vscode-go-to-edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b284a0e

Please sign in to comment.