summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test
blob: ed7f106c12311bfd90fbf3636bd835c9cdb7fab8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
--source include/galera_cluster.inc
--source include/have_innodb.inc

# Suppress expected warnings:

CALL mtr.add_suppression("Aborting");
CALL mtr.add_suppression("unknown option '--galera-unknown-option'");

# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--source include/auto_increment_offset_save.inc

#
# We should count the number of "Assertion failed" warnings
# in the log file before and after testing. To do this we need
# to save original log file before testing:
#
--let TEST_LOG=$MYSQLTEST_VARDIR/log/mysqld.2.err
--perl
   use strict;
   my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
   my $test_log_copy=$test_log . '.copy';
   if (-e $test_log_copy) {
      unlink $test_log_copy;
   }
EOF
--copy_file $TEST_LOG $TEST_LOG.copy

--connection node_2

CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a');

SELECT * FROM t1;

# Initiate normal shutdown on the node 2 and
# waiting until shutdown has been completed:

--echo Shutting down server ...
--source include/shutdown_mysqld.inc

--connection node_1

--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

# Some updates on node 1:

UPDATE t1 SET f2 = 'b' WHERE f1 > 1;
UPDATE t1 SET f2 = 'c' WHERE f1 > 2;

SELECT * FROM t1;

# Remove the "grastate.dat" file (to initiate new SST)
# and restart node 2 with unknown option:

--connection node_2

--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat

--let $start_mysqld_params=--galera-unknown-option

--echo Starting server ...
--exec echo "try:$start_mysqld_params" > $_expect_file_name

# Sleep to ensure that server exited...

--sleep 30

# Restart node 2 without unknown option:

--let $start_mysqld_params=

--echo Starting server ...
--source include/start_mysqld.inc

--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

# Sanity check (node 2 is running now and can perform SQL operators):

SELECT * FROM t1;

# Initiate normal shutdown on the node 2 and
# waiting until shutdown has been completed:

--echo Shutting down server ...
--source include/shutdown_mysqld.inc

--connection node_1

--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

# Some updates on node 1 - to initiate IST next time:

UPDATE t1 SET f2 = 'd' WHERE f1 > 1;
UPDATE t1 SET f2 = 'd' WHERE f1 > 2;

SELECT * FROM t1;

# Restart node 2 with unknown option:

--connection node_2

--let $start_mysqld_params=--galera-unknown-option

--echo Starting server ...
--exec echo "try:$start_mysqld_params" > $_expect_file_name

# Sleep to ensure that server exited...

--sleep 30

# Restart node 2 without unknown option:

--let $start_mysqld_params=

--echo Starting server ...
--source include/start_mysqld.inc

--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

# Sanity check (node 2 is running now and can perform SQL operators):

SELECT * FROM t1;

--connection node_1

DROP TABLE t1;
--source include/auto_increment_offset_restore.inc

#
# We should count the number of "Assertion failed" warnings
# in the log file during test phase - to print the error message
# if quantity of such warnings in log file increased at the end
# of the test:
#
--perl
   use strict;
   my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
   my $test_log_copy=$test_log . '.copy';
   open(FILE, $test_log_copy) or die("Unable to open $test_log_copy: $!\n");
   my $initial=grep(/Assertion * failed/gi,<FILE>);
   close(FILE);
   open(FILE, $test_log) or die("Unable to open $test_log: $!\n");
   my $count_warnings=grep(/Assertion * failed/gi,<FILE>);
   close(FILE);
   if ($count_warnings != $initial) {
      my $diff=$count_warnings-$initial;
      print "Assertion failed $diff times.\n";
   }
EOF
--remove_file $TEST_LOG.copy

--source include/auto_increment_offset_restore.inc