From 30adcb517736d912dde34122178a1ead08913c7c Mon Sep 17 00:00:00 2001 From: meiji163 Date: Thu, 19 Dec 2024 11:20:43 -0800 Subject: [PATCH 1/2] reproduce bug in localtests --- localtests/bit-unique-key/create.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 localtests/bit-unique-key/create.sql diff --git a/localtests/bit-unique-key/create.sql b/localtests/bit-unique-key/create.sql new file mode 100644 index 000000000..0497ae429 --- /dev/null +++ b/localtests/bit-unique-key/create.sql @@ -0,0 +1,9 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + `id` bigint not null, + `bit_col` bit not null, + primary key (`id`, `bit_col`) +) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +insert into gh_ost_test values (1, b'1'); +insert into gh_ost_test values (2, b'1'); +insert into gh_ost_test values (3, b'1'); From 72a7b6e90be23740ce586cc6c94f6599715ca795 Mon Sep 17 00:00:00 2001 From: meiji163 Date: Thu, 19 Dec 2024 16:02:20 -0800 Subject: [PATCH 2/2] add localtest timeout 60s --- localtests/test.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/localtests/test.sh b/localtests/test.sh index 0c8670cb6..589a7aa8c 100755 --- a/localtests/test.sh +++ b/localtests/test.sh @@ -18,6 +18,7 @@ ghost_structure_output_file=/tmp/gh-ost-test.ghost.structure.sql orig_content_output_file=/tmp/gh-ost-test.orig.content.csv ghost_content_output_file=/tmp/gh-ost-test.ghost.content.csv throttle_flag_file=/tmp/gh-ost-test.ghost.throttle.flag +timeout_duration="60s" master_host= master_port= @@ -67,7 +68,7 @@ verify_master_and_replica() { echo "Expecting test replica to have binlog_format=ROW" exit 1 fi - read replica_host replica_port <<< $(gh-ost-test-mysql-replica -e "select @@hostname, @@port" -ss) + read -r replica_host replica_port <<< "$(gh-ost-test-mysql-replica -e "select @@hostname, @@port" -ss)" [ "$replica_host" == "$(hostname)" ] && replica_host="127.0.0.1" echo "# replica verified at $replica_host:$replica_port" } @@ -190,9 +191,14 @@ test_single() { echo_dot echo $cmd > $exec_command_file echo_dot - bash $exec_command_file 1> $test_logfile 2>&1 + # run test in background so we can interrupt the "timeout" command + trap 'test -d /proc/$pid && kill -INT -$pid' INT + timeout "$timeout_duration" bash $exec_command_file 1> $test_logfile 2>&1 & + pid=$! + wait $pid execution_result=$? + trap - INT if [ -f $tests_path/$test_name/sql_mode ] ; then gh-ost-test-mysql-master --default-character-set=utf8mb4 test -e "set @@global.sql_mode='${original_sql_mode}'" @@ -203,6 +209,16 @@ test_single() { gh-ost-test-mysql-master --default-character-set=utf8mb4 test < $tests_path/$test_name/destroy.sql fi + if [ $execution_result -eq 124 ] ; then + echo + echo "ERROR $test_name execution exceeded timeout $timeout_duration" + return 1 + elif [ $execution_result -eq 130 ] ; then + echo + echo "$test_name execution interrupted" + return 130 + fi + if [ -f $tests_path/$test_name/expect_failure ] ; then if [ $execution_result -eq 0 ] ; then echo @@ -281,6 +297,10 @@ build_binary() { test_all() { build_binary test_dirs=$(find "$tests_path" -mindepth 1 -maxdepth 1 ! -path . -type d | grep "$test_pattern" | sort) + if [ -z "$test_dirs" ] ; then + echo "No tests found" + return 0 + fi while read -r test_dir; do test_name=$(basename "$test_dir") if ! test_single "$test_name" ; then