MINI MINI MANI MO

Path : /opt/mysql/mysql-test/suite/group_replication/t/
File Upload :
Current File : //opt/mysql/mysql-test/suite/group_replication/t/gr_no_user_start_failure.test

################################################################################
# This test proves that the server cannot start when the mysql.session
# is not present.
#
# 0) Start with GR stopped in both servers
# 1) Remove the mysql.session
# 2) Start group replication and see the command errors out
# 3) Restart the server and check the it errors out
# 4) Restore the user
#
################################################################################

--source ../inc/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--source ../inc/group_replication.inc

--echo #
--echo # Delete the user and check the start fails
--echo #

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

#save user timestamps for later restore
let $date_to_restore=`SELECT password_last_changed from mysql.user where user='mysql.session'`;
let $date_to_restore_priv=`SELECT timestamp from mysql.tables_priv where user='mysql.session'`;

DROP USER "mysql.session"@"localhost";

--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"

--error ER_GROUP_REPLICATION_CONFIGURATION
START GROUP_REPLICATION;

--let $assert_text= Member 1 is OFFLINE
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE member_state="OFFLINE"] = 1
--source include/assert.inc

--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let $assert_only_after = CURRENT_TEST: group_replication.gr_no_user_start_failure
--let $assert_count = 1
--let $assert_select = There was an error when trying to access the server with user: mysql.session. Make
--let $assert_text = Found the expected error about the missing user in server log
--source include/assert_grep.inc

--echo #
--echo # Restart the server
--echo # Check the plugin is not running
--echo #

--let $allow_rpl_inited=1
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
--let $_group_replication_group_whitelist= `SELECT @@GLOBAL.group_replication_ip_whitelist`
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_start_on_boot=1 --group_replication_group_name=$group_replication_group_name --group_replication_ip_whitelist=$_group_replication_group_whitelist
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME $_group_replication_group_whitelist GROUP_REPLICATION_GROUP_WHITELIST
--source include/restart_mysqld.inc

--let $rpl_server_number= 1
--source include/rpl_reconnect.inc

--let $assert_text= Member 1 is OFFLINE
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE member_state="OFFLINE"] = 1
--source include/assert.inc

--echo #
--echo # Restore the user
--echo #

--disable_query_log
--eval INSERT IGNORE INTO mysql.user VALUES ('localhost','mysql.session','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0,'mysql_native_password','*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE','N',"$date_to_restore",NULL,'Y');

--eval INSERT IGNORE INTO mysql.tables_priv VALUES ('localhost', 'mysql', 'mysql.session', 'user', 'root\@localhost', "$date_to_restore_priv", 'Select', '');

INSERT IGNORE INTO mysql.db VALUES ('localhost', 'performance_schema', 'mysql.session','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N');
--enable_query_log

FLUSH PRIVILEGES;

--echo #
--echo # Suppress errors
--echo #

SET SESSION sql_log_bin= 0;
call mtr.add_suppression("There was an error when trying to access the server with user: mysql.session.*");
call mtr.add_suppression("It was not possible to establish a connection to server SQL service");
call mtr.add_suppression("Error calling group communication interfaces while trying to leave the group");
SET SESSION sql_log_bin= 1;

--source ../inc/group_replication_end.inc

OHA YOOOO