summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/binlog/t/binlog_expire_warnings.test
blob: 2e0831ad8787d1bc5d721fb84aa07c1bd5103eee (plain)
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# ==== Requirements ====
#
# Verify the logic for warnings related to expire-logs-days and
# binlog-expire-logs-seconds on server start:
#
# R0. All the following shall hold with binlog disabled and binlog enabled.
#
# R1. Binlog off warnings:
#
#     R1.1. If the binary log is disabled, using any of
#           binlog-expire-logs-seconds or expire_logs_days shall
#           generate a warning.
#
#     R1.2. If the binary log is enabled, or if
#           binlog-expire-logs-seconds / expire_logs_days is not used,
#           there shall be no warning for this case.
#
# R2. Values:
#
#     R2.1. None of expire-logs-days or binlog-expire-logs-seconds is
#           set: both shall use their default values (days=0, seconds=0)
#
#     R2.2. Exactly one of expire-logs-days or binlog-expire-logs-seconds
#           is set: that value is propogated to other variable.
#
#     R2.3. Both expire-logs-days or binlog-expire-logs-seconds are
#           set, and at least one of them is set to zero: the last set value
#           should be effective and its value will be propogated to other
#           variable.
#
#     R2.4. Both expire-logs-days and binlog-expire-logs-seconds are
#           set, and both are non-zero: the last set value
#           should be effective and its value will be propogated to other
#           variable.
#
# ==== Implementation ====
#
# Test all combinations of:
#
# - log-bin: on, off
# - expire-logs-days: not set, set to 0, set to nonzero
# - binlog-expire-logs-seconds: not set, set to 0, set to nonzero
# - Verify option value propogation, by varying the order, in which options
#   are set
#      --expire_logs_days --binlog_expire_logs_seconds
#      --binlog_expire_logs_seconds --expire_logs_days
# For each such scenario, state the expected warnings and values, and
# use extra/binlog_tests/binlog_expire_warnings.inc to execute the
# scenario.
#
# ==== References ====
#
#  MDEV-19371: Implement binlog_expire_logs_seconds for purging of binary
#              logs
#
--source include/have_binlog_format_row.inc

# Restarts the server with new options.
--source include/force_restart.inc

# A bit slow, since it restarts the server many times.  Also, this is
# unlikely to break in the future, so not important to run frequently.
--source include/big_test.inc


--let $ofile = $MYSQLTEST_VARDIR/tmp/binlog_expire_warnings-output.err

--let $i = 0
while ($i < 2) {

if ($i == 0) {
    --echo #### Binary log ENABLED ####
    --let $options =
    --let $binlog_off = 0
  }
  if ($i == 1) {
    --echo #### Binary log DISABLED ####
    --let $options = --skip-log-bin
    --let $binlog_off = 1
  }

  --echo ==== Don't set any option ====

  --let $days =
  --let $seconds =
  --let $expect_binlog_off_days_and_seconds_warning = 0
  --let $expect_days = 0
  --let $expect_seconds = 0
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ==== Set one option to zero ====

  --echo ---- days=0 ----
  --let $days = 0
  --let $seconds =
  --let $expect_binlog_off_days_and_seconds_warning = 0
  --let $expect_days = 0
  --let $expect_seconds = 0
  --let $option_invoke_order= days_then_seconds
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ---- seconds=0 ----
  --let $days =
  --let $seconds = 0
  --let $expect_binlog_off_days_and_seconds_warning = 0
  --let $expect_days = 0
  --let $expect_seconds = 0
  --let $option_invoke_order= seconds_then_days
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ==== Set one option to non-zero ====

  --echo ---- days=2 ----
  --let $days = 2
  --let $seconds =
  --let $expect_binlog_off_days_and_seconds_warning = $binlog_off
  --let $expect_days = 2
  --let $expect_seconds = `SELECT $days * 24 * 60 * 60`
  --let $option_invoke_order= days_then_seconds
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ---- seconds=86400 ----
  --let $days =
  --let $seconds = 86400
  --let $expect_binlog_off_days_and_seconds_warning = $binlog_off
  --let $expect_days = 1
  --let $expect_seconds = 86400
  --let $option_invoke_order= days_then_seconds
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ==== Set both options to zero ====

  --let $days = 0
  --let $seconds = 0
  --let $expect_binlog_off_days_and_seconds_warning = 0
  --let $expect_days = 0
  --let $expect_seconds = 0
  --let $option_invoke_order= days_then_seconds
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ==== Set both options: one to zero and one to non-zero ====
  --echo ---- days=1 seconds=0 ----
  --echo ---- The later seconds=0 will override days.
  --let $days = 1
  --let $seconds = 0
  --let $expect_binlog_off_days_and_seconds_warning = 0
  --let $expect_days = 0
  --let $expect_seconds = 0
  --let $option_invoke_order= days_then_seconds
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ---- seconds=0 days=1 ----
  --echo ---- The later days=1 will override seconds.
  --let $days = 1
  --let $seconds = 0
  --let $expect_binlog_off_days_and_seconds_warning = $binlog_off
  --let $expect_days = 1
  --let $expect_seconds = 86400
  --let $option_invoke_order= seconds_then_days
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ---- days=0 seconds=86400 ----
  --echo ---- The later seconds=86400 will override days.
  --let $days = 0
  --let $seconds = 86400
  --let $expect_binlog_off_days_and_seconds_warning = $binlog_off
  --let $expect_days = 1
  --let $expect_seconds = 86400
  --let $option_invoke_order= days_then_seconds
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ==== Set both options to non-zero ====

  --echo ---- days=1 and seconds=172800 ----
  --echo ---- Since binlog_expire_logs_seconds is set later expire_log_days
  --echo ---- becomes 2
  --let $days = 1
  --let $seconds = 172800
  --let $expect_binlog_off_days_and_seconds_warning = $binlog_off
  --let $expect_days = 2
  --let $expect_seconds = 172800
  --let $option_invoke_order= days_then_seconds
  --source suite/binlog/include/binlog_expire_warnings.inc

  --echo ---- days=1 and seconds=172800 ----
  --echo ---- Since expire_logs_days is set later binlog_expire_logs_seconds
  --echo ---- becomes 86400
  --let $days = 1
  --let $seconds = 172800
  --let $expect_binlog_off_days_and_seconds_warning = $binlog_off
  --let $expect_days = 1
  --let $expect_seconds = 86400
  --let $option_invoke_order= seconds_then_days
  --source suite/binlog/include/binlog_expire_warnings.inc

  --inc $i
}

# cleanup
--remove_file $ofile