From 6c52ed66a2e86844f7d1ae9312382de2beb153f5 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Sun, 22 Nov 2026 20:39:49 +0800 Subject: [PATCH 1/5] tests: reproduce changefeed creation after PD scale-in --- .../run.sh | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100755 tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh diff --git a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh new file mode 100755 index 0000000000..a2e7f8e7f2 --- /dev/null +++ b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +set -eu + +CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +source "$CUR/../_utils/test_prepare" + +if [ "$NEXT_GEN" = 1 ]; then + echo "[$(date)] skip $TEST_NAME: PD scale-in regression only applies to the classic architecture" + exit 0 +fi + +WORK_DIR=$OUT_DIR/$TEST_NAME +CDC_BINARY=${CDC_BINARY:-cdc.test} +NEW_PD_HOST=127.0.0.1 +NEW_PD_PORT=2879 +NEW_PD_PEER_PORT=2880 +NEW_PD_ADDR="http://$NEW_PD_HOST:$NEW_PD_PORT" + +wait_for_log() { + local pattern=$1 + local retries=${2:-90} + + for ((i = 0; i < retries; i++)); do + if grep -Fq "$pattern" "$WORK_DIR/cdc.log"; then + return 0 + fi + sleep 1 + done + + return 1 +} + +wait_for_new_pd_tso() { + for ((i = 0; i < 30; i++)); do + if run_cdc_cli_tso_query "$NEW_PD_HOST" "$NEW_PD_PORT" >/dev/null 2>&1; then + return 0 + fi + sleep 1 + done + + return 1 +} + +wait_for_pd4_leader() { + for ((i = 0; i < 60; i++)); do + if curl -fsS "$NEW_PD_ADDR/pd/api/v1/leader" | + tr -d '[:space:]' | + grep -Fq '"name":"pd4"'; then + return 0 + fi + sleep 1 + done + + return 1 +} + +remove_pd_member() { + local pd_name=$1 + + for ((i = 0; i < 30; i++)); do + if ! curl -fsS "$NEW_PD_ADDR/pd/api/v1/members" | + tr -d '[:space:]' | + grep -Fq "\"name\":\"$pd_name\""; then + return 0 + fi + curl -fsS -X DELETE "$NEW_PD_ADDR/pd/api/v1/members/name/$pd_name" >/dev/null 2>&1 || true + sleep 1 + done + + return 1 +} + +prepare() { + rm -rf "$WORK_DIR" + mkdir -p "$WORK_DIR" + + start_tidb_cluster --workdir "$WORK_DIR" --multiple-upstream-pd true + + local initial_pd_addrs + initial_pd_addrs="http://${UP_PD_HOST_1}:${UP_PD_PORT_1},http://${UP_PD_HOST_2}:${UP_PD_PORT_2},http://${UP_PD_HOST_3}:${UP_PD_PORT_3}" + TICDC_NEWARCH=false run_cdc_server \ + --workdir "$WORK_DIR" \ + --binary "$CDC_BINARY" \ + --pd "$initial_pd_addrs" + + pd-server \ + --advertise-client-urls "$NEW_PD_ADDR" \ + --client-urls "http://0.0.0.0:$NEW_PD_PORT" \ + --advertise-peer-urls "http://$NEW_PD_HOST:$NEW_PD_PEER_PORT" \ + --peer-urls "http://0.0.0.0:$NEW_PD_PEER_PORT" \ + --config "$WORK_DIR/pd-config.toml" \ + --log-file "$WORK_DIR/pd4.log" \ + --data-dir "$WORK_DIR/pd4" \ + --name pd4 \ + --join "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" & + + check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" + wait_for_log "$NEW_PD_ADDR" || { + echo "TiCDC did not discover the newly added PD endpoint" + return 1 + } + + curl -fsS -X POST "$NEW_PD_ADDR/pd/api/v1/leader/transfer/pd4" + wait_for_pd4_leader || { + echo "PD leader was not transferred to pd4" + return 1 + } + for pd_name in pd1 pd2 pd3; do + remove_pd_member "$pd_name" || { + echo "failed to remove $pd_name" + return 1 + } + done + + check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" + wait_for_new_pd_tso || { + echo "the new PD endpoint did not serve TSO after the original PD nodes were removed" + return 1 + } +} + +trap 'stop_test "$WORK_DIR"' EXIT + +prepare + +# The create request does not specify pd_addrs, so TiCDC must reuse the default +# upstream clients after every PD endpoint supplied at startup is gone. +create_response=$(curl -fsS \ + --user ticdc:ticdc_secret \ + --header 'Content-Type: application/json' \ + --data '{"changefeed_id":"test","sink_uri":"blackhole://"}' \ + "http://${CDC_HOST}:${CDC_PORT}/api/v2/changefeeds") + +echo "$create_response" | tr -d '[:space:]' | grep -Fq '"id":"test"' + +echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" From c49118dafd9853b66f307e5ccfcdbafc1266f2a9 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Sun, 22 Nov 2026 21:40:10 +0800 Subject: [PATCH 2/5] tests: move PD scale-in coverage to classic HTTP API --- .../run.sh | 137 ------------------ .../http_api_compatibility/run.sh | 125 ++++++++++++++++ 2 files changed, 125 insertions(+), 137 deletions(-) delete mode 100755 tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh diff --git a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh deleted file mode 100755 index a2e7f8e7f2..0000000000 --- a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash - -set -eu - -CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -source "$CUR/../_utils/test_prepare" - -if [ "$NEXT_GEN" = 1 ]; then - echo "[$(date)] skip $TEST_NAME: PD scale-in regression only applies to the classic architecture" - exit 0 -fi - -WORK_DIR=$OUT_DIR/$TEST_NAME -CDC_BINARY=${CDC_BINARY:-cdc.test} -NEW_PD_HOST=127.0.0.1 -NEW_PD_PORT=2879 -NEW_PD_PEER_PORT=2880 -NEW_PD_ADDR="http://$NEW_PD_HOST:$NEW_PD_PORT" - -wait_for_log() { - local pattern=$1 - local retries=${2:-90} - - for ((i = 0; i < retries; i++)); do - if grep -Fq "$pattern" "$WORK_DIR/cdc.log"; then - return 0 - fi - sleep 1 - done - - return 1 -} - -wait_for_new_pd_tso() { - for ((i = 0; i < 30; i++)); do - if run_cdc_cli_tso_query "$NEW_PD_HOST" "$NEW_PD_PORT" >/dev/null 2>&1; then - return 0 - fi - sleep 1 - done - - return 1 -} - -wait_for_pd4_leader() { - for ((i = 0; i < 60; i++)); do - if curl -fsS "$NEW_PD_ADDR/pd/api/v1/leader" | - tr -d '[:space:]' | - grep -Fq '"name":"pd4"'; then - return 0 - fi - sleep 1 - done - - return 1 -} - -remove_pd_member() { - local pd_name=$1 - - for ((i = 0; i < 30; i++)); do - if ! curl -fsS "$NEW_PD_ADDR/pd/api/v1/members" | - tr -d '[:space:]' | - grep -Fq "\"name\":\"$pd_name\""; then - return 0 - fi - curl -fsS -X DELETE "$NEW_PD_ADDR/pd/api/v1/members/name/$pd_name" >/dev/null 2>&1 || true - sleep 1 - done - - return 1 -} - -prepare() { - rm -rf "$WORK_DIR" - mkdir -p "$WORK_DIR" - - start_tidb_cluster --workdir "$WORK_DIR" --multiple-upstream-pd true - - local initial_pd_addrs - initial_pd_addrs="http://${UP_PD_HOST_1}:${UP_PD_PORT_1},http://${UP_PD_HOST_2}:${UP_PD_PORT_2},http://${UP_PD_HOST_3}:${UP_PD_PORT_3}" - TICDC_NEWARCH=false run_cdc_server \ - --workdir "$WORK_DIR" \ - --binary "$CDC_BINARY" \ - --pd "$initial_pd_addrs" - - pd-server \ - --advertise-client-urls "$NEW_PD_ADDR" \ - --client-urls "http://0.0.0.0:$NEW_PD_PORT" \ - --advertise-peer-urls "http://$NEW_PD_HOST:$NEW_PD_PEER_PORT" \ - --peer-urls "http://0.0.0.0:$NEW_PD_PEER_PORT" \ - --config "$WORK_DIR/pd-config.toml" \ - --log-file "$WORK_DIR/pd4.log" \ - --data-dir "$WORK_DIR/pd4" \ - --name pd4 \ - --join "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" & - - check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" - wait_for_log "$NEW_PD_ADDR" || { - echo "TiCDC did not discover the newly added PD endpoint" - return 1 - } - - curl -fsS -X POST "$NEW_PD_ADDR/pd/api/v1/leader/transfer/pd4" - wait_for_pd4_leader || { - echo "PD leader was not transferred to pd4" - return 1 - } - for pd_name in pd1 pd2 pd3; do - remove_pd_member "$pd_name" || { - echo "failed to remove $pd_name" - return 1 - } - done - - check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" - wait_for_new_pd_tso || { - echo "the new PD endpoint did not serve TSO after the original PD nodes were removed" - return 1 - } -} - -trap 'stop_test "$WORK_DIR"' EXIT - -prepare - -# The create request does not specify pd_addrs, so TiCDC must reuse the default -# upstream clients after every PD endpoint supplied at startup is gone. -create_response=$(curl -fsS \ - --user ticdc:ticdc_secret \ - --header 'Content-Type: application/json' \ - --data '{"changefeed_id":"test","sink_uri":"blackhole://"}' \ - "http://${CDC_HOST}:${CDC_PORT}/api/v2/changefeeds") - -echo "$create_response" | tr -d '[:space:]' | grep -Fq '"id":"test"' - -echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" diff --git a/tests/integration_tests/http_api_compatibility/run.sh b/tests/integration_tests/http_api_compatibility/run.sh index 40d8fed430..dcdb98f7d5 100644 --- a/tests/integration_tests/http_api_compatibility/run.sh +++ b/tests/integration_tests/http_api_compatibility/run.sh @@ -3,12 +3,137 @@ set -eu CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +source "$CUR/../_utils/test_prepare" # This case is only for old architecture. if [ "${NEXT_GEN:-0}" = 1 ]; then exit 0 fi +WORK_DIR=$OUT_DIR/${TEST_NAME}_pd_scale_in +CDC_BINARY=${CDC_BINARY:-cdc.test} +NEW_PD_HOST=127.0.0.1 +NEW_PD_PORT=2879 +NEW_PD_PEER_PORT=2880 +NEW_PD_ADDR="http://$NEW_PD_HOST:$NEW_PD_PORT" + +wait_for_log() { + local pattern=$1 + local retries=${2:-90} + + for ((i = 0; i < retries; i++)); do + if grep -Fq "$pattern" "$WORK_DIR/cdc.log"; then + return 0 + fi + sleep 1 + done + + return 1 +} + +wait_for_new_pd_tso() { + for ((i = 0; i < 30; i++)); do + if run_cdc_cli_tso_query "$NEW_PD_HOST" "$NEW_PD_PORT" >/dev/null 2>&1; then + return 0 + fi + sleep 1 + done + + return 1 +} + +wait_for_pd4_leader() { + for ((i = 0; i < 60; i++)); do + if curl -fsS "$NEW_PD_ADDR/pd/api/v1/leader" | + tr -d '[:space:]' | + grep -Fq '"name":"pd4"'; then + return 0 + fi + sleep 1 + done + + return 1 +} + +remove_pd_member() { + local pd_name=$1 + + for ((i = 0; i < 30; i++)); do + if ! curl -fsS "$NEW_PD_ADDR/pd/api/v1/members" | + tr -d '[:space:]' | + grep -Fq "\"name\":\"$pd_name\""; then + return 0 + fi + curl -fsS -X DELETE "$NEW_PD_ADDR/pd/api/v1/members/name/$pd_name" >/dev/null 2>&1 || true + sleep 1 + done + + return 1 +} + +test_create_changefeed_after_pd_scale_in() { + rm -rf "$WORK_DIR" + mkdir -p "$WORK_DIR" + + start_tidb_cluster --workdir "$WORK_DIR" --multiple-upstream-pd true + + local initial_pd_addrs + initial_pd_addrs="http://${UP_PD_HOST_1}:${UP_PD_PORT_1},http://${UP_PD_HOST_2}:${UP_PD_PORT_2},http://${UP_PD_HOST_3}:${UP_PD_PORT_3}" + TICDC_NEWARCH=false run_cdc_server \ + --workdir "$WORK_DIR" \ + --binary "$CDC_BINARY" \ + --pd "$initial_pd_addrs" + + pd-server \ + --advertise-client-urls "$NEW_PD_ADDR" \ + --client-urls "http://0.0.0.0:$NEW_PD_PORT" \ + --advertise-peer-urls "http://$NEW_PD_HOST:$NEW_PD_PEER_PORT" \ + --peer-urls "http://0.0.0.0:$NEW_PD_PEER_PORT" \ + --config "$WORK_DIR/pd-config.toml" \ + --log-file "$WORK_DIR/pd4.log" \ + --data-dir "$WORK_DIR/pd4" \ + --name pd4 \ + --join "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" & + + check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" + wait_for_log "$NEW_PD_ADDR" || { + echo "TiCDC did not discover the newly added PD endpoint" + return 1 + } + + curl -fsS -X POST "$NEW_PD_ADDR/pd/api/v1/leader/transfer/pd4" + wait_for_pd4_leader || { + echo "PD leader was not transferred to pd4" + return 1 + } + for pd_name in pd1 pd2 pd3; do + remove_pd_member "$pd_name" || { + echo "failed to remove $pd_name" + return 1 + } + done + + check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" + wait_for_new_pd_tso || { + echo "the new PD endpoint did not serve TSO after the original PD nodes were removed" + return 1 + } + + local create_response + create_response=$(curl -fsS \ + --user ticdc:ticdc_secret \ + --header 'Content-Type: application/json' \ + --data '{"changefeed_id":"after-pd-scale-in","sink_uri":"blackhole://"}' \ + "http://${CDC_HOST}:${CDC_PORT}/api/v2/changefeeds") + + echo "$create_response" | tr -d '[:space:]' | grep -Fq '"id":"after-pd-scale-in"' +} + export TICDC_NEWARCH=false bash "$CUR/../http_api/run.sh" "$@" + +# Use a fresh cluster for the PD membership test so changefeed metadata created +# by the HTTP API compatibility test cannot affect this stage. +trap 'stop_test "$WORK_DIR"' EXIT +test_create_changefeed_after_pd_scale_in export TICDC_NEWARCH=true From 5b0ab0ff33d8c33ceab6c1a55ab3d3783f61da30 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Sun, 22 Nov 2026 22:08:05 +0800 Subject: [PATCH 3/5] tests: run PD scale-in regression in CI --- .../run.sh | 141 ++++++++++++++++++ .../http_api_compatibility/run.sh | 125 ---------------- tests/integration_tests/run_light_it_in_ci.sh | 2 +- 3 files changed, 142 insertions(+), 126 deletions(-) create mode 100755 tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh diff --git a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh new file mode 100755 index 0000000000..b560467755 --- /dev/null +++ b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh @@ -0,0 +1,141 @@ +#!/bin/bash + +set -eu + +CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +source "$CUR/../_utils/test_prepare" + +SINK_TYPE=$1 +if [ "$NEXT_GEN" = 1 ]; then + echo "[$(date)] skip $TEST_NAME: PD scale-in regression only applies to the classic architecture" + exit 0 +fi +if [ "$SINK_TYPE" != "mysql" ]; then + exit 0 +fi + +WORK_DIR=$OUT_DIR/$TEST_NAME +CDC_BINARY=${CDC_BINARY:-cdc.test} +NEW_PD_HOST=127.0.0.1 +NEW_PD_PORT=2879 +NEW_PD_PEER_PORT=2880 +NEW_PD_ADDR="http://$NEW_PD_HOST:$NEW_PD_PORT" + +wait_for_log() { + local pattern=$1 + local retries=${2:-90} + + for ((i = 0; i < retries; i++)); do + if grep -Fq "$pattern" "$WORK_DIR/cdc.log"; then + return 0 + fi + sleep 1 + done + + return 1 +} + +wait_for_new_pd_tso() { + for ((i = 0; i < 30; i++)); do + if run_cdc_cli_tso_query "$NEW_PD_HOST" "$NEW_PD_PORT" >/dev/null 2>&1; then + return 0 + fi + sleep 1 + done + + return 1 +} + +wait_for_pd4_leader() { + for ((i = 0; i < 60; i++)); do + if curl -fsS "$NEW_PD_ADDR/pd/api/v1/leader" | + tr -d '[:space:]' | + grep -Fq '"name":"pd4"'; then + return 0 + fi + sleep 1 + done + + return 1 +} + +remove_pd_member() { + local pd_name=$1 + + for ((i = 0; i < 30; i++)); do + if ! curl -fsS "$NEW_PD_ADDR/pd/api/v1/members" | + tr -d '[:space:]' | + grep -Fq "\"name\":\"$pd_name\""; then + return 0 + fi + curl -fsS -X DELETE "$NEW_PD_ADDR/pd/api/v1/members/name/$pd_name" >/dev/null 2>&1 || true + sleep 1 + done + + return 1 +} + +prepare() { + rm -rf "$WORK_DIR" + mkdir -p "$WORK_DIR" + + start_tidb_cluster --workdir "$WORK_DIR" --multiple-upstream-pd true + + local initial_pd_addrs + initial_pd_addrs="http://${UP_PD_HOST_1}:${UP_PD_PORT_1},http://${UP_PD_HOST_2}:${UP_PD_PORT_2},http://${UP_PD_HOST_3}:${UP_PD_PORT_3}" + TICDC_NEWARCH=false run_cdc_server \ + --workdir "$WORK_DIR" \ + --binary "$CDC_BINARY" \ + --pd "$initial_pd_addrs" + + pd-server \ + --advertise-client-urls "$NEW_PD_ADDR" \ + --client-urls "http://0.0.0.0:$NEW_PD_PORT" \ + --advertise-peer-urls "http://$NEW_PD_HOST:$NEW_PD_PEER_PORT" \ + --peer-urls "http://0.0.0.0:$NEW_PD_PEER_PORT" \ + --config "$WORK_DIR/pd-config.toml" \ + --log-file "$WORK_DIR/pd4.log" \ + --data-dir "$WORK_DIR/pd4" \ + --name pd4 \ + --join "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" & + + check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" + wait_for_log "$NEW_PD_ADDR" || { + echo "TiCDC did not discover the newly added PD endpoint" + return 1 + } + + curl -fsS -X POST "$NEW_PD_ADDR/pd/api/v1/leader/transfer/pd4" + wait_for_pd4_leader || { + echo "PD leader was not transferred to pd4" + return 1 + } + for pd_name in pd1 pd2 pd3; do + remove_pd_member "$pd_name" || { + echo "failed to remove $pd_name" + return 1 + } + done + + check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" + wait_for_new_pd_tso || { + echo "the new PD endpoint did not serve TSO after the original PD nodes were removed" + return 1 + } +} + +trap 'stop_test "$WORK_DIR"' EXIT + +prepare + +# The create request does not specify pd_addrs, so TiCDC must reuse the default +# upstream clients after every PD endpoint supplied at startup is gone. +create_response=$(curl -fsS \ + --user ticdc:ticdc_secret \ + --header 'Content-Type: application/json' \ + --data '{"changefeed_id":"test","sink_uri":"blackhole://"}' \ + "http://${CDC_HOST}:${CDC_PORT}/api/v2/changefeeds") + +echo "$create_response" | tr -d '[:space:]' | grep -Fq '"id":"test"' + +echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" diff --git a/tests/integration_tests/http_api_compatibility/run.sh b/tests/integration_tests/http_api_compatibility/run.sh index dcdb98f7d5..40d8fed430 100644 --- a/tests/integration_tests/http_api_compatibility/run.sh +++ b/tests/integration_tests/http_api_compatibility/run.sh @@ -3,137 +3,12 @@ set -eu CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -source "$CUR/../_utils/test_prepare" # This case is only for old architecture. if [ "${NEXT_GEN:-0}" = 1 ]; then exit 0 fi -WORK_DIR=$OUT_DIR/${TEST_NAME}_pd_scale_in -CDC_BINARY=${CDC_BINARY:-cdc.test} -NEW_PD_HOST=127.0.0.1 -NEW_PD_PORT=2879 -NEW_PD_PEER_PORT=2880 -NEW_PD_ADDR="http://$NEW_PD_HOST:$NEW_PD_PORT" - -wait_for_log() { - local pattern=$1 - local retries=${2:-90} - - for ((i = 0; i < retries; i++)); do - if grep -Fq "$pattern" "$WORK_DIR/cdc.log"; then - return 0 - fi - sleep 1 - done - - return 1 -} - -wait_for_new_pd_tso() { - for ((i = 0; i < 30; i++)); do - if run_cdc_cli_tso_query "$NEW_PD_HOST" "$NEW_PD_PORT" >/dev/null 2>&1; then - return 0 - fi - sleep 1 - done - - return 1 -} - -wait_for_pd4_leader() { - for ((i = 0; i < 60; i++)); do - if curl -fsS "$NEW_PD_ADDR/pd/api/v1/leader" | - tr -d '[:space:]' | - grep -Fq '"name":"pd4"'; then - return 0 - fi - sleep 1 - done - - return 1 -} - -remove_pd_member() { - local pd_name=$1 - - for ((i = 0; i < 30; i++)); do - if ! curl -fsS "$NEW_PD_ADDR/pd/api/v1/members" | - tr -d '[:space:]' | - grep -Fq "\"name\":\"$pd_name\""; then - return 0 - fi - curl -fsS -X DELETE "$NEW_PD_ADDR/pd/api/v1/members/name/$pd_name" >/dev/null 2>&1 || true - sleep 1 - done - - return 1 -} - -test_create_changefeed_after_pd_scale_in() { - rm -rf "$WORK_DIR" - mkdir -p "$WORK_DIR" - - start_tidb_cluster --workdir "$WORK_DIR" --multiple-upstream-pd true - - local initial_pd_addrs - initial_pd_addrs="http://${UP_PD_HOST_1}:${UP_PD_PORT_1},http://${UP_PD_HOST_2}:${UP_PD_PORT_2},http://${UP_PD_HOST_3}:${UP_PD_PORT_3}" - TICDC_NEWARCH=false run_cdc_server \ - --workdir "$WORK_DIR" \ - --binary "$CDC_BINARY" \ - --pd "$initial_pd_addrs" - - pd-server \ - --advertise-client-urls "$NEW_PD_ADDR" \ - --client-urls "http://0.0.0.0:$NEW_PD_PORT" \ - --advertise-peer-urls "http://$NEW_PD_HOST:$NEW_PD_PEER_PORT" \ - --peer-urls "http://0.0.0.0:$NEW_PD_PEER_PORT" \ - --config "$WORK_DIR/pd-config.toml" \ - --log-file "$WORK_DIR/pd4.log" \ - --data-dir "$WORK_DIR/pd4" \ - --name pd4 \ - --join "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" & - - check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" - wait_for_log "$NEW_PD_ADDR" || { - echo "TiCDC did not discover the newly added PD endpoint" - return 1 - } - - curl -fsS -X POST "$NEW_PD_ADDR/pd/api/v1/leader/transfer/pd4" - wait_for_pd4_leader || { - echo "PD leader was not transferred to pd4" - return 1 - } - for pd_name in pd1 pd2 pd3; do - remove_pd_member "$pd_name" || { - echo "failed to remove $pd_name" - return 1 - } - done - - check_pd_health "$NEW_PD_HOST" "$NEW_PD_PORT" - wait_for_new_pd_tso || { - echo "the new PD endpoint did not serve TSO after the original PD nodes were removed" - return 1 - } - - local create_response - create_response=$(curl -fsS \ - --user ticdc:ticdc_secret \ - --header 'Content-Type: application/json' \ - --data '{"changefeed_id":"after-pd-scale-in","sink_uri":"blackhole://"}' \ - "http://${CDC_HOST}:${CDC_PORT}/api/v2/changefeeds") - - echo "$create_response" | tr -d '[:space:]' | grep -Fq '"id":"after-pd-scale-in"' -} - export TICDC_NEWARCH=false bash "$CUR/../http_api/run.sh" "$@" - -# Use a fresh cluster for the PD membership test so changefeed metadata created -# by the HTTP API compatibility test cannot affect this stage. -trap 'stop_test "$WORK_DIR"' EXIT -test_create_changefeed_after_pd_scale_in export TICDC_NEWARCH=true diff --git a/tests/integration_tests/run_light_it_in_ci.sh b/tests/integration_tests/run_light_it_in_ci.sh index 31914ffdc9..18e6494f1a 100755 --- a/tests/integration_tests/run_light_it_in_ci.sh +++ b/tests/integration_tests/run_light_it_in_ci.sh @@ -44,7 +44,7 @@ mysql_groups=( # G05 'vector simple partition_table fail_over_ddl_F conflict_key_generated_column mysql_conflict_keys wide_table' # G06 - 'http_api http_api_compatibility http_api_tls_old_arch fail_over_ddl_G synced_status same_upstream_downstream' + 'http_api http_api_compatibility http_api_tls_old_arch changefeed_create_after_pd_scale_in fail_over_ddl_G synced_status same_upstream_downstream' # G07 'fail_over_ddl_H changefeed_update_config synced_status_with_redo redo_apply_table_route' # G08 From 23378edca966f5b0be7056e272195e5b2d5bbe40 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Mon, 23 Nov 2026 11:04:12 +0800 Subject: [PATCH 4/5] tests: run PD scale-in regression on new architecture --- .../changefeed_create_after_pd_scale_in/run.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh index b560467755..b3c6bdd797 100755 --- a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh +++ b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh @@ -6,10 +6,6 @@ CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) source "$CUR/../_utils/test_prepare" SINK_TYPE=$1 -if [ "$NEXT_GEN" = 1 ]; then - echo "[$(date)] skip $TEST_NAME: PD scale-in regression only applies to the classic architecture" - exit 0 -fi if [ "$SINK_TYPE" != "mysql" ]; then exit 0 fi @@ -83,7 +79,7 @@ prepare() { local initial_pd_addrs initial_pd_addrs="http://${UP_PD_HOST_1}:${UP_PD_PORT_1},http://${UP_PD_HOST_2}:${UP_PD_PORT_2},http://${UP_PD_HOST_3}:${UP_PD_PORT_3}" - TICDC_NEWARCH=false run_cdc_server \ + run_cdc_server \ --workdir "$WORK_DIR" \ --binary "$CDC_BINARY" \ --pd "$initial_pd_addrs" From aa42481a5ddac305565ddf118525b61b60a54fcc Mon Sep 17 00:00:00 2001 From: lidezhu Date: Mon, 23 Nov 2026 15:47:35 +0800 Subject: [PATCH 5/5] tests: stabilize PD scale-in regression setup --- .../run.sh | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh index b3c6bdd797..aa69a91278 100755 --- a/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh +++ b/tests/integration_tests/changefeed_create_after_pd_scale_in/run.sh @@ -42,6 +42,24 @@ wait_for_new_pd_tso() { return 1 } +wait_for_new_pd_metadata_write() { + local probe_service_id="ticdc-pd-scale-in-readiness-probe" + + for ((i = 0; i < 60; i++)); do + # Deleting an absent service safepoint is idempotent, but still commits a + # PD GC state transaction. This verifies metadata writes without leaving + # probe data behind. + if curl -fsS -X DELETE \ + "$NEW_PD_ADDR/pd/api/v1/gc/safepoint/$probe_service_id" \ + >/dev/null 2>&1; then + return 0 + fi + sleep 1 + done + + return 1 +} + wait_for_pd4_leader() { for ((i = 0; i < 60; i++)); do if curl -fsS "$NEW_PD_ADDR/pd/api/v1/leader" | @@ -118,6 +136,10 @@ prepare() { echo "the new PD endpoint did not serve TSO after the original PD nodes were removed" return 1 } + wait_for_new_pd_metadata_write || { + echo "the new PD endpoint did not accept metadata writes after the original PD nodes were removed" + return 1 + } } trap 'stop_test "$WORK_DIR"' EXIT