|
| 1 | +################################################################################ |
| 2 | +# |
| 3 | +# Creation Date: 19-Feb-2018 |
| 4 | +# Test Author: Mohit Joshi |
| 5 | +# |
| 6 | +# The aim of this testcase is to test persisted behavior of all system |
| 7 | +# variables with SET PERSIST and RESET PERSIST IF EXISTS clauses. |
| 8 | +# |
| 9 | +# Test: |
| 10 | +# 0. SET PERSIST is applicable on GLOBAL,dynamic variables only. Hence, verify |
| 11 | +# that variables in performance_schema.global_variables are actually |
| 12 | +# settable with SET GLOBAL. |
| 13 | +# 1. Check that there are no persisted variable settings due to improper |
| 14 | +# cleanup by other testcases. |
| 15 | +# 2. Test SET PERSIST. Verify persisted variables. |
| 16 | +# 3. Restart server, it must preserve the persisted variable settings. |
| 17 | +# Verify persisted configuration. |
| 18 | +# 4. Test RESET PERSIST IF EXISTS. Verify persisted variable settings are |
| 19 | +# removed. |
| 20 | +# 5. Clean up. |
| 21 | + |
| 22 | +# Note - Currently there are 557 global variables |
| 23 | +# -> SELECT COUNT(*) FROM performance_schema.global_variables |
| 24 | +# In future, if a new global variable is added, it will be automatically |
| 25 | +# picked up from performance_schema.global_variables table. |
| 26 | +# |
| 27 | +# Out of all, 354 are global persistent variable. In future, if a new global |
| 28 | +# persistent variable is added, it is the responsibility of the Dev to |
| 29 | +# edit this variable. |
| 30 | +# -> $total_persistent_var=354 |
| 31 | +################################################################################ |
| 32 | + |
| 33 | +--echo ######################################################################## |
| 34 | +--echo # Run only on debug build,non-windows as few server variables are not |
| 35 | +--echo # available on all platforms. |
| 36 | +--echo ######################################################################## |
| 37 | +--source include/have_debug.inc |
| 38 | +--source include/not_windows.inc |
| 39 | + |
| 40 | +let $total_global_vars=`SELECT COUNT(*) FROM performance_schema.global_variables`; |
| 41 | +let $total_persistent_vars=354; |
| 42 | + |
| 43 | +--echo ############################################################## |
| 44 | +--echo # 0. Verify that variables present in performance_schema.global |
| 45 | +--echo # variables are actually global variables and can be set using |
| 46 | +--echo # SET GLOBAL |
| 47 | +--echo ############################################################### |
| 48 | + |
| 49 | +CREATE TABLE global_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024)); |
| 50 | + |
| 51 | +# Following variables cannot be set in this format: |
| 52 | +# -> SET GLOBAL innodb_monitor_enable = @@global.innodb_monitor_enable |
| 53 | +# ERROR 1231 (42000): Variable 'innodb_monitor_enable' can't be set to the value of 'NULL' |
| 54 | +# -> SET GLOBAL innodb_monitor_disable = @@global.innodb_monitor_disable; |
| 55 | +# ERROR 1231 (42000): Variable 'innodb_monitor_disable' can't be set to the value of 'NULL' |
| 56 | +# -> SET GLOBAL innodb_monitor_reset = @@global.innodb_monitor_reset; |
| 57 | +# ERROR 1231 (42000): Variable 'innodb_monitor_reset' can't be set to the value of 'NULL' |
| 58 | +# -> SET GLOBAL innodb_monitor_reset_all = @@global.innodb_monitor_reset_all; |
| 59 | +# ERROR 1231 (42000): Variable 'innodb_monitor_reset_all' can't be set to the value of 'NULL' |
| 60 | + |
| 61 | +# Bug#27534122 - RBR_EXEC_MODE DOES NOT SUPPORT GLOBAL SCOPE |
| 62 | +INSERT INTO global_vars (var_name, var_value) SELECT * FROM |
| 63 | +performance_schema.global_variables WHERE variable_name NOT IN |
| 64 | +('innodb_monitor_enable', |
| 65 | +'innodb_monitor_disable', |
| 66 | +'innodb_monitor_reset', |
| 67 | +'innodb_monitor_reset_all', |
| 68 | +'rbr_exec_mode'); |
| 69 | + |
| 70 | +--let $count_vars= `SELECT COUNT(*) FROM global_vars;` |
| 71 | +--let $var_id=1 |
| 72 | +--disable_query_log |
| 73 | +--disable_warnings |
| 74 | + |
| 75 | +while($var_id <= $count_vars) |
| 76 | +{ |
| 77 | +--let $var_name= `SELECT var_name FROM global_vars WHERE id=$var_id;` |
| 78 | +--error 0,ER_INCORRECT_GLOBAL_LOCAL_VAR,ER_WRONG_ARGUMENTS |
| 79 | +--eval SET GLOBAL $var_name = @@global.$var_name |
| 80 | +--inc $var_id |
| 81 | +} |
| 82 | + |
| 83 | +--enable_warnings |
| 84 | +--enable_query_log |
| 85 | + |
| 86 | +--echo ############################################################ |
| 87 | +--echo # 1. Check that there are no persisted variable settings. |
| 88 | +--echo ############################################################ |
| 89 | + |
| 90 | +--let $assert_text= 'Expect 0 persisted variables.' |
| 91 | +--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0 |
| 92 | +--source include/assert.inc |
| 93 | + |
| 94 | +--echo |
| 95 | +--echo ############################################################ |
| 96 | +--echo # 2. Initialization. Test SET PERSIST. Verify persisted |
| 97 | +--echo # variables. |
| 98 | +--echo ############################################################ |
| 99 | + |
| 100 | +--let $MYSQLD_DATADIR= `select @@datadir;` |
| 101 | + |
| 102 | +CREATE TABLE all_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024)); |
| 103 | + |
| 104 | +# Currently we are not able to test the below 11 global variables because of |
| 105 | +# open bugs (listed below). Once the bugs are fixed, |
| 106 | +# below query must be modified. |
| 107 | +# |
| 108 | +# Bug#27512616 - SET PERSIST COMMAND FAILS TO MAP DEFAULT(NULL) VALUES IN MYSQLD-AUTO.CNF |
| 109 | +# Bug#27523095 - SET PERSIST MANDATORY_ROLES FAILS TO START THE SERVER |
| 110 | +# Bug#27534122 - RBR_EXEC_MODE DOES NOT SUPPORT GLOBAL SCOPE |
| 111 | +# Bug#27534041 - SET GLOBAL INNODB_MONITOR_ENABLE CAUSES SERVER TO CRASH |
| 112 | +# Bug#27534089 - LOG_SYS_* GLOBAL VARIABLES DO NOT WORK WITH SET GLOBAL/PERSIST |
| 113 | + |
| 114 | +INSERT INTO all_vars (var_name, var_value) |
| 115 | +SELECT * FROM performance_schema.global_variables |
| 116 | +WHERE variable_name NOT IN |
| 117 | +('keyring_operations', |
| 118 | +'mandatory_roles', |
| 119 | +'innodb_ft_aux_table', |
| 120 | +'innodb_ft_user_stopword_table', |
| 121 | +'innodb_tmpdir', |
| 122 | +'innodb_ft_server_stopword_table', |
| 123 | +'rbr_exec_mode', |
| 124 | +'log_syslog', |
| 125 | +'log_syslog_facility', |
| 126 | +'log_syslog_include_pid', |
| 127 | +'log_syslog_tag') |
| 128 | +ORDER BY variable_name; |
| 129 | + |
| 130 | +--let $count_vars= `SELECT COUNT(*) FROM all_vars;` |
| 131 | +--echo |
| 132 | +--let $assert_text= 'Expect 557 variables in the table. Due to open Bugs, we are checking for 546' |
| 133 | +--let $assert_cond= [SELECT COUNT(*) as count FROM all_vars, count, 1] = $total_global_vars-11 |
| 134 | +--source include/assert.inc |
| 135 | + |
| 136 | +--echo |
| 137 | +--echo # Test SET PERSIST |
| 138 | +--let $var_id=1 |
| 139 | +--disable_query_log |
| 140 | +--disable_warnings |
| 141 | +while($var_id <= $count_vars) |
| 142 | +{ |
| 143 | + --let $var_names= `SELECT var_name FROM all_vars WHERE id=$var_id;` |
| 144 | + --error 0,ER_INCORRECT_GLOBAL_LOCAL_VAR,ER_WRONG_VALUE_FOR_VAR |
| 145 | + --eval SET PERSIST $var_names = @@GLOBAL.$var_names |
| 146 | + --inc $var_id |
| 147 | +} |
| 148 | +# Below 4 tests have default value as "" and these variables can't be set to |
| 149 | +# empty value. Hence, setting them seperately. |
| 150 | +SET PERSIST innodb_monitor_enable= "latch"; |
| 151 | +SET PERSIST innodb_monitor_disable="latch"; |
| 152 | +SET PERSIST innodb_monitor_reset="latch"; |
| 153 | +SET PERSIST innodb_monitor_reset_all="latch"; |
| 154 | + |
| 155 | +--enable_warnings |
| 156 | +--enable_query_log |
| 157 | +--echo |
| 158 | +--let $assert_text= 'Expect 354 persisted variables in the table. Due to open Bugs, we are checking for 349' |
| 159 | + |
| 160 | +# Below are the persisted variables we are unable to test at the moment due to |
| 161 | +# existing Bugs. |
| 162 | +# 1. keyring_operations (Bug#27523095) |
| 163 | +# 2. mandatory_roles (Bug#27523095) |
| 164 | +# 3. innodb_ft_aux_table (Bug#27512616) |
| 165 | +# 4. innodb_ft_user_stopword_table (Bug#27512616) |
| 166 | +# 5. innodb_ft_server_stopword_table (Bug#27512616) |
| 167 | +--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $total_persistent_vars-5 |
| 168 | +--source include/assert.inc |
| 169 | + |
| 170 | +--echo |
| 171 | +--echo ############################################################ |
| 172 | +--echo # 3. Restart server, it must preserve the persisted variable |
| 173 | +--echo # settings. Verify persisted configuration. |
| 174 | +--echo ############################################################ |
| 175 | + |
| 176 | +--source include/restart_mysqld.inc |
| 177 | +--source include/wait_until_connected_again.inc |
| 178 | + |
| 179 | +--echo |
| 180 | +--let $assert_text= 'Expect 349 persisted variables in persisted_variables table.' |
| 181 | +--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $total_persistent_vars-5 |
| 182 | +--source include/assert.inc |
| 183 | + |
| 184 | +--let $assert_text= 'Expect 349 persisted variables shown as PERSISTED in variables_info table.' |
| 185 | +--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.variables_info WHERE variable_source="PERSISTED", count, 1] = $total_persistent_vars-5 |
| 186 | +--source include/assert.inc |
| 187 | + |
| 188 | + --let $assert_text= 'Expect 349 persisted variables with matching peristed and global values.' |
| 189 | + --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] = $total_persistent_vars-5 |
| 190 | + |
| 191 | +--echo |
| 192 | +--echo ############################################################ |
| 193 | +--echo # 4. Test RESET PERSIST IF EXISTS. Verify persisted variable |
| 194 | +--echo # settings are removed. |
| 195 | +--echo ############################################################ |
| 196 | + |
| 197 | +--disable_query_log |
| 198 | +--disable_warnings |
| 199 | +--let $var_id=1 |
| 200 | +while ( $var_id <= $count_vars ) |
| 201 | +{ |
| 202 | + --let $var_names= `SELECT var_name FROM all_vars WHERE id=$var_id` |
| 203 | + --eval RESET PERSIST IF EXISTS $var_names |
| 204 | + --inc $var_id |
| 205 | +} |
| 206 | +--enable_query_log |
| 207 | +--enable_warnings |
| 208 | + |
| 209 | +--echo |
| 210 | +--let $assert_text= 'Expect 0 persisted variables.' |
| 211 | +--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0 |
| 212 | +--source include/assert.inc |
| 213 | + |
| 214 | +--echo |
| 215 | +--echo ############################################################ |
| 216 | +--echo # 5. Clean up. |
| 217 | +--echo ############################################################ |
| 218 | + |
| 219 | +--let $count_vars= |
| 220 | +--let $var_id= |
| 221 | +--let $var_names= |
| 222 | +--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf |
| 223 | +DROP TABLE all_vars; |
| 224 | +DROP TABLE global_vars; |
| 225 | +# Restart |
| 226 | +--let restart_parameters= |
| 227 | +--source include/restart_mysqld.inc |
0 commit comments