summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMagnus Svensson <msvensson@mysql.com>2008-08-04 22:25:45 +0200
committerMagnus Svensson <msvensson@mysql.com>2008-08-04 22:25:45 +0200
commited8bc526aefee79be003676ec544c6baf904fd12 (patch)
treecac0c8650787148caef0ca6a3c90a4680d7fa260 /mysql-test
parentafbbe64aae7755122fb8a43c282b0aea3ee17ed4 (diff)
parent39ad2dc05ae2cf6798d60397e82cddba16ddb244 (diff)
downloadmariadb-git-ed8bc526aefee79be003676ec544c6baf904fd12.tar.gz
Merge
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/include/analyze-sync_with_master.test6
-rw-r--r--mysql-test/include/analyze_failure_sync_with_master.test15
-rw-r--r--mysql-test/include/mysqltest-x.inc1
-rw-r--r--mysql-test/lib/mtr_cases.pm12
-rw-r--r--mysql-test/lib/mtr_report.pm50
-rwxr-xr-xmysql-test/mysql-test-run.pl184
-rw-r--r--mysql-test/r/mysqltest.result10
-rw-r--r--mysql-test/t/fix_priv_tables.test3
-rw-r--r--mysql-test/t/mysqltest.test20
-rw-r--r--mysql-test/t/openssl_1.test8
10 files changed, 246 insertions, 63 deletions
diff --git a/mysql-test/include/analyze-sync_with_master.test b/mysql-test/include/analyze-sync_with_master.test
new file mode 100644
index 00000000000..684c0dbbab7
--- /dev/null
+++ b/mysql-test/include/analyze-sync_with_master.test
@@ -0,0 +1,6 @@
+SHOW PROCESSLIST;
+
+let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
+eval SHOW BINLOG EVENTS IN '$binlog_name';
+
+exit; \ No newline at end of file
diff --git a/mysql-test/include/analyze_failure_sync_with_master.test b/mysql-test/include/analyze_failure_sync_with_master.test
deleted file mode 100644
index e6fd32d2f46..00000000000
--- a/mysql-test/include/analyze_failure_sync_with_master.test
+++ /dev/null
@@ -1,15 +0,0 @@
-# Connect to both master and slave
-connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
-connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
-
-vertical_results;
-
-echo == MASTER ===========================================================;
-connection master;
-show master status;
-show slave status;
-
-echo == SLAVE ===========================================================;
-connection slave;
-show master status;
-show slave status;
diff --git a/mysql-test/include/mysqltest-x.inc b/mysql-test/include/mysqltest-x.inc
index dd1468aed07..797c5c39f3f 100644
--- a/mysql-test/include/mysqltest-x.inc
+++ b/mysql-test/include/mysqltest-x.inc
@@ -1,2 +1,3 @@
echo Output from mysqltest-x.inc;
+exit;
diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
index 863c3c71adb..93236e483a1 100644
--- a/mysql-test/lib/mtr_cases.pm
+++ b/mysql-test/lib/mtr_cases.pm
@@ -690,12 +690,16 @@ sub collect_one_test_case {
name => "$suitename.$tname",
path => "$testdir/$filename",
- # TODO allow nonexistsing result file
- # in that case .test must issue "exit" otherwise test
- # should fail by default
- result_file => "$resdir/$tname.result",
);
+ my $result_file= "$resdir/$tname.result";
+ if (-f $result_file) {
+ # Allow nonexistsing result file
+ # in that case .test must issue "exit" otherwise test
+ # should fail by default
+ $tinfo->{result_file}= $result_file;
+ }
+
# ----------------------------------------------------------------------
# Skip some tests but include in list, just mark them as skipped
# ----------------------------------------------------------------------
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index b5c868cb20a..6a46a372c45 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -103,17 +103,24 @@ sub mtr_report_test ($) {
my ($tinfo)= @_;
_mtr_report_test_name($tinfo);
- if ($tinfo->{'result'} eq 'MTR_RES_FAILED'){
+ my $comment= $tinfo->{'comment'};
+ my $logfile= $tinfo->{'logfile'};
+ my $warnings= $tinfo->{'warnings'};
+ my $result= $tinfo->{'result'};
- if ( defined $tinfo->{'warnings'} )
+ if ($result eq 'MTR_RES_FAILED'){
+
+ if ( $warnings )
{
mtr_report("[ fail ] Found warnings in server log file!");
- mtr_report($tinfo->{'warnings'});
+ mtr_report($warnings);
return;
}
- if ( defined $tinfo->{'timeout'} )
+ my $timeout= $tinfo->{'timeout'};
+ if ( $timeout )
{
- mtr_report("[ fail ] timeout");
+ mtr_report("[ fail ] timeout after $timeout minutes");
+ mtr_report("\n$tinfo->{'comment'}");
return;
}
else
@@ -121,43 +128,42 @@ sub mtr_report_test ($) {
mtr_report("[ fail ]");
}
- if ( $tinfo->{'comment'} )
+ if ( $logfile )
+ {
+ # Test failure was detected by test tool and its report
+ # about what failed has been saved to file. Display the report.
+ mtr_report("\n$logfile\n");
+ }
+ if ( $comment )
{
# The test failure has been detected by mysql-test-run.pl
# when starting the servers or due to other error, the reason for
# failing the test is saved in "comment"
- mtr_report("\nERROR: $tinfo->{'comment'}");
+ mtr_report("\n$comment\n");
}
- elsif ( $tinfo->{logfile} )
- {
- # Test failure was detected by test tool and its report
- # about what failed has been saved to file. Display the report.
- mtr_report("\n");
- mtr_report($tinfo->{logfile}, "\n");
- }
- else
+ if ( !$logfile and !$comment )
{
# Neither this script or the test tool has recorded info
# about why the test has failed. Should be debugged.
- mtr_report("\nUnexpected termination, probably when starting mysqld");;
+ mtr_report("\nUnknown result, neither 'comment' or 'logfile' set");
}
}
- elsif ($tinfo->{'result'} eq 'MTR_RES_SKIPPED')
+ elsif ($result eq 'MTR_RES_SKIPPED')
{
if ( $tinfo->{'disable'} )
{
- mtr_report("[ disabled ] $tinfo->{'comment'}");
+ mtr_report("[ disabled ] $comment");
}
- elsif ( $tinfo->{'comment'} )
+ elsif ( $comment )
{
if ( $tinfo->{skip_detected_by_test} )
{
- mtr_report("[ skip ]. $tinfo->{'comment'}");
+ mtr_report("[ skip ]. $comment");
}
else
{
- mtr_report("[ skip ] $tinfo->{'comment'}");
+ mtr_report("[ skip ] $comment");
}
}
else
@@ -165,7 +171,7 @@ sub mtr_report_test ($) {
mtr_report("[ skip ]");
}
}
- elsif ($tinfo->{'result'} eq 'MTR_RES_PASSED')
+ elsif ($result eq 'MTR_RES_PASSED')
{
my $timer_str= $tinfo->{timer} || "";
$tot_real_time += ($timer_str/1000);
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index af62536e462..0e30d045781 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -164,7 +164,7 @@ my $opt_repeat= 1;
my $opt_retry= 3;
my $opt_retry_failure= 2;
-my $opt_parallel;
+my $opt_parallel= $ENV{MTR_PARALLEL};
my $opt_strace_client;
@@ -291,8 +291,9 @@ sub main {
my $tinfo = My::Test->new
(
name => 'report_features',
- result_file => undef, # Prints result
+ # No result_file => Prints result
path => 'include/report-features.test'.
+ template_path => "include/default_my.cnf",
master_opt => [],
slave_opt => [],
);
@@ -615,6 +616,7 @@ sub run_worker ($) {
}
setup_vardir();
+ check_running_as_root();
mysql_install_db($thread_num);
if ( using_extern() ) {
@@ -2332,7 +2334,6 @@ sub initialize_servers {
mysql_install_db(0);
}
}
- check_running_as_root();
}
@@ -2691,6 +2692,120 @@ sub check_testcase($$)
}
+# Start run mysqltest on one server
+#
+# RETURN VALUE
+# 0 OK
+# 1 Check failed
+#
+sub start_run_one ($$) {
+ my ($mysqld, $run)= @_;
+
+ my $name= "$run-".$mysqld->name();
+
+ my $args;
+ mtr_init_args(\$args);
+
+ mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
+ mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
+
+ mtr_add_arg($args, "--silent");
+ mtr_add_arg($args, "--skip-safemalloc");
+ mtr_add_arg($args, "--test-file=%s", "include/$run.test");
+
+ my $errfile= "$opt_vardir/tmp/$name.err";
+ my $proc= My::SafeProcess->new
+ (
+ name => $name,
+ path => $exe_mysqltest,
+ error => $errfile,
+ output => $errfile,
+ args => \$args,
+ user_data => $errfile,
+ );
+ mtr_verbose("Started $proc");
+ return $proc;
+}
+
+
+#
+# Run script on all servers, collect results
+#
+# RETURN VALUE
+# 0 ok
+# 1 Failure
+
+sub run_on_all($$)
+{
+ my ($tinfo, $run)= @_;
+ my $tname= $tinfo->{name};
+
+ # Start the mysqltest processes in parallel to save time
+ # also makes it possible to wait for any process to exit during the check
+ # and to have a timeout process
+ my %started;
+ foreach my $mysqld ( mysqlds() )
+ {
+ if ( defined $mysqld->{'proc'} )
+ {
+ my $proc= start_run_one($mysqld, $run);
+ $started{$proc->pid()}= $proc;
+ }
+ }
+
+ # Return immediately if no check proceess was started
+ return 0 unless ( keys %started );
+
+ my $timeout_proc= My::SafeProcess->timer(60); # Seconds
+
+ while (1){
+ my $result;
+ my $proc= My::SafeProcess->wait_any();
+ mtr_report("Got $proc");
+
+ if ( delete $started{$proc->pid()} ) {
+
+ # One mysqltest process returned
+ my $err_file= $proc->user_data();
+ my $res= $proc->exit_status();
+
+ # Append the report from .err file
+ $tinfo->{comment}.= " == $err_file ==\n";
+ $tinfo->{comment}.= mtr_grab_file($err_file);
+ $tinfo->{comment}.= "\n";
+
+ # Remove the .err file
+ unlink($err_file);
+
+ if ( keys(%started) == 0){
+ # All completed
+ $timeout_proc->kill();
+ return 0;
+ }
+
+ # Wait for next process to exit
+ next;
+ }
+ elsif ( $proc eq $timeout_proc ) {
+ $tinfo->{comment}.= "Timeout $timeout_proc expired for running '$run'";
+ }
+ else {
+ # Unknown process returned, most likley a crash, abort everything
+ $tinfo->{comment}.=
+ "Unexpected process $proc returned during ".
+ "execution of '$run'";
+ }
+
+ # Kill any check processes still running
+ map($_->kill(), values(%started));
+
+ $timeout_proc->kill();
+
+ return 1;
+ }
+}
+
+
sub mark_log {
my ($log, $tinfo)= @_;
my $log_msg= "CURRENT_TEST: $tinfo->{name}\n";
@@ -2728,6 +2843,26 @@ sub find_testcase_skipped_reason($)
}
+sub find_analyze_request
+{
+ # Open the test log file
+ my $F= IO::File->new($path_current_testlog)
+ or return;
+ my $analyze;
+
+ while ( my $line= <$F> )
+ {
+ # Look for "reason: <reason for skipping test>"
+ if ( $line =~ /analyze: (.*)/ )
+ {
+ $analyze= $1;
+ }
+ }
+
+ return $analyze;
+}
+
+
# Return timezone value of tinfo or default value
sub timezone {
my ($tinfo)= @_;
@@ -2931,6 +3066,13 @@ sub run_testcase ($) {
}
elsif ( $res == 1 )
{
+ # Check if the test tool requests that
+ # an analyze script should be run
+ my $analyze= find_analyze_request();
+ if ($analyze){
+ run_on_all($tinfo, "analyze-$analyze");
+ }
+
# Test case failure reported by mysqltest
report_failure_and_restart($tinfo);
}
@@ -2989,8 +3131,10 @@ sub run_testcase ($) {
# ----------------------------------------------------
if ( $proc eq $test_timeout_proc )
{
- mtr_report("Test case timeout!");
- $tinfo->{'timeout'}= 1; # Mark as timeout
+ $tinfo->{comment}=
+ "Test case timeout after $opt_testcase_timeout minute(s)\n\n";
+ $tinfo->{'timeout'}= $opt_testcase_timeout; # Mark as timeout
+ run_on_all($tinfo, 'analyze-timeout');
report_failure_and_restart($tinfo);
return 1;
}
@@ -3307,7 +3451,6 @@ sub report_failure_and_restart ($) {
$tinfo->{'failures'}= $test_failures + 1;
- my $logfile= $path_current_testlog;
if ( $tinfo->{comment} )
{
# The test failure has been detected by mysql-test-run.pl
@@ -3315,12 +3458,17 @@ sub report_failure_and_restart ($) {
# failing the test is saved in "comment"
;
}
- elsif ( defined $logfile and -f $logfile )
+
+ if ( !defined $tinfo->{logfile} )
{
- # Test failure was detected by test tool and its report
- # about what failed has been saved to file. Save the report
- # in tinfo
- $tinfo->{logfile}= mtr_fromfile($logfile);
+ my $logfile= $path_current_testlog;
+ if ( defined $logfile and -f $logfile )
+ {
+ # Test failure was detected by test tool and its report
+ # about what failed has been saved to file. Save the report
+ # in tinfo
+ $tinfo->{logfile}= mtr_fromfile($logfile);
+ }
}
after_failure($tinfo);
@@ -3898,6 +4046,16 @@ sub start_servers($) {
$mysqld->{'proc'}) == 0) {
$tinfo->{comment}=
"Failed to start ".$mysqld->name();
+
+ my $logfile= $mysqld->value('log-error');
+ if ( defined $logfile and -f $logfile )
+ {
+ $tinfo->{logfile}= mtr_fromfile($logfile);
+ }
+ else
+ {
+ $tinfo->{logfile}= "Could not open server logfile: '$logfile'";
+ }
return 1;
}
}
@@ -4018,8 +4176,6 @@ sub start_mysqltest ($) {
mtr_add_arg($args, "--sleep=%d", $opt_sleep);
}
- client_debug_arg($args, "mysqltest");
-
if ( $opt_ssl )
{
# Turn on SSL for _all_ test cases if option --ssl was used
@@ -4075,6 +4231,8 @@ sub start_mysqltest ($) {
mtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
}
+ client_debug_arg($args, "mysqltest");
+
if ( $opt_record )
{
mtr_add_arg($args, "--record");
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index fc1dc5c0863..26b9044a499 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -486,8 +486,6 @@ mysqltest: At line 3: query 'create table t1 (a int primary key);
insert into t1 values (1);
select 'select-me';
insertz 'error query'' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insertz 'error query'' at line 1
-
-More results from queries before failure can be found in MYSQLTEST_VARDIR/log/bug11731.log
drop table t1;
Multi statement using expected error
create table t1 (a int primary key);
@@ -730,4 +728,12 @@ col
z
hej
mysqltest: At line 1: Found junk ' != 143' after $variable in expression
+select 1;
+1
+1
+select 1;
+1
+1
+-- a comment for the server;
+mysqltest: At line 1: Found line beginning with -- that didn't contain a valid mysqltest command, check your syntax or use # if you intended to write a comment
End of tests
diff --git a/mysql-test/t/fix_priv_tables.test b/mysql-test/t/fix_priv_tables.test
index 3051fd88076..c7cd500f8d2 100644
--- a/mysql-test/t/fix_priv_tables.test
+++ b/mysql-test/t/fix_priv_tables.test
@@ -51,7 +51,8 @@ echo;
-- disable_query_log
# Run the mysql_fix_privilege_tables.sql using "mysql --force"
---exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/fix_priv_tables.log 2>&1
+--exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log 2>&1
+--remove_file $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log
-- enable_query_log
-- enable_result_log
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 1bc6a4a625a..0253b5818ee 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -1225,7 +1225,7 @@ select "a" as col1, "c" as col2;
--exec echo "replace_result a;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "replace_result a ;" | $MYSQL_TEST 2>&1
---exec echo "replace_result a b; echo OK;" | $MYSQL_TEST 2>&1
+--exec echo "replace_result a b; echo OK; exit;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1
--error 1
@@ -1289,7 +1289,7 @@ while ($i)
dec $i;
}
EOF
---exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $MYSQL_TEST 2>&1
+--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK; exit;" | $MYSQL_TEST 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
# Repeat connect/disconnect
@@ -1496,6 +1496,7 @@ echo Multi statement using expected error;
--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
+--exec echo "exit;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
# These two should work since the error is expected
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
@@ -1688,6 +1689,7 @@ EOF
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp
--error 1
--diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
+exit;
EOF
# Execute the above diffs, and send their output to /dev/null - only
@@ -2151,5 +2153,19 @@ EOF
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
+# ----------------------------------------------------------------------------
+# Test that -- is not allowed as comment, only as mysqltest builtin command
+# ----------------------------------------------------------------------------
+
+# valid
+select 1;
+--query select 1
+--query -- a comment for the server
+
+# Not valid, "select" is not a mysqltest command
+--error 1
+--exec echo "--select 1;" | $MYSQL_TEST 2>&1
+
+
--echo End of tests
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index 111c723e19c..a76f62c9611 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -101,7 +101,7 @@ drop table t1;
# - Apparently selecting a cipher doesn't work at all
# - Usa a cipher that both yaSSL and OpenSSL supports
#
---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql
+--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit;" > $MYSQLTEST_VARDIR/tmp/test.sql
--exec $MYSQL_TEST --ssl-cipher=DHE-RSA-AES256-SHA < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
#
@@ -155,18 +155,18 @@ SET GLOBAL event_scheduler=0;
#
# Test to connect using a list of ciphers
#
---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql
+--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit;" > $MYSQLTEST_VARDIR/tmp/test.sql
--exec $MYSQL_TEST --ssl-cipher=UNKNOWN-CIPHER:AES128-SHA < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
# Test to connect using a specifi cipher
#
---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql
+--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit;" > $MYSQLTEST_VARDIR/tmp/test.sql
--exec $MYSQL_TEST --ssl-cipher=AES128-SHA < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
# Test to connect using an unknown cipher
#
---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql
+--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit" > $MYSQLTEST_VARDIR/tmp/test.sql
--error 1
--exec $MYSQL_TEST --ssl-cipher=UNKNOWN-CIPHER < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1