Debian Codegraph @

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

raw
1 ################################################################################
2 # Base test to verify the basic TLS 1.3 support on Group Replication.
3 #
4 # Test:
5 # 0. The test requires two servers: M1 and M2.
6 # 1. Setup the first member (M1) with a recovery user that requires TLS 1.3.
7 # 2. Add some data and bootstrap start a group on M1.
8 # 3. Configure joining member (M2) to use SSL options on recovery. Start GR on
9 # M2. Check the data is there.
10 # 4. Clean up.
11 ################################################################################
12
13 --source include/have_tlsv13.inc
14 --source include/have_group_replication_plugin.inc
15 --let $rpl_skip_group_replication_start= 1
16 --source include/group_replication.inc
17
18 --echo #
19 --echo # Setup the first member with a recovery user that requires TLS 1.3
20 --echo #
21 --let $rpl_connection_name= server1
22 --source include/rpl_connection.inc
23
24 # create a user for replication that requires ssl encryption
25 SET SESSION sql_log_bin=0;
26 CREATE USER 'rec_ssl_user'@'%' REQUIRE SSL;
27 GRANT replication slave ON *.* TO 'rec_ssl_user'@'%';
28 GRANT GROUP_REPLICATION_STREAM ON *.* TO 'rec_ssl_user'@'%';
29 FLUSH PRIVILEGES;
30 SET SESSION sql_log_bin=1;
31
32 SET @tls_version_saved= @@GLOBAL.tls_version;
33 SET GLOBAL tls_version='TLSv1.3';
34
35 SET @conf_rec_ssl_mode= @@GLOBAL.group_replication_ssl_mode;
36 SET GLOBAL group_replication_ssl_mode= REQUIRED;
37
38 ALTER INSTANCE RELOAD TLS;
39
40 --echo #
41 --echo # Add some data and start the member
42 --echo #
43
44 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
45 INSERT INTO t1 VALUES (1);
46
47 --source include/start_and_bootstrap_group_replication.inc
48
49 --echo #
50 --echo # Configure a joining member to use SSL options on recovery and start it
51 --echo #
52 --let $rpl_connection_name= server2
53 --source include/rpl_connection.inc
54
55 SET SESSION sql_log_bin=0;
56 CREATE USER 'rec_ssl_user'@'%' REQUIRE SSL;
57 GRANT replication slave ON *.* TO 'rec_ssl_user'@'%';
58 GRANT GROUP_REPLICATION_STREAM ON *.* TO 'rec_ssl_user'@'%';
59 FLUSH PRIVILEGES;
60 SET SESSION sql_log_bin=1;
61
62 --disable_warnings
63 CHANGE REPLICATION SOURCE TO SOURCE_USER="rec_ssl_user" FOR CHANNEL "group_replication_recovery";
64 --enable_warnings
65
66 SET @group_replication_recovery_use_ssl_saved= @@GLOBAL.group_replication_recovery_use_ssl;
67 SET GLOBAL group_replication_recovery_use_ssl=1;
68
69 SET @conf_rec_ssl_mode= @@GLOBAL.group_replication_ssl_mode;
70 SET GLOBAL group_replication_ssl_mode= REQUIRED;
71
72 --source include/start_group_replication.inc
73
74 --echo #
75 --echo # Check the data is there
76 --echo #
77
78 --let $assert_text= On the recovered member, the table should exist and have 1 elements;
79 --let $assert_cond= [select count(*) from t1] = 1;
80 --source include/assert.inc
81
82 --echo #
83 --echo # Clean up
84 --echo #
85
86 SET @@GLOBAL.group_replication_recovery_use_ssl= @group_replication_recovery_use_ssl_saved;
87
88 --let $rpl_connection_name= server1
89 --source include/rpl_connection.inc
90
91 SET @@GLOBAL.tls_version= @tls_version_saved;
92
93 SET @@GLOBAL.group_replication_ssl_mode= @conf_rec_ssl_mode;
94 ALTER INSTANCE RELOAD TLS;
95
96 SET SESSION sql_log_bin=0;
97 DROP USER 'rec_ssl_user';
98 SET SESSION sql_log_bin=1;
99
100 DROP TABLE t1;
101
102 --let $rpl_connection_name= server2
103 --source include/rpl_connection.inc
104
105 SET SESSION sql_log_bin=0;
106 DROP USER 'rec_ssl_user';
107 SET SESSION sql_log_bin=1;
108
109 SET @@GLOBAL.group_replication_ssl_mode= @conf_rec_ssl_mode;
110 ALTER INSTANCE RELOAD TLS;
111
112 --source include/group_replication_end.inc