polardbxengine/mysql-test/suite/x/t/notices_gr_join_leave.test

304 lines
11 KiB
Plaintext

################################################################################
#
# WL#10655: Global notification for GR membership changes
#
# This test case checks that enabled notices are triggered and delivered to
# client.
#
# This file covers the scenarios for regular bootstrap, join, leave, recovering.
#
#
# +----+---------------------------------------------+------------+---------|
# | | Scenario\Where | | |
# | | | Server1 | Server2 |
# | | | triggering | |
# | | | event | |
# +----+---------------------------------------------+------------+---------|
# | 1 | SERVER BOOTSTRAPS GROUP | VC,2xSC | N/A |
# | 2 | SERVER JOINS and STARTS RECOVERY | VC,SC | VC,SC |
# | 3 | SERVER RECOVERED | SC | SC |
# | 4 | SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)| VC,SC | VC |
# +----+---------------------------------------------+------------+---------|
#
# Scenarios described inside the table will be repeated two times:
#
# * X Protocol GR notices enabled - verify delivery of the notices
# * X Protocol GR notices disabled - verify that X Plugin doesn't send the notices
#
--source include/count_sessions.inc
--source include/force_restart.inc
--source include/big_test.inc
--source include/have_mysqlx_plugin.inc
--source include/have_group_replication_plugin.inc
## Test starts here
--let $xtest=$MYSQL_TMP_DIR/group_replication_setup_and_xnotices_test.tmp
--write_file $xtest
-->import group_replication.macro
-->import assert_notices.macro
-->import assert_status_variable.macro
-->echo
-->echo ###
-->echo ### Sets up the group with two servers: server1 and server2
-->echo ###
callmacro Connect_to_all_mysqld_instances verify %SERVER_NUMBER%;
callmacro %ENABLE_NOTICES% %SERVER_NUMBER%
{"notice":["group_replication/membership/quorum_loss",
"group_replication/membership/view",
"group_replication/status/role_change",
"group_replication/status/state_change"]};
callmacro Connect_to_all_mysqld_instances server %SERVER_NUMBER%;
callmacro GR_clear_bootstrap_group %SERVER_NUMBER%;
-->echo
-->echo ### Scenario 1: SERVER BOOTSTRAPS GROUP
-->echo ### Expected:
-->echo ### - Myself: 1 VIEW CHANGED, 2 STATE CHANGED
-->echo ### - Others: N/A
-->echo ##########################################################################
callmacro GR_start_and_bootstrap %SERVER_NUMBER% %GR_NAME% ONLINE;
callmacro %ASSERT_NOTICES% view_changed verify_1;
callmacro %ASSERT_NOTICES% state_changed verify_1;
callmacro %ASSERT_NOTICES% state_changed verify_1;
callmacro %ASSERT_NOTICES% none verify_1;
callmacro %ASSERT_NOTICES% none verify_2;
-->echo
-->echo ### Scenario 2: MEMBER JOINS, but blocks recovering
-->echo ### Expected:
-->echo ### - Myself: 1 VIEW CHANGED, 1 STATE CHANGED
-->echo ### - Others: 1 VIEW CHANGED, 1 STATE CHANGED
-->echo ##########################################################################
# this will make server2 stay on recovery
callmacro Setsession server_1;
callmacro GR_stop_applier_sql_thread;
callmacro Setsession server_2;
callmacro GR_start %GR_NAME% RECOVERING;
callmacro %ASSERT_NOTICES% view_changed verify_1;
callmacro %ASSERT_NOTICES% state_changed verify_1;
callmacro %ASSERT_NOTICES% none verify_1;
callmacro %ASSERT_NOTICES% view_changed verify_2;
callmacro %ASSERT_NOTICES% state_changed verify_2;
callmacro %ASSERT_NOTICES% none verify_2;
-->echo
-->echo ### Scenario 3: MEMBER RECOVERS JOINS
-->echo ### Expected:
-->echo ### - Myself: 1 STATE CHANGED
-->echo ### - Others: 1 STATE CHANGED
-->echo ##########################################################################
callmacro Setsession server_1;
callmacro GR_start_applier_sql_thread;
callmacro Setsession server_2;
callmacro GR_wait_for_member_state ONLINE;
callmacro %ASSERT_NOTICES% state_changed verify_1;
callmacro %ASSERT_NOTICES% none verify_1;
callmacro %ASSERT_NOTICES% state_changed verify_2;
callmacro %ASSERT_NOTICES% none verify_2;
-->echo
-->echo ### Scenario 4: SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)
-->echo ### Expected:
-->echo ### - Myself (leaving): 1 VIEW CHANGED, 1 STATE CHANGED
-->echo ### - Others: 1 VIEW CHANGED
-->echo ##########################################################################
callmacro Setsession server_2;
noquery_result;
quiet;
SET SESSION sql_log_bin=0;
call mtr.add_suppression("Table 'tab1' already exists");
call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group");
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
call mtr.add_suppression("Slave SQL for channel 'group_replication_applier': ... The slave coordinator and worker threads are stopped,*");
SET SESSION sql_log_bin=1;
noquiet;
SET SESSION sql_log_bin=0;
CREATE TABLE test.tab1 (a INT PRIMARY KEY);
SET SESSION sql_log_bin=1;
callmacro Setsession server_1;
CREATE TABLE test.tab1 (a INT PRIMARY KEY);
query_result;
callmacro Setsession server_2;
callmacro GR_wait_for_member_state ERROR;
callmacro GR_wait_for_number_of_members 1;
callmacro %ASSERT_NOTICES% view_changed verify_1;
callmacro %ASSERT_NOTICES% none verify_1;
callmacro %ASSERT_NOTICES% state_changed verify_2;
callmacro %ASSERT_NOTICES% view_changed verify_2;
callmacro %ASSERT_NOTICES% none verify_2;
callmacro Setsession server_2;
callmacro GR_stop;
callmacro GR_wait_for_member_state OFFLINE;
callmacro %ASSERT_NOTICES% state_changed verify_2;
callmacro %ASSERT_NOTICES% none verify_2;
-->echo
-->echo ### Cleanup: in xtest deallocation of GR and drop of data
-->echo ##########################################################################
callmacro Setsession server_1;
callmacro GR_stop;
noquery_result;
DROP TABLE test.tab1;
RESET MASTER;
query_result;
callmacro Setsession server_2;
noquery_result;
DROP TABLE test.tab1;
RESET MASTER;
query_result;
-->echo
-->echo ### Postcheck: Assert session status variables
-->echo ### Expected:
-->echo ### - Myself 10 global-notices (7 from the tests scenarios + 2 from cleanup + 1 from connection)
-->echo ### - Other 7 global-notices (6 from the tests scenarios + 1 from connection)
-->echo ##########################################################################
callmacro Setsession verify_1;
callmacro %ASSERT_STATUS% Mysqlx_notice_global_sent 10;
callmacro Assert_received_notices;
callmacro Setsession verify_2;
callmacro %ASSERT_STATUS% Mysqlx_notice_global_sent 7;
callmacro Assert_received_notices;
EOF
## Setup X Plugin & GR
--let $dont_reset_global_status_variables=1
--source include/xplugin_preamble.inc
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc
--let $ceiling= `SELECT $rpl_server_count + 1`
--let $i = 1
while ($i < $ceiling)
{
--let $rpl_connection_silent= 1
--let $rpl_connection_name= server$i
--echo [Setup XPlugin user on connection '$rpl_connection_name']
--source include/rpl_connection.inc
--let $create_user_disable_binlog=1
--source include/xplugin_create_user.inc
--inc $i
}
--let $rpl_connection_silent= 0
--echo
--echo ## Protocol GR notices enabled - verify delivery of the notices
--echo ##########################################################################
exec $MYSQLXTEST
-ux_root --ssl-mode=disabled --file=$xtest
-v %SERVER_NUMBER%=$rpl_server_count
-v %GR_NAME%=$group_replication_group_name
-v %ASSERT_NOTICES%=CHK_assert_notice
-v %ASSERT_STATUS%=Assert_status_variable
-v %ENABLE_NOTICES%=Enable_notice
-v %SERVER_XPORT_1%=$MASTER_X_MYPORT_1
-v %SERVER_XPORT_2%=$MASTER_X_MYPORT_2 2>&1;
--echo
--echo ## X Protocol GR notices disabled - verify that X Plugin doesn't send the notices
--echo ##########################################################################
exec $MYSQLXTEST
-ux_root --ssl-mode=disabled --file=$xtest
-v %SERVER_NUMBER%=$rpl_server_count
-v %GR_NAME%=$group_replication_group_name
-v %ASSERT_NOTICES%=CHK_assert_notice_none_ignore_args
-v %ASSERT_STATUS%=CHK_assert_ignore
-v %ENABLE_NOTICES%=Dont_enable_notice
-v %SERVER_XPORT_1%=$MASTER_X_MYPORT_1
-v %SERVER_XPORT_2%=$MASTER_X_MYPORT_2 2>&1;
--echo
--echo ## Assert global status variables responsible for monitoring of global notices
--echo ## Expected:
--echo ## - Global Mysqlx_notified_by_group_replication must be two times higher than
--echo ## the session Mysqlx_notice_global_sent (test was executed two times).
--echo ##########################################################################
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
## Assert from xtest (Mysqlx_notice_global_sent 9) + additional one notice per connection (3 conn * 2 tests)
--let $assert_text= Verify if the number of send global notices matches Mysqlx_notice_global_sent.
--let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notice_global_sent", Value, 1] = 15
--source include/assert.inc
--let $assert_text= Verify if the number of send global notices matches Mysqlx_notified_by_group_replication.
--let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notified_by_group_replication", Value, 1] = 18
--source include/assert.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
## Assert from xtest (Mysqlx_notice_global_sent 6) + additional one notice per connection (2 conn * 2 tests)
--let $assert_text= Verify if the number of send global notices matches Mysqlx_notice_global_sent.
--let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notice_global_sent", Value, 1] = 10
--source include/assert.inc
--let $assert_text= Verify if the number of send global notices matches Mysqlx_notified_by_group_replication.
--let $assert_cond= [SHOW STATUS LIKE "Mysqlx_notified_by_group_replication", Value, 1] = 12
--source include/assert.inc
## Cleanup
--remove_file $xtest
--source include/group_replication_end.inc
--let $i = 1
--let $rpl_connection_silent=1
while ($i < $ceiling)
{
--let $rpl_connection_silent= 1
--let $rpl_connection_name= server$i
--source include/rpl_connection.inc
--source include/xplugin_drop_user.inc
--inc $i
}
# Following connections are established by group_replication.inc,
# still group_replication_end.inc doesn't disconnects them.
#
# Releasing the connections manually
#
--disconnect server1
--disconnect server2
--disconnect master1
--disconnect master
--disconnect slave1
--disconnect slave
--connection default
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc