diff --git a/tests/integrationtest2/README.md b/tests/integrationtest2/README.md new file mode 100644 index 0000000000000..9f814d3fb9de8 --- /dev/null +++ b/tests/integrationtest2/README.md @@ -0,0 +1,90 @@ +# IntegrationTest + +IntegrationTest is a integration test command tool, also with some useful test cases for TiDB execute plan logic, we can run case via `run-tests.sh`. + +``` +Usage: ./run-tests.sh [options] + + -h: Print this help message. + + -s : Use tidb-server in for testing. + eg. "./run-tests.sh -s ./integrationtest_tidb-server" + + -b : "y" or "Y" for building test binaries [default "y" if this option is not specified]. + "n" or "N" for not to build. + The building of tidb-server will be skiped if "-s " is provided. + + -r |all: Run tests in file "t/.test" and record result to file "r/.result". + "all" for running all tests and record their results. + + -t : Run tests in file "t/.test". + This option will be ignored if "-r " is provided. + Run all tests if this option is not provided. + + -v : Add to $GOPATH. + + -p : Use port generator in for generating port numbers. +``` + +## How it works + +IntegrationTest will read test case in `t/*.test`, and execute them in TiDB server with `s/*.json` stat, and compare integration result in `r/*.result`. + +For convenience, we can generate new `*.result` and `*.json` from execute by use `-r` parameter for `run-tests.sh` + +## Usage + +### Regression Execute Plan Modification + +After modify code and before commit, please run this command under TiDB root folder. + +```sh +make dev +``` + +or + +```sh +make integrationtest +``` + +It will identify execute plan change. + +### Generate New Result from Execute + +Add a new test file in `t/` folder, file name should ended with `.test`. Or add new test queries at the end of some files. Then run shell below, it will generate results based on last execution. + +```sh +cd tests/integrationtest +./run-tests.sh -r [casename] +``` + +## How to debug integration test + +### Visual Studio Code + +1. Add or create a configuration to `.vscode/launch.json`, an example is shown below. If you want to change some configurations, such as using `TiKV` to run integration tests or others, you can modify `pkg/config/config.toml.example`. + +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug TiDB With Default Config", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${fileWorkspaceFolder}/cmd/tidb-server", + "args": ["--config=${fileWorkspaceFolder}/pkg/config/config.toml.example"] + } + ] +} +``` + +2. To run `TiDB-Server`, you could bring up **Run and Debug** view, select the **Run and Debug** icon in the **Activity Bar** on the side of VS Code. You can also use shortcut **F5**. + +3. Use any mysql client application you like to run SQLs in integration test, the default port is `4000` and default user is `root` without password. Taking `mysql` as an example, you can use `mysql --comments --host 127.0.0.1 --port 4000 -u root` command to do this. + +### Goland + +You could follow to run a `TiDB-Server` with or without `TiKV`. Then use any mysql client application you like to run SQLs. diff --git a/tests/integrationtest2/config.toml b/tests/integrationtest2/config.toml new file mode 100644 index 0000000000000..9653b7bad7864 --- /dev/null +++ b/tests/integrationtest2/config.toml @@ -0,0 +1,32 @@ +# Copyright 2021 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +lease = "0" +host = "127.0.0.1" +new_collations_enabled_on_first_bootstrap = true +enable-table-lock = true + +[status] +status-host = "127.0.0.1" + +[performance] +stats-lease = "0" + +[tikv-client.async-commit] +safe-window = 0 +allowed-clock-drift = 0 + +[experimental] +enable-new-charset = true +allow-expression-index = true diff --git a/tests/integrationtest2/download_integration_test_binaries.sh b/tests/integrationtest2/download_integration_test_binaries.sh new file mode 100755 index 0000000000000..cf17f266b2aed --- /dev/null +++ b/tests/integrationtest2/download_integration_test_binaries.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# Copyright 2024 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# help +# download some third party tools for br&lightning integration test +# example: ./download_integration_test_binaries.sh master + + +set -o errexit +set -o pipefail + + +# Specify which branch to be utilized for executing the test, which is +# exclusively accessible when obtaining binaries from +# http://fileserver.pingcap.net. +branch=${1:-master} +file_server_url=${2:-http://fileserver.pingcap.net} + +tikv_sha1_url="${file_server_url}/download/refs/pingcap/tikv/${branch}/sha1" +pd_sha1_url="${file_server_url}/download/refs/pingcap/pd/${branch}/sha1" +tiflash_sha1_url="${file_server_url}/download/refs/pingcap/tiflash/${branch}/sha1" +ticdc_sha1_url="${file_server_url}/download/refs/pingcap/ticdc/${branch}/sha1" + +pd_sha1=$(curl "$pd_sha1_url") +tikv_sha1=$(curl "$tikv_sha1_url") +tiflash_sha1=$(curl "$tiflash_sha1_url") +ticdc_sha1=$(curl "$ticdc_sha1_url") + +# download pd / tikv / tiflash binary build from tibuid multibranch pipeline +pd_download_url="${file_server_url}/download/builds/pingcap/pd/${pd_sha1}/centos7/pd-server.tar.gz" +tikv_download_url="${file_server_url}/download/builds/pingcap/tikv/${tikv_sha1}/centos7/tikv-server.tar.gz" +tiflash_download_url="${file_server_url}/download/builds/pingcap/tiflash/${branch}/${tiflash_sha1}/centos7/tiflash.tar.gz" +ticdc_download_url="${file_server_url}/download/builds/pingcap/ticdc/${ticdc_sha1}/centos7/ticdc-linux-amd64.tar.gz" + +set -o nounset + +# See https://misc.flogisoft.com/bash/tip_colors_and_formatting. +color-green() { # Green + echo -e "\x1B[1;32m${*}\x1B[0m" +} + +function download() { + local url=$1 + local file_name=$2 + local file_path=$3 + if [[ -f "${file_path}" ]]; then + echo "file ${file_name} already exists, skip download" + return + fi + echo "download ${file_name} from ${url}" + wget --no-verbose --retry-connrefused --waitretry=1 -t 3 -O "${file_path}" "${url}" +} + +function main() { + rm -rf third_bin + rm -rf tmp + mkdir third_bin + mkdir tmp + + #PD server + download "$pd_download_url" "pd-server.tar.gz" "tmp/pd-server.tar.gz" + # tar -xzf tmp/pd-server.tar.gz -C third_bin --wildcards 'bin/*' + tar -xzf tmp/pd-server.tar.gz -C third_bin + mv third_bin/bin/* third_bin/ + + #TiKV server + download "$tikv_download_url" "tikv-server.tar.gz" "tmp/tikv-server.tar.gz" + # tar -xzf tmp/tikv-server.tar.gz -C third_bin --wildcards 'bin/*' + tar -xzf tmp/tikv-server.tar.gz -C third_bin + mv third_bin/bin/* third_bin/ + + #TiFlash + download "$tiflash_download_url" "tiflash.tar.gz" "tmp/tiflash.tar.gz" + tar -xzf tmp/tiflash.tar.gz -C third_bin + mv third_bin/tiflash third_bin/_tiflash + mv third_bin/_tiflash/* third_bin && rm -rf third_bin/_tiflash + + #TiCDC + download "$ticdc_download_url" "ticdc-linux-amd64.tar.gz" "tmp/ticdc-linux-amd64.tar.gz" + # tar -xzf tmp/ticdc-linux-amd64.tar.gz -C third_bin --wildcards '*/bin/*' + tar -xzf tmp/ticdc-linux-amd64.tar.gz -C third_bin + mv third_bin/ticdc-linux-amd64/bin/* third_bin/ + + chmod +x third_bin/* + rm -rf tmp + # rm -rf third_bin/bin + ls -alh third_bin/ +} + +main "$@" + +color-green "Download SUCCESS" diff --git a/tests/integrationtest2/r/br_integration.result b/tests/integrationtest2/r/br_integration.result new file mode 100644 index 0000000000000..c5433f88c7c7f --- /dev/null +++ b/tests/integrationtest2/r/br_integration.result @@ -0,0 +1,10 @@ +CREATE TABLE t1 (a INT PRIMARY KEY NONCLUSTERED AUTO_INCREMENT, b INT) AUTO_ID_CACHE = 100; +INSERT INTO t1 (b) VALUES (1), (2), (3); +SHOW TABLE t1 NEXT_ROW_ID; +DB_NAME TABLE_NAME COLUMN_NAME NEXT_GLOBAL_ROW_ID ID_TYPE +br_integration t1 _tidb_rowid 101 _TIDB_ROWID +br_integration t1 _tidb_rowid 1 AUTO_INCREMENT +SHOW TABLE tt1 NEXT_ROW_ID; +DB_NAME TABLE_NAME COLUMN_NAME NEXT_GLOBAL_ROW_ID ID_TYPE +br_integration tt1 _tidb_rowid 1 _TIDB_ROWID +br_integration tt1 _tidb_rowid 1 AUTO_INCREMENT diff --git a/tests/integrationtest2/run-tests.sh b/tests/integrationtest2/run-tests.sh new file mode 100755 index 0000000000000..fca13ea399714 --- /dev/null +++ b/tests/integrationtest2/run-tests.sh @@ -0,0 +1,417 @@ +#!/usr/bin/env bash +# Copyright 2024 PingCAP, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -x + +# Variables to set paths for each server binary +TIDB_BIN="./third_bin/tidb-server" +TIKV_BIN="./third_bin/tikv-server" +PD_BIN="./third_bin/pd-server" +DUMPLING_BIN="./third_bin/dumpling" +TICDC_BIN="./third_bin/cdc" +TIFLASH_BIN="./third_bin/tiflash-server" + +# Variables to set data directories +PD_DATA_DIR="./data/pd_data" +PD_DATA_DIR2="./data/pd_data2" +TIKV_DATA_DIR="./data/tikv_data" +TIKV_DATA_DIR2="./data/tikv_data2" +TIFLASH_DATA_DIR="./data/tiflash_data" +TIFLASH_DATA_DIR2="./data/tiflash_data2" +TICDC_DATA_DIR="./data/ticdc_data" + +rm -rf ./data +mkdir ./data + +TIDB_LOG_FILE="./logs/tidb.log" +TIDB_LOG_FILE2="./logs/tidb2.log" +TIKV_LOG_FILE="./logs/tikv.log" +TIKV_LOG_FILE2="./logs/tikv2.log" +TIFLASH_LOG_FILE="./logs/tiflash.log" +TIFLASH_LOG_FILE2="./logs/tiflash2.log" +PD_LOG_FILE="./logs/pd.log" +PD_LOG_FILE2="./logs/pd2.log" +TICDC_LOG_FILE="./logs/ticdc.log" + +rm -rf ./logs +mkdir ./logs + +build=1 +mysql_tester="./mysql_tester" +tidb_server="" +ticdc_server=$TICDC_BIN +portgenerator="" +mysql_tester_log="./integration-test.out" +tests="" +record=0 +record_case="" +stats="s" + +set -eu +trap 'set +e; PIDS=$(jobs -p); [ -n "$PIDS" ] && kill -9 $PIDS' EXIT +# make tests stable time zone wise +export TZ="Asia/Shanghai" + +function help_message() +{ + echo "Usage: $0 [options] + + -h: Print this help message. + + -s : Use tidb-server in for testing. + eg. \"./run-tests.sh -s ./integrationtest_tidb-server\" + + -b : \"y\" or \"Y\" for building test binaries [default \"y\" if this option is not specified]. + \"n\" or \"N\" for not to build. + The building of tidb-server will be skiped if \"-s \" is provided. + The building of portgenerator will be skiped if \"-s \" is provided. + + -r |all: Run tests in file \"t/.test\" and record result to file \"r/.result\". + \"all\" for running all tests and record their results. + + -t : Run tests in file \"t/.test\". + This option will be ignored if \"-r \" is provided. + Run all tests if this option is not provided. + +" +} + +# Function to find an available port starting from a given port +function find_available_port() { + local port=$1 + + while :; do + if [ "$port" -ge 65536 ]; then + echo "Error: No available ports found below 65536." >&2 + exit 1 + fi + if ! lsof -i :"$port" &> /dev/null; then + echo $port + return 0 + fi + ((port++)) + done +} + +# Function to find multiple available ports starting from a given port +function find_multiple_available_ports() { + local start_port=$1 + local count=$2 + local ports=() + + while [ ${#ports[@]} -lt $count ]; do + local available_port=$(find_available_port $start_port) + if [ $? -eq 0 ]; then + ports+=($available_port) + ((start_port = available_port + 1)) + else + echo "Error: Could not find an available port." >&2 + exit 1 + fi + done + + echo "${ports[@]}" +} + +function build_tidb_server() +{ + tidb_server="./integrationtest_tidb-server" + echo "building tidb-server binary: $tidb_server" + rm -rf $tidb_server + mkdir -p third_bin + rm -rf third_bin/br + rm -rf third_bin/dumpling + + cd ../.. + make server + make build_br + make build_dumpling + + cd - + ln -s ../../bin/tidb-server $tidb_server + ln -s ../../../bin/br third_bin/br + ln -s ../../../bin/dumpling third_bin/dumpling +} + +function build_mysql_tester() +{ + echo "building mysql-tester binary: $mysql_tester" + rm -rf $mysql_tester + GOBIN=$PWD go install github.com/bb7133/mysql-tester/src@67e4fbf902623a98a859fb3d1bd39088bec8da6f + mv src mysql_tester +} + +while getopts "t:s:r:b:d:c:i:h" opt; do + case $opt in + t) + tests="$OPTARG" + ;; + s) + tidb_server="$OPTARG" + ;; + r) + record=1 + record_case="$OPTARG" + ;; + b) + case $OPTARG in + y|Y) + build=1 + ;; + n|N) + build=0 + ;; + *) + help_message 1>&2 + exit 1 + ;; + esac + ;; + h) + help_message + exit 0 + ;; + *) + help_message 1>&2 + exit 1 + ;; + esac +done + +if [ $build -eq 1 ]; then + if [ -z "$tidb_server" ]; then + build_tidb_server + else + echo "skip building tidb-server, using existing binary: $tidb_server" + fi + build_mysql_tester +else + if [ -z "$tidb_server" ]; then + tidb_server="./integrationtest_tidb-server" + if [[ ! -f "$tidb_server" ]]; then + build_tidb_server + else + echo "skip building tidb-server, using existing binary: $tidb_server" + fi + fi + if [ -z "$mysql_tester" ]; then + mysql_tester="./mysql_tester" + if [[ ! -f "$mysql_tester" ]]; then + build_mysql_tester + else + echo "skip building mysql-tester, using existing binary: $mysql_tester" + fi + fi +fi + +# PD Server Configuration +start_pd_server() { + client_port=${1:-2379} + peer_port=${2:-2380} + data_dir=${3:-$PD_DATA_DIR} + log_dir=${4:-$PD_LOG_FILE} + + echo "Starting PD server..." + mkdir -p $data_dir + + $PD_BIN --name="pd" --data-dir="$data_dir" --log-file="$log_dir" \ + --client-urls="http://127.0.0.1:$client_port" \ + --peer-urls="http://127.0.0.1:$peer_port" \ + --advertise-client-urls="http://127.0.0.1:$client_port" \ + --advertise-peer-urls="http://127.0.0.1:$peer_port" & +# --config="config/pd.toml" + sleep 5 # Wait for PD to sart +} + +# TiKV Server Configuration +start_tikv_server() { + pd_client_port=${1:-2379} + tikv_port=${2:-20160} + tikv_status_port=${3:-20180} + data_dir=${4:-$TIKV_DATA_DIR} + log_dir=${5:-$TIKV_LOG_FILE} + + echo "Starting TiKV server..." + mkdir -p $data_dir + + $TIKV_BIN --pd="http://127.0.0.1:$pd_client_port" \ + --addr="127.0.0.1:$tikv_port" \ + --advertise-addr="127.0.0.1:$tikv_port" \ + --status-addr="127.0.0.1:$tikv_status_port" \ + --data-dir="$data_dir" \ + --log-file="$log_dir" & + sleep 5 # Wait for TiKV to connect to PD +} + +# TiFlash Server Configuration +start_tiflash_server() { + echo "Starting TiFlash server..." + mkdir -p $TIFLASH_DATA_DIR + $TIFLASH_BIN --data-dir=$TIFLASH_DATA_DIR --log-file=tiflash.log & + + sleep 5 # Wait for TiFlash to connect +} + +function start_tidb_server() +{ + pd_client_addr=${1:-127.0.0.1:2379} + tidb_port=${2:-4000} + tidb_status_port=${3:-10080} + log_file=${4:-$TIDB_LOG_FILE} + + config_file="config.toml" + echo "start tidb-server, log file: $log_file" + $tidb_server -P "$tidb_port" \ + -status "$tidb_status_port" \ + -config $config_file \ + -store tikv \ + -path "${pd_client_addr}" > $log_file 2>&1 & + SERVER_PID=$! + echo "tidb-server(PID: $SERVER_PID) started, port: $tidb_port" +} + +function start_ticdc_server() { + pd_client_addr=${1:-http://127.0.0.1:2379} + ticdc_port=${2:-8300} + downstream_port=${3:-4100} + + echo "Starting TiCDC server..." + mkdir -p $TICDC_DATA_DIR + $TICDC_BIN server --pd=$pd_client_addr --addr=127.0.0.1:$ticdc_port --data-dir=$TICDC_DATA_DIR --log-file=$TICDC_LOG_FILE & + sleep 5 # Wait for TiCDC to connect + + $TICDC_BIN cli changefeed create --server=127.0.0.1:$ticdc_port --sink-uri="mysql://root:@127.0.0.1:$downstream_port/" --changefeed-id="simple-replication-task" + sleep 5 # Wait for changefeed to connect +} + +function start_tidb_cluster() +{ + local ports=($(find_multiple_available_ports 2379 2)) + if [ $? -ne 0 ]; then + echo "Error: Could not find multiple available ports." >&2 + exit 1 + fi + pd_client_port=${ports[0]} + pd_peer_port=${ports[1]} + upstream_pd_client_port=$pd_client_port + start_pd_server $pd_client_port $pd_peer_port $PD_DATA_DIR $PD_LOG_FILE + + local ports=($(find_multiple_available_ports 20160 2)) + if [ $? -ne 0 ]; then + echo "Error: Could not find multiple available ports." >&2 + exit 1 + fi + tikv_port=${ports[0]} + tikv_status_port=${ports[1]} + start_tikv_server $pd_client_port $tikv_port $tikv_status_port $TIKV_DATA_DIR $TIKV_LOG_FILE + + tidb_port=$(find_available_port 4000) + UPSTREAM_PORT=$tidb_port + tidb_status_port=$(find_available_port 10080) + start_tidb_server "127.0.0.1:$pd_client_port" $tidb_port $tidb_status_port $TIDB_LOG_FILE + + local ports=($(find_multiple_available_ports 2379 2)) + if [ $? -ne 0 ]; then + echo "Error: Could not find multiple available ports." >&2 + exit 1 + fi + pd_client_port=${ports[0]} + pd_peer_port=${ports[1]} + start_pd_server $pd_client_port $pd_peer_port $PD_DATA_DIR2 $PD_LOG_FILE2 + + local ports=($(find_multiple_available_ports 20160 2)) + if [ $? -ne 0 ]; then + echo "Error: Could not find multiple available ports." >&2 + exit 1 + fi + tikv_port=${ports[0]} + tikv_status_port=${ports[1]} + start_tikv_server $pd_client_port $tikv_port $tikv_status_port $TIKV_DATA_DIR2 $TIKV_LOG_FILE2 + + tidb_port=$(find_available_port 4000) + DOWNSTREAM_PORT=$tidb_port + tidb_status_port=$(find_available_port 10080) + start_tidb_server "127.0.0.1:$pd_client_port" $tidb_port $tidb_status_port $TIDB_LOG_FILE2 + + echo "TiDB cluster started successfully!" +} + +function run_mysql_tester() +{ + if [ $record -eq 1 ]; then + echo "run & record integration test cases: $tests" + $mysql_tester \ + -port "$UPSTREAM_PORT" \ + -downstream "root:@tcp(127.0.0.1:$DOWNSTREAM_PORT)/test" \ + --check-error=true \ + --path-dumpling="./third_bin/dumpling" \ + --record $@ + else + echo "run integration test cases: $tests" + $mysql_tester \ + -port "$UPSTREAM_PORT" \ + -downstream "root:@tcp(127.0.0.1:$DOWNSTREAM_PORT)/test" \ + --check-error=true \ + --path-dumpling="./third_bin/dumpling" \ + $@ + fi +} + +start_tidb_cluster + +if [ $record -eq 1 ]; then + if [ "$record_case" = 'all' ]; then + tests='' + else + tests=$record_case + fi +fi + +non_ticdc_cases=() +ticdc_cases=() + +if [ -z "$tests" ]; then + while IFS= read -r file; do + file_name=$(basename "$file" .test) + if [[ "$file" == t/ticdc/* ]]; then + ticdc_cases+=("ticdc/$file_name") + else + non_ticdc_cases+=("$file_name") + fi + done < <(find t -name "*.test") +else + ticdc_cases=($(echo "$tests" | grep 'ticdc/' || echo "")) + non_ticdc_cases=($(echo "$tests" | grep -v 'ticdc/' || echo "")) +fi + +if [ ${#non_ticdc_cases[@]} -ne 0 ]; then + run_mysql_tester "${non_ticdc_cases[@]}" +fi + +if [ ${#ticdc_cases[@]} -ne 0 ]; then + ticdc_port=$(find_available_port 8300) + start_ticdc_server "http://127.0.0.1:$upstream_pd_client_port" $ticdc_port $tidb_port + + echo "TiCDC started successfully!" + + run_mysql_tester "${ticdc_cases[@]}" +fi + +kill -15 $SERVER_PID +while ps -p $SERVER_PID > /dev/null; do + sleep 1 +done + +echo "integrationtest passed!" diff --git a/tests/integrationtest2/t/br_integration.test b/tests/integrationtest2/t/br_integration.test new file mode 100644 index 0000000000000..5645c37e101d9 --- /dev/null +++ b/tests/integrationtest2/t/br_integration.test @@ -0,0 +1,9 @@ +# Test BR and AutoIncrement + +CREATE TABLE t1 (a INT PRIMARY KEY NONCLUSTERED AUTO_INCREMENT, b INT) AUTO_ID_CACHE = 100; +INSERT INTO t1 (b) VALUES (1), (2), (3); +SHOW TABLE t1 NEXT_ROW_ID; + +--backup_and_restore t1 AS tt1 + +SHOW TABLE tt1 NEXT_ROW_ID; \ No newline at end of file diff --git a/tests/integrationtest2/t/dumpling_import_integration.test b/tests/integrationtest2/t/dumpling_import_integration.test new file mode 100644 index 0000000000000..b18c74cc3209a --- /dev/null +++ b/tests/integrationtest2/t/dumpling_import_integration.test @@ -0,0 +1,10 @@ +# Test Lightning and AutoRandom + +CREATE TABLE t2(c BIGINT AUTO_RANDOM PRIMARY KEY, a INT, b INT); +INSERT INTO t2(a, b) VALUES (1, 1), (2, 2), (3, 3); +SELECT (c & 31) as inc FROM t2 ORDER BY inc; + +--dump_and_import t2 AS tt2 + +INSERT INTO tt2(a, b) VALUES (1, 1), (2, 2), (3, 3); +SELECT (c & 31) as inc FROM tt2 ORDER BY inc; \ No newline at end of file diff --git a/tests/integrationtest2/t/ticdc/cdc_integration.test b/tests/integrationtest2/t/ticdc/cdc_integration.test new file mode 100644 index 0000000000000..41ace6336ea94 --- /dev/null +++ b/tests/integrationtest2/t/ticdc/cdc_integration.test @@ -0,0 +1,13 @@ +# Test TiCDC replication + +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, UNIQUE KEY (b)); + +INSERT INTO t3 VALUES (1, 23); +--error 1062 +INSERT INTO t3 VALUES (11, 23); + +--replication_checkpoint +--connection downstream +use ticdc__cdc_integration; +--error 1062 +INSERT INTO t3 VALUES (11, 23);