Skip to content

Commit 5db266e

Browse files
author
Shlomi Noach
committed
tests expecting ROW binlog format, gracefully waiting for replication to catch up
1 parent 9890e66 commit 5db266e

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

localtests/test.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ verify_master_and_replica() {
2929
echo "Cannot verify gh-ost-test-mysql-replica"
3030
exit 1
3131
fi
32+
if [ "$(gh-ost-test-mysql-replica -e "select @@global.binlog_format" -ss)" != "ROW" ] ; then
33+
echo "Expecting test replica to have binlog_format=ROW"
34+
exit 1
35+
fi
3236
read replica_host replica_port <<< $(gh-ost-test-mysql-replica -e "select @@hostname, @@port" -ss)
3337
}
3438

@@ -42,14 +46,29 @@ echo_dot() {
4246
echo -n "."
4347
}
4448

49+
start_replication() {
50+
gh-ost-test-mysql-replica -e "stop slave; start slave;"
51+
num_attempts=0
52+
while gh-ost-test-mysql-replica -e "show slave status\G" | grep Seconds_Behind_Master | grep -q NULL ; do
53+
((num_attempts=num_attempts+1))
54+
if [ $num_attempts -gt 10 ] ; then
55+
echo
56+
echo "ERROR replication failure"
57+
exit 1
58+
fi
59+
echo_dot
60+
sleep 1
61+
done
62+
}
63+
4564
test_single() {
4665
local test_name
4766
test_name="$1"
4867

4968
echo -n "Testing: $test_name"
5069

5170
echo_dot
52-
gh-ost-test-mysql-replica -e "stop slave; start slave; do sleep(1)"
71+
start_replication
5372
echo_dot
5473
gh-ost-test-mysql-master --default-character-set=utf8mb4 test < $tests_path/$test_name/create.sql
5574

@@ -82,7 +101,7 @@ test_single() {
82101
--table=gh_ost_test \
83102
--alter='engine=innodb' \
84103
--exact-rowcount \
85-
--switch-to-rbr \
104+
--assume-rbr \
86105
--initially-drop-old-table \
87106
--initially-drop-ghost-table \
88107
--throttle-query='select timestampdiff(second, min(last_update), now()) < 5 from _gh_ost_test_ghc' \

0 commit comments

Comments
 (0)