summaryrefslogtreecommitdiff
path: root/mysql-test/include
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-04-28 12:22:32 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-04-28 12:22:32 +0300
commitf740d23ce6574bf57449aa48b22d6345f35ad2c0 (patch)
tree85eb18f1464b3dc76e571354401a2072cb8c8ba0 /mysql-test/include
parente21c15a7e626b5c01d9770d82aaed56053c7baef (diff)
parent97e0c260dc8273f809915505f8dfdccd948b4b99 (diff)
downloadmariadb-git-f740d23ce6574bf57449aa48b22d6345f35ad2c0.tar.gz
Merge 10.1 into 10.2
Diffstat (limited to 'mysql-test/include')
-rw-r--r--mysql-test/include/assert_grep.inc154
-rw-r--r--mysql-test/include/diff_servers.inc67
-rw-r--r--mysql-test/include/galera_wait_ready.inc2
-rw-r--r--mysql-test/include/mysqlhotcopy.inc2
4 files changed, 224 insertions, 1 deletions
diff --git a/mysql-test/include/assert_grep.inc b/mysql-test/include/assert_grep.inc
new file mode 100644
index 00000000000..a980a6d73b1
--- /dev/null
+++ b/mysql-test/include/assert_grep.inc
@@ -0,0 +1,154 @@
+# ==== Purpose ====
+#
+# Grep a file for a pattern, produce a single string out of the
+# matching lines, and assert that the string matches a given regular
+# expression.
+#
+# ==== Usage ====
+#
+# --let $assert_text= TEXT
+# --let $assert_file= FILE
+# --let $assert_select= REGEX
+# [--let $assert_match= REGEX | --let $assert_count= NUMBER]
+# [--let $assert_only_after= REGEX]
+# --source include/assert_grep.inc
+#
+# Parameters:
+#
+# $assert_text
+# Text that describes what is being checked. This text is written to
+# the query log so it should not contain non-deterministic elements.
+#
+# $assert_file
+# File to search.
+#
+# $assert_select
+# All lines matching this text will be checked.
+#
+# $assert_match
+# The script will find all lines that match $assert_select,
+# concatenate them to a long string, and assert that it matches
+# $assert_match.
+#
+# $assert_count
+# Instead of asserting that the selected lines match
+# $assert_match, assert that there were exactly $assert_count
+# matching lines.
+#
+# $assert_only_after
+# Reset all the lines matched and the counter when finding this pattern.
+# It is useful for searching things in the mysqld.err log file just
+# after the last server restart for example (discarding the log content
+# of previous server executions).
+
+
+if (!$assert_text)
+{
+ --die !!!ERROR IN TEST: you must set $assert_text
+}
+if (!$assert_file)
+{
+ --die !!!ERROR IN TEST: you must set $assert_file
+}
+if (!$assert_select)
+{
+ --die !!!ERROR IN TEST: you must set $assert_select
+}
+if ($assert_match == '')
+{
+ if ($assert_count == '')
+ {
+ --die !!!ERROR IN TEST: you must set either $assert_match or $assert_count
+ }
+}
+if ($assert_match != '')
+{
+ if ($assert_count != '')
+ {
+ --echo assert_text='$assert_text' assert_count='$assert_count'
+ --die !!!ERROR IN TEST: you must set only one of $assert_match or $assert_count
+ }
+}
+
+
+--let $include_filename= assert_grep.inc [$assert_text]
+--source include/begin_include_file.inc
+
+
+--let _AG_ASSERT_TEXT= $assert_text
+--let _AG_ASSERT_FILE= $assert_file
+--let _AG_ASSERT_SELECT= $assert_select
+--let _AG_ASSERT_MATCH= $assert_match
+--let _AG_ASSERT_COUNT= $assert_count
+--let _AG_OUT= `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/_ag_', UUID())`
+--let _AG_ASSERT_ONLY_AFTER= $assert_only_after
+
+
+--perl
+ use strict;
+ use warnings;
+ my $file= $ENV{'_AG_ASSERT_FILE'};
+ my $assert_select= $ENV{'_AG_ASSERT_SELECT'};
+ my $assert_match= $ENV{'_AG_ASSERT_MATCH'};
+ my $assert_count= $ENV{'_AG_ASSERT_COUNT'};
+ my $assert_only_after= $ENV{'_AG_ASSERT_ONLY_AFTER'};
+ my $out= $ENV{'_AG_OUT'};
+
+ my $result= '';
+ my $count= 0;
+ open(FILE, "$file") or die("Error $? opening $file: $!\n");
+ while (<FILE>) {
+ my $line = $_;
+ if ($assert_only_after && $line =~ /$assert_only_after/) {
+ $result = "";
+ $count = 0;
+ }
+ if ($line =~ /$assert_select/) {
+ if ($assert_count ne '') {
+ $count++;
+ }
+ else {
+ $result .= $line;
+ }
+ }
+ }
+ close(FILE) or die("Error $? closing $file: $!");
+ open OUT, "> $out" or die("Error $? opening $out: $!");
+ if ($assert_count ne '' && ($count != $assert_count)) {
+ print OUT ($count) or die("Error $? writing $out: $!");
+ }
+ elsif ($assert_count eq '' && $result !~ /$assert_match/) {
+ print OUT ($result) or die("Error $? writing $out: $!");
+ }
+ else {
+ print OUT ("assert_grep.inc ok");
+ }
+ close OUT or die("Error $? closing $out: $!");
+EOF
+
+
+--let $_ag_outcome= `SELECT LOAD_FILE('$_AG_OUT')`
+if ($_ag_outcome != 'assert_grep.inc ok')
+{
+ --source include/show_rpl_debug_info.inc
+ --echo include/assert_grep.inc failed!
+ --echo assert_text: '$assert_text'
+ --echo assert_file: '$assert_file'
+ --echo assert_select: '$assert_select'
+ --echo assert_match: '$assert_match'
+ --echo assert_count: '$assert_count'
+ --echo assert_only_after: '$assert_only_after'
+ if ($assert_match != '')
+ {
+ --echo matching lines: '$_ag_outcome'
+ }
+ if ($assert_count != '')
+ {
+ --echo number of matching lines: $_ag_outcome
+ }
+ --die assert_grep.inc failed.
+}
+
+
+--let $include_filename= include/assert_grep.inc [$assert_text]
+--source include/end_include_file.inc
diff --git a/mysql-test/include/diff_servers.inc b/mysql-test/include/diff_servers.inc
new file mode 100644
index 00000000000..5ec7efc38b9
--- /dev/null
+++ b/mysql-test/include/diff_servers.inc
@@ -0,0 +1,67 @@
+# ==== Purpose ====
+#
+# Check that two or more servers have identical databases; fail if not.
+#
+# ==== Usage ====
+#
+# --let $diff_servers= 1 2
+# [--let $databases= db1 db2 ...]
+# [--let $rpl_debug= 1]
+# --source include/diff_servers.inc
+
+# pretty-print header
+--let $_ds_info= servers=$diff_servers
+if ($databases != '')
+{
+ --let $_ds_info= $_ds_info databases=$databases
+}
+--let $include_filename= diff_servers.inc [$_ds_info]
+--source include/begin_include_file.inc
+
+# get databases
+--let $_ds_databases= $diff_database
+if ($_ds_databases == '')
+{
+ --let $_ds_databases= `SELECT GROUP_CONCAT(SCHEMA_NAME SEPARATOR ' ') FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'mtr', 'mysql', 'performance_schema')`
+}
+
+# generate command line
+--let $_ds_arg= --defaults-group-suffix=.
+--let $_ds_number_pos= `SELECT LOCATE('$_ds_arg', '$MYSQL_DUMP') + LENGTH('$_ds_arg')`
+--let $_ds_pre_command= `SELECT SUBSTR('$MYSQL_DUMP', 1, $_ds_number_pos - 1)`
+--let $_ds_post_command= `SELECT SUBSTR('$MYSQL_DUMP', $_ds_number_pos + 1)`
+--let $_ds_post_command= $_ds_post_command --compact --order-by-primary --skip-extended-insert --no-create-info --databases $_ds_databases
+--let $_ds_prev_outfile=
+
+# iterate over servers
+--let $_ds_servers= $diff_servers
+while ($_ds_servers != '')
+{
+ --let $_ds_server_number= `SELECT SUBSTRING_INDEX('$_ds_servers', ' ', 1)`
+ --let $_ds_servers= `SELECT TRIM(SUBSTRING('$_ds_servers', 1 + LENGTH('_$ds_server_number')))`
+ --let $_ds_outfile= $MYSQLTEST_VARDIR/tmp/diff_servers_$_ds_server_number
+
+ if ($rpl_debug)
+ {
+ --echo generating dump from server '$_ds_server_number' using command '$_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile'
+ --echo remaining servers: '$_ds_servers'
+ }
+ --exec $_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile
+
+ if ($_ds_prev_outfile != '')
+ {
+ if ($rpl_debug)
+ {
+ --echo diffing files '$_ds_prev_outfile' and '$_ds_outfile'
+ }
+ --diff_files $_ds_prev_outfile $_ds_outfile
+
+ --remove_file $_ds_prev_outfile
+ }
+ --let $_ds_prev_outfile= $_ds_outfile
+}
+
+--remove_file $_ds_prev_outfile
+
+--let $include_filename= diff_servers.inc [servers=$_ds_info]
+--source include/end_include_file.inc
diff --git a/mysql-test/include/galera_wait_ready.inc b/mysql-test/include/galera_wait_ready.inc
new file mode 100644
index 00000000000..e20f01fad90
--- /dev/null
+++ b/mysql-test/include/galera_wait_ready.inc
@@ -0,0 +1,2 @@
+let $wait_condition = SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' AND VARIABLE_VALUE = 'ON';
+--source include/wait_condition.inc
diff --git a/mysql-test/include/mysqlhotcopy.inc b/mysql-test/include/mysqlhotcopy.inc
index f775d782b28..2fc14d599d9 100644
--- a/mysql-test/include/mysqlhotcopy.inc
+++ b/mysql-test/include/mysqlhotcopy.inc
@@ -109,7 +109,7 @@ DROP DATABASE hotcopy_save;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
--list_files $MYSQLD_DATADIR/hotcopy_save
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
---error 1
+--error 1,9,11,110,2304,255
--exec $MYSQLHOTCOPY --quiet -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save
--replace_result $MASTER_MYSOCK MASTER_MYSOCK
--exec $MYSQLHOTCOPY --quiet --allowold -S $MASTER_MYSOCK -u root hotcopy_test hotcopy_save