| 1 |
# ==== Requirements ==== |
| 2 |
# |
| 3 |
# Verify the logic for warnings related to expire-logs-days and |
| 4 |
# binlog-expire-logs-seconds on server start: |
| 5 |
# |
| 6 |
# R0. All the following shall hold with binlog disabled and binlog enabled. |
| 7 |
# |
| 8 |
# R1. Binlog off warnings: |
| 9 |
# |
| 10 |
# R1.1. If the binary log is disabled, using any of |
| 11 |
# binlog-expire-logs-seconds or expire_logs_days shall |
| 12 |
# generate a warning. |
| 13 |
# |
| 14 |
# R1.2. If the binary log is enabled, or if |
| 15 |
# binlog-expire-logs-seconds / expire_logs_days is not used, |
| 16 |
# there shall be no warning for this case. |
| 17 |
# |
| 18 |
# R2. Values: |
| 19 |
# |
| 20 |
# R2.1. None of expire-logs-days or binlog-expire-logs-seconds is |
| 21 |
# set: both shall use their default values (days=0, seconds=0) |
| 22 |
# |
| 23 |
# R2.2. Exactly one of expire-logs-days or binlog-expire-logs-seconds |
| 24 |
# is set: that value is propogated to other variable. |
| 25 |
# |
| 26 |
# R2.3. Both expire-logs-days or binlog-expire-logs-seconds are |
| 27 |
# set, and at least one of them is set to zero: the last set value |
| 28 |
# should be effective and its value will be propogated to other |
| 29 |
# variable. |
| 30 |
# |
| 31 |
# R2.4. Both expire-logs-days and binlog-expire-logs-seconds are |
| 32 |
# set, and both are non-zero: the last set value |
| 33 |
# should be effective and its value will be propogated to other |
| 34 |
# variable. |
| 35 |
# |
| 36 |
# ==== Implementation ==== |
| 37 |
# |
| 38 |
# Test all combinations of: |
| 39 |
# |
| 40 |
# - log-bin: on, off |
| 41 |
# - expire-logs-days: not set, set to 0, set to nonzero |
| 42 |
# - binlog-expire-logs-seconds: not set, set to 0, set to nonzero |
| 43 |
# - Verify option value propogation, by varying the order, in which options |
| 44 |
# are set |
| 45 |
# --expire_logs_days --binlog_expire_logs_seconds |
| 46 |
# --binlog_expire_logs_seconds --expire_logs_days |
| 47 |
# For each such scenario, state the expected warnings and values, and |
| 48 |
# use extra/binlog_tests/binlog_expire_warnings.inc to execute the |
| 49 |
# scenario. |
| 50 |
# |
| 51 |
# ==== References ==== |
| 52 |
# |
| 53 |
# MDEV-19371: Implement binlog_expire_logs_seconds for purging of binary |
| 54 |
# logs |
| 55 |
# |
| 56 |
--source include/have_binlog_format_row.inc |
| 57 |
|
| 58 |
# Restarts the server with new options. |
| 59 |
--source include/force_restart.inc |
| 60 |
|
| 61 |
# A bit slow, since it restarts the server many times. Also, this is |
| 62 |
# unlikely to break in the future, so not important to run frequently. |
| 63 |
--source include/big_test.inc |
| 64 |
|
| 65 |
|
| 66 |
--let $ofile = $MYSQLTEST_VARDIR/tmp/binlog_expire_warnings-output.err |
| 67 |
|
| 68 |
--let $i = 0 |
| 69 |
while ($i < 2) { |
| 70 |
|
| 71 |
if ($i == 0) { |
| 72 |
--echo #### Binary log ENABLED #### |
| 73 |
--let $options = |
| 74 |
--let $binlog_off = 0 |
| 75 |
} |
| 76 |
if ($i == 1) { |
| 77 |
--echo #### Binary log DISABLED #### |
| 78 |
--let $options = --skip-log-bin |
| 79 |
--let $binlog_off = 1 |
| 80 |
} |
| 81 |
|
| 82 |
--echo ==== Don't set any option ==== |
| 83 |
|
| 84 |
--let $days = |
| 85 |
--let $seconds = |
| 86 |
--let $expect_binlog_off_days_and_seconds_warning = 0 |
| 87 |
--let $expect_days = 0 |
| 88 |
--let $expect_seconds = 0 |
| 89 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 90 |
|
| 91 |
--echo ==== Set one option to zero ==== |
| 92 |
|
| 93 |
--echo ---- days=0 ---- |
| 94 |
--let $days = 0 |
| 95 |
--let $seconds = |
| 96 |
--let $expect_binlog_off_days_and_seconds_warning = 0 |
| 97 |
--let $expect_days = 0 |
| 98 |
--let $expect_seconds = 0 |
| 99 |
--let $option_invoke_order= days_then_seconds |
| 100 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 101 |
|
| 102 |
--echo ---- seconds=0 ---- |
| 103 |
--let $days = |
| 104 |
--let $seconds = 0 |
| 105 |
--let $expect_binlog_off_days_and_seconds_warning = 0 |
| 106 |
--let $expect_days = 0 |
| 107 |
--let $expect_seconds = 0 |
| 108 |
--let $option_invoke_order= seconds_then_days |
| 109 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 110 |
|
| 111 |
--echo ==== Set one option to non-zero ==== |
| 112 |
|
| 113 |
--echo ---- days=2 ---- |
| 114 |
--let $days = 2 |
| 115 |
--let $seconds = |
| 116 |
--let $expect_binlog_off_days_and_seconds_warning = $binlog_off |
| 117 |
--let $expect_days = 2 |
| 118 |
--let $expect_seconds = `SELECT $days * 24 * 60 * 60` |
| 119 |
--let $option_invoke_order= days_then_seconds |
| 120 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 121 |
|
| 122 |
--echo ---- seconds=86400 ---- |
| 123 |
--let $days = |
| 124 |
--let $seconds = 86400 |
| 125 |
--let $expect_binlog_off_days_and_seconds_warning = $binlog_off |
| 126 |
--let $expect_days = 1 |
| 127 |
--let $expect_seconds = 86400 |
| 128 |
--let $option_invoke_order= days_then_seconds |
| 129 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 130 |
|
| 131 |
--echo ==== Set both options to zero ==== |
| 132 |
|
| 133 |
--let $days = 0 |
| 134 |
--let $seconds = 0 |
| 135 |
--let $expect_binlog_off_days_and_seconds_warning = 0 |
| 136 |
--let $expect_days = 0 |
| 137 |
--let $expect_seconds = 0 |
| 138 |
--let $option_invoke_order= days_then_seconds |
| 139 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 140 |
|
| 141 |
--echo ==== Set both options: one to zero and one to non-zero ==== |
| 142 |
--echo ---- days=1 seconds=0 ---- |
| 143 |
--echo ---- The later seconds=0 will override days. |
| 144 |
--let $days = 1 |
| 145 |
--let $seconds = 0 |
| 146 |
--let $expect_binlog_off_days_and_seconds_warning = 0 |
| 147 |
--let $expect_days = 0 |
| 148 |
--let $expect_seconds = 0 |
| 149 |
--let $option_invoke_order= days_then_seconds |
| 150 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 151 |
|
| 152 |
--echo ---- seconds=0 days=1 ---- |
| 153 |
--echo ---- The later days=1 will override seconds. |
| 154 |
--let $days = 1 |
| 155 |
--let $seconds = 0 |
| 156 |
--let $expect_binlog_off_days_and_seconds_warning = $binlog_off |
| 157 |
--let $expect_days = 1 |
| 158 |
--let $expect_seconds = 86400 |
| 159 |
--let $option_invoke_order= seconds_then_days |
| 160 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 161 |
|
| 162 |
--echo ---- days=0 seconds=86400 ---- |
| 163 |
--echo ---- The later seconds=86400 will override days. |
| 164 |
--let $days = 0 |
| 165 |
--let $seconds = 86400 |
| 166 |
--let $expect_binlog_off_days_and_seconds_warning = $binlog_off |
| 167 |
--let $expect_days = 1 |
| 168 |
--let $expect_seconds = 86400 |
| 169 |
--let $option_invoke_order= days_then_seconds |
| 170 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 171 |
|
| 172 |
--echo ==== Set both options to non-zero ==== |
| 173 |
|
| 174 |
--echo ---- days=1 and seconds=172800 ---- |
| 175 |
--echo ---- Since binlog_expire_logs_seconds is set later expire_log_days |
| 176 |
--echo ---- becomes 2 |
| 177 |
--let $days = 1 |
| 178 |
--let $seconds = 172800 |
| 179 |
--let $expect_binlog_off_days_and_seconds_warning = $binlog_off |
| 180 |
--let $expect_days = 2 |
| 181 |
--let $expect_seconds = 172800 |
| 182 |
--let $option_invoke_order= days_then_seconds |
| 183 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 184 |
|
| 185 |
--echo ---- days=1 and seconds=172800 ---- |
| 186 |
--echo ---- Since expire_logs_days is set later binlog_expire_logs_seconds |
| 187 |
--echo ---- becomes 86400 |
| 188 |
--let $days = 1 |
| 189 |
--let $seconds = 172800 |
| 190 |
--let $expect_binlog_off_days_and_seconds_warning = $binlog_off |
| 191 |
--let $expect_days = 1 |
| 192 |
--let $expect_seconds = 86400 |
| 193 |
--let $option_invoke_order= seconds_then_days |
| 194 |
--source suite/binlog/include/binlog_expire_warnings.inc |
| 195 |
|
| 196 |
--inc $i |
| 197 |
} |
| 198 |
|
| 199 |
# cleanup |
| 200 |
--remove_file $ofile |