Commit 7db72512 authored by Sergei Golubchik's avatar Sergei Golubchik

mtr: support for rdiff files

parent 60a27449
......@@ -29,7 +29,6 @@ use mtr_report;
use mtr_match;
# Options used for the collect phase
our $start_from;
our $skip_rpl;
our $do_test;
our $skip_test;
......@@ -862,14 +861,17 @@ sub collect_one_test_case {
if ($tinfo->{combinations}) {
my $re = '(?:' . join('|', @{$tinfo->{combinations}}) . ')';
my $found = 0;
for (<$resdir/$tname,*.result>) {
m|$tname((?:,$re)+)\.result$| or next;
my $combs = $&;
for (<$resdir/$tname,*.{rdiff,result}>) {
my ($combs, $ext) = m@$tname((?:,$re)+)\.(rdiff|result)$@ or next;
my @commas = ($combs =~ m/,/g);
# prefer the most specific result file
if (@commas > $found) {
$found = @commas;
$tinfo->{result_file} = $_;
if ($ext eq 'rdiff' and not $::exe_patch) {
$tinfo->{skip} = 1;
$tinfo->{comment} = "requires patch executable";
}
}
}
}
......
......@@ -185,6 +185,7 @@ my $DEFAULT_SUITES= join(',', qw(
my $opt_suites;
our $opt_verbose= 0; # Verbose output, enable with --verbose
our $exe_patch;
our $exe_mysql;
our $exe_mysql_plugin;
our $exe_mysqladmin;
......@@ -2035,6 +2036,8 @@ sub find_mysqld {
sub executable_setup () {
$exe_patch='patch' if `patch -v`;
#
# Check if libtool is available in this distribution/clone
# we need it when valgrinding or debugging non installed binary
......@@ -2399,7 +2402,6 @@ sub environment_setup {
{
$ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."/std_data";
}
#
# Some stupid^H^H^H^H^H^Hignorant network providers set up "wildcard DNS"
......@@ -3229,7 +3231,8 @@ sub mysql_server_start($) {
# Run <tname>-master.sh
if ($mysqld->option('#!run-master-sh') and
run_sh_script($tinfo->{master_sh}) )
defined $tinfo->{master_sh} and
run_system('/bin/sh ' . $tinfo->{master_sh}) )
{
$tinfo->{'comment'}= "Failed to execute '$tinfo->{master_sh}'";
return 1;
......@@ -3237,7 +3240,8 @@ sub mysql_server_start($) {
# Run <tname>-slave.sh
if ($mysqld->option('#!run-slave-sh') and
run_sh_script($tinfo->{slave_sh}))
defined $tinfo->{slave_sh} and
run_system('/bin/sh ' . $tinfo->{slave_sh}))
{
$tinfo->{'comment'}= "Failed to execute '$tinfo->{slave_sh}'";
return 1;
......@@ -3710,16 +3714,35 @@ sub run_query {
sub do_before_run_mysqltest($)
{
my $tinfo= shift;
my $resfile= $tinfo->{result_file};
# Remove old files produced by mysqltest
my $base_file= mtr_match_extension($tinfo->{result_file},
"result"); # Trim extension
if (defined $base_file ){
unlink("$base_file.reject");
unlink("$base_file.progress");
unlink("$base_file.log");
unlink("$base_file.warnings");
die "unsupported result file name $resfile, stoping" unless
$resfile =~ /^(.*)\.(rdiff|result)$/;
my $base_file= $1;
# if the result file is a diff, make a proper result file
if ($2 eq 'rdiff') {
my $resdir= dirname($resfile);
# we'll use a separate extension for generated result files
# to be able to distinguish them from manually created version
# controlled results, and to ignore them in bzr.
my $dest = "$base_file.result~";
if (-w $resdir) {
# don't rebuild a file if it's up to date
unless (-e $dest and -M $dest < -M $resfile) {
run_system("$exe_patch -o $dest -i $resfile -r - -f -s -d $resdir");
}
} else {
$dest = $opt_tmpdir . '/' . basename($dest);
run_system("$exe_patch -o $dest -i $resfile -r - -f -s -d $resdir");
}
$tinfo->{result_file} = $dest;
}
unlink("$base_file.reject");
unlink("$base_file.progress");
unlink("$base_file.log");
unlink("$base_file.warnings");
}
......@@ -5204,13 +5227,10 @@ sub report_failure_and_restart ($) {
}
sub run_sh_script {
sub run_system($) {
my ($script)= @_;
return 0 unless defined $script;
mtr_verbose("Running '$script'");
my $ret= system("/bin/sh $script") >> 8;
my $ret= system($script) >> 8;
return $ret;
}
......
--- suite/rpl/r/rpl_insert_delayed.result 2012-02-06 21:37:21.000000000 +0100
+++ suite/rpl/r/rpl_insert_delayed,stmt.reject 2012-02-06 23:12:55.000000000 +0100
@@ -15,17 +15,17 @@
insert delayed into t1 values(10, "my name");
flush table t1;
insert delayed into t1 values(10, "is Bond"), (20, "James Bond");
+ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
flush table t1;
select * from t1;
id name
10 my name
-20 James Bond
select * from t1;
id name
10 my name
-20 James Bond
delete from t1 where id!=10;
insert delayed into t1 values(20, "is Bond"), (10, "James Bond");
+ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
flush table t1;
select * from t1;
id name
@@ -38,17 +38,31 @@
USE test;
DROP SCHEMA mysqlslap;
use test;
+FLUSH LOGS;
+FLUSH LOGS;
CREATE TABLE t1(a int, UNIQUE(a));
INSERT DELAYED IGNORE INTO t1 VALUES(1);
INSERT DELAYED IGNORE INTO t1 VALUES(1);
flush table t1;
+use `test`; INSERT IGNORE INTO t1 VALUES(1)
+use `test`; INSERT IGNORE INTO t1 VALUES(1)
select * from t1;
a
1
On slave
+show binlog events in 'slave-bin.000002' from <binlog_start> limit 1,6;
+Log_name Pos Event_type Server_id End_log_pos Info
+slave-bin.000002 # Query # # BEGIN
+slave-bin.000002 # Query # # use `test`; INSERT IGNORE INTO t1 VALUES(1)
+slave-bin.000002 # Query # # COMMIT
+slave-bin.000002 # Query # # BEGIN
+slave-bin.000002 # Query # # use `test`; INSERT IGNORE INTO t1 VALUES(1)
+slave-bin.000002 # Query # # COMMIT
select * from t1;
a
1
drop table t1;
+FLUSH LOGS;
+FLUSH LOGS;
End of 5.0 tests
include/rpl_end.inc
include/master-slave.inc
[connection master]
CREATE SCHEMA IF NOT EXISTS mysqlslap;
USE mysqlslap;
CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)) ENGINE=MyISAM;
FLUSH TABLE t1;
SELECT COUNT(*) FROM t1;
COUNT(*)
5000
use mysqlslap;
SELECT COUNT(*) FROM t1;
COUNT(*)
5000
truncate table t1;
insert delayed into t1 values(10, "my name");
flush table t1;
insert delayed into t1 values(10, "is Bond"), (20, "James Bond");
ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
flush table t1;
select * from t1;
id name
10 my name
select * from t1;
id name
10 my name
delete from t1 where id!=10;
insert delayed into t1 values(20, "is Bond"), (10, "James Bond");
ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
flush table t1;
select * from t1;
id name
10 my name
20 is Bond
select * from t1;
id name
10 my name
20 is Bond
USE test;
DROP SCHEMA mysqlslap;
use test;
FLUSH LOGS;
FLUSH LOGS;
CREATE TABLE t1(a int, UNIQUE(a));
INSERT DELAYED IGNORE INTO t1 VALUES(1);
INSERT DELAYED IGNORE INTO t1 VALUES(1);
flush table t1;
use `test`; INSERT IGNORE INTO t1 VALUES(1)
use `test`; INSERT IGNORE INTO t1 VALUES(1)
select * from t1;
a
1
On slave
show binlog events in 'slave-bin.000002' from <binlog_start> limit 1,6;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000002 # Query # # BEGIN
slave-bin.000002 # Query # # use `test`; INSERT IGNORE INTO t1 VALUES(1)
slave-bin.000002 # Query # # COMMIT
slave-bin.000002 # Query # # BEGIN
slave-bin.000002 # Query # # use `test`; INSERT IGNORE INTO t1 VALUES(1)
slave-bin.000002 # Query # # COMMIT
select * from t1;
a
1
drop table t1;
FLUSH LOGS;
FLUSH LOGS;
End of 5.0 tests
include/rpl_end.inc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment