Debian Codegraph @

mysql-test/suite/sys_vars/t/persisted_sysvars_with_aliases.test

raw
1 # ==== Purpose ====
2 #
3 # Verify that system variable aliases work with SET PERSIST and with
4 # command-line options.
5 #
6 # ==== Requirements ====
7 #
8 # R1. When using SET PERSIST or RESET PERSIST, with either the old
9 # name or the new name, all the following shall be updated for both
10 # the old and the new name:
11 #
12 # R1.1. The global value.
13 # R1.2. The value in the persisted variables file.
14 # R1.3. The value in performance_schema.persisted_variables.
15 # R1.4. The source in performance_schema.variables_info.
16 #
17 # R2. When loading the persisted variables file, both old and new
18 # value shall be loaded, in each of the following cases:
19 #
20 # R2.1. The file contains both old name and the new name.
21 # R2.2. The file contains only new name.
22 # R2.3. The file contains only old name.
23 #
24 # R3. When using command-line arguments, both old and new name shall
25 # be set, in each of the following cases:
26 #
27 # R3.1. The command line contains both old name and the new name.
28 # R3.2. The command line contains only new name.
29 # R3.3. The command line contains only old name.
30 #
31 # R4. Deprecation warnings shall be generated in the following cases:
32 #
33 # R4.1. When using SET PERSIST with the old name.
34 # R4.2. When loading a file that the old name and not the new name.
35 # R4.3. When using an old name on the command line.
36 #
37 # R5. Deprecation warnings shall not be generated in the following cases:
38 #
39 # R5.1. When using SET PERSIST with the new name.
40 # R5.2. When using RESET PERSIST, with old or new name.
41 # R5.3. When loading a file that contains the new name (with or
42 # without the old name).
43 #
44 # ==== Implementation ====
45 #
46 # We rely on the framework to iterate over JSON objects, and use the
47 # specifications of system variable behaviors
48 # inc/json_sysvar_spec.inc.
49 #
50 # The test executes in several phases. Each new phase begins by
51 # restarting the server. Each phase tests some set of requirements
52 # for all server variables together. This strategy, contrary to
53 # testing all requirements for a variable at a time, minimizes server
54 # restarts. The following phases are executed:
55 #
56 # - Verify the dynamic behavior when altering persisted variables with
57 # the server online. This verifies that SET PERSIST, RESET PERSIST,
58 # and SET PERSIST_ONLY have the expected side effects on
59 # @@global.variables and performance_schema tables. It also verifies
60 # that there are deprecation warnings as expected.
61 #
62 # - Verify behavior of persisted options, when both old and new names
63 # are persisted. This restarts the server and verifies that the
64 # variables have the expected values.
65 #
66 # - Verify behavior of persisted options, when just the new name is
67 # persisted. This simulates the situation after downgrade from a
68 # future version where the old variables have been removed. It
69 # works by modifying the persisted variables file, restarting the
70 # server, and checking that the values are as expected.
71 #
72 # - Verify behavior of persisted options, when just the old name is
73 # persisted. This simulates the situation after upgrade from a
74 # version before the variables existed. It works analogously to the
75 # previous case. It also verifies that there are deprecation
76 # warnings as expected, and that the previous two phases did not
77 # generate deprecation warnings.
78 #
79 # - Verify behavior of command-line options, when both old and new
80 # names are specified.
81 #
82 # - Verify behavior of command-line options, when just new names are
83 # specified.
84 #
85 # - Verify behavior of command-line options, when just old names are
86 # specified.
87 #
88 # ==== References ====
89 #
90 # WL#14194: Replace old terms in replication system variables,
91 # options, and strings
92
93
94 # This test checks the behavior of configuration variables. If the
95 # test is invoked with some of those variables set to specific values,
96 # that interferes with the test. So we disable runs that set the
97 # tested variables.
98
99 # Binlog-less runs use --skip-log-replica-updates.
100 --source include/have_log_bin.inc
101
102
103 --echo #### Initialize ####
104
105 --source include/save_error_log_position.inc
106
107 # Don't suppress these warnings from the log. This allows us to assert
108 # that they exist in the log.
109 let $messages =
110 The variable .* has been renamed to .*, and the old name deprecated.
111 .* is deprecated and will be removed in a future release. Please use .* instead.
112 ;
113 --let $suppress_mode = IGNORE_GLOBAL_SUPPRESSIONS
114 --source include/suppress_messages.inc
115
116 # Tell restart_mysqld.inc to not echo parameters. This is important
117 # since one of the parameters is --slave_load_tmpdir with a local
118 # path.
119 --let $do_not_echo_parameters = 1
120
121 --let $assert_escape = 1
122
123 --let $json_verbose = name, alias, invalid, global, session, cmdline, persist, persist_as_readonly, dynamic
124 --source ../inc/json_sysvar_spec.inc
125
126 --let $json_label = value
127 --source include/create_json_iterator.inc
128
129 # Tell assertions_for_sysvar_value.inc to check the global variable.
130 --let $scope = global
131
132 --echo #### Test ####
133
134 --echo ==== R1. Checks without server restart ====
135 --echo * Also checking R4.1: deprecation warning for SET PERSIST <old>
136 --echo * Also checking R5.1: no deprecation warning for SET PERSIST <new>
137 --echo * Also checking R5.2: no deprecation warning for RESET PERSIST
138
139 --let $persisted_variables_file = `SELECT CONCAT(@@global.datadir, 'mysqld-auto.cnf')`
140 --let $escape_persisted_json = 1
141 --let $persisted_json = LOAD
142
143 --let $all_names =
144 --let $all_aliases =
145 --let $persist_deprecation_warnings =
146 --let $command_line_deprecation_warnings =
147
148 --let $expect_truncation_warning = 0
149
150 --let $json_array = $sysvar_specs
151 --source $json_sysvar_start
152 while (!$json_sysvar_done) {
153 --echo ---- $name ----
154
155 # Sanity-check the specification
156 if (!$dynamic) {
157 if ($persist) {
158 if (!$persist_as_readonly) {
159 --die !!! ERROR IN TEST: if readonly variable is persistable, it must be persist_as_readonly
160 }
161 }
162 }
163 if ($persist_as_readonly) {
164 if (!$persist) {
165 --die !!! ERROR IN TEST: persist_as_readonly is only allowed for variables having persist set.
166 }
167 }
168
169 # Collect command-line options
170 if ($cmdline) {
171 --let $json_array = $values
172 --let $json_start = 2
173 --source $json_value_start
174 --let $json_key = $json_value_value
175 --let $json_object = $value_map
176 --source include/json_lookup.inc
177 --let $command_line_names = $command_line_names --$name=$json_value
178 --let $command_line_aliases = $command_line_aliases --$alias=$json_value
179 let $command_line_deprecation_warnings = $command_line_deprecation_warnings
180 .*The syntax .$alias. is deprecated and will be removed in a future release. Please use $name instead.;
181 }
182
183 if ($persist) {
184 # Collect comma-separated lists of all names, and of all aliases
185 if ($all_names) {
186 --let $all_names = $all_names,
187 --let $all_aliases = $all_aliases,
188 }
189 # Variables tagged as "PERSIST_AS_READONLY" are stored in a
190 # sub-document.
191 if ($persist_as_readonly) {
192 --let $subsection = mysql_static_variables
193 }
194 if (!$persist_as_readonly) {
195 --let $subsection = mysql_dynamic_variables
196 }
197 --let $all_names = $all_names '$.$subsection.$name'
198 --let $all_aliases = $all_aliases '$.$subsection.$alias'
199 # Collect expected list of deprecation warnings that will be given on
200 # a later server restart.
201 let $persist_deprecation_warnings = $persist_deprecation_warnings
202 .*The variable $alias has been renamed to $name, and the old name deprecated.*;
203 if ($dynamic) {
204 --let $readonly_counter = 2
205 --let $expect_source = DYNAMIC
206 }
207 if (!$dynamic) {
208 --let $readonly_counter = 1
209 --let $expect_source = COMPILED
210 }
211 while ($readonly_counter) {
212 if ($readonly_counter == 2) {
213 --let $persist_scope = PERSIST
214 --let $expect_persisted_value = SAME_AS_VALUE
215 }
216 if ($readonly_counter == 1) {
217 --let $persist_scope = PERSIST_ONLY
218 --let $expect_value = $default
219 }
220
221 --let $json_array = $values
222 --let $json_start = 0
223 --source $json_value_start
224
225 --echo # R1. SET <new> when variable was previously unset
226 if ($mask_value) {
227 --replace_result $json_value_value VALUE
228 }
229 eval SET @@$persist_scope.$name = $json_value_value;
230 --let $expect_deprecation_warning = 0
231 --source ../inc/assertions_for_sysvar_warnings.inc
232 if ($persist_scope == PERSIST) {
233 --let $expect_value = $json_value_value
234 }
235 if ($persist_scope == PERSIST_ONLY) {
236 --let $expect_persisted_value = $json_value_value
237 }
238 --let $expect_persisted_ps = exists
239 --let $expect_persisted_json = exists
240 --source ../inc/assertions_for_sysvar_and_alias_value.inc
241
242 --echo # R1. SET <old> when variable was previously set through <new>
243 --source $json_value_next
244 if ($mask_value) {
245 --replace_result $json_value_value VALUE
246 }
247 eval SET @@$persist_scope.$alias = $json_value_value;
248 --let $expect_deprecation_warning = 1
249 --source ../inc/assertions_for_sysvar_warnings.inc
250 if ($persist_scope == PERSIST) {
251 --let $expect_value = $json_value_value
252 }
253 if ($persist_scope == PERSIST_ONLY) {
254 --let $expect_persisted_value = $json_value_value
255 }
256 --let $expect_persisted_ps = exists
257 --let $expect_persisted_json = exists
258 --source ../inc/assertions_for_sysvar_and_alias_value.inc
259
260 --echo # R1. SET <old> = DEFAULT
261 --let $skip_set_default = 0
262 if ($persist_scope == PERSIST_ONLY) {
263 if ($skip_set_persist_only_default) {
264 --let $skip_set_default = 1
265 }
266 }
267 if (!$skip_set_default) {
268 eval SET @@$persist_scope.$alias = DEFAULT;
269 --let $expect_deprecation_warning = 1
270 --source ../inc/assertions_for_sysvar_warnings.inc
271 if ($persist_scope == PERSIST) {
272 --let $expect_value = $default
273 }
274 if ($persist_scope == PERSIST_ONLY) {
275 --let $expect_persisted_value = $default
276 }
277 --let $expect_persisted_ps = exists
278 --let $expect_persisted_json = exists
279 --source ../inc/assertions_for_sysvar_and_alias_value.inc
280 }
281
282 --echo # R1. RESET <old>
283 eval RESET PERSIST $alias;
284 --let $expect_deprecation_warning = 0
285 --source ../inc/assertions_for_sysvar_warnings.inc
286 --let $expect_persisted_ps = noexists
287 --let $expect_persisted_json = noexists
288 --source ../inc/assertions_for_sysvar_and_alias_value.inc
289
290 --echo # R1. SET <old> when variable was previously unset
291 if ($mask_value) {
292 --replace_result $json_value_value VALUE
293 }
294 eval SET $persist_scope $alias = $json_value_value;
295 --let $expect_deprecation_warning = 1
296 --source ../inc/assertions_for_sysvar_warnings.inc
297 if ($persist_scope == PERSIST) {
298 --let $expect_value = $json_value_value
299 }
300 if ($persist_scope == PERSIST_ONLY) {
301 --let $expect_persisted_value = $json_value_value
302 }
303 --let $expect_persisted_ps = exists
304 --let $expect_persisted_json = exists
305 --source ../inc/assertions_for_sysvar_and_alias_value.inc
306
307 --echo # R1. SET <new> when variable was previously set through <old>
308 --source $json_value_next
309 if ($mask_value) {
310 --replace_result $json_value_value VALUE
311 }
312 eval SET $persist_scope $name = $json_value_value;
313 --let $expect_deprecation_warning = 0
314 --source ../inc/assertions_for_sysvar_warnings.inc
315 if ($persist_scope == PERSIST) {
316 --let $expect_value = $json_value_value
317 }
318 if ($persist_scope == PERSIST_ONLY) {
319 --let $expect_persisted_value = $json_value_value
320 }
321 --let $expect_persisted_ps = exists
322 --let $expect_persisted_json = exists
323 --source ../inc/assertions_for_sysvar_and_alias_value.inc
324
325 --echo # R1. RESET <new>
326 eval RESET PERSIST $name;
327 --let $expect_deprecation_warning = 0
328 --source ../inc/assertions_for_sysvar_warnings.inc
329 --let $expect_persisted_ps = noexists
330 --let $expect_persisted_json = noexists
331 --source ../inc/assertions_for_sysvar_and_alias_value.inc
332
333 # Restore default global value. This makes the second iteration
334 # for a dynamic variable have the same initial state as the first
335 # and only iteation for a readonly variable.
336 if ($dynamic) {
337 eval SET GLOBAL $name = DEFAULT;
338 --let $expect_deprecation_warning = 0
339 --source ../inc/assertions_for_sysvar_warnings.inc
340 }
341
342 --dec $readonly_counter
343 }
344
345 # Persist a value for the next restart
346 if ($mask_value) {
347 --replace_result $json_value_value VALUE
348 }
349 eval SET PERSIST_ONLY $name = $json_value_value;
350 --let $expect_deprecation_warning = 0
351 --source ../inc/assertions_for_sysvar_warnings.inc
352 }
353
354 --source $json_sysvar_next
355 }
356
357 --let $expect_source = PERSISTED
358
359 --echo
360 --echo ==== R2.1. Server restart with both old and new name in file ====
361 --echo
362
363 # Restart server.
364 --source include/restart_mysqld.inc
365 --let $error_pattern = NONE
366 --source include/assert_error_log.inc
367 # Load file contents.
368 --source ../inc/load_persisted_json.inc
369 # Iterate over variables and check them.
370 --let $json_array = $sysvar_specs
371 --source $json_sysvar_start
372 while (!$json_sysvar_done) {
373 if ($persist) {
374 --let $json_array = $values
375 --let $json_start = 2
376 --source $json_value_start
377 --let $expect_value = $json_value_value
378
379 --let $expect_persisted_json = exists
380 --let $expect_persisted_ps = exists
381 --let $expect_persisted_value = SAME_AS_VALUE
382 --source ../inc/assertions_for_sysvar_and_alias_value.inc
383 }
384
385 --source $json_sysvar_next
386 }
387
388 --echo
389 --echo ==== R2.2. Server restart with only new name in file ====
390 --echo
391
392 # Remove 'old' names from persisted file
393 --let $filtered_json = `SELECT JSON_REMOVE('$persisted_json', $all_aliases)`
394 --let $write_var = escape(\',$filtered_json)
395 --let $write_to_file = $persisted_variables_file
396 --source include/write_var_to_file.inc
397 # Restart server.
398 --source include/restart_mysqld.inc
399 --let $error_pattern = NONE
400 --source include/assert_error_log.inc
401 # Load file contents.
402 --source ../inc/load_persisted_json.inc
403 # Iterate over variables and check them.
404 --let $json_array = $sysvar_specs
405 --source $json_sysvar_start
406 while (!$json_sysvar_done) {
407 if ($persist) {
408 --let $json_array = $values
409 --let $json_start = 2
410 --source $json_value_start
411 --let $expect_value = $json_value_value
412
413 --let $variable = $name
414 --let $expect_persisted_json = exists
415 --let $expect_persisted_ps = exists
416 --source ../inc/assertions_for_sysvar_value.inc
417
418 --let $variable = $alias
419 --let $expect_persisted_json = noexists
420 --let $expect_persisted_ps = exists
421 --source ../inc/assertions_for_sysvar_value.inc
422 }
423 --source $json_sysvar_next
424 }
425
426 # Force rewriting the file. This will write both old and new names, so
427 # below we expect both to exist in the file.
428 SET PERSIST binlog_format = 'row';
429 RESET PERSIST binlog_format;
430 --let $expect_persisted_json = exists
431 # Load file contents.
432 --source ../inc/load_persisted_json.inc
433 # Iterate over variables and check them.
434 --let $json_array = $sysvar_specs
435 --source $json_sysvar_start
436 while (!$json_sysvar_done) {
437 if ($persist) {
438 --let $json_array = $values
439 --let $json_start = 2
440 --source $json_value_start
441 --let $expect_value = $json_value_value
442
443 --let $expect_persisted_json = exists
444 --let $expect_persisted_ps = exists
445 --source ../inc/assertions_for_sysvar_and_alias_value.inc
446 }
447 --source $json_sysvar_next
448 }
449
450 --echo
451 --echo ==== R2.3. Server restart with only old name in file ====
452 --echo
453
454 # Remove 'new' names from persisted file
455 --let $filtered_json = `SELECT JSON_REMOVE('$persisted_json', $all_names)`
456 --let $write_var = escape(\',$filtered_json)
457 --let $write_to_file = $persisted_variables_file
458 --source include/write_var_to_file.inc
459 # Restart server and check deprecation warnings.
460 --echo * R5.3: no deprecation warnings up till now
461 --source include/restart_mysqld.inc
462 --echo * R4.2: deprecation warnings when loading file containing only old names
463 --let $error_pattern = $persist_deprecation_warnings
464 --source include/assert_error_log.inc
465 # Load file contents.
466 --source ../inc/load_persisted_json.inc
467 # Iterate over variables and check them.
468 --let $json_array = $sysvar_specs
469 --source $json_sysvar_start
470 while (!$json_sysvar_done) {
471 if ($persist) {
472 --let $json_array = $values
473 --let $json_start = 2
474 --source $json_value_start
475 --let $expect_value = $json_value_value
476
477 --let $variable = $name
478 --let $expect_persisted_json = noexists
479 --let $expect_persisted_ps = exists
480 --source ../inc/assertions_for_sysvar_value.inc
481
482 --let $variable = $alias
483 --let $expect_persisted_json = exists
484 --let $expect_persisted_ps = exists
485 --source ../inc/assertions_for_sysvar_value.inc
486 }
487 --source $json_sysvar_next
488 }
489
490 # Force rewriting the file. This will write both old and new names, so
491 # below we expect both to exist in the file.
492 SET PERSIST binlog_format = 'row';
493 RESET PERSIST binlog_format;
494 --let $expect_persisted_json = exists
495 # Load file contents.
496 --source ../inc/load_persisted_json.inc
497 # Iterate over variables and check them.
498 --let $json_array = $sysvar_specs
499 --source $json_sysvar_start
500 while (!$json_sysvar_done) {
501 if ($persist) {
502 --let $json_array = $values
503 --let $json_start = 2
504 --source $json_value_start
505 --let $expect_value = $json_value_value
506
507 --let $expect_persisted_json = exists
508 --let $expect_persisted_ps = exists
509 --source ../inc/assertions_for_sysvar_and_alias_value.inc
510 }
511 --source $json_sysvar_next
512 }
513
514 --echo
515 --echo ==== R3.1. Server restart with both old and new names on command line ====
516 --echo * Also checking R4.3 (deprecation warning for old name on command line)
517 --echo
518
519 --let $expect_source = COMMAND_LINE
520 --let $expect_persisted_json = noexists
521 --let $expect_persisted_ps = noexists
522
523 RESET PERSIST;
524 --source ../inc/load_persisted_json.inc
525
526 # Restart server.
527 --let $restart_parameters = restart:$command_line_names $command_line_aliases
528 --source include/restart_mysqld.inc
529 --echo * R4.3: deprecation warnings when using old names on command line
530 --let $error_pattern = $command_line_deprecation_warnings
531 --source include/assert_error_log.inc
532 # Iterate over variables and check them.
533 --let $json_array = $sysvar_specs
534 --source $json_sysvar_start
535 while (!$json_sysvar_done) {
536 if ($cmdline) {
537 --let $json_array = $values
538 --let $json_start = 2
539 --source $json_value_start
540 --let $expect_value = $json_value_value
541
542 --source ../inc/assertions_for_sysvar_and_alias_value.inc
543 }
544
545 --source $json_sysvar_next
546 }
547
548 --echo
549 --echo ==== R3.2. Server restart with only new names on command line ====
550 --echo
551
552 --let $expect_source = COMMAND_LINE
553 --let $expect_persisted_json = noexists
554 --let $expect_persisted_ps = noexists
555
556 RESET PERSIST;
557 --source ../inc/load_persisted_json.inc
558
559 # Restart server.
560 --let $restart_parameters = restart:$command_line_names
561 --source include/restart_mysqld.inc
562 --let $error_pattern = NONE
563 --source include/assert_error_log.inc
564 # Iterate over variables and check them.
565 --let $json_array = $sysvar_specs
566 --source $json_sysvar_start
567 while (!$json_sysvar_done) {
568 if ($cmdline) {
569 --let $json_array = $values
570 --let $json_start = 2
571 --source $json_value_start
572 --let $expect_value = $json_value_value
573
574 --source ../inc/assertions_for_sysvar_and_alias_value.inc
575 }
576
577 --source $json_sysvar_next
578 }
579
580 --echo
581 --echo ==== R3.3. Server restart with only old names on command line ====
582 --echo * Also checking R4.3 (deprecation warning for old name on command line)
583 --echo
584
585 --let $expect_source = COMMAND_LINE
586 --let $expect_persisted_json = noexists
587 --let $expect_persisted_ps = noexists
588
589 RESET PERSIST;
590 --source ../inc/load_persisted_json.inc
591
592 # Restart server.
593 --let $restart_parameters = restart:$command_line_aliases
594 --source include/restart_mysqld.inc
595 --echo * R4.3: deprecation warnings when using old names on command line
596 --let $error_pattern = $command_line_deprecation_warnings
597 --source include/assert_error_log.inc
598 # Iterate over variables and check them.
599 --let $json_array = $sysvar_specs
600 --source $json_sysvar_start
601 while (!$json_sysvar_done) {
602 if ($cmdline) {
603 --let $json_array = $values
604 --let $json_start = 2
605 --source $json_value_start
606 --let $expect_value = $json_value_value
607
608 --source ../inc/assertions_for_sysvar_and_alias_value.inc
609 }
610
611 --source $json_sysvar_next
612 }
613
614 --echo #### Clean up ####
615
616 --source include/destroy_json_functions.inc
617 --let $restart_parameters = restart:
618 --source include/restart_mysqld.inc