Update samples and remove old tests.

This commit is contained in:
Daniel Nichter
2013-02-20 08:38:42 -07:00
parent e62a02e0d3
commit 92194f1711
9 changed files with 17 additions and 207 deletions

View File

@@ -5334,6 +5334,7 @@ sub exec_event {
};
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($e);
chomp($e);
$e =~ s/ at \S+ line \d+, \S+ line \d+\.$//;
$results->{error} = $e;
}
@@ -6319,21 +6320,28 @@ sub main {
}
# ##########################################################################
# Execute and compare the queries.
# Check and maybe create the --upgrade-table.
# ##########################################################################
if ( $host1 && $host2 ) {
if ( $host1 ) {
check_upgrade_table(
host => $host1,
upgrade_table => $o->get('upgrade-table'),
OptionParser => $o,
);
}
if ( $host2 ) {
check_upgrade_table(
host => $host2,
upgrade_table => $o->get('upgrade-table'),
OptionParser => $o,
);
}
# ##########################################################################
# Execute and compare the queries.
# ##########################################################################
if ( $host1 && $host2 ) {
compare_host_to_host(
file => $file,
host1 => $host1,

View File

@@ -86,6 +86,7 @@ sub exec_event {
};
if ( my $e = $EVAL_ERROR ) {
PTDEBUG && _d($e);
chomp($e);
$e =~ s/ at \S+ line \d+, \S+ line \d+\.$//;
$results->{error} = $e;
}

View File

@@ -1,53 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-upgrade";
# This runs immediately if the server is already running, else it starts it.
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('master1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
}
elsif ( !$dbh2 ) {
plan skip_all => 'Cannot connect to second sandbox master';
}
else {
plan tests => 2;
}
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times";
# Issue 391: Add --pid option to all scripts
`touch /tmp/mk-script.pid`;
my $output = `$cmd $trunk/t/pt-upgrade/samples/001/select-one.log --pid /tmp/mk-script.pid 2>&1`;
like(
$output,
qr{PID file /tmp/mk-script.pid already exists},
'Dies if PID file already exists (--pid without --daemonize) (issue 391)'
);
`rm -rf /tmp/mk-script.pid`;
# #############################################################################
# Done.
# #############################################################################
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -18,7 +18,7 @@ select nonexistent_col from test.t
On both hosts:
DBD::mysql::st execute failed: Unknown column 'nonexistent_col' in 'field list' [for Statement "select nonexistent_col from test.t"] at /Users/daniel/p/pt-upgrade-2.2/bin/pt-upgrade line 5327, <> line 1.
DBD::mysql::st execute failed: Unknown column 'nonexistent_col' in 'field list' [for Statement "select nonexistent_col from test.t"]
select nonexistent_col from test.t

View File

@@ -16,7 +16,7 @@ select host?_col from test.t
-- 1.
DBD::mysql::st execute failed: Unknown column 'host2_col' in 'field list' [for Statement "select host2_col from test.t"] at /Users/daniel/p/pt-upgrade-2.2/bin/pt-upgrade line 5327, <> line 1.
DBD::mysql::st execute failed: Unknown column 'host2_col' in 'field list' [for Statement "select host2_col from test.t"]
vs.

View File

@@ -20,7 +20,7 @@ No error
vs.
DBD::mysql::st execute failed: Unknown column 'host1_col' in 'field list' [for Statement "select host1_col from test.t"] at /Users/daniel/p/pt-upgrade-2.2/bin/pt-upgrade line 5327, <> line 1.
DBD::mysql::st execute failed: Unknown column 'host1_col' in 'field list' [for Statement "select host1_col from test.t"]
select host1_col from test.t

View File

@@ -83,11 +83,11 @@ while ( my $sampleno = readdir $dh ) {
q{"s/query_time => '[0-9.]*'/query_time => '0'/"},
],
),
"$sampleno: results: $result"
) or diag($test_diff);
"$sampleno/${basename}_results/$result"
) or diag("\n\n---- DIFF ----\n\n", $test_diff,
"\n\n---- OUTPUT ----\n\n", $output);
}
}
}
}

View File

@@ -1,56 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-upgrade";
# This runs immediately if the server is already running, else it starts it.
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('master1');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
}
elsif ( !$dbh2 ) {
plan skip_all => 'Cannot connect to second sandbox master';
}
else {
plan tests => 2;
}
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('master1', 't/pt-upgrade/samples/001/tables.sql');
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times";
# Test that non-SELECT queries are skipped by default.
ok(
no_diff(
"$cmd $trunk/t/pt-upgrade/samples/001/non-selects.log",
't/pt-upgrade/samples/001/non-selects.txt'
),
'Non-SELECT are skipped by default'
);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh1);
diag(`$trunk/sandbox/stop-sandbox master 12348 >/dev/null`);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -1,90 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-upgrade";
diag(`$trunk/sandbox/stop-sandbox master 12349 >/dev/null`);
diag(`QUERY_CACHE_SIZE=1048576 $trunk/sandbox/start-sandbox master 12349 >/dev/null`);
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh1 = $sb->get_dbh_for('master');
my $dbh2 = $sb->get_dbh_for('master2');
if ( !$dbh1 ) {
plan skip_all => 'Cannot connect to sandbox master';
}
elsif ( !$dbh2 ) {
diag(`$trunk/sandbox/stop-sandbox master 12349 >/dev/null`);
plan skip_all => 'Cannot connect to second sandbox master';
}
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
$sb->load_file('master2', 't/pt-upgrade/samples/001/tables.sql');
my $output;
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox,L=1 P=12349 --compare results,warnings --zero-query-times --compare-results-method rows --limit 10";
# This test really deals with,
# http://code.google.com/p/maatkit/issues/detail?id=754
# http://bugs.mysql.com/bug.php?id=49634
my $qc = $dbh2->selectrow_arrayref("show variables like 'query_cache_size'")->[1];
is(
$qc,
1048576,
'Query size'
);
$qc = $dbh2->selectrow_arrayref("show variables like 'query_cache_type'")->[1];
is(
$qc,
'ON',
'Query cache ON'
);
diag(`$cmd $trunk/t/pt-upgrade/samples/001/one-error.log >/dev/null 2>&1`);
$output = `$cmd $trunk/t/pt-upgrade/samples/001/one-error.log`;
like(
$output,
qr/# 3B323396273BC4C7-1 127.1:12349 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
'--clear-warnings',
);
# This produces a similar result to --clear-warnings. The difference is that
# the script reports that the borked query has both Errors and Warnings.
# This happens because with --clear-warnings the script fails to clear the
# warnings for the borked query (since it has no tables) so it skips the
# CompareWarnings module (it skips any module that fails) thereby negating its
# ability to check/report Warnings.
# Normalize path- and script-dependent parts of the error message (like the
# line number at which the error occurs).
$output = `$cmd --no-clear-warnings $trunk/t/pt-upgrade/samples/001/one-error.log`;
like(
$output,
qr/# 3B323396273BC4C7-1 127.1:12349 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
'--no-clear-warnings'
);
# #############################################################################
# Done.
# #############################################################################
diag(`$trunk/sandbox/stop-sandbox 12349 >/dev/null`);
$sb->wipe_clean($dbh1);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
done_testing;
exit;