Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # This server proves that if correctly configured we can clone a
4 # a group replication member and its recovery settings for privilege
5 # checks users and require row format are preserved.
6 #
7 # ==== Implementation ====
8 #
9 # 0. The test requires two servers: M1 and M2 with group replication and clone
10 # 1. Install clone plugin on server1.
11 # 2. Set a privileged user for server 1 GR recovery channel
12 # 3. Bootstrap server1 and add some data
13 # 4. Restart server 2 with a monitoring process (mysqld_safe) if needed
14 # 5. Setup the server so group replication starts on boot
15 # Install the Clone plugin
16 # 6. On a empty server2 start group replication
17 # Wait for it to restart and come back
18 # Check clone was completed
19 # 7. Check that the recovery privileged user was preserved
20 # 8. Cleanup
21 #
22 # ==== References ====
23 #
24 # Bug#29995256: PRIVILEGE_CHECKS_USER NOT CLONED FOR RECOVERY CHANNEL
25 #
26
27 --source include/big_test.inc
28 --source include/have_mysqld_monitoring_process.inc
29 --source include/have_clone_plugin.inc
30 --source include/have_group_replication_plugin.inc
31 --let $rpl_skip_group_replication_start= 1
32 --source include/group_replication.inc
33
34 --echo #
35 --echo # 1. Install clone plugin on server1.
36
37 --let $rpl_connection_name= server1
38 --source include/rpl_connection.inc
39
40 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
41 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
42
43 --echo #
44 --echo # 2. Set a privileged user for server 1 GR recovery channel
45
46 CREATE USER 'u1'@'localhost';
47 GRANT SESSION_VARIABLES_ADMIN, REPLICATION_APPLIER ON *.* TO 'u1'@'localhost';
48 GRANT CREATE,INSERT ON *.* TO 'u1'@'localhost';
49
50 CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = 'u1'@'localhost' FOR CHANNEL 'group_replication_recovery';
51
52 --echo #
53 --echo # 3. Bootstrap server1 and add some data
54
55 --source include/start_and_bootstrap_group_replication.inc
56
57 CREATE DATABASE db1;
58 CREATE TABLE db1.t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
59 INSERT INTO db1.t1 VALUES (1);
60
61 --echo #
62 --echo # 4. Restart server 2 with a monitoring process (mysqld_safe) if needed
63
64 --let $rpl_connection_name= server2
65 --source include/rpl_connection.inc
66
67 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
68 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
69 --let $_group_replication_start_boot_save= `SELECT @@GLOBAL.group_replication_start_on_boot`
70 --let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack`
71
72 --let $plugin_list= $GROUP_REPLICATION
73 --source include/spawn_monitoring_process.inc
74
75 --echo #
76 --echo # 5. Setup the server so group replication starts on boot
77 --echo # Install the Clone plugin
78
79 --disable_query_log
80 --eval SET PERSIST group_replication_group_name= "$group_replication_group_name"
81 --eval SET PERSIST group_replication_local_address= "$_group_replication_local_address"
82 --eval SET PERSIST group_replication_group_seeds= "$_group_replication_group_seeds"
83 --eval SET PERSIST group_replication_communication_stack= "$_group_replication_comm_stack"
84
85 SET PERSIST group_replication_start_on_boot= ON;
86 --enable_query_log
87
88 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
89 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
90
91 --echo #
92 --echo # 6. On a empty server2 start group replication
93 --echo # Wait for it to restart and come back
94 --echo # Check clone was completed
95
96 --let $_group_replication_threshold_save= `SELECT @@GLOBAL.group_replication_clone_threshold`
97 SET GLOBAL group_replication_clone_threshold= 1;
98
99 START GROUP_REPLICATION;
100
101 --source include/wait_until_disconnected.inc
102
103 --let $rpl_server_number= 2
104 --source include/rpl_reconnect.inc
105
106 --let $group_replication_member_state=ONLINE
107 --source include/gr_wait_for_member_state.inc
108
109 --let $assert_text= Clone must be completed
110 --let $assert_cond= [SELECT state="Completed" FROM performance_schema.clone_status] = 1;
111 --source include/assert.inc
112
113 # See if the data has been properly cloned in server2
114 --let $diff_tables=server1:db1.t1,server2:db1.t1
115 --source include/diff_tables.inc
116
117 --echo #
118 --echo # 7. Check that the recovery privileged user was preserved
119
120 --let $rpl_connection_name= server1
121 --source include/rpl_connection.inc
122
123 --let $slave_rl_info_count = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_recovery" AND Privilege_checks_username = "u1" AND Privilege_checks_hostname="localhost" AND Require_row_format=1`
124 --let $assert_text= Credentials on server 1 are preserved
125 --let $assert_cond= $slave_rl_info_count = 1
126 --source include/assert.inc
127
128 --let $rpl_connection_name= server2
129 --source include/rpl_connection.inc
130
131 --let $slave_rl_info_count = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_recovery" AND Privilege_checks_username = "u1" AND Privilege_checks_hostname="localhost" AND Require_row_format=1`
132 --let $assert_text= Credentials on server 2 were proprely cloned
133 --let $assert_cond= $slave_rl_info_count = 1
134 --source include/assert.inc
135
136 --let $perf_schema_count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE channel_name= "group_replication_recovery" AND privilege_checks_user = "'u1'@'localhost'" AND require_row_format=1`
137 --let $assert_text= Performance schema values on server 2 are correct
138 --let $assert_cond= $perf_schema_count = 1
139 --source include/assert.inc
140
141 --echo #
142 --echo # 8. Cleanup
143
144 --eval SET GLOBAL group_replication_clone_threshold= $_group_replication_threshold_save
145
146 RESET PERSIST IF EXISTS group_replication_group_name;
147 RESET PERSIST IF EXISTS group_replication_local_address;
148 RESET PERSIST IF EXISTS group_replication_group_seeds;
149 RESET PERSIST IF EXISTS group_replication_start_on_boot;
150 RESET PERSIST IF EXISTS group_replication_communication_stack;
151
152 DROP TABLE db1.t1;
153 DROP DATABASE db1;
154
155 --source include/rpl_sync.inc
156
157 --let $rpl_connection_name= server1
158 --source include/rpl_connection.inc
159
160 CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = NULL FOR CHANNEL 'group_replication_recovery';
161
162 --let $rpl_connection_name= server2
163 --source include/rpl_connection.inc
164
165 CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = NULL FOR CHANNEL 'group_replication_recovery';
166
167 --let $rpl_connection_name= server1
168 --source include/rpl_connection.inc
169
170 DROP USER u1@localhost;
171
172 UNINSTALL PLUGIN clone;
173
174 --let $rpl_connection_name= server2
175 --source include/rpl_connection.inc
176
177 UNINSTALL PLUGIN clone;
178
179 set session sql_log_bin=0;
180 call mtr.add_suppression("This member will start distributed recovery using clone. It is due to the number of missing transactions being higher than the configured threshold of*");
181 call mtr.add_suppression("Clone removing all user data for provisioning: Started");
182 call mtr.add_suppression("Clone removing all user data for provisioning: Finished");
183 set session sql_log_bin=1;
184
185 --source include/clean_monitoring_process.inc
186
187 --replace_result $_group_replication_start_boot_save START_ON_BOOT_VALUE
188 --eval SET GLOBAL group_replication_start_on_boot= $_group_replication_start_boot_save
189
190 --source include/group_replication_end.inc