github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/README.md (about)

     1  ## Preparations
     2  
     3  1. The following executables must be copied or generated or linked into these locations, `sync_diff_inspector` can be downloaded from [tidb-community-toolkit](https://download.pingcap.org/tidb-community-toolkit-v4.0.2-linux-amd64.tar.gz), `tidb-server` related binaries can be downloaded from [tidb-community-server](https://download.pingcap.org/tidb-community-server-v4.0.2-linux-amd64.tar.gz):
     4  
     5      * `bin/tidb-server` # version >= 4.0.0-rc.1
     6      * `bin/tikv-server` # version >= 4.0.0-rc.1
     7      * `bin/pd-server`   # version >= 4.0.0-rc.1
     8      * `bin/pd-ctl`      # version >= 4.0.0-rc.1
     9      * `bin/tiflash`     # needs tiflash binary and some necessary so files
    10      * `bin/sync_diff_inspector`
    11      * [bin/go-ycsb](https://github.com/pingcap/go-ycsb)
    12      * [bin/etcdctl](https://github.com/etcd-io/etcd/tree/master/etcdctl)
    13      * [bin/jq](https://stedolan.github.io/jq/)
    14      * [bin/minio](https://github.com/minio/minio)
    15  
    16      > If you are running tests on MacOS, tidb related binaries can be downloaded from tiup mirrors, such as https://tiup-mirrors.pingcap.com/tidb-v4.0.2-darwin-amd64.tar.gz. And `sync_diff_inspector` can be compiled by yourself from source [tidb-tools](https://github.com/pingcap/tidb-tools)
    17  
    18      > All Tiflash required files can be found in [tidb-community-server](https://download.pingcap.org/tidb-community-server-v4.0.2-linux-amd64.tar.gz) packages. You should put `flash_cluster_manager`, `libtiflash_proxy.so` and `tiflash` into `bin` directory in TiCDC code base.
    19  
    20  2. The following programs must be installed:
    21  
    22      * `mysql` (the MySQL cli client, currently [mysql client 8.0 is not supported](https://github.com/pingcap/tidb/issues/14021))
    23  
    24  3. The user used to execute the tests must have permission to create the folder /tmp/tidb_cdc_test. All test artifacts will be written into this folder.
    25  
    26  
    27  ## Running
    28  
    29  ### Unit Test
    30  
    31  1. Unit test does not need any dependencies, just running `make unit_test` in root dir of source code, or cd into directory of a test case and run single case via `GO111MODULE=on go test -check.f TestXXX`.
    32  
    33  ### Integration Test
    34  
    35  1. Run `make integration_test_build` to generate TiCDC related binaries for integration test
    36  
    37  2. Run `make integration_test` to execute the integration tests. This command will
    38  
    39      1. Check that all required executables exist.
    40      2. Execute `tests/run.sh`
    41  
    42      > If want to run one integration test case only, just pass the CASE parameter, such as `make integration_test CASE=simple`.
    43  
    44      > There exists some environment variables that you can set by yourself, variable details can be found in [test_prepare](_utils/test_prepare).
    45  
    46      > `MySQL sink` will be used by default, if you want to test `Kafka sink`, please run with `make integration_test CASE=simple kafka`
    47  
    48  3. After executing the tests, run `make coverage` to get a coverage report at `/tmp/tidb_cdc_test/all_cov.html`.
    49  
    50  
    51  ## Writing new tests
    52  
    53  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.