mariadb/mysql-test/suite/binlog/t/binlog_expire_warnings.test
2021-05-10 09:36:40 +05:30

200 lines
6.4 KiB
Text

# ==== 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