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 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
31 changes: 27 additions & 4 deletions dm/tests/_utils/run_downstream_cluster
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# tools to run a TiDB cluster
# parameter 1: work directory
set -eu
set -ux
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.

skip check error for start tikv fail for unknow reason like below, but tikv log didn't show any error.

+ sleep 10
+ bin/tikv-server --pd 127.0.0.1:2379 -A 127.0.0.1:2016 --status-addr 127.0.0.1:2018 --log-file /tmp/dm_test/many_tables/tikv.log --log-level info -s /tmp/dm_test/many_tables/tikv
script returned exit code 2+ ls /tmp/dm_test

Also all command have checked error.

WORK_DIR=$1

export PD_PEER_ADDR="127.0.0.1:2380"
Expand Down Expand Up @@ -32,55 +32,78 @@ EOF
--log-file "$WORK_DIR/pd.log" \
--config "$WORK_DIR/pd.toml" \
--data-dir "$WORK_DIR/pd" &
sleep 10
# wait until PD is online...
echo "after start PD...."
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")
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

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" &
sleep 10
# wait until TiKV is online...
i=0
while ! curl "http://$PD_ADDR/pd/api/v1/cluster/status" | tee /dev/stderr | grep '"is_initialized": true'; do
i=$((i + 1))
if [ "$i" -gt 20 ]; then
echo 'Failed to initialize TiKV cluster'
return 1
fi
echo 'Waiting for TiKV ready...'
sleep 5
done
}

start_tidb() {
echo "Starting TiDB..."
bin/tidb-server --version
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 10
# 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