Debian Codegraph @

mysql-test/suite/galera/t/galera_restart_on_unknown_option.test

raw
1 --source include/galera_cluster.inc
2 --source include/have_innodb.inc
3
4 # Suppress expected warnings:
5
6 CALL mtr.add_suppression("Aborting");
7 CALL mtr.add_suppression("unknown option '--galera-unknown-option'");
8
9 # Save original auto_increment_offset values.
10 --let $node_1=node_1
11 --let $node_2=node_2
12 --source include/auto_increment_offset_save.inc
13
14 #
15 # We should count the number of "Assertion failed" warnings
16 # in the log file before and after testing. To do this we need
17 # to save original log file before testing:
18 #
19 --let TEST_LOG=$MYSQLTEST_VARDIR/log/mysqld.2.err
20 --perl
21 use strict;
22 my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
23 my $test_log_copy=$test_log . '.copy';
24 if (-e $test_log_copy) {
25 unlink $test_log_copy;
26 }
27 EOF
28 --copy_file $TEST_LOG $TEST_LOG.copy
29
30 --connection node_2
31
32 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
33 INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a');
34
35 SELECT * FROM t1;
36
37 # Initiate normal shutdown on the node 2 and
38 # waiting until shutdown has been completed:
39
40 --echo Shutting down server ...
41 --source include/shutdown_mysqld.inc
42
43 --connection node_1
44
45 --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
46 --source include/wait_condition.inc
47
48 # Some updates on node 1:
49
50 UPDATE t1 SET f2 = 'b' WHERE f1 > 1;
51 UPDATE t1 SET f2 = 'c' WHERE f1 > 2;
52
53 SELECT * FROM t1;
54
55 # Remove the "grastate.dat" file (to initiate new SST)
56 # and restart node 2 with unknown option:
57
58 --connection node_2
59
60 --remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
61
62 --let $start_mysqld_params=--galera-unknown-option
63
64 --echo Starting server ...
65 --write_line "try:$start_mysqld_params" $_expect_file_name
66
67 # Sleep to ensure that server exited...
68
69 --sleep 30
70
71 # Restart node 2 without unknown option:
72
73 --let $start_mysqld_params=
74
75 --echo Starting server ...
76 --source include/start_mysqld.inc
77
78 --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
79 --source include/wait_condition.inc
80
81 # Sanity check (node 2 is running now and can perform SQL operators):
82
83 SELECT * FROM t1;
84
85 # Initiate normal shutdown on the node 2 and
86 # waiting until shutdown has been completed:
87
88 --echo Shutting down server ...
89 --source include/shutdown_mysqld.inc
90
91 --connection node_1
92
93 --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
94 --source include/wait_condition.inc
95
96 # Some updates on node 1 - to initiate IST next time:
97
98 UPDATE t1 SET f2 = 'd' WHERE f1 > 1;
99 UPDATE t1 SET f2 = 'd' WHERE f1 > 2;
100
101 SELECT * FROM t1;
102
103 # Restart node 2 with unknown option:
104
105 --connection node_2
106
107 --let $start_mysqld_params=--galera-unknown-option
108
109 --echo Starting server ...
110 --write_line "try:$start_mysqld_params" $_expect_file_name
111
112 # Sleep to ensure that server exited...
113
114 --sleep 30
115
116 # Restart node 2 without unknown option:
117
118 --let $start_mysqld_params=
119
120 --echo Starting server ...
121 --source include/start_mysqld.inc
122
123 --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
124 --source include/wait_condition.inc
125
126 # Sanity check (node 2 is running now and can perform SQL operators):
127
128 call mtr.add_suppression("WSREP: Failed to scan the last segment to the end\\. Last events may be missing\\. Last recovered event: ");
129 SELECT * FROM t1;
130
131 --connection node_1
132
133 DROP TABLE t1;
134 --source include/auto_increment_offset_restore.inc
135
136 #
137 # We should count the number of "Assertion failed" warnings
138 # in the log file during test phase - to print the error message
139 # if quantity of such warnings in log file increased at the end
140 # of the test:
141 #
142 --perl
143 use strict;
144 my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
145 my $test_log_copy=$test_log . '.copy';
146 open(FILE, $test_log_copy) or die("Unable to open $test_log_copy: $!\n");
147 my $initial=grep(/Assertion * failed/gi,<FILE>);
148 close(FILE);
149 open(FILE, $test_log) or die("Unable to open $test_log: $!\n");
150 my $count_warnings=grep(/Assertion * failed/gi,<FILE>);
151 close(FILE);
152 if ($count_warnings != $initial) {
153 my $diff=$count_warnings-$initial;
154 print "Assertion failed $diff times.\n";
155 }
156 EOF
157 --remove_file $TEST_LOG.copy
158
159 --source include/auto_increment_offset_restore.inc