Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7f3a8aa
test(dm): add MariaDB source smoke integration case
joechenrh Apr 9, 2026
8df3e70
Merge branch 'master' into mariadb-source-smoke-dm
joechenrh Apr 10, 2026
9b321e8
test(dm): next-gen TiDB integration test compatibility
joechenrh Apr 17, 2026
ef58291
test(dm): simplify test scripts with shared cleanup functions
joechenrh Apr 17, 2026
c0cff14
test(dm): fix new_relay config normalization leaking into import
joechenrh Apr 17, 2026
2caf0e5
test(dm): skip test_tls on next-gen — Lightning needs HTTPS on status…
joechenrh Apr 17, 2026
de9eb41
test(dm): kill dm-masters sequentially in cleanup_process
joechenrh Apr 17, 2026
06ec850
test(dm): fix many_tables double TiDB start on classic + sequential m…
joechenrh Apr 17, 2026
549220b
test(dm): fix print_status infinite loop + tolerate SIGKILL exit
joechenrh Apr 18, 2026
ee1b260
test(dm): fix shfmt formatting + address gemini review comments
joechenrh Apr 20, 2026
bb087b9
test(dm): remove internal tracking docs from repo
joechenrh Apr 20, 2026
a2e9bca
test(dm): always set keyspace-name and tikv-worker-url in run_tidb_se…
joechenrh Apr 20, 2026
ba180b9
test(dm): revert keyspace-name on classic + remove debug log
joechenrh Apr 20, 2026
ac26f26
test(dm): centralize TIDB_EXTRA_ARGS, dedup session normalization, si…
joechenrh Apr 20, 2026
b956ed9
test(dm): add mariadb_source to G10 test group
joechenrh Apr 20, 2026
a92af04
test(dm): remove mariadb_source from G10, skip in others check
joechenrh Apr 20, 2026
1ef325b
test(dm): fix print_status ((i++)) crash with set -e
joechenrh Apr 20, 2026
b62df2a
test(dm): add mariadb_source to G10 group
joechenrh Apr 21, 2026
763d36f
test(dm): remove need_mariadb/need_mysql from run.sh
joechenrh Apr 21, 2026
0086f17
test(dm): make MariaDB handling optional in run.sh
joechenrh Apr 21, 2026
6750060
test(dm): fix G09 openapi and G10 all_mode flaky tests
joechenrh Apr 21, 2026
943d341
test(dm): restore TiDB after import_into_mode cleanup
joechenrh Apr 21, 2026
1107b33
Revert "test(dm): restore TiDB after import_into_mode cleanup"
joechenrh Apr 21, 2026
4ff624f
test(dm): fix G10 flakes — reorder mariadb_source, increase failover …
joechenrh Apr 21, 2026
ec5a550
test(dm): fix openapi delete_master_with_retry flaky test
joechenrh Apr 22, 2026
ce818ae
dm: fix session.Close() hang when etcd quorum is lost
joechenrh Apr 22, 2026
830be2c
Revert "dm: fix session.Close() hang when etcd quorum is lost"
joechenrh Apr 22, 2026
48cacca
test(dm): fix Python 2 SyntaxError in openapi_cluster_check
joechenrh Apr 23, 2026
338d4d5
test(dm): fix s3_dumpling_lightning flake — wait for Sync before chec…
joechenrh Apr 23, 2026
a1d83b3
test(dm): add diagnostic output to mariadb_source test
joechenrh Apr 23, 2026
13c8ec2
test(dm): fix ha_cases3_1 flake — serialize dmctl_start_task calls
joechenrh Apr 24, 2026
3b8e983
test(dm): fix mariadb_source collation, enable on next-gen
joechenrh Apr 24, 2026
4f45cad
test(dm): use SYSTEM TiDB directly as downstream on next-gen
joechenrh Apr 24, 2026
546056b
test(dm): include dxf_service in run_tidb_server on next-gen
joechenrh Apr 27, 2026
4589b38
test(dm): fix G06 metrics flake — sync data before checking lag metric
joechenrh Apr 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ install_test_python_dep:
@echo "install python requirments for test"
pip install --user -q -r ./dm/tests/requirements.txt

check_third_party_binary_for_dm : sync-diff-inspector
check_third_party_binary_for_dm:
@which bin/sync_diff_inspector
@which bin/tidb-server
@which mysql
@which bin/minio
Expand Down
87 changes: 87 additions & 0 deletions dm/tests/_utils/cluster_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
# Cluster lifecycle operations for DM integration tests.
#
# Sourced by test_prepare. Provides functions to start, stop, and restart
# downstream TiDB clusters in both classic and next-gen modes.
#
# Startup delegates to standalone scripts (which manage their own processes).
# Cleanup runs in the test's shell (needs access to pgrep/kill).

CUR_CLUSTER_LIB=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

# ---------------------------------------------------------------------------
# Cleanup
# ---------------------------------------------------------------------------

