From 92194f17110b96d53923dde74dad96025268a79c Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Wed, 20 Feb 2013 08:38:42 -0700 Subject: [PATCH] Update samples and remove old tests. --- bin/pt-upgrade | 12 ++- lib/EventExecutor.pm | 1 + t/pt-upgrade/daemon.t | 53 ----------- .../samples/005/error_on_both_hosts.txt | 2 +- t/pt-upgrade/samples/005/error_on_host1.txt | 2 +- t/pt-upgrade/samples/005/error_on_host2.txt | 2 +- t/pt-upgrade/save_results.t | 6 +- t/pt-upgrade/skip_non_select.t | 56 ------------ t/pt-upgrade/warnings.t | 90 ------------------- 9 files changed, 17 insertions(+), 207 deletions(-) delete mode 100644 t/pt-upgrade/daemon.t delete mode 100644 t/pt-upgrade/skip_non_select.t delete mode 100644 t/pt-upgrade/warnings.t diff --git a/bin/pt-upgrade b/bin/pt-upgrade index 28bb5b4a..ba580eb0 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -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, diff --git a/lib/EventExecutor.pm b/lib/EventExecutor.pm index fffb2a7f..fd89bfd5 100644 --- a/lib/EventExecutor.pm +++ b/lib/EventExecutor.pm @@ -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; } diff --git a/t/pt-upgrade/daemon.t b/t/pt-upgrade/daemon.t deleted file mode 100644 index f0ab38a2..00000000 --- a/t/pt-upgrade/daemon.t +++ /dev/null @@ -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; diff --git a/t/pt-upgrade/samples/005/error_on_both_hosts.txt b/t/pt-upgrade/samples/005/error_on_both_hosts.txt index 6aa3dc1c..f28d69e9 100644 --- a/t/pt-upgrade/samples/005/error_on_both_hosts.txt +++ b/t/pt-upgrade/samples/005/error_on_both_hosts.txt @@ -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 diff --git a/t/pt-upgrade/samples/005/error_on_host1.txt b/t/pt-upgrade/samples/005/error_on_host1.txt index 5fdbb471..9721ae00 100644 --- a/t/pt-upgrade/samples/005/error_on_host1.txt +++ b/t/pt-upgrade/samples/005/error_on_host1.txt @@ -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. diff --git a/t/pt-upgrade/samples/005/error_on_host2.txt b/t/pt-upgrade/samples/005/error_on_host2.txt index 9c5033a8..a8b7208e 100644 --- a/t/pt-upgrade/samples/005/error_on_host2.txt +++ b/t/pt-upgrade/samples/005/error_on_host2.txt @@ -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 diff --git a/t/pt-upgrade/save_results.t b/t/pt-upgrade/save_results.t index 5266194f..00774744 100644 --- a/t/pt-upgrade/save_results.t +++ b/t/pt-upgrade/save_results.t @@ -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); } } - } } diff --git a/t/pt-upgrade/skip_non_select.t b/t/pt-upgrade/skip_non_select.t deleted file mode 100644 index 105a70e2..00000000 --- a/t/pt-upgrade/skip_non_select.t +++ /dev/null @@ -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; diff --git a/t/pt-upgrade/warnings.t b/t/pt-upgrade/warnings.t deleted file mode 100644 index 70259a86..00000000 --- a/t/pt-upgrade/warnings.t +++ /dev/null @@ -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;