Debian Codegraph @

mysql-test/suite/binlog/t/binlog_expire_logs_days_deprecation.test

raw
1 ###############################################################################
2 # Bug#26274274: IGNORE EXPIRE_LOGS_DAYS IF BINLOG_EXPIRE_LOGS_SECONDS IS SET #
3 # #
4 # This test case will test setting binlog_expire_logs_seconds and #
5 # expire_logs_days either as start up parameter or as dynamic global #
6 # variables, verifying that proper warning and error is thrown by the server. #
7 # #
8 # Bug#27252658: CHANGE DEFAULT VALUE OF BINLOG_EXPIRE_LOGS_SECONDS #
9 # #
10 # Here we will also test if the default value of binlog_expire_logs_seconds #
11 # and expire_logs_days is used as accoradance to the rule as mentioned below #
12 # with title Bug#27252658. #
13 # #
14 # These cases will be tested here. #
15 # #
16 # 1) expire_logs_days (>0) binlog_expire_logs_seconds (>0) #
17 # This case will check the following: #
18 # 1.1) The value of expire_logs_days is ignored and the purge time was #
19 # calculated only using binlog_expire_logs_seconds value. #
20 # 1.2) There is an error while trying to set binlog_expire_logs_seconds #
21 # and expire_logs_days dynamically. #
22 # 1.3) A warning message is printed describing the ignored value of #
23 # expire_logs_days when used together with binlog_expire_logs_seconds #
24 # 1.4) Bug#27252658: #
25 # If user provides values for both options, both variables are set #
26 # accordingly and 'binlog_expire_logs_seconds' takes effect. #
27 # #
28 # 2) expire_logs_days (>0) binlog_expire_logs_seconds (=0) #
29 # This case will check the following: #
30 # 2.1) The value of expire_logs_days is used when #
31 # binlog_expire_logs_seconds is not set or set to 0 #
32 # 2.2) No warning message is printed in this case as the user has not #
33 # specified any value for binlog_expire_logs_seconds. #
34 # 2.3) Bug#27252658: #
35 # If user provides a value for only one of the options,that particular#
36 # variable is set accordingly, and the other variable defaults to 0. #
37 # #
38 # 3) expire_logs_days (=0) binlog_expire_logs_seconds (>0) #
39 # This case will check the following: #
40 # 3.1) No warning message is printed in this case as the user has not #
41 # specified any value for expire_logs_days. #
42 # 3.2) Bug#27252658: #
43 # If user provides a value for only one of the options,that particular#
44 # variable is set accordingly, and the other variable defaults to 0. #
45 # #
46 # 4) expire_logs_days (=0) or binlog_expire_logs_seconds (=0) #
47 # Bug#27252658: #
48 # This case will check the following: #
49 # 4.1) Nothing should be purged at restart when any one of the variable is #
50 # set to 0 and other variable is not specified at start. #
51 # 4.2) If one of these variable is set to zero and other is not specified #
52 # at start up then there will not be any purging. #
53 # 4.3) Both the variable are set to 0. #
54 # #
55 # 5) expire_logs_days and binlog_expire_logs_seconds both not specified #
56 # This case will check the following: #
57 # 5.1) Bug#27252658: #
58 # If user does not provide a value for any of the options, then #
59 # 'binlog_expire_logs_seconds' defaults to 30*24*60*60 and #
60 # 'expire_logs_days' to 0. #
61 ###############################################################################
62
63
64 # Test in this file is binlog format agnostic, thus no need
65 # to rerun it for every format.
66 --source include/have_binlog_format_row.inc
67 --source include/linux.inc
68
69 CALL mtr.add_suppression("The option expire_logs_days cannot be used together*");
70 --let $saved_expire_logs_days= `SELECT @@GLOBAL.expire_logs_days`
71 --let $saved_binlog_expire_logs_seconds= `SELECT @@GLOBAL.binlog_expire_logs_seconds`
72 # Set the datadir
73 --let $MYSQLD_DATADIR= `SELECT @@datadir`
74 --let $ofile= $MYSQLTEST_VARDIR/tmp/binlog_deprecations-output.err
75
76 --echo ####
77 --echo #### Case 1:
78 --echo ####
79
80 --echo #### Case 1.1:
81
82 # Restart the server with expire_logs_days (>0) binlog_expire_logs_seconds (>0)
83 # Here we have set binlog_expire_logs_seconds as well so expire_logs_days will
84 # be ignored and the purge will happen.
85
86 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
87
88 --let $restart_parameters=restart:--binlog_expire_logs_seconds=2 --expire_logs_days=1 --log-error=$ofile
89 --source include/restart_mysqld.inc
90 --let $first_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
91 FLUSH LOGS;
92 # Sleep for twice of binlog_expire_logs_seconds value
93 --sleep 4
94 --file_exists $MYSQLD_DATADIR/$first_binlog_file
95 FLUSH LOGS;
96 --error 1
97 --file_exists $MYSQLD_DATADIR/$first_binlog_file
98
99 --echo #### Case 1.2:
100
101 # There should be an error while setting the variables dynamically.
102 --error ER_BINLOG_EXPIRE_LOG_DAYS_AND_SECS_USED_TOGETHER
103 SET GLOBAL expire_logs_days= 10;
104 --echo #### Case 1.3:
105
106 # Check if the warning is there in the error log when expire_logs_days is used along
107 # with binlog_expire_logs_seconds.
108
109 --let $assert_text= Assert that there is a warning at bootstrap for expire_logs_days
110 --let $assert_file= $ofile
111 --let $assert_select= The option expire_logs_days cannot be used together with option binlog_expire_logs_seconds.
112 --let $assert_count= 1
113 --source include/assert_grep.inc
114
115 --echo #### Case 1.4
116
117 # Check if the value of expire_logs_days is changed to 0.
118 --let $expire_logs_days_value = `SELECT @@GLOBAL.expire_logs_days`
119 --let $assert_cond = $expire_logs_days_value = 0
120 --let $assert_text = The value of expire_logs_days is not changed.
121 --source include/assert.inc
122
123 # Check if the value of binlog_expire_logs_seconds is not changed.
124 --let $binlog_expire_logs_seconds_value = `SELECT @@GLOBAL.binlog_expire_logs_seconds`
125 --let $assert_cond = $binlog_expire_logs_seconds_value = 2
126 --let $assert_text = The value of binlog_expire_logs_seconds is not changed.
127 --source include/assert.inc
128
129 --echo ####
130 --echo #### Case 2:
131 --echo ####
132
133 --echo #### Case 2.1:
134
135 # Restart the server with expire_logs_days (>0) & binlog_expire_logs_seconds (=0)
136 # Here we have not set binlog_expire_logs_seconds as well so expire_logs_days will
137 # not be ignored and the purge will not happen.
138 --remove_file $ofile
139 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
140
141 --let $restart_parameters=restart: --expire_logs_days=1 --binlog_expire_logs_seconds=0 --log-error=$ofile
142 --source include/restart_mysqld.inc
143 --let $first_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
144 FLUSH LOGS;
145 --sleep 4
146 --file_exists $MYSQLD_DATADIR/$first_binlog_file
147 FLUSH LOGS;
148 #The file still exists
149 --file_exists $MYSQLD_DATADIR/$first_binlog_file
150
151 --echo #### Case 2.2:
152
153 # Check if the warning is not there in the error log when binlog_expire_logs_seconds
154 # is not used (or have a value = 0) with expire_logs_days.
155
156 # When binlog_expire_logs_seconds is specified a value '0' (same as the above in restart command)
157 --let $assert_text= There is no warning at server start when binlog_expire_logs_seconds is not set.
158 --let $assert_file= $ofile
159 --let $assert_select= The option expire_logs_days cannot be used together with option binlog_expire_logs_seconds.
160 --let $assert_count= 0
161 --source include/assert_grep.inc
162
163 # When binlog_expire_logs_seconds is not specified
164 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
165 --let $restart_parameters=restart: --expire_logs_days=1 --log-error=$ofile
166 --source include/restart_mysqld.inc
167
168 --let $assert_text= There is no warning at server start when binlog_expire_logs_seconds is not set.
169 --let $assert_file= $ofile
170 --let $assert_select= The option expire_logs_days cannot be used together with option binlog_expire_logs_seconds.
171 --let $assert_count= 0
172 --source include/assert_grep.inc
173
174 --echo #### Case 2.3
175
176 # Check if the value of expire_logs_days is not changed.
177 --let $expire_logs_days_value = `SELECT @@GLOBAL.expire_logs_days`
178 --let $assert_cond = $expire_logs_days_value = 1
179 --let $assert_text = The value of expire_logs_days is not changed.
180 --source include/assert.inc
181
182 # Check if the value of binlog_expire_logs_seconds is set to 0 and not 30 (the default value).
183 --let $binlog_expire_logs_seconds_value = `SELECT @@GLOBAL.binlog_expire_logs_seconds`
184 --let $assert_cond = $binlog_expire_logs_seconds_value = 0
185 --let $assert_text = The value of binlog_expire_logs_seconds is changed from default 2592000 to 0 .
186 --source include/assert.inc
187
188 --echo ####
189 --echo #### Case 3:
190 --echo ####
191
192 --echo #### Case 3.1:
193 # Check if the warning is not there in the error log when expire_logs_days is not used (or
194 # have a value = 0) with binlog_expire_logs_seconds.
195
196 # When expire_logs_days is specified a value '0'
197
198 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
199 --let $restart_parameters=restart: --binlog_expire_logs_seconds=5 --expire_logs_days=0 --log-error=$ofile
200 --source include/restart_mysqld.inc
201
202 --let $assert_text= There is a no warning at server start for expire_logs_days
203 --let $assert_file= $ofile
204 --let $assert_select= The option expire_logs_days cannot be used together with option binlog_expire_logs_seconds.
205 --let $assert_count= 0
206 --source include/assert_grep.inc
207
208 # When expire_logs_days is not specified
209 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
210 --let $restart_parameters=restart: --binlog_expire_logs_seconds=5 --log-error=$ofile
211 --source include/restart_mysqld.inc
212
213 --let $assert_text= There is a no warning at server start for expire_logs_days
214 --let $assert_file= $ofile
215 --let $assert_select= The option expire_logs_days cannot be used together with option binlog_expire_logs_seconds.
216 --let $assert_count= 0
217 --source include/assert_grep.inc
218
219 --echo #### Case 3.2
220
221 # Check if the value of expire_logs_days is set to 0 (The default value).
222 --let $expire_logs_days_value = `SELECT @@GLOBAL.expire_logs_days`
223 --let $assert_cond = $expire_logs_days_value = 0
224 --let $assert_text = The value of expire_logs_days is 0.
225 --source include/assert.inc
226
227 # Check if the value of binlog_expire_logs_seconds is not changed.
228 --let $binlog_expire_logs_seconds_value = `SELECT @@GLOBAL.binlog_expire_logs_seconds`
229 --let $assert_cond = $binlog_expire_logs_seconds_value = 5
230 --let $assert_text = The value of binlog_expire_logs_seconds is not changed.
231 --source include/assert.inc
232
233 --echo ####
234 --echo #### Case 4:
235 --echo ####
236
237 --echo #### Case 4.1: server start should not purge the file
238 --let $first_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
239 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
240 --let $restart_parameters=restart: --log-error=$ofile --expire_logs_days=0
241 --source include/restart_mysqld.inc
242
243 --file_exists $MYSQLD_DATADIR/$first_binlog_file
244
245 --echo #### Case 4.2: flush logs should not purge the file
246 --let $first_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
247 FLUSH LOGS;
248 --sleep 4
249 --file_exists $MYSQLD_DATADIR/$first_binlog_file
250 FLUSH LOGS;
251 #The file still exists
252 --file_exists $MYSQLD_DATADIR/$first_binlog_file
253
254 --echo #### Case 4.3
255
256 # Check if the value of binlog_expire_logs_seconds is set to 0 and not 30*24*60*60 (the default value).
257
258 --let $binlog_expire_logs_seconds_value = `SELECT @@GLOBAL.binlog_expire_logs_seconds`
259 --let $assert_cond = $binlog_expire_logs_seconds_value = 0
260 --let $assert_text = The value of binlog_expire_logs_seconds is changed to 0.
261 --source include/assert.inc
262
263
264 --echo ####
265 --echo #### Case 5:
266 --echo ####
267
268 --echo #### Case 5.1
269
270 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
271 --let $restart_parameters=restart: --log-error=$ofile
272 --source include/restart_mysqld.inc
273 # Check if the value of expire_logs_days is set to 0 (the default value).
274 # And the value of binlog_expire_logs_seconds is set to 30*24*60*60
275
276 --let $expire_logs_days_value = `SELECT @@GLOBAL.expire_logs_days`
277 --let $assert_cond = $expire_logs_days_value = 0
278 --let $assert_text = The value of expire_logs_days is 0.
279 --source include/assert.inc
280
281 --let $binlog_expire_logs_seconds_value = `SELECT @@GLOBAL.binlog_expire_logs_seconds`
282 --let $assert_cond = $binlog_expire_logs_seconds_value = 2592000
283 --let $assert_text = The value of binlog_expire_logs_seconds is changed to 2592000(30 days).
284 --source include/assert.inc
285
286 # reset the variables
287 --eval SET GLOBAL binlog_expire_logs_seconds= $saved_binlog_expire_logs_seconds
288 --eval SET GLOBAL expire_logs_days= $saved_expire_logs_days
289
290 # Restore default settings
291 --let $restart_parameters = restart:
292 --source include/restart_mysqld.inc
293
294 --remove_file $MYSQLTEST_VARDIR/tmp/binlog_deprecations-output.err