Skip to content

Commit 2e889de

Browse files
Fix test cases in galera suite
Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
1 parent 969fc61 commit 2e889de

File tree

4 files changed

+160
-4
lines changed

4 files changed

+160
-4
lines changed

mysql-test/include/assert_grep.inc

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# ==== Purpose ====
2+
#
3+
# Grep a file for a pattern, produce a single string out of the
4+
# matching lines, and assert that the string matches a given regular
5+
# expression.
6+
#
7+
# ==== Usage ====
8+
#
9+
# --let $assert_text= TEXT
10+
# --let $assert_file= FILE
11+
# --let $assert_select= REGEX
12+
# [--let $assert_match= REGEX | --let $assert_count= NUMBER]
13+
# [--let $assert_only_after= REGEX]
14+
# --source include/assert_grep.inc
15+
#
16+
# Parameters:
17+
#
18+
# $assert_text
19+
# Text that describes what is being checked. This text is written to
20+
# the query log so it should not contain non-deterministic elements.
21+
#
22+
# $assert_file
23+
# File to search.
24+
#
25+
# $assert_select
26+
# All lines matching this text will be checked.
27+
#
28+
# $assert_match
29+
# The script will find all lines that match $assert_select,
30+
# concatenate them to a long string, and assert that it matches
31+
# $assert_match.
32+
#
33+
# $assert_count
34+
# Instead of asserting that the selected lines match
35+
# $assert_match, assert that there were exactly $assert_count
36+
# matching lines.
37+
#
38+
# $assert_only_after
39+
# Reset all the lines matched and the counter when finding this pattern.
40+
# It is useful for searching things in the mysqld.err log file just
41+
# after the last server restart for example (discarding the log content
42+
# of previous server executions).
43+
44+
45+
if (!$assert_text)
46+
{
47+
--die !!!ERROR IN TEST: you must set $assert_text
48+
}
49+
if (!$assert_file)
50+
{
51+
--die !!!ERROR IN TEST: you must set $assert_file
52+
}
53+
if (!$assert_select)
54+
{
55+
--die !!!ERROR IN TEST: you must set $assert_select
56+
}
57+
if ($assert_match == '')
58+
{
59+
if ($assert_count == '')
60+
{
61+
--die !!!ERROR IN TEST: you must set either $assert_match or $assert_count
62+
}
63+
}
64+
if ($assert_match != '')
65+
{
66+
if ($assert_count != '')
67+
{
68+
--echo assert_text='$assert_text' assert_count='$assert_count'
69+
--die !!!ERROR IN TEST: you must set only one of $assert_match or $assert_count
70+
}
71+
}
72+
73+
74+
--let $include_filename= assert_grep.inc [$assert_text]
75+
--source include/begin_include_file.inc
76+
77+
78+
--let _AG_ASSERT_TEXT= $assert_text
79+
--let _AG_ASSERT_FILE= $assert_file
80+
--let _AG_ASSERT_SELECT= $assert_select
81+
--let _AG_ASSERT_MATCH= $assert_match
82+
--let _AG_ASSERT_COUNT= $assert_count
83+
--let _AG_OUT= `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/_ag_', UUID())`
84+
--let _AG_ASSERT_ONLY_AFTER= $assert_only_after
85+
86+
87+
--perl
88+
use strict;
89+
use warnings;
90+
my $file= $ENV{'_AG_ASSERT_FILE'};
91+
my $assert_select= $ENV{'_AG_ASSERT_SELECT'};
92+
my $assert_match= $ENV{'_AG_ASSERT_MATCH'};
93+
my $assert_count= $ENV{'_AG_ASSERT_COUNT'};
94+
my $assert_only_after= $ENV{'_AG_ASSERT_ONLY_AFTER'};
95+
my $out= $ENV{'_AG_OUT'};
96+
97+
my $result= '';
98+
my $count= 0;
99+
open(FILE, "$file") or die("Error $? opening $file: $!\n");
100+
while (<FILE>) {
101+
my $line = $_;
102+
if ($assert_only_after && $line =~ /$assert_only_after/) {
103+
$result = "";
104+
$count = 0;
105+
}
106+
if ($line =~ /$assert_select/) {
107+
if ($assert_count ne '') {
108+
$count++;
109+
}
110+
else {
111+
$result .= $line;
112+
}
113+
}
114+
}
115+
close(FILE) or die("Error $? closing $file: $!");
116+
open OUT, "> $out" or die("Error $? opening $out: $!");
117+
if ($assert_count ne '' && ($count != $assert_count)) {
118+
print OUT ($count) or die("Error $? writing $out: $!");
119+
}
120+
elsif ($assert_count eq '' && $result !~ /$assert_match/) {
121+
print OUT ($result) or die("Error $? writing $out: $!");
122+
}
123+
else {
124+
print OUT ("assert_grep.inc ok");
125+
}
126+
close OUT or die("Error $? closing $out: $!");
127+
EOF
128+
129+
130+
--let $_ag_outcome= `SELECT LOAD_FILE('$_AG_OUT')`
131+
if ($_ag_outcome != 'assert_grep.inc ok')
132+
{
133+
--source include/show_rpl_debug_info.inc
134+
--echo include/assert_grep.inc failed!
135+
--echo assert_text: '$assert_text'
136+
--echo assert_file: '$assert_file'
137+
--echo assert_select: '$assert_select'
138+
--echo assert_match: '$assert_match'
139+
--echo assert_count: '$assert_count'
140+
--echo assert_only_after: '$assert_only_after'
141+
if ($assert_match != '')
142+
{
143+
--echo matching lines: '$_ag_outcome'
144+
}
145+
if ($assert_count != '')
146+
{
147+
--echo number of matching lines: $_ag_outcome
148+
}
149+
--die assert_grep.inc failed.
150+
}
151+
152+
153+
--let $include_filename= include/assert_grep.inc [$assert_text]
154+
--source include/end_include_file.inc