# Kill the port-4000 TiDB (SYSTEM TiDB on next-gen, unistore on classic).
cleanup_tidb_server() {
local pattern='tidb-server.*-P 4000'
local pids
pids=$(pgrep -f "$pattern" || true)
echo "tidb-server on port 4000 pids=${pids:-none}"
if [ -n "$pids" ]; then
kill -HUP $pids 2>/dev/null || true
fi
for _ in $(seq 1 120); do
if ! pgrep -f "$pattern" >/dev/null 2>&1; then
echo "tidb-server on port 4000 already exit"
rm -f /tmp/*_tidb/*/tmp-storage/_dir.lock 2>/dev/null || true
return 0
fi
sleep 1
done
echo "tidb-server on port 4000 didn't exit in 120s"
pgrep -af "$pattern" || true
return 1
}

# Tear down the full downstream cluster.
# Next-gen: only TiDB (preserve PD + TiKV + MinIO + tikv-worker).
# Classic: kill everything + clean unistore data.
cleanup_downstream_cluster() {
if [ "${NEXT_GEN:-}" = "1" ]; then
cleanup_tidb_server
else
killall -9 tidb-server 2>/dev/null || true
killall -9 tikv-server 2>/dev/null || true
killall -9 pd-server 2>/dev/null || true
wait_process_exit tidb-server
wait_process_exit tikv-server
wait_process_exit pd-server
rm -rf /tmp/tidb
fi
}

# ---------------------------------------------------------------------------
# Startup
# ---------------------------------------------------------------------------

# Start or restart a single downstream TiDB.
# Args: port password [config_file]
run_tidb_server() {
"$CUR_CLUSTER_LIB/run_tidb_server" "$@"
}

# Start a full downstream cluster (PD + TiKV + TiDB).
# Classic: single PD + TiKV + TiDB.
# Next-gen: MinIO + PD + TiKV + tikv-worker + SYSTEM TiDB + user TiDB.
# Args: work_dir
run_downstream_cluster() {
if [ "${NEXT_GEN:-}" = "1" ]; then
"$CUR_CLUSTER_LIB/run_downstream_cluster_nextgen" "$@"
else
"$CUR_CLUSTER_LIB/run_downstream_cluster_classic" "$@"
fi
}

# Start a TLS-enabled downstream cluster.
# Classic: full PD + TiKV + TiDB with TLS on separate ports.
# Next-gen: restart only user TiDB with client-facing TLS.
# Args: work_dir conf_dir cluster_ca cluster_cert cluster_key db_ca db_cert db_key
run_downstream_cluster_with_tls() {
if [ "${NEXT_GEN:-}" = "1" ]; then
"$CUR_CLUSTER_LIB/run_downstream_cluster_with_tls_nextgen" "$@"
else
"$CUR_CLUSTER_LIB/run_downstream_cluster_with_tls_classic" "$@"
fi
}
23 changes: 23 additions & 0 deletions dm/tests/_utils/env_variables
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
MYSQL_HOST1=${MYSQL_HOST1:-127.0.0.1}
MYSQL_HOST2=${MYSQL_HOST2:-127.0.0.1}
MARIADB_HOST1=${MARIADB_HOST1:-127.0.0.1}
TIDB_HOST=${TIDB_HOST:-127.0.0.1}
MYSQL_PORT1=${MYSQL_PORT1:-3306}
MYSQL_PORT2=${MYSQL_PORT2:-3307}
MARIADB_PORT1=${MARIADB_PORT1:-3308}
MYSQL_PASSWORD1=${MYSQL_PASSWORD1:-123456}
MYSQL_PASSWORD2=${MYSQL_PASSWORD2:-123456}
MARIADB_PASSWORD1=${MARIADB_PASSWORD1:-123456}
TIDB_PASSWORD=${TIDB_PASSWORD:-123456}

TIDB_PORT=${TIDB_PORT:-4000}
Expand Down Expand Up @@ -34,3 +37,23 @@ SOURCE_ID2="mysql-replica-02"
RESET_MASTER=${RESET_MASTER:-true}

VERBOSE=${VERBOSE:-false}

# Cluster endpoints. On next-gen, PD_ADDR etc. are always set because a real
# TiKV cluster is required. On classic, they're only set by the individual
# cluster scripts (run_downstream_cluster_classic) when a real cluster is
# needed — most classic tests use unistore (no PD/TiKV).
if [ "${NEXT_GEN:-}" = "1" ]; then
export PD_PEER_ADDR=${PD_PEER_ADDR:-"127.0.0.1:2380"}
export PD_ADDR=${PD_ADDR:-"127.0.0.1:2379"}
export TIKV_ADDR=${TIKV_ADDR:-"127.0.0.1:2016"}
export TIKV_STATUS_ADDR=${TIKV_STATUS_ADDR:-"127.0.0.1:2018"}
export MINIO_ADDR=${MINIO_ADDR:-"127.0.0.1:9000"}
export MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-"minioadmin"}
export MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-"minioadmin"}
export MINIO_BUCKET=${MINIO_BUCKET:-"next-gen-test"}
export TIKV_WORKER_ADDR=${TIKV_WORKER_ADDR:-"127.0.0.1:19000"}
export KEYSPACE_NAME=${KEYSPACE_NAME:-"SYSTEM"}

