Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that the replication asynchronous connection failover feature cannot
3 # be enabled when a replication channel is already running.
4 #
5 # Test:
6 # 0. The test requires 4 servers:
7 # server1: group primary
8 # server2: group secondary
9 # server3: group secondary
10 # server4: replica server
11 # 1. Deploy a 3 members group in single primary mode.
12 # 2. Create and start a replication channel.
13 # 3. Configure replica to manage the asynchronous connection
14 # to the group.
15 # 4. Clean up.
16 ################################################################################
17 --source include/big_test.inc
18 --source include/have_group_replication_plugin.inc
19 --let $rpl_skip_group_replication_start= 1
20 --let $rpl_server_count= 4
21 --source include/group_replication.inc
22
23
24 --echo
25 --echo ############################################################
26 --echo # 1. Deploy a 3 members group in single primary mode.
27 --let $rpl_connection_name= server1
28 --source include/rpl_connection.inc
29 --let $server1_uuid= `SELECT @@server_uuid`
30 --source include/start_and_bootstrap_group_replication.inc
31
32 --let $rpl_connection_name= server2
33 --source include/rpl_connection.inc
34 --source include/start_group_replication.inc
35
36 --let $rpl_connection_name= server3
37 --source include/rpl_connection.inc
38 --source include/start_group_replication.inc
39
40
41 --echo
42 --echo ############################################################
43 --echo # 2. Create and start a replication channel.
44 --let $rpl_connection_name= server4
45 --source include/rpl_connection.inc
46 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
47 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_PORT=$SERVER_MYPORT_1, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1'
48
49 --let $rpl_channel_name='ch1'
50 --source include/start_slave.inc
51 --let $rpl_channel_name=
52
53 --let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server1
54 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\' AND source_uuid=\'$server1_uuid\', SERVICE_STATE, 1]" = "ON"
55 --source include/assert.inc
56
57
58 --echo
59 --echo ############################################################
60 --echo # 3. Configure replica to manage the asynchronous connection
61 --echo # to the group.
62 --let $rpl_connection_name= server4
63 --source include/rpl_connection.inc
64
65 --error ER_REPLICA_CHANNEL_MUST_STOP
66 CHANGE REPLICATION SOURCE TO SOURCE_CONNECTION_AUTO_FAILOVER=1 FOR CHANNEL 'ch1';
67
68 --let $rpl_channel_name='ch1'
69 --source include/stop_slave.inc
70
71 CHANGE REPLICATION SOURCE TO SOURCE_CONNECTION_AUTO_FAILOVER=1 FOR CHANNEL 'ch1';
72
73 --source include/start_slave.inc
74 --let $rpl_channel_name=
75
76 --replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2 $group_replication_group_name GROUP_NAME
77 --eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_replication_group_name', '127.0.0.1', $SERVER_MYPORT_2, '', 90, 70)
78
79 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed'
80 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_replication_group_name", count, 1] = 1
81 --source include/assert.inc
82
83 --echo "['There are 3 rows in performance_schema.replication_asynchronous_connection_failover']"
84 --let $wait_condition= SELECT COUNT(*)=3 FROM performance_schema.replication_asynchronous_connection_failover
85 --source include/wait_condition.inc
86
87
88 --echo
89 --echo ############################################################
90 --echo # 4. Clean up.
91 --let $rpl_connection_name= server4
92 --source include/rpl_connection.inc
93 --let $rpl_channel_name='ch1'
94 --source include/stop_slave.inc
95
96 --let $rpl_reset_slave_all= 1
97 --let $rpl_multi_source= 1
98 --source include/rpl_reset_slave.inc
99 --let $rpl_channel_name=
100 --let $rpl_reset_slave_all=
101 --let $rpl_multi_source=
102
103 --replace_result $group_replication_group_name GROUP_NAME
104 --eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_replication_group_name')
105
106 --let $assert_text= 'There are no rows in performance_schema.replication_asynchronous_connection_failover'
107 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 0
108 --source include/assert.inc
109
110 --let $assert_text= 'There are no rows in performance_schema.replication_asynchronous_connection_failover_managed'
111 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed, count, 1] = 0
112 --source include/assert.inc
113
114 SET SESSION sql_log_bin = 0;
115 call mtr.add_suppression("The source .* for channel 'ch1' has joined the group .*, and so added its entry into replication_asynchronous_connection_failover table.");
116 call mtr.add_suppression("The group .* for the channel .* has been removed, and so removed its entry from replication_asynchronous_connection_failover_managed and all the group members from replication_asynchronous_connection_failover table.");
117 call mtr.add_suppression("The group .* for the channel .* has been added, and so added its entry in replication_asynchronous_connection_failover_managed and source to replication_asynchronous_connection_failover table.");
118 SET SESSION sql_log_bin = 1;
119
120 --let $rpl_connection_name= server3
121 --source include/rpl_connection.inc
122 --source include/stop_group_replication.inc
123
124 --let $rpl_connection_name= server2
125 --source include/rpl_connection.inc
126 --source include/stop_group_replication.inc
127
128 --let $rpl_connection_name= server1
129 --source include/rpl_connection.inc
130 --source include/stop_group_replication.inc
131
132 --source include/group_replication_end.inc