| 1 |
# |
| 2 |
# Purpose: |
| 3 |
# |
| 4 |
# This test ensures that the mariadb-binlog CLI tool can filter log events |
| 5 |
# using GTID ranges. More specifically, this test ensures the following |
| 6 |
# capabilities: |
| 7 |
# 1) GTIDs can be used to filter results on local binlog files |
| 8 |
# 2) GTIDs can be used to filter results from remote servers |
| 9 |
# 3) For a given GTID range, its start-position is exclusive and its |
| 10 |
# stop-position is inclusive. This allows users to receive events strictly |
| 11 |
# after what they already have. |
| 12 |
# 4) After the events have been written, the session server id and domain id |
| 13 |
# are reset to their former values |
| 14 |
# |
| 15 |
# |
| 16 |
# Methodology: |
| 17 |
# |
| 18 |
# This test validates the expected capabilities using the following test cases |
| 19 |
# on both a local binlog file and remote server for all binlog formats. |
| 20 |
# Test Case 1) The end of the binlog file resets the server and domain id of |
| 21 |
# the session |
| 22 |
# Test Case 2) Single GTID range specified |
| 23 |
# Test Case 3) Single GTID range with different server_ids |
| 24 |
# Test Case 4) Multiple GTID ranges specified |
| 25 |
# Test Case 5) Multiple GTID ranges specified where the domain ids are |
| 26 |
# listed in different orders between start/stop position |
| 27 |
# Test Case 6) Only start position specified |
| 28 |
# Test Case 7) Only stop position specified |
| 29 |
# Test Case 8) Seq_no=0 in --start-position includes all events for a domain |
| 30 |
# Test Case 9) Seq_no=0 in --stop-position excludes all events for a domain |
| 31 |
# Test Case 10) Output stops for all domain ids when all --stop-position GTID |
| 32 |
# values have been hit. |
| 33 |
# Test Case 11) All GTID events from other domains are printed until |
| 34 |
# the --stop-position values are hit |
| 35 |
# Test Case 12) Scalar and GTID values can be used together for stop or start |
| 36 |
# position |
| 37 |
# Test Case 13) If the start position is delayed within the binlog, events |
| 38 |
# occurring before that position are ignored |
| 39 |
# Test Case 14) If start position is repeated, the last specification |
| 40 |
# overrides all previous ones |
| 41 |
# Test Case 15) If stop position is repeated, the last specification |
| 42 |
# overrides all previous ones |
| 43 |
# Test Case 16) Start position with --offset=<n> skips n events after the |
| 44 |
# first GTID is found |
| 45 |
# Test Case 17) Start position with --start-datetime=<T> where T occurs |
| 46 |
# after the specified GTID results in no events before T |
| 47 |
# Test Case 18) If --stop-position is specified, domains which are not present |
| 48 |
# in its list should be excluded from output |
| 49 |
# Test Case 19) If the start and stop GTIDs in any domain are equal, the |
| 50 |
# domain should not have any output |
| 51 |
# Test Case 20) If --start-position and --stop-position have different domain |
| 52 |
# ids, only events from GTIDs in the --stop-position list are |
| 53 |
# output |
| 54 |
# Test Case 21) Successive binary logs (e.g. logs with previous logs that |
| 55 |
# have been purged) will write events when the --start-position |
| 56 |
# matches their Gtid_list_log_event state |
| 57 |
# Test Case 22) Successive binary logs can be called with --stop-position and |
| 58 |
# without --start-position |
| 59 |
# |
| 60 |
# To validate for data consistency, each test case compares a checksum of |
| 61 |
# correct data against a variant created after replaying the binlog using |
| 62 |
# --(start|stop)-position. If the checksums are identical, the test passes. |
| 63 |
# If the checksums differ, data has been changed and the test fails. |
| 64 |
# |
| 65 |
# Additionally, this test validates the following error scenarios: |
| 66 |
# Error Case 1) A GTID --start-position that does not mention all domains |
| 67 |
# that make up the binary log state should error |
| 68 |
# Error Case 2) A GTID --start-position with any sequence numbers which |
| 69 |
# occur before the binary log state should result in error |
| 70 |
# Error Case 3) A GTID --start-position with any sequence numbers that are not |
| 71 |
# eventually processed results in error |
| 72 |
# Error Case 4) User provides invalid positions |
| 73 |
# Error Case 5) User provides GTID ranges with repeated domain ids |
| 74 |
# |
| 75 |
# References: |
| 76 |
# MDEV-4989: Support for GTID in mysqlbinlog |
| 77 |
# |
| 78 |
|
| 79 |
--source include/have_log_bin.inc |
| 80 |
|
| 81 |
--echo ############################### |
| 82 |
--echo # Test Setup |
| 83 |
--echo ############################### |
| 84 |
|
| 85 |
## Save old state |
| 86 |
# |
| 87 |
let orig_gtid_domain_id = `select @@session.gtid_domain_id`; |
| 88 |
let orig_server_id = `select @@session.server_id`; |
| 89 |
RESET MASTER; |
| 90 |
|
| 91 |
|
| 92 |
--echo ###################################### |
| 93 |
--echo # Test Group 1 |
| 94 |
--echo # Run test cases on local log file |
| 95 |
--echo ###################################### |
| 96 |
--let is_remote= 0 |
| 97 |
--source include/mysqlbinlog_gtid_window_test_cases.inc |
| 98 |
|
| 99 |
--echo ###################################### |
| 100 |
--echo # Test Group 2 |
| 101 |
--echo # Run test cases on remote host |
| 102 |
--echo ###################################### |
| 103 |
--let is_remote= 1 |
| 104 |
--source include/mysqlbinlog_gtid_window_test_cases.inc |
| 105 |
|
| 106 |
# Note that error cases 1-3 are in mysqlbinlog_gtid_window_test_cases.inc |
| 107 |
# because we validate for error consistency of GTID state between |
| 108 |
# mariadb-binlog working on local files and receiving errors from a server |
| 109 |
|
| 110 |
--let err_out_= $MYSQLTEST_VARDIR/tmp/err.out |
| 111 |
--let tmp_out_= $MYSQLTEST_VARDIR/tmp/std.out |
| 112 |
|
| 113 |
--let $MYSQLD_DATADIR=`select @@datadir` |
| 114 |
--echo # |
| 115 |
--echo # Error Case 4: |
| 116 |
--echo # User provides invalid positions |
| 117 |
--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=z |
| 118 |
--error 1 |
| 119 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=z |
| 120 |
|
| 121 |
--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1- |
| 122 |
--error 1 |
| 123 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1- |
| 124 |
|
| 125 |
--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2 |
| 126 |
--error 1 |
| 127 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1-2 |
| 128 |
|
| 129 |
--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2- |
| 130 |
--error 1 |
| 131 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=1-2- |
| 132 |
|
| 133 |
--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=-1 |
| 134 |
--error 1 |
| 135 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=-1 |
| 136 |
|
| 137 |
--echo # |
| 138 |
--echo # Error Case 5: |
| 139 |
--echo # User provides GTID ranges with repeated domain ids |
| 140 |
--echo # MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12 |
| 141 |
--error 1 |
| 142 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12 |
| 143 |
|
| 144 |
|
| 145 |
--echo ############################## |
| 146 |
--echo # Cleanup |
| 147 |
--echo ############################## |
| 148 |
--eval SET @@global.gtid_domain_id= $orig_gtid_domain_id |
| 149 |
--eval SET @@global.server_id= $orig_server_id |
| 150 |
|
| 151 |
--echo # End of the tests |