mysql-test/suite/galera/r/GAL-401.result

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true';
22
SET @@global.wsrep_desync = 1;
3-
SET SESSION wsrep_sync_wait=0;
3+
SET SESSION wsrep_dirty_reads=1;
44
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
55
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
66
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
77
SHOW STATUS LIKE 'wsrep_desync_count';
88
Variable_name Value
99
wsrep_desync_count 0
1010
SET @@global.wsrep_desync = 0;
11-
SET SESSION wsrep_sync_wait=7;
1211
SHOW CREATE TABLE t1;
1312
Table Create Table
1413
t1 CREATE TABLE `t1` (

mysql-test/suite/galera/r/lp1376747-4.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
22
INSERT INTO t1 VALUES (1);
33
SET session wsrep_sync_wait=0;
44
SET session wsrep_causal_reads=OFF;
5+
Warnings:
6+
Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead
57
FLUSH TABLE WITH READ LOCK;
68
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
79
INSERT INTO t1 VALUES (2,3);
810
SET session wsrep_sync_wait=0;
911
SET session wsrep_causal_reads=OFF;
12+
Warnings:
13+
Warning 1287 '@@wsrep_causal_reads' is deprecated and will be removed in a future release. Please use '@@wsrep_sync_wait=1' instead
1014
SHOW CREATE TABLE t1;
1115
Table Create Table
1216
t1 CREATE TABLE `t1` (

mysql-test/suite/galera/t/GAL-401.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true';
99
# Desync and disconnect node 2 from the PC:
1010
--connection node_2
1111
SET @@global.wsrep_desync = 1;
12-
SET SESSION wsrep_sync_wait=0;
12+
SET SESSION wsrep_dirty_reads=1;
1313
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
1414
--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
1515
--source include/wait_condition.inc
@@ -41,7 +41,6 @@ SET @@global.wsrep_desync = 0;
4141
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
4242
--source include/wait_condition.inc
4343

44-
SET SESSION wsrep_sync_wait=7;
4544
SHOW CREATE TABLE t1;
4645
DROP TABLE t1;
4746
CALL mtr.add_suppression("WSREP: Protocol violation. JOIN message sender (.*) is not in state transfer \\(SYNCED\\). Message ignored.");

0 commit comments

Comments
 (0)