Debian Codegraph @

mysql-test/suite/group_replication/t/gr_set_gtid_mode.test

raw
1 ################################################################################
2 # Validate that is not possible to change GTID_MODE to
3 # others modes except ON when Group Replication is running.
4 #
5 # Test:
6 # 0. The test requires two servers: M1 and M2.
7 # 1. With members ONLINE. On M1, validate that it is not possible to change
8 # GTID_MODE to others modes except ON when Group Replication is running.
9 # 2. Stop GR on M1 to make it OFFLINE. Then validate that it is possible to
10 # change GTID_MODE to others modes than ON when Group Replication is not
11 # running. But start group replication will fail after that.
12 # 3. Change GTID_MODE back to ON and Start GR on M1. Check that Group
13 # Replication is working fine by creating table and adding some data into it.
14 # 4. Check that GTID_EXECUTED on M1 contains all transactions. Also check that
15 # data is on tables.
16 # 5. Clean up.
17 ################################################################################
18 --source include/big_test.inc
19 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9429490
20 --source include/have_group_replication_plugin.inc
21 --source include/group_replication.inc
22
23 # Keep binary logs with only GTIDs from test.
24 --connection server1
25 SET SESSION sql_log_bin= 0;
26 --source include/gtid_utils.inc
27 SET SESSION sql_log_bin= 1;
28 --connection server2
29 SET SESSION sql_log_bin= 0;
30 --source include/gtid_utils.inc
31 SET SESSION sql_log_bin= 1;
32
33 --let $expected_gtid_set= "8a94f357-aab4-11df-86ab-c80aa9429490:1-5"
34
35
36 --echo
37 --echo ############################################################
38 --echo # 1. Validate that it is not possible to change GTID_MODE to
39 --echo # others modes except ON when Group Replication is running.
40 --connection server1
41 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
42 SET @@GLOBAL.GTID_MODE= OFF;
43
44 --let $assert_text= GTID_MODE must be ON
45 --let $assert_cond= "[SELECT @@GLOBAL.GTID_MODE]" = "ON"
46 --source include/assert.inc
47
48
49 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
50 SET @@GLOBAL.GTID_MODE= OFF_PERMISSIVE;
51
52 --let $assert_text= GTID_MODE must be ON
53 --let $assert_cond= "[SELECT @@GLOBAL.GTID_MODE]" = "ON"
54 --source include/assert.inc
55
56
57 --error ER_CANT_SET_GTID_MODE
58 SET @@GLOBAL.GTID_MODE= ON_PERMISSIVE;
59
60 --let $assert_text= GTID_MODE must be ON
61 --let $assert_cond= "[SELECT @@GLOBAL.GTID_MODE]" = "ON"
62 --source include/assert.inc
63
64
65 SET @@GLOBAL.GTID_MODE= ON;
66
67 --let $assert_text= GTID_MODE must be ON
68 --let $assert_cond= "[SELECT @@GLOBAL.GTID_MODE]" = "ON"
69 --source include/assert.inc
70
71
72 --echo
73 --echo ############################################################
74 --echo # 2. Validate that it is possible to change GTID_MODE to other
75 --echo # modes than ON when Group Replication is not running.
76 --echo # But start group replication will fail after that.
77 --source include/stop_group_replication.inc
78
79 SET @@GLOBAL.GTID_MODE= ON_PERMISSIVE;
80
81 --let $assert_text= GTID_MODE must be ON_PERMISSIVE
82 --let $assert_cond= "[SELECT @@GLOBAL.GTID_MODE]" = "ON_PERMISSIVE"
83 --source include/assert.inc
84
85 --error ER_GROUP_REPLICATION_CONFIGURATION
86 START GROUP_REPLICATION;
87
88 SET @@GLOBAL.GTID_MODE= OFF_PERMISSIVE;
89
90 --let $assert_text= GTID_MODE must be OFF_PERMISSIVE
91 --let $assert_cond= "[SELECT @@GLOBAL.GTID_MODE]" = "OFF_PERMISSIVE"
92 --source include/assert.inc
93
94 --error ER_GROUP_REPLICATION_CONFIGURATION
95 START GROUP_REPLICATION;
96
97 SET @@GLOBAL.GTID_MODE= OFF;
98 --let $assert_text= GTID_MODE must be OFF
99 --let $assert_cond= "[SELECT @@GLOBAL.GTID_MODE]" = "OFF"
100 --source include/assert.inc
101
102 --error ER_GROUP_REPLICATION_CONFIGURATION
103 START GROUP_REPLICATION;
104
105 SET SESSION sql_log_bin= 0;
106 call mtr.add_suppression("Gtid mode should be ON for Group Replication");
107 SET SESSION sql_log_bin= 1;
108
109
110 --echo
111 --echo ############################################################
112 --echo # 3. Change GTID_MODE back to ON and check that Group
113 --echo # Replication will work properly.
114 SET @@GLOBAL.GTID_MODE= OFF_PERMISSIVE;
115 SET @@GLOBAL.GTID_MODE= ON_PERMISSIVE;
116 SET @@GLOBAL.GTID_MODE= ON;
117
118 --source include/start_group_replication.inc
119
120 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
121 INSERT INTO t1 VALUES (1);
122
123 --source include/rpl_sync.inc
124
125
126 --echo
127 --echo ############################################################
128 --echo # 4. Check that GTID_EXECUTED on server 1 contains all
129 --echo # transactions.
130 --echo # Also check that data is on tables.
131 --connection server1
132 --let $assert_text= GTID_EXECUTED must contain all committed GTIDs
133 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, $expected_gtid_set)
134 --source include/assert.inc
135
136 --let $assert_text= 'There is a value 1 in table t1'
137 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
138 --source include/assert.inc
139
140 --connection server2
141 --let $assert_text= GTID_EXECUTED must contain all committed GTIDs
142 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, $expected_gtid_set)
143 --source include/assert.inc
144
145 --let $assert_text= 'There is a value 1 in table t1'
146 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
147 --source include/assert.inc
148
149
150 --echo
151 --echo ############################################################
152 --echo # 5. Clean up.
153 DROP TABLE t1;
154
155 --connection server1
156 SET SESSION sql_log_bin= 0;
157 --source include/gtid_utils_end.inc
158 SET SESSION sql_log_bin= 1;
159 --connection server2
160 SET SESSION sql_log_bin= 0;
161 --source include/gtid_utils_end.inc
162 SET SESSION sql_log_bin= 1;
163
164 --source include/group_replication_end.inc