tests/

directory
v1.0.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2019 License: Apache-2.0

README

Preparations

  1. The following five executables must be copied or generated or linked into these locations, mydumper and sync_diff_inspector can be downloaded from tidb-enterprise-tools-latest-linux-amd64:

    • bin/tidb-server
    • bin/sync_diff_inspector
    • bin/mydumper
    • bin/dm-master.test # generated by make dm_integration_test_build
    • bin/dm-worker.test # generated by make dm_integration_test_build
  2. The following programs must be installed:

    • mysql (the CLI client)
    • python2.7 or python3.x
  3. The user executing the tests must have permission to create the folder /tmp/dm_test. All test artifacts will be written into this folder.

Running

Unit Test

  1. Setup a MySQL server with binlog enabled first, export proper enviroment variable MYSQL_HOST and MYSQL_PORT

  2. Run make test to run unit test

Integration Test

  1. Run make dm_integration_test_build to generate DM related binary for integration test

  2. Run make integration_test to execute the integration tests. This command will

    1. Check that all required executables exist.
    2. Execute tests/run.sh
  3. After executing the tests, run make coverage to get a coverage report at /tmp/dm_test/all_cov.html.

Writing new tests

New integration tests can be written as shell scripts in tests/TEST_NAME/run.sh. The script should exit with a nonzero error code on failure.

Several convenient commands are provided:

  • run_dm_master <WORKDIR> <PORT> <CONFIG> — Starts dm-master using config provided, on given port, running in workdir.
  • run_dm_worker <WORKDIR> <PORT> <CONFIG> — Starts dm-worker using config provided, on given port, running in workdir.
  • run_sql <SQL> <PORT> — Executes an SQL query in database based on port provided
  • run_sql_file <path_to_SQL_file> <PORT> — Executes all SQLs in given file to the database on port provided
  • check_contains <TEXT> — Checks if the previous run_sql/run_sql_file result contains the given text (in -E format)
  • check_sync_diff <WORKDIR> <CONFIG> - Runs sync_diff_inspector to check diff between databases, using config file provided
  • check_port_alive <PORT> - Wrapper to check a port is alive, at most 20 times.
  • check_port <HOST> <PORT> - Checks a host:port is alive.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL