1# ==== Purpose ====
2#
3# Test verifies that Start binlog_dump message will report GTID position
4# requested by slave when log_warnings > 1.
5#
6# ==== Implementation ====
7#
8# Steps:
9#    0 - Have LOG_WARNINGS=2
10#    1 - On a fresh slave server which has not replicated any GTIDs execute
11#        "CHANGE MASTER TO MASTER_USE_GTID=current_pos;" command. Start the
12#        slave.
13#    2 - In Master error log verify that pattern "using_gtid(1), gtid('')" is
14#        present.
15#    3 - On slave server do STOP SLAVE and execute "CHANGE MASTER TO
16#        MASTER_USE_GTID=no;" command. Start the slave threads.
17#    4 - In Master error log verify that pattern "using_gtid(0), gtid('')" is
18#        present.
19#    5-  Execute a DDL and DML on master server. This will generated two GTIDs
20#        on the master server ('0-1-2'). Sync the slave server with master.
21#    6 - On slave do STOP SLAVE and execute "CHANGE MASTER TO
22#        MASTER_USE_GTID=slave_pos;" command. Start slave threads.
23#    7 - In Master error verify that pattern "using_gtid(1), gtid('0-1-2')" is
24#        present.
25#    8 - On Master change domain ID to 10 and execute a DML operation. It will
26#        generate a GTID 10-1-1.
27#    9 - On slave do STOP SLAVE and execute "CHANGE MASTER TO
28#        MASTER_USE_GTID=slave_pos;" command. Start slave threads.
29#    10 -In Master error verify that pattern "using_gtid(1),
30#        gtid('0-1-2,10-1-1')" is present.
31#
32# ==== References ====
33#
34# MDEV-20428: "Start binlog_dump" message doesn't indicate GTID position
35#
36
37--source include/have_binlog_format_mixed.inc
38--source include/have_innodb.inc
39--source include/master-slave.inc
40
41--connection master
42SET GLOBAL LOG_WARNINGS=2;
43
44--connection slave
45--source include/stop_slave.inc
46CHANGE MASTER TO MASTER_USE_GTID=current_pos;
47--source include/start_slave.inc
48
49--connection master
50# Check error log for correct messages.
51let $log_error_= `SELECT @@GLOBAL.log_error`;
52if(!$log_error_)
53{
54    # MySQL Server on windows is started with --console and thus
55    # does not know the location of its .err log, use default location
56    let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
57}
58--echo "Test Case 1: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(1), gtid('')"
59--let SEARCH_FILE=$log_error_
60--let SEARCH_RANGE=-50000
61--let SEARCH_PATTERN=using_gtid\(1\), gtid\(\'\'\).*
62--source include/search_pattern_in_file.inc
63
64--connection slave
65--source include/stop_slave.inc
66CHANGE MASTER TO MASTER_USE_GTID=no;
67--source include/start_slave.inc
68
69--connection master
70--echo "Test Case 2: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(0), gtid('')"
71--let SEARCH_FILE=$log_error_
72--let SEARCH_RANGE=-50000
73--let SEARCH_PATTERN=using_gtid\(0\), gtid\(\'\'\).*
74--source include/search_pattern_in_file.inc
75CREATE TABLE t (f INT) ENGINE=INNODB;
76INSERT INTO t VALUES(10);
77save_master_pos;
78
79--connection slave
80sync_with_master;
81
82--connection slave
83--source include/stop_slave.inc
84CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
85--source include/start_slave.inc
86
87--connection master
88--echo "Test Case 3: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(1), gtid('0-1-2')"
89--let SEARCH_FILE=$log_error_
90--let SEARCH_RANGE=-50000
91--let SEARCH_PATTERN=using_gtid\(1\), gtid\(\'0-1-2\'\).*
92--source include/search_pattern_in_file.inc
93SET @@SESSION.gtid_domain_id=10;
94INSERT INTO t VALUES(20);
95save_master_pos;
96
97--connection slave
98sync_with_master;
99
100--connection slave
101--source include/stop_slave.inc
102CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
103--source include/start_slave.inc
104
105--connection master
106--echo "Test Case 4: Start binlog_dump to slave_server(#), pos(master-bin.000001, ###), using_gtid(1), gtid('0-1-2,10-1-1')"
107--let SEARCH_FILE=$log_error_
108--let SEARCH_RANGE=-50000
109--let SEARCH_PATTERN=using_gtid\(1\), gtid\(\'0-1-2,10-1-1\'\).*
110--source include/search_pattern_in_file.inc
111
112--echo "===== Clean up ====="
113--connection slave
114--source include/stop_slave.inc
115CHANGE MASTER TO MASTER_USE_GTID=no;
116--source include/start_slave.inc
117
118--connection master
119DROP TABLE t;
120SET GLOBAL LOG_WARNINGS=default;
121--source include/rpl_end.inc
122