-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpull_mode.test
More file actions
173 lines (145 loc) · 5.59 KB
/
pull_mode.test
File metadata and controls
173 lines (145 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
--source ../include/have_binsrv.inc
--source ../include/v80_v84_compatibility_defines.inc
--source include/count_sessions.inc
# in case of --repeat=N, we need to start from a fresh binary log to make
# this test deterministic
--echo *** Resetting replication at the very beginning of the test.
--disable_query_log
eval $stmt_reset_binary_logs_and_gtids;
--enable_query_log
# identifying backend storage type ('file' or 's3')
--source ../include/identify_storage_backend.inc
# creating data directory, configuration file, etc.
--let $binsrv_connect_timeout = 3
--let $binsrv_read_timeout = 3
--let $binsrv_idle_time = 1
--let $binsrv_verify_checksum = TRUE
--let $binsrv_replication_mode = position
--source ../include/set_up_binsrv_environment.inc
--echo
--echo *** Starting Binlog Server Utility in background in pull mode
--let $binsrv_pid_file = $MYSQL_TMP_DIR/binsrv_utility.pid
--let $binsrv_spawn_cmd_line = $BINSRV pull $binsrv_config_file_path > /dev/null & echo \$! > $binsrv_pid_file
--let EXPORTED_BINSRV_SPAWN_CMD_LINE = $binsrv_spawn_cmd_line
--perl
use strict;
use warnings;
my $cmd = $ENV{'EXPORTED_BINSRV_SPAWN_CMD_LINE'};
system("$cmd");
EOF
--let $read_from_file = $binsrv_pid_file
--source include/read_file_to_var.inc
--let $binsrv_pid = $result
--echo
--echo *** Determining the first fresh binary log name.
--let $first_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
--echo
--echo *** Creating a simple table and filling it with some data.
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(DEFAULT);
--echo
--echo *** Restarting the server with a pause to test for the STOP event in
--echo *** the binary log and reconnection logic.
--source include/shutdown_mysqld.inc
# Sleeping here deliberately so that the Binlog Server Utility would encounter
# read timeout and would try to reconnect several times.
--sleep 10
--source include/start_mysqld.inc
--echo
--echo *** Determining the second binary log name.
--let $second_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
--echo
--echo *** Filling the table with some more data.
INSERT INTO t1 VALUES(DEFAULT);
--echo
--echo *** Killing the server and restarting it after a pause to test for the
--echo *** missing ROTATE / STOP event at the end of the binary log .
--source include/kill_mysqld.inc
# Sleeping here deliberately so that the Binlog Server Utility would encounter
# read timeout and would try to reconnect several times.
--sleep 10
--source include/start_mysqld.inc
--echo
--echo *** Determining the third binary log name.
--let $third_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
--echo
--echo *** Filling the table with some more data again and dropping the table.
INSERT INTO t1 VALUES(DEFAULT);
DROP TABLE t1;
--echo
--echo *** FLUSHING the binlog one more time to make sure that the third one
--echo *** is no longer open.
FLUSH BINARY LOGS;
--echo
--echo *** Determining the fourth binary log name.
--let $fourth_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
--echo
--echo *** Waiting till Binlog Server Utility starts processing the fourth
--echo *** binary log.
# We grep the Binlog Server Utility log file in a loop until we encounter the
# fourth binary log file name.
--let $max_number_of_attempts = 60
--let $iteration = 0
while($iteration < $max_number_of_attempts)
{
--error 0, 1
--exec grep --silent $fourth_binlog $binsrv_log_path
--let $grep_status = $__error
if ($grep_status == 0)
{
--let $iteration = $max_number_of_attempts
}
if ($grep_status != 0)
{
--sleep 1
--inc $iteration
}
}
if ($grep_status != 0)
{
--die The Binlog Server Utility did not start processing the fourth binary log.
}
--echo
--echo *** Sending SIGTERM signal to the Binlog Server Utility and waiting for
--echo *** the process to terminate
--replace_result $binsrv_pid <BINSRV_PID>
--exec kill -s TERM $binsrv_pid
--let EXPORTED_BINSRV_PID = $binsrv_pid
--perl
use strict;
use warnings;
use Errno;
my $pid = $ENV{'EXPORTED_BINSRV_PID'};
my $not_present = (!kill(0, $pid) && $! == Errno::ESRCH);
while (!$not_present) {
sleep(1);
$not_present = (!kill(0, $pid) && $! == Errno::ESRCH);
}
EOF
--remove_file $binsrv_pid_file
--echo
--echo *** Comparing server and downloaded versions of the first binlog file
--let $local_file = $binlog_base_dir/$first_binlog
--let $storage_object = $binsrv_storage_path/$first_binlog
--source ../include/diff_with_storage_object.inc
--echo
--echo *** Comparing server and downloaded versions of the second binlog file
--let $local_file = $binlog_base_dir/$second_binlog
--let $storage_object = $binsrv_storage_path/$second_binlog
--source ../include/diff_with_storage_object.inc
--echo
--echo *** Comparing server and downloaded versions of the third binlog file
--let $local_file = $binlog_base_dir/$third_binlog
--let $storage_object = $binsrv_storage_path/$third_binlog
--source ../include/diff_with_storage_object.inc
# cleaning up
--source ../include/tear_down_binsrv_environment.inc
# As the Binlog Server Utility interrupts the connection upon timeout, here we
# need to close it on the MySQL server side as well in order to make sure that
# MTR 'check-test' before and after the test produces the same output.
--let $binlog_dump_connection_id = `SELECT ID FROM performance_schema.processlist WHERE COMMAND = 'Binlog Dump'`
--replace_result $binlog_dump_connection_id <CONNECTION_ID>
eval KILL CONNECTION $binlog_dump_connection_id;
# Also, we use 'count_sessions' include files to make sure that 'Binlog Dump'
# connection is indeed closed.
--source include/wait_until_count_sessions.inc