Debian Codegraph @

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

raw
1 ################################################################################
2 # This test verifies that recovery SSL connection options work properly when the
3 # server restarts.
4 # Placing the connection credentials in server1 options file, and setting the
5 # start on boot option to 1, when the server is restarted we verify that group
6 # replication is running fine and recovery was successful.
7 #
8 # Test:
9 # 0. The test requires two servers: M1 and M2.
10 # Set group name and ssl options in opt file.
11 # 1. Restart member M1 with group_replication_start_on_boot=ON.
12 # 2. Stop GR on M1.
13 # 3. Create a replication user that requires SSL then bootstrap start GR on M2.
14 # 4. Add some data for recovery on M2.
15 # 5. Configure M1 to use replication user on recovery. Restart server M1. Group
16 # replication should start on boot and come ONLINE.
17 # 6. On M1 check that recovery is successful. Check all is fine.
18 # 7. Clean up.
19 ################################################################################
20
21 --source include/big_test.inc
22 --let $group_replication_group_name= 7e8daba0-e793-11e4-b571-0800200c9a66
23 --source include/have_group_replication_plugin.inc
24 --source include/force_restart.inc
25
26 # We need to restart server 1 to simulate start_on_boot option since
27 # on MTR it is impossible to compute ports on configuration files.
28 --connection server1
29 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
30 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
31 --let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_bootstrap_group=1 --group_replication_start_on_boot=1
32 --replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
33 --source include/restart_mysqld.inc
34
35 --connection server2
36 #Connection options (Update the options file if changed)
37 --let $recovery_user= rec_ssl_user
38
39 --echo #
40 --echo # On server 1 stop group replication that started at boot
41 --echo #
42
43 --connection server1
44 --source include/stop_group_replication.inc
45
46 --echo #
47 --echo # On server 2 before start, create a replication user that requires SSL
48 --echo #
49
50 --connection server2
51
52 # create a user for replication that requires ssl encryption
53 set session sql_log_bin=0;
54 CREATE USER 'rec_ssl_user'@'%' REQUIRE SSL;
55 GRANT replication slave ON *.* TO 'rec_ssl_user'@'%';
56 GRANT GROUP_REPLICATION_STREAM ON *.* TO 'rec_ssl_user'@'%';
57 FLUSH PRIVILEGES;
58 set session sql_log_bin=1;
59
60 --let $conf_rec_ssl_mode_s2= `SELECT @@GLOBAL.group_replication_ssl_mode;`
61 --eval SET GLOBAL group_replication_ssl_mode= REQUIRED
62
63 --echo #
64 --echo # Start the member and add some data
65 --echo #
66
67 --source include/start_and_bootstrap_group_replication.inc
68
69 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
70 INSERT INTO t1 VALUES (1);
71
72 --echo #
73 --echo # On server 1 restart the server. Group replication should start at boot
74 --echo #
75
76 --connection server1
77
78 set session sql_log_bin=0;
79 CREATE USER 'rec_ssl_user'@'%' REQUIRE SSL;
80 GRANT replication slave ON *.* TO 'rec_ssl_user'@'%';
81 GRANT GROUP_REPLICATION_STREAM ON *.* TO 'rec_ssl_user'@'%';
82 FLUSH PRIVILEGES;
83 set session sql_log_bin=1;
84
85 --let $conf_rec_ssl_mode_s1= `SELECT @@GLOBAL.group_replication_ssl_mode;`
86 --eval SET GLOBAL group_replication_ssl_mode= REQUIRED
87
88 --disable_warnings
89 CHANGE REPLICATION SOURCE TO SOURCE_USER= 'rec_ssl_user' FOR CHANNEL 'group_replication_recovery';
90 --enable_warnings
91
92 --let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_start_on_boot=1 --group_replication_ssl_mode=REQUIRED
93 --replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
94 --source include/restart_mysqld.inc
95
96 --let $group_replication_member_state= ONLINE
97 --source include/gr_wait_for_member_state.inc
98
99 --echo #
100 --echo # On server 1 after restart, recovery should be successful
101 --echo #
102
103 --let $assert_text= On the recovered member, the table should exist and have 1 elements;
104 --let $assert_cond= [select count(*) from t1] = 1;
105 --source include/assert.inc
106
107 INSERT INTO t1 VALUES (2);
108
109 --connection server2
110
111 --let $wait_condition= SELECT count(*)=2 FROM t1;
112 --source include/wait_condition.inc
113
114 --echo #
115 --echo # Cleanup
116 --echo #
117
118 --connection server1
119
120 DROP TABLE t1;
121
122 --connection server2
123
124 --let $wait_condition= SELECT count(*)=0 FROM information_schema.tables WHERE table_name = "t1";
125 --source include/wait_condition.inc
126
127 set session sql_log_bin=0;
128 DROP USER 'rec_ssl_user';
129 set session sql_log_bin=1;
130
131 --source include/stop_group_replication.inc
132
133 --disable_query_log
134 --eval SET GLOBAL group_replication_ssl_mode= $conf_rec_ssl_mode_s2
135 --enable_query_log
136
137 RESET SLAVE ALL FOR CHANNEL "group_replication_applier";
138 RESET MASTER;
139
140 --connection server1
141
142 --source include/stop_group_replication.inc
143
144 --disable_query_log
145 --eval SET GLOBAL group_replication_ssl_mode= $conf_rec_ssl_mode_s1
146 --enable_query_log
147
148 RESET SLAVE ALL FOR CHANNEL "group_replication_applier";
149 RESET MASTER;
150
151 --let $rpl_connection_name= server1
152 --source include/rpl_connection.inc
153
154 SET SESSION sql_log_bin=0;
155 DROP USER 'rec_ssl_user';
156 SET SESSION sql_log_bin=1;
157
158 --source include/gr_clear_configuration.inc