# Extra CLI flags for user TiDB.
export TIDB_EXTRA_ARGS="-keyspace-name ${KEYSPACE_NAME}"
fi
23 changes: 16 additions & 7 deletions dm/tests/_utils/ha_cases_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ ha_test2="ha_test2"
master_ports=($MASTER_PORT1 $MASTER_PORT2 $MASTER_PORT3)
worker_ports=($WORKER1_PORT $WORKER2_PORT $WORKER3_PORT $WORKER4_PORT $WORKER5_PORT)

# print_debug_status dumps query-status for both tasks when check_sync_diff
# fails, so the CI log shows what went wrong before the test exits.
function print_debug_status() {
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT3" \
"query-status test" \
"fail me!" 1 &&
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT3" \
"query-status test2" \
"fail me!" 1 && exit 1
}

function load_data() {
port=$1
pswd=$2
Expand Down Expand Up @@ -135,13 +146,11 @@ function start_multi_tasks_cluster() {
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER5_PORT

echo "start DM task"

dmctl_start_task &
pid1=$!
dmctl_start_task "$cur/conf/dm-task2.yaml" &
pid2=$!

wait "$pid1" "$pid2"
# Run sequentially — parallel dmctl calls write the same log file
# ($workdir/dmctl.$ts.log) when executed in the same second, causing
# output corruption and false "result count mismatch" failures.
dmctl_start_task
dmctl_start_task "$cur/conf/dm-task2.yaml"
}

function cleanup() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#!/usr/bin/env bash
# tools to run a TiDB cluster
# Start a classic (single-PD + single-TiKV + single-TiDB) downstream cluster.
# parameter 1: work directory
set -eux
CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source "$CUR/env_variables"
WORK_DIR=$1

export PD_PEER_ADDR="127.0.0.1:2380"
export PD_ADDR="127.0.0.1:2379"

export TIDB_IP="127.0.0.1"
export TIDB_PORT="4000"
export TIDB_ADDR="127.0.0.1:4000"

export TIDB_STATUS_ADDR="127.0.0.1:10080"
export TIKV_ADDR="127.0.0.1:2016"
export TIKV_STATUS_ADDR="127.0.0.1:2018"
# Classic cluster needs these — on next-gen they come from env_variables.
export PD_PEER_ADDR=${PD_PEER_ADDR:-"127.0.0.1:2380"}
export PD_ADDR=${PD_ADDR:-"127.0.0.1:2379"}
export TIKV_ADDR=${TIKV_ADDR:-"127.0.0.1:2016"}
export TIKV_STATUS_ADDR=${TIKV_STATUS_ADDR:-"127.0.0.1:2018"}

start_pd() {
echo "Starting PD..."
Expand Down Expand Up @@ -44,7 +41,7 @@ EOF
i=$((i + 1))
if [ "$i" -gt 20 ]; then
echo 'Failed to start PD'
return 1
exit 1
fi
echo 'Waiting for PD ready...'
sleep 3
Expand Down Expand Up @@ -80,47 +77,18 @@ start_tikv() {
i=$((i + 1))
if [ "$i" -gt 20 ]; then
echo 'Failed to initialize TiKV cluster after 20 attempts'
return 1
exit 1
fi

echo 'Waiting for TiKV ready...'
sleep 5
done
}

start_tidb() {
echo "Starting TiDB..."
bin/tidb-server -V
bin/tidb-server \
-P 4000 \
--status 10080 \
--advertise-address="127.0.0.1" \
--store tikv \
--path "$PD_ADDR" \
--log-file "$WORK_DIR/tidb.log" &
sleep 5
# wait until TiDB is online...
i=0
while true; do
response=$(curl -s -o /dev/null -w "%{http_code}" "http://$TIDB_IP:10080/status" || echo "")
echo "curl response: $response"
if [ "$response" -eq 200 ]; then
echo 'Start TiDB success'
break
fi
i=$((i + 1))
if [ "$i" -gt 50 ]; then
echo 'Failed to start TiDB'
return 1
fi
echo 'Waiting for TiDB ready...'
sleep 3
done
}

start_pd
start_tikv
start_tidb

mysql -uroot -h127.0.0.1 -P4000 --default-character-set utf8 -e "CREATE USER 'test'@'%' IDENTIFIED BY '123456';" || true
mysql -uroot -h127.0.0.1 -P4000 --default-character-set utf8 -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRANT OPTION;" || true
# PD_ADDR is already exported above; run_tidb_server derives --store tikv
# from it automatically.
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
"$CUR_DIR/run_tidb_server" 4000 123456
Loading