################################################################################ # This test is to verify that group replication variables are persisted into # mysqld-auto.cnf file, and, server can restart successfully using this file. # # Test: # 0. The test requires one server. Check that there are no persisted variables. # 1. Test SET PERSIST_ONLY. Verify persisted variables. # 2. Restart server, it must bootstrap the group and preserve the persisted # variables settings. Verify persisted configuration. # 3. Test RESET PERSIST IF EXISTS. Verify that there are no persisted variables. # 4. Clean up. ################################################################################ --source include/big_test.inc --source include/have_group_replication_plugin.inc --let $rpl_skip_group_replication_start= 1 --source include/group_replication.inc --echo --echo ############################################################ --echo # 0. Check that there are no persisted variables. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $assert_text= 'Expect 0 persisted variables.' --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0 --source include/assert.inc --echo --echo ############################################################ --echo # 1. Test SET PERSIST_ONLY. Verify persisted variables. --replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" SET GLOBAL group_replication_start_on_boot= ON; SET GLOBAL group_replication_bootstrap_group= ON; CREATE TABLE grvars (id INT PRIMARY KEY AUTO_INCREMENT, varname VARCHAR(64), varvalue VARCHAR(256)); INSERT INTO grvars (varname, varvalue) SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE 'group_replication%' ORDER BY VARIABLE_NAME; --let $countvars= `SELECT COUNT(*) FROM grvars;` --echo --let $varid=1 while ( $varid <= $countvars ) { --let $varnames= `SELECT varname FROM grvars WHERE id=$varid` --eval SET PERSIST_ONLY $varnames = @@GLOBAL.$varnames --inc $varid } --echo --let $assert_text= 'Expect $countvars persisted variables.' --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $countvars --source include/assert.inc --echo --echo ############################################################ --echo # 2. Restart server, it must bootstrap the group and preserve --echo # the persisted settings. Verify persisted configuration. --let $allow_rpl_inited= 1 --source include/restart_mysqld.inc --let $rpl_server_number= 1 --source include/rpl_reconnect.inc --let $MYSQLD_DATADIR= `select @@datadir;` --let $group_replication_member_state= ONLINE --source include/gr_wait_for_member_state.inc --echo --let $assert_text= 'Expect $countvars persisted variables in persisted_variables table.' --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $countvars --source include/assert.inc --let $assert_text= 'Expect $countvars persisted variables shown as PERSISTED in variables_info table.' --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.variables_info WHERE variable_source="PERSISTED", count, 1] = $countvars --source include/assert.inc # TODO: Update this once Bug#27322592 is FIXED. --let $assert_text= 'Expect 45 persisted variables with matching persisted and global values.' --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.variables_info vi JOIN performance_schema.persisted_variables pv JOIN performance_schema.global_variables gv ON vi.variable_name=pv.variable_name AND vi.variable_name=gv.variable_name AND pv.variable_value=gv.variable_value WHERE vi.variable_source="PERSISTED", count, 1] = 45 --source include/assert.inc --echo --echo ############################################################ --echo # 3. Test RESET PERSIST IF EXISTS. --echo # Verify that there are no persisted variables. --let $varid=1 while ( $varid <= $countvars ) { --let $varnames= `SELECT varname FROM grvars WHERE id=$varid` --eval RESET PERSIST IF EXISTS $varnames --inc $varid } --echo --let $assert_text= 'Expect 0 persisted variables.' --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0 --source include/assert.inc --echo --echo ############################################################ --echo # 4. Clean up. --let $countvars= --let $varid= --let $varnames= --remove_file $MYSQLD_DATADIR/mysqld-auto.cnf SET GLOBAL group_replication_start_on_boot= OFF; SET GLOBAL group_replication_bootstrap_group= OFF; DROP TABLE grvars; --source include/group_replication_end.inc