| 1 |
# |
| 2 |
# WL#9236: Add a new variable binlog_expire_logs_seconds |
| 3 |
# |
| 4 |
# ==== Purpose ==== |
| 5 |
# The test case test the following: |
| 6 |
# |
| 7 |
# 1. If binlog_expire_logs_seconds = 0 and expire_logs_days = 0, no purge happens. |
| 8 |
# |
| 9 |
# 2. In all the below listed cases it purges the binary logs older than the timeout |
| 10 |
# and keeps the binary logs newer than the timeout. |
| 11 |
# |
| 12 |
# 2.1. binlog_expire_logs_seconds > 0 and expire_logs_days > 0 |
| 13 |
# 2.2. binlog_expire_logs_seconds > 0 and expire_logs_days = 0 |
| 14 |
# 2.3. binlog_expire_logs_seconds = 0 and expire_logs_days > 0 |
| 15 |
# 2.4. binlog_expire_logs_seconds = 1, testing smallest value |
| 16 |
# 2.5. binlog_expire_logs_seconds = 8553600, testing max value 99days |
| 17 |
# |
| 18 |
# Additional tests for the boundaries of expire_logs_days already |
| 19 |
# exist on the sys_vars.expire_logs_days_basic test case. |
| 20 |
|
| 21 |
# Test in this file is binlog format agnostic, thus no need |
| 22 |
# to rerun it for every format. |
| 23 |
--source include/have_binlog_format_row.inc |
| 24 |
--source include/not_windows.inc |
| 25 |
|
| 26 |
--let $saved_expire_logs_days= `SELECT @@GLOBAL.expire_logs_days` |
| 27 |
--let $saved_binlog_expire_logs_seconds= `SELECT @@GLOBAL.binlog_expire_logs_seconds` |
| 28 |
# Set the datadir |
| 29 |
--let $MYSQLD_DATADIR= `SELECT @@datadir` |
| 30 |
|
| 31 |
--echo #### |
| 32 |
--echo #### 1. When binlog_expire_logs_seconds == 0 and expire_logs_days == 0 |
| 33 |
--echo #### no purge should happen |
| 34 |
|
| 35 |
SET GLOBAL binlog_expire_logs_seconds= 0; |
| 36 |
SET GLOBAL expire_logs_days= 0; |
| 37 |
|
| 38 |
# This will test the expire period for three scenarios, described in the .inc file. |
| 39 |
--source suite/binlog/include/binlog_expire_logs_seconds.inc |
| 40 |
|
| 41 |
--echo #### |
| 42 |
--echo #### 2.1: binlog_expire_logs_seconds > 0 and expire_logs_days > 0 |
| 43 |
--echo #### expire_logs_days=1.5 and binlog_expire_logs_seconds=86400 |
| 44 |
--echo #### Since binlog_expire_logs_seconds is set later |
| 45 |
--echo #### expire_logs_days value will be overridden should be |
| 46 |
--echo #### '0.000347222' |
| 47 |
--echo #### |
| 48 |
|
| 49 |
# Here we will test both with smaller values and larger values |
| 50 |
|
| 51 |
--echo Testing with smaller values of binlog_expire_logs_seconds |
| 52 |
|
| 53 |
SET GLOBAL expire_logs_days= 1.5; |
| 54 |
SET GLOBAL binlog_expire_logs_seconds= 30 ; |
| 55 |
SELECT @@expire_logs_days as 'Expected_0.000347222'; |
| 56 |
SELECT @@binlog_expire_logs_seconds as Expected_30; |
| 57 |
|
| 58 |
--let $expire_logs_seconds= `SELECT @@global.binlog_expire_logs_seconds` |
| 59 |
|
| 60 |
--let $first_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 61 |
FLUSH LOGS; |
| 62 |
|
| 63 |
--sleep $expire_logs_seconds |
| 64 |
|
| 65 |
--let $second_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 66 |
FLUSH LOGS; |
| 67 |
|
| 68 |
# The sleep is in two parts to ensure a time gap between first_binlog_file |
| 69 |
# and second_binlog_file, by doing that we can check that one is purged and |
| 70 |
# another isn't. |
| 71 |
# sleep for n seconds here, n < $expire_logs_seconds |
| 72 |
--sleep 3 |
| 73 |
FLUSH LOGS; |
| 74 |
|
| 75 |
--error 1 |
| 76 |
--file_exists $MYSQLD_DATADIR/$first_binlog_file |
| 77 |
|
| 78 |
--file_exists $MYSQLD_DATADIR/$second_binlog_file |
| 79 |
|
| 80 |
RESET MASTER; |
| 81 |
--echo #### |
| 82 |
--echo #### 2.2: binlog_expire_logs_seconds = 43200 and expire_logs_days = 0 |
| 83 |
--echo #### |
| 84 |
|
| 85 |
SET GLOBAL expire_logs_days=0; |
| 86 |
SET GLOBAL binlog_expire_logs_seconds=43200; |
| 87 |
SELECT @@expire_logs_days as 'Expected_0.5'; |
| 88 |
SELECT @@binlog_expire_logs_seconds as Expected_43200; |
| 89 |
|
| 90 |
# This will test the expire period for three scenarios, described in the .inc file. |
| 91 |
|
| 92 |
--source suite/binlog/include/binlog_expire_logs_seconds.inc |
| 93 |
|
| 94 |
--echo #### |
| 95 |
--echo #### 2.3: binlog_expire_logs_seconds == 0 and expire_logs_days > 0 |
| 96 |
--echo #### |
| 97 |
|
| 98 |
SET GLOBAL binlog_expire_logs_seconds= 0; |
| 99 |
SET GLOBAL expire_logs_days= 1; |
| 100 |
SELECT @@expire_logs_days as Expected_1; |
| 101 |
SELECT @@binlog_expire_logs_seconds as Expected_86400; |
| 102 |
|
| 103 |
# This will test the expire period for three scenarios, described in the .inc file. |
| 104 |
--source suite/binlog/include/binlog_expire_logs_seconds.inc |
| 105 |
|
| 106 |
--echo #### |
| 107 |
--echo #### 2.4: binlog_expire_logs_seconds = 1 |
| 108 |
--echo #### |
| 109 |
SET GLOBAL binlog_expire_logs_seconds= 1; |
| 110 |
SELECT @@expire_logs_days; |
| 111 |
SELECT @@binlog_expire_logs_seconds as Expected_1; |
| 112 |
|
| 113 |
--echo #### |
| 114 |
--echo #### 2.5. binlog_expire_logs_seconds = 8553600, testing max value 99days |
| 115 |
--echo #### |
| 116 |
SET GLOBAL binlog_expire_logs_seconds= 8553600; |
| 117 |
SELECT @@expire_logs_days; |
| 118 |
SELECT @@binlog_expire_logs_seconds as Expected_8553600; |
| 119 |
|
| 120 |
# reset the variables |
| 121 |
--eval SET GLOBAL binlog_expire_logs_seconds= $saved_binlog_expire_logs_seconds |
| 122 |
--eval SET GLOBAL expire_logs_days= $saved_expire_logs_days |