Debian Codegraph @

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

raw
1 ################################################################################
2 # Base test to verify the basic SSL options functioning and their manipulation
3 #
4 # Test:
5 # 0. The test requires two servers: M1 and M2.
6 # 1. Set ssl related global variables and do initial setup.
7 # 2. Setup the first member (M1) with a recovery user that requires SSL.
8 # 3. Add some data and bootstrap start a group on M1.
9 # 4. Try to configure SSL variables with invalid and long path (i.e 540 vs 512)
10 # max on M2. Expect errors.
11 # 5. When SSL is required, check that recovery cannot advance when it is not
12 # properly configured i.e. set SSL var to bad path and start GR on M2.
13 # Member state should become ERROR.
14 # 6. Check that when SSL is properly configured all goes fine i.e. set SSL var
15 # to correct path and start GR on M2.
16 # 7. Check the data is there on M2.
17 # 8. Clean up.
18 ################################################################################
19
20 --source include/have_group_replication_xcom_communication_stack.inc
21 --source include/big_test.inc
22 --let $group_replication_group_name= ebe0b000-f0e7-11e4-b80c-0800200c9a66
23 --source include/have_group_replication_plugin.inc
24 --let $rpl_skip_group_replication_start= 1
25 --source include/group_replication.inc
26
27 ##
28 ## Global variables and initial setup
29 ##
30
31 --let $tmpdir_name=`SELECT UUID()`
32 --let $tmpdir=$MYSQLTEST_VARDIR/tmp/$tmpdir_name
33 --let $CERTDIR_LOCATION=$tmpdir/certs
34 --let $CADIR_LOCATION=$tmpdir/certs/cacerts
35 --let $CRLDIR_LOCATION=$tmpdir/certs/crldir
36
37 --error 0, 1
38 --rmdir $CADIR_LOCATION
39 --error 0, 1
40 --rmdir $CERTDIR_LOCATION
41 --error 0, 1
42 --rmdir $CRLDIR_LOCATION
43 --error 0, 1
44 --rmdir $tmpdir
45
46 --mkdir $tmpdir
47 --mkdir $CERTDIR_LOCATION
48 --mkdir $CADIR_LOCATION
49 --mkdir $CRLDIR_LOCATION
50
51 --copy_file $MYSQL_TEST_DIR/std_data/cacert.pem $CADIR_LOCATION/cacert.pem
52 --copy_file $MYSQL_TEST_DIR/std_data/client-cert.pem $CERTDIR_LOCATION/client-cert.pem
53 --copy_file $MYSQL_TEST_DIR/std_data/client-key.pem $CERTDIR_LOCATION/client-key.pem
54 --copy_file $MYSQL_TEST_DIR/std_data/crl-client-revoked.crl $CRLDIR_LOCATION/crl-client-revoked.crl
55
56 ##
57 ## End of setup
58 ##
59
60 --echo #
61 --echo # Setup the first member with a recovery user that requires SSL
62 --echo #
63
64 --connection server1
65 --echo server1
66
67 # create a user for replication that requires ssl encryption
68 set session sql_log_bin=0;
69 CREATE USER 'rec_ssl_user'@'%' REQUIRE SSL;
70 GRANT replication slave ON *.* TO 'rec_ssl_user'@'%';
71 set session sql_log_bin=1;
72
73
74 --echo #
75 --echo # Add some data and start the first member
76 --echo #
77
78 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
79 INSERT INTO t1 VALUES (1);
80
81 --source include/start_and_bootstrap_group_replication.inc
82
83 --echo #
84 --echo # Verify that we cannot set invalid and really long paths in the SSL options
85 --echo #
86
87 --connection server2
88 --echo server2
89
90 --let $conf_rec_retries= `SELECT @@GLOBAL.group_replication_recovery_retry_count;`
91 --let $conf_rec_ssl_verify= `SELECT @@GLOBAL.group_replication_recovery_ssl_verify_server_cert;`
92 --let $conf_rec_use_ssl= `SELECT @@GLOBAL.group_replication_recovery_use_ssl;`
93
94 --let $conf_rec_ssl_ca= `SELECT @@GLOBAL.group_replication_recovery_ssl_ca;`
95 --let $conf_rec_ssl_capath= `SELECT @@GLOBAL.group_replication_recovery_ssl_capath;`
96 --let $conf_rec_ssl_cert= `SELECT @@GLOBAL.group_replication_recovery_ssl_cert;`
97 --let $conf_rec_ssl_cipher= `SELECT @@GLOBAL.group_replication_recovery_ssl_cipher;`
98 --let $conf_rec_ssl_key= `SELECT @@GLOBAL.group_replication_recovery_ssl_key;`
99
100 # Test that variables doesn't accept invalid inputs.
101 --error ER_WRONG_VALUE_FOR_VAR
102 SET GLOBAL group_replication_recovery_ssl_verify_server_cert= NULL;
103
104 --error ER_WRONG_VALUE_FOR_VAR
105 SET GLOBAL group_replication_recovery_ssl_verify_server_cert= "a";
106
107 --error ER_WRONG_TYPE_FOR_VAR
108 SET GLOBAL group_replication_recovery_ssl_verify_server_cert= 1.2;
109
110 --error ER_WRONG_VALUE_FOR_VAR
111 SET GLOBAL group_replication_recovery_use_ssl= NULL;
112
113 --error ER_WRONG_VALUE_FOR_VAR
114 SET GLOBAL group_replication_recovery_use_ssl= "a";
115
116 --error ER_WRONG_TYPE_FOR_VAR
117 SET GLOBAL group_replication_recovery_use_ssl= 1.2;
118
119 # Create a really long path (540 characters vs 512 maximum)
120 --let $long_path= long_path/long_path/long_path/long_path/long_path/long_path/
121 --let $long_path= $long_path$long_path$long_path
122 --let $recovery_invalid_SSL_PATH= $long_path$long_path$long_path
123
124 --error ER_WRONG_VALUE_FOR_VAR
125 --eval SET GLOBAL group_replication_recovery_ssl_ca= '$recovery_invalid_SSL_PATH'
126 --error ER_WRONG_VALUE_FOR_VAR
127 --eval SET GLOBAL group_replication_recovery_ssl_capath= '$recovery_invalid_SSL_PATH'
128 --error ER_WRONG_VALUE_FOR_VAR
129 --eval SET GLOBAL group_replication_recovery_ssl_cert= '$recovery_invalid_SSL_PATH'
130 --error ER_WRONG_VALUE_FOR_VAR
131 --eval SET GLOBAL group_replication_recovery_ssl_cipher= '$recovery_invalid_SSL_PATH'
132 --error ER_WRONG_VALUE_FOR_VAR
133 --eval SET GLOBAL group_replication_recovery_ssl_key= '$recovery_invalid_SSL_PATH'
134 --error ER_WRONG_VALUE_FOR_VAR
135 --eval SET GLOBAL group_replication_recovery_ssl_crl= '$recovery_invalid_SSL_PATH'
136 --error ER_WRONG_VALUE_FOR_VAR
137 --eval SET GLOBAL group_replication_recovery_ssl_crlpath= '$recovery_invalid_SSL_PATH'
138
139
140 --echo #
141 --echo # See when SSL is required that Recovery cannot advance when not properly configured
142 --echo #
143
144 set session sql_log_bin=0;
145 call mtr.add_suppression("There was an error when connecting to the donor*");
146 call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Replica I/O for channel group_replication_recovery.");
147 call mtr.add_suppression("Maximum number of retries when*");
148 call mtr.add_suppression("Fatal error during the incremental recovery process of Group Replication. The server will leave the group.");
149 call mtr.add_suppression("The member is leaving a group without being on one");
150 call mtr.add_suppression("The member is already leaving or joining a group.");
151 call mtr.add_suppression("Error leaving the group");
152 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
153 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
154 set session sql_log_bin=1;
155
156 --disable_warnings
157 CHANGE REPLICATION SOURCE TO SOURCE_USER= 'rec_ssl_user', SOURCE_PASSWORD='' FOR CHANNEL 'group_replication_recovery';
158 --enable_warnings
159
160 --eval SET GLOBAL group_replication_recovery_use_ssl=1
161 --eval SET GLOBAL group_replication_recovery_ssl_ca= '/bad_path_parameter/file'
162
163 #try once and fail
164 --eval SET GLOBAL group_replication_recovery_retry_count= 1
165 --eval SET GLOBAL group_replication_group_name= '$group_replication_group_name'
166
167 --let $group_replication_start_member_state= ERROR
168 --source include/start_group_replication.inc
169
170 #
171 # Set this back to the previous value, since it could be that
172 # on slow machines we take more than one attempt.
173 #
174 --replace_result $conf_rec_retries CONF_REC_RETRIES
175 --eval SET @@GLOBAL.group_replication_recovery_retry_count= $conf_rec_retries
176 --source include/stop_group_replication.inc
177
178 --echo #
179 --echo # See that when SSL is properly configured all goes fine
180 --echo #
181
182 SET GLOBAL group_replication_recovery_use_ssl=1;
183 SET GLOBAL group_replication_recovery_ssl_verify_server_cert=1;
184
185 --replace_result $tmpdir TMPDIR
186 --eval SET GLOBAL group_replication_recovery_ssl_ca= '$CADIR_LOCATION/cacert.pem'
187
188 --replace_result $tmpdir TMPDIR
189 --eval SET GLOBAL group_replication_recovery_ssl_capath= ''
190
191 --replace_result $tmpdir TMPDIR
192 --eval SET GLOBAL group_replication_recovery_ssl_cert= '$CERTDIR_LOCATION/client-cert.pem'
193
194 --replace_result $tmpdir TMPDIR
195 --eval SET GLOBAL group_replication_recovery_ssl_key= '$CERTDIR_LOCATION/client-key.pem'
196
197 --source include/start_group_replication.inc
198
199 # Check also that a valid cipher is accepted (not used due to portability issues)
200 --eval SET GLOBAL group_replication_recovery_ssl_cipher= 'ECDHE-RSA-AES256-GCM-SHA384'
201
202 --echo #
203 --echo # Check the data is there
204 --echo #
205
206 --source include/rpl_sync.inc
207
208 --let $assert_text= On the recovered member, the table should exist and have 1 elements;
209 --let $assert_cond= [SELECT COUNT(*) FROM t1] = 1;
210 --source include/assert.inc
211
212 --echo #
213 --echo # Clean up
214 --echo #
215
216 # No need to print this to the result file
217
218 --disable_query_log
219 --eval SET @@GLOBAL.group_replication_recovery_use_ssl= $conf_rec_use_ssl
220 --eval SET @@GLOBAL.group_replication_recovery_ssl_verify_server_cert= $conf_rec_ssl_verify
221 --eval SET @@GLOBAL.group_replication_recovery_retry_count= $conf_rec_retries
222
223 --eval SET @@GLOBAL.group_replication_recovery_ssl_ca= "$conf_rec_ssl_ca"
224 --eval SET @@GLOBAL.group_replication_recovery_ssl_capath= "$conf_rec_ssl_capath"
225 --eval SET @@GLOBAL.group_replication_recovery_ssl_cert= "$conf_rec_ssl_cert"
226 --eval SET @@GLOBAL.group_replication_recovery_ssl_cipher= "$conf_rec_ssl_cipher"
227 --eval SET @@GLOBAL.group_replication_recovery_ssl_key= "$conf_rec_ssl_key"
228 --enable_query_log
229
230 --connection server1
231 --echo server1
232
233 set session sql_log_bin=0;
234 DROP USER 'rec_ssl_user';
235 set session sql_log_bin=1;
236
237 DROP TABLE t1;
238
239 #
240 # Finally remove the temporary directory
241 #
242 --force-rmdir $tmpdir
243
244 --source include/group_replication_end.inc