| 1 |
############################################################################### |
| 2 |
# # |
| 3 |
# Variable Name: init_replica # |
| 4 |
# Scope: GLOBAL # |
| 5 |
# Access Type: Dynamic # |
| 6 |
# Data Type: string # |
| 7 |
# Default Value: # |
| 8 |
# Range: # |
| 9 |
# # |
| 10 |
# # |
| 11 |
# Creation Date: 2008-03-08 # |
| 12 |
# Author: Rizwan # |
| 13 |
# Modified: HHunger 2008-09-29 Fixed the bug by inserting the usual wait and # |
| 14 |
# SQL-Satements to control master and slave, # |
| 15 |
# deleted the sleep and made improvements like: # |
| 16 |
# - Replaced the opt file by dynamic variables, # |
| 17 |
# - Made the tests independant of the initial # |
| 18 |
# values of the global variables, # |
| 19 |
# - Reduced the test to the needed test case to # |
| 20 |
# save run time, # |
| 21 |
# - Beautification. # |
| 22 |
# # |
| 23 |
# Description: Test Cases of Dynamic System Variable init_replica # |
| 24 |
# that checks the behavior of this variable # |
| 25 |
# # |
| 26 |
# Reference: # |
| 27 |
# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # |
| 28 |
# # |
| 29 |
############################################################################### |
| 30 |
|
| 31 |
source include/master-slave.inc; |
| 32 |
--echo connection slave |
| 33 |
connection slave; |
| 34 |
--disable_query_log |
| 35 |
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); |
| 36 |
--enable_query_log |
| 37 |
# |
| 38 |
# save the current values |
| 39 |
|
| 40 |
SET @start_max_connections= @@global.max_connections; |
| 41 |
SET @start_init_replica= @@global.init_replica; |
| 42 |
|
| 43 |
# setting of a global value with an effect on the next start of the slave server |
| 44 |
# check that @@global.init_replica could be set |
| 45 |
SET NAMES utf8; |
| 46 |
let $my_init_replica= |
| 47 |
'SET @@global.max_connections = @@global.max_connections + 1 -- комментарий'; |
| 48 |
eval SET @@global.init_replica = $my_init_replica; |
| 49 |
|
| 50 |
# show the data type of the variable |
| 51 |
--disable_warnings |
| 52 |
DROP TABLE IF EXISTS t1; |
| 53 |
CREATE TEMPORARY TABLE t1 AS SELECT @@global.init_replica AS my_column; |
| 54 |
--enable_warnings |
| 55 |
DESCRIBE t1; |
| 56 |
select length(my_column) from t1; |
| 57 |
DROP TABLE t1; |
| 58 |
# |
| 59 |
# check that the new setting of @@global.init_replica becomes immediately visible |
| 60 |
eval SELECT @@global.init_replica = $my_init_replica; |
| 61 |
--echo Expect 1 |
| 62 |
# wait for the slave threads have set the global variable. |
| 63 |
let $wait_timeout= 90; |
| 64 |
let $wait_condition= SELECT @@global.max_connections = @start_max_connections; |
| 65 |
--source include/wait_condition_sp.inc |
| 66 |
# check that the action in init_replica does not happen immediately |
| 67 |
--let $assert_text= @@global.max_connections = @start_max_connections |
| 68 |
--let $assert_cond= @@global.max_connections = @start_max_connections |
| 69 |
--source include/assert.inc |
| 70 |
# |
| 71 |
# reset of the server |
| 72 |
STOP SLAVE; |
| 73 |
--wait_for_slave_to_stop |
| 74 |
RESET MASTER; |
| 75 |
RESET SLAVE; |
| 76 |
START SLAVE; |
| 77 |
source include/wait_for_slave_to_start.inc; |
| 78 |
# |
| 79 |
# wait for the slave threads have set the global variable. |
| 80 |
let $wait_timeout= 90; |
| 81 |
let $wait_condition= SELECT @@global.max_connections = @start_max_connections + 1; |
| 82 |
--source include/wait_condition_sp.inc |
| 83 |
# check that the action in init_replica was executed and had the intended effect |
| 84 |
--let $assert_text= @@global.max_connections = @start_max_connections + 1 |
| 85 |
--let $assert_cond= @@global.max_connections = @start_max_connections + 1 |
| 86 |
--source include/assert.inc |
| 87 |
# |
| 88 |
# Setting a variable(which is local to a session) and must not be visible |
| 89 |
SET @@global.init_replica = "SET @a=5"; |
| 90 |
# |
| 91 |
STOP SLAVE; |
| 92 |
--wait_for_slave_to_stop |
| 93 |
RESET MASTER; |
| 94 |
RESET SLAVE; |
| 95 |
START SLAVE; |
| 96 |
source include/wait_for_slave_to_start.inc; |
| 97 |
# |
| 98 |
SHOW VARIABLES LIKE 'init_replica'; |
| 99 |
# expect NULL |
| 100 |
SELECT @a; |
| 101 |
--echo Expect NULL |
| 102 |
# |
| 103 |
# Clean up |
| 104 |
SET @@global.max_connections= @start_max_connections; |
| 105 |
SET @@global.init_replica= @start_init_replica; |
| 106 |
################################################## |
| 107 |
# End of functionality Testing for init_replica # |
| 108 |
################################################## |
| 109 |
|
| 110 |
--source include/rpl_end.inc |