Skip to content

Commit

Permalink
dm: fix integration test in rocky8.9 (pingcap#11751)
Browse files Browse the repository at this point in the history
  • Loading branch information
River2000i authored and ti-chi-bot committed Dec 23, 2024
1 parent 3703b18 commit f371292
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 10 deletions.
51 changes: 42 additions & 9 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,96 @@ start_pd() {
max-replicas = 1
EOF

pd-server --version
bin/pd-server --version
mkdir -p "$WORK_DIR/pd"
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...
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 "")
echo "curl response: $response"
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 --version
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
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'
return 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 ! 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 "")
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
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

0 comments on commit f371292

Please sign in to comment.