1########################################################################
2#
3# This test validate that all servers that have GR stopped or uninstalled
4# do not receive or send messages to the group.
5#
6# Test:
7#    0. This test requires two servers with GR
8#    1. Load plugin replication observers example on server1
9#    2. Load plugin replication observers example on server2 and store
10#       variables to use when start GR
11#    3. Stop GR on server2
12#    4. Server2 will not be able to send message, GR is stopped
13#    5. Server1 send a message on GR delivery system
14#    6. Start Group Replication on server 2
15#    7. Uninstall GR from server1
16#    8. Server1 will not be able to send message, GR plugin isn't present
17#    9. Server2 send another message on GR delivery system. This will be
18#       delivered.
19#   10. Start GR on server1, which will make it wait for the delivery of new
20#       view, and that will happen only after delivery of service message.
21#       This will give some time to server to receive and write it to error
22#       log.
23#   11. Assert server 2 received message from itself
24#   12. Assert server 1 received message from itself
25#   13. Cleanup
26#
27########################################################################
28
29--source include/have_replication_observers_example_plugin.inc
30--source include/have_group_replication_plugin.inc
31--source include/group_replication.inc
32
33--echo
34--echo # 1. Load plugin replication observers example on server1
35
36--source include/install_replication_observers_example.inc
37
38--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
39--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
40
41--echo
42--echo # 2. Load plugin replication observers example on server2 and store
43--echo #    variables to use when start GR
44
45--let $rpl_connection_name= server2
46--source include/rpl_connection.inc
47
48--source include/install_replication_observers_example.inc
49
50--echo
51--echo # 3. Stop GR on server2
52
53--source include/stop_group_replication.inc
54
55--echo
56--echo # 4. Server2 will not be able to send message, GR is stopped
57
58--error ER_UDF_ERROR
59SELECT group_replication_service_message_send("tag", "Server2 sent a message");
60
61--echo
62--echo # 5. Server1 send a message on GR delivery system
63
64--let $rpl_connection_name= server1
65--source include/rpl_connection.inc
66
67SELECT group_replication_service_message_send("tag", "Server1 sent a message");
68
69--echo
70--echo # 6. Start Group Replication on server 2
71
72--let $rpl_connection_name= server2
73--source include/rpl_connection.inc
74
75--source include/start_group_replication.inc
76
77--echo
78--echo # 7. Uninstall GR from server1
79
80--let $rpl_connection_name= server1
81--source include/rpl_connection.inc
82
83--source include/uninstall_group_replication_plugin.inc
84
85--echo
86--echo # 8. Server1 will not be able to send message, GR plugin isn't present
87
88--error ER_UDF_ERROR
89SELECT group_replication_service_message_send("tag", "Server1 sent another message");
90
91--echo
92--echo # 9. Server2 send another message on GR delivery system. This will be
93--echo #    delivered.
94
95--let $rpl_connection_name= server2
96--source include/rpl_connection.inc
97
98SELECT group_replication_service_message_send("tag", "Server2 sent another message");
99
100--echo
101--echo # 10. Start GR on server1, which will make it wait for the delivery of new
102--echo #     view, and that will happen only after delivery of service message.
103--echo #     This will give some time to server to receive and write it to error
104--echo #     log.
105
106--let $rpl_connection_name= server1
107--source include/rpl_connection.inc
108
109--source include/install_group_replication_plugin.inc
110
111--replace_result $_group_replication_group_seeds GROUP_SEEDS
112--eval SET @@global.group_replication_group_seeds="$_group_replication_group_seeds"
113--replace_result $_group_replication_local_address LOCAL_ADDRESS
114--eval SET @@global.group_replication_local_address="$_group_replication_local_address"
115
116--source include/start_group_replication.inc
117
118--echo
119--echo # 11. Assert server 2 received message from itself
120
121--let $rpl_connection_name= server2
122--source include/rpl_connection.inc
123
124--let $assert_file= $MYSQLTEST_VARDIR/tmp/gr_message_service_stop_uninstall_gr.2.err
125--let $assert_count = 1
126--let $assert_select = Plugin replication_observers_example reported: 'Service message recv TAG: "tag", TAG_SIZE: 3, MSG: "Server2 sent another message", MSG_SIZE: 28.'
127--let $assert_text = Server 2 received message from itself.
128--source include/assert_grep.inc
129
130--echo
131--echo # 12. Assert server 1 received message from itself
132
133--let $rpl_connection_name= server1
134--source include/rpl_connection.inc
135
136--let $assert_file= $MYSQLTEST_VARDIR/tmp/gr_message_service_stop_uninstall_gr.1.err
137--let $assert_count = 1
138--let $assert_select = Plugin replication_observers_example reported: 'Service message recv TAG: "tag", TAG_SIZE: 3, MSG: "Server1 sent a message", MSG_SIZE: 22.'
139--let $assert_text = Server 1 received one message from itself.
140--source include/assert_grep.inc
141
142--echo
143--echo # 13. Cleanup
144
145--source include/uninstall_replication_observers_example.inc
146
147--let $rpl_connection_name= server2
148--source include/rpl_connection.inc
149
150--source include/uninstall_replication_observers_example.inc
151
152--source include/group_replication_end.inc
153