Integration tests
This folder contains all tests which relies on external processes such as TiDB.
Preparations
-
The following executables must be copied or linked into these locations:
bin/tidb-serverbin/tikv-serverbin/pd-serverbin/pd-ctlbin/miniobin/mcbin/tiflash
The versions must be ≥2.1.0.
What's more, there must be dynamic link library for TiFlash, see make target
binto learn more. You can install most of dependencies by runningdownload_tools.sh. -
make build_for_lightning_integration_test -
The following programs must be installed:
mysql(the CLI client)curlopensslwgetlsof
-
The user executing the tests must have permission to create the folder
/tmp/lightning_test. All test artifacts will be written into this folder.
Running
Run make lightning_integration_test to execute all the integration tests.
- Logs will be written into
/tmp/lightning_testdirectory.
Run tests/run.sh --debug to pause immediately after all servers are started.
If you only want to run some tests, you can use:
TEST_NAME="lightning_gcs lightning_view" lightning/tests/run.sh
Case names are separated by spaces.
Writing new tests
- New integration tests can be written as shell scripts in
tests/TEST_NAME/run.sh.TEST_NAMEshould start withlightning_.- The script should exit with a nonzero error code on failure.
- Add TEST_NAME to existing group in run_group_lightning_tests.sh(Recommended), or add a new group for it.
- If you add a new group, the name of the new group must be added to CI lightning-integration-test.
Several convenient commands are provided in utils:
run_sql <SQL>— Executes an SQL query on the TiDB databaserun_lightning [CONFIG]— Startstidb-lightningusingtests/TEST_NAME/CONFIG.tomlcheck_contains <TEXT>— Checks if the previousrun_sqlresult contains the given text (in-Eformat)check_not_contains <TEXT>— Checks if the previousrun_sqlresult does not contain the given text (in-Eformat)