https://github.com/tikv/copr-test
https://github.com/tikv/copr-test
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/tikv/copr-test
- Owner: tikv
- License: apache-2.0
- Created: 2019-10-15T07:09:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-13T11:44:27.000Z (about 2 years ago)
- Last Synced: 2024-05-13T12:55:44.575Z (about 2 years ago)
- Language: Go
- Size: 4.29 MB
- Stars: 9
- Watchers: 26
- Forks: 39
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Coprocessor Tests
Copr-test is a collection of integration tests for the Coprocessor module of TiKV. Coprocessor
executes TiDB push-down executors to improve performance.
## Push Down Test
`./push-down-test`
Currently we only have push-down-test to test the Coprocessor module. Push-down-test exists to
make sure that execution results are consistent between TiDB and Coprocessor. It works by
executeing test cases on a standalone TiDB (with mocktikv) and on a TiDB cluster (with TiKV
Coprocessor) and comparing the two execution results.
Currently TiKV Coprocessor supports two execution models, the non-vectorized, traditional model and
the newer vectorized model. Requests that cannot be processed by the vectorized model will fallback
to the traditional model. Thus push-down-test also makes sure that the two execution model produce
same results, by comparing the following three combinations:
- TiDB
- TiDB + TiKV (Non-Vectorized)
- TiDB + TiKV (Vectorized)
### Function Whitelist
The Coprocessor module does not support all functions of TiDB (and some are implemented but not
fully tested), so that TiDB [whitelists](https://github.com/pingcap/tidb/blob/a090e6be2991bf85b18fcdb096f84d41f4f6bd85/expression/expr_to_pb.go#L303)
the functions that can be pushed down to TiKV Coprocessor. In push-down-test however, we use
[failpoint] to control the whitelist. The whitelist can be found in `push-down-test/functions.txt`
in this repository. This means that you can test whether or not a specific TiKV Coprocessor function
implementation produces identical results to TiDB by adding the function name into the
`push-down-test/functions.txt` file, instead of modifying TiDB's source code. This is extremely
useful when we only want to add an implementation at TiKV side but not enabling the push down at
TiDB side for now.
### Test Cases
We have already added some test cases generated by [randgen] in the push-down-test. Feel free to
add new ones. Your test case should be placed in the `push-down-test/sql` directory and ends with
`.sql` suffix. Subdirectories are also supported.
### Run Tests Locally
Push-down-test will be run on our CI platform for TiKV PR automatically. You can also run it locally
in order to debug easier. Before that, make sure that you have set up an environment to successfully
build [TiDB], [PD] and [TiKV].
Sample step:
```sh
mkdir my_workspace
cd my_workspace
git clone --depth=1 https://github.com/pingcap/pd.git
git clone --depth=1 https://github.com/pingcap/tidb.git
git clone --depth=1 https://github.com/tikv/tikv.git
git clone https://github.com/tikv/copr-test.git
cd pd
make
cd ../tikv
make build # This make take a while. Be patient.
cd ../copr-test
export pd_bin=`realpath ../pd/bin/pd-server`
export tikv_bin=`realpath ../tikv/target/debug/tikv-server`
export tidb_src_dir=`realpath ../tidb`
# Run all tests
make push-down-test
# You can run other target like `push-down-without-vec`
# which will start a `mysql` client to run `push-down-without-vec` only.
# You can reproduce failed SQL more conveniently
make push-down-without-vec
# If you want to clean the `push-down-test/build` directory and kill all the tidb/pd/tikv processes, run:
make clean
```
If you want to filter some test cases:
```sh
include=1_arith_1.sql make push-down-test
exclude=1_arith_1.sql make push-down-test
```
[failpoint]: https://github.com/pingcap/failpoint
[randgen]: https://github.com/MariaDB/randgen
[TiDB]: https://github.com/pingcap/community/blob/master/CONTRIBUTING.md#building-tidb-on-a-local-osshell-environment
[PD]: https://github.com/pingcap/pd#build
[TiKV]: https://github.com/tikv/tikv/blob/master/CONTRIBUTING.md#building-and-setting-up-a-development-workspace