# copr-test **Repository Path**: pingcap/copr-test ## Basic Information - **Project Name**: copr-test - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-06-27 - **Last Updated**: 2025-01-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## 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