Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dm: fix integration test in rocky8.9 #11751

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f0ec446
add log
River2000i Nov 14, 2024
204b8c1
add dependency for validate IP addresses with SANs
River2000i Nov 15, 2024
81dfe81
retry when curl command get not zero
River2000i Nov 18, 2024
6c45472
add log
River2000i Nov 18, 2024
69b422c
add log
River2000i Nov 18, 2024
d40822f
debug
River2000i Nov 18, 2024
3f27bce
Fix TLS generation script to use RSA keys instead of EC keys
River2000i Nov 19, 2024
768db29
revet debug
River2000i Nov 19, 2024
6d18136
fix
River2000i Nov 19, 2024
df4ec61
revert
River2000i Nov 19, 2024
3966225
Revert "Fix TLS generation script to use RSA keys instead of EC keys"
River2000i Nov 20, 2024
8f360ed
fix
River2000i Nov 20, 2024
edec99b
check curl get 200
River2000i Nov 21, 2024
24a3b14
fmt
River2000i Nov 21, 2024
aae5267
use env_var set mysql cli password
River2000i Nov 21, 2024
060bdf4
debug
River2000i Nov 21, 2024
2b5be5e
debug
River2000i Nov 21, 2024
907d518
debug
River2000i Nov 21, 2024
8f0cfe0
debug
River2000i Nov 21, 2024
30e3bfe
debug
River2000i Nov 21, 2024
19b2ade
fix
River2000i Nov 21, 2024
e5ac23e
fix
River2000i Nov 21, 2024
efcb1f1
fmt
River2000i Nov 21, 2024
59e6309
add log
River2000i Nov 21, 2024
2ed926b
fix
River2000i Nov 21, 2024
ef7b1cb
debug
River2000i Nov 21, 2024
ce65c18
Merge remote-tracking branch 'upstream/master' into fix-openssl-ci-test
River2000i Nov 21, 2024
3efe23f
ignore check running dump task in running stage
River2000i Nov 21, 2024
1c60df9
fix
River2000i Nov 21, 2024
57a0695
debug: check tikv-server exit with error 2
purelind Nov 25, 2024
b4205a4
debug: check tikv-server exit with error 2
purelind Nov 25, 2024
314a1e2
debug: check tikv-server error 2
purelind Nov 25, 2024
7689858
fix: fix error exit in shell pipe
purelind Nov 26, 2024
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
64 changes: 49 additions & 15 deletions dm/tests/_utils/run_downstream_cluster
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
# tools to run a TiDB cluster
# parameter 1: work directory
set -eu
set -eux
WORK_DIR=$1

export PD_PEER_ADDR="127.0.0.1:2380"
Expand All @@ -24,63 +24,97 @@ start_pd() {
max-replicas = 1
EOF

pd-server --version
bin/pd-server --version
mkdir -p "$WORK_DIR/pd"
bin/pd-server \
nohup bin/pd-server \
--client-urls "http://$PD_ADDR" \
--peer-urls "http://$PD_PEER_ADDR" \
--log-file "$WORK_DIR/pd.log" \
--config "$WORK_DIR/pd.toml" \
--data-dir "$WORK_DIR/pd" &
# wait until PD is online...
--data-dir "$WORK_DIR/pd" >/dev/null 2>&1 &
sleep 5
i=0
while ! curl "http://$PD_ADDR/pd/api/v1/version"; do
while true; do
response=$(curl -s -o /dev/null -w "%{http_code}" "http://$PD_ADDR/pd/api/v1/version")
echo "curl response: $response"
Copy link
Contributor Author

@River2000i River2000i Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. validate http code instead of curl success or not. Since curl get success but may get [PD:server:ErrServerNotStarted]server not started
  2. sleep for waiting for port listening. Since curl may failure by Connection refused (7) then the test failure

if [ "$response" -eq 200 ]; then
echo 'Start PD success'
break
fi
i=$((i + 1))
if [ "$i" -gt 20 ]; then
echo 'Failed to start PD'
return 1
fi
echo 'Waiting for PD ready...'
sleep 3
done
}

start_tikv() {
echo "Starting TiKV..."
mkdir -p "$WORK_DIR/tikv"
bin/tikv-server \
bin/tikv-server --version
nohup bin/tikv-server \
--pd "$PD_ADDR" \
-A "$TIKV_ADDR" \
--status-addr "$TIKV_STATUS_ADDR" \
--log-file "$WORK_DIR/tikv.log" \
--log-level info \
-s "$WORK_DIR/tikv" &
while ! curl "http://$PD_ADDR/pd/api/v1/cluster/status" | tee /dev/stderr | grep '"is_initialized": true'; do
-s "$WORK_DIR/tikv" >/dev/null 2>&1 &
sleep 5
i=0
while true; do
response=$(curl -s "http://$PD_ADDR/pd/api/v1/cluster/status" || echo "")

if [ -z "$response" ]; then
echo "Failed to connect to PD server"
else
echo "PD response: $response"
if echo "$response" | grep -q '"is_initialized": true'; then
echo "TiKV cluster initialized successfully"
break
fi
fi

i=$((i + 1))
if [ "$i" -gt 20 ]; then
echo 'Failed to initialize TiKV cluster'
echo 'Failed to initialize TiKV cluster after 20 attempts'
echo "Last response: $response"
return 1
fi

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

start_tidb() {
echo "Starting TiDB..."
bin/tidb-server \
bin/tidb-server -V
nohup bin/tidb-server \
-P 4000 \
--status 10080 \
--advertise-address="127.0.0.1" \
--store tikv \
--path "$PD_ADDR" \
--log-file "$WORK_DIR/tidb.log" &

--log-file "$WORK_DIR/tidb.log" >/dev/null 2>&1 &
sleep 5
# wait until TiDB is online...
i=0
while ! curl "http://$TIDB_IP:10080/status"; do
while true; do
response=$(curl -s -o /dev/null -w "%{http_code}" "http://$TIDB_IP:10080/status")
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
}
Expand Down
2 changes: 1 addition & 1 deletion dm/tests/_utils/run_sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ fi
if [[ $# -ge 4 ]]; then
echo "$1" | iconv -f utf8 -t $4 | mysql -u$user -h127.0.0.1 -P$2 -p$3 --default-character-set $4 -E >>$OUTFILE
else
mysql -u$user -h127.0.0.1 -P$2 -p$3 --default-character-set utf8 -E -e "$1" >>$OUTFILE
MYSQL_PWD=$3 mysql -u$user -h127.0.0.1 -P$2 --default-character-set utf8 -E -e "$1" >>$OUTFILE
fi
2 changes: 2 additions & 0 deletions dm/tests/many_tables/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ function run() {
pkill -hup tidb-server 2>/dev/null || true
wait_process_exit tidb-server
# now worker will process some binlog events, save table checkpoint and meet downstream error
echo "start incremental_data_2"
incremental_data_2
echo "finish incremental_data_2"
sleep 30

resume_num=$(grep 'unit process error' $WORK_DIR/worker1/log/dm-worker.log | wc -l)
Expand Down
2 changes: 1 addition & 1 deletion dm/tests/openapi/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function init_noshard_data() {
function init_dump_data() {

run_sql_source1 "CREATE TABLE openapi.t1(i TINYINT, j INT UNIQUE KEY);"
run_sql_source1 "INSERT INTO openapi.t1(i,j) VALUES (1, 2),(3,4);"
run_sql_source1 "INSERT INTO openapi.t1(i,j) VALUES (1, 2),(3,4),(5,6),(7,8),(9,10),(11,12),(13,14),(15,16),(17,18);"
}

function init_shard_data() {
Expand Down
1 change: 1 addition & 0 deletions dm/tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
requests
ipaddress
5 changes: 5 additions & 0 deletions dm/tests/tls/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ EOF
--log-file "$WORK_DIR/tidb.log" 2>&1 &

sleep 5

echo "show databases without TLS"
mysql -uroot -h127.0.0.1 -P4400 --default-character-set utf8 -E -e "SHOW DATABASES;"
echo "drop database tls with TLS"
# if execute failed, print tidb's log for debug
mysql -uroot -h127.0.0.1 -P4400 --default-character-set utf8 --ssl-ca $cur/conf/ca.pem --ssl-cert $cur/conf/dm.pem --ssl-key $cur/conf/dm.key -E -e "drop database if exists tls" || (cat $WORK_DIR/tidb.log && exit 1)
echo "drop database dm_meta with TLS"
mysql -uroot -h127.0.0.1 -P4400 --default-character-set utf8 --ssl-ca $cur/conf/ca.pem --ssl-cert $cur/conf/dm.pem --ssl-key $cur/conf/dm.key -E -e "drop database if exists dm_meta"
}

Expand Down
Loading