Add $ENV{PERCONA_VERSION_CHECK}=0 to PerconaTest so tests don't version-check. Implement v-c in half the tools. Make util/update-modules clean up its temp files.

This commit is contained in:
Daniel Nichter
2012-08-21 16:15:44 -06:00
parent a95aa2b3bc
commit ee583ba729
14 changed files with 127 additions and 13 deletions

View File

@@ -4728,6 +4728,7 @@ sub _touch {
sysopen my $fh, $file, O_WRONLY|O_CREAT|O_NONBLOCK
or die "Cannot create $file : $!";
close $fh or die "Cannot close $file : $!";
utime(undef, undef, $file);
}
sub encode_client_response {
@@ -4801,7 +4802,7 @@ my @beginning_of_txn;
my $q = new Quoter;
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
# Reset global vars else tests, which run this tool as a module,
# may encounter weird results.
@@ -5287,6 +5288,14 @@ sub main {
});
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($src->{dbh});
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Start archiving.
# ########################################################################

View File

@@ -3887,7 +3887,7 @@ use Percona::Toolkit;
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
# ########################################################################
# Get configuration information.
@@ -3971,6 +3971,14 @@ sub main {
$daemon->make_PID_file();
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($configs[0]->{dbh});
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# #########################################################################
# Diff the given configs.
# #########################################################################

View File

@@ -3392,7 +3392,7 @@ my %is_proc_info = (
);
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
my $q = new Quoter();
@@ -3439,7 +3439,7 @@ sub main {
$o->usage_or_errors();
# ########################################################################
# Start working.
# Connect to MySQL and set up the --dest, if any.
# ########################################################################
my $dbh = get_cxn($source_dsn, 1);
my $dest_dbh;
@@ -3481,7 +3481,9 @@ sub main {
}
}
# ########################################################################
# Daemonize only after (potentially) asking for passwords for --ask-pass.
# ########################################################################
my $daemon;
if ( $o->get('daemonize') ) {
$daemon = new Daemon(o=>$o);
@@ -3494,6 +3496,17 @@ sub main {
$daemon->make_PID_file();
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Start looking for and logging deadlocks.
# ########################################################################
my $last_fingerprint = '';
$oktorun = 1;

View File

@@ -4483,7 +4483,17 @@ sub main {
$o->usage_or_errors();
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check();
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Interactive mode. Delegate to DiskstatsMenu::run_interactive
# ########################################################################
my $diskstats = new DiskstatsMenu();
return $diskstats->run_interactive(
OptionParser => $o,

View File

@@ -4304,7 +4304,7 @@ my $hdr_width = $max_width - 2; # for '# '
my $hdr_fmt = "# %-${hdr_width}s\n";
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
my %summary = ( 'Total Indexes' => 0 );
my %seen_tbl;
@@ -4348,6 +4348,14 @@ sub main {
my $dbh = $dp->get_dbh($dp->get_cxn_params($dsn),
{ AutoCommit => 1, });
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# #######################################################################
# Do the main work.
# #######################################################################

View File

@@ -3395,7 +3395,7 @@ my @stored_code_tests = qw(
);
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
# ########################################################################
# Get configuration information.
@@ -3517,6 +3517,14 @@ sub main {
# Discover if we need to get stored code. Need dbh to do this.
my $need_stored_code = grep { $o->got($_); } @stored_code_tests;
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Go do it.
# ########################################################################

View File

@@ -3049,7 +3049,8 @@ Transformers->import(qw(parse_timestamp));
my $oktorun;
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
$oktorun = 1;
# ########################################################################
# Get configuration information.
@@ -3125,7 +3126,9 @@ sub main {
$ins_sth = $dst_dbh->prepare($sql);
}
# ########################################################################
# Daemonize only after (potentially) asking for passwords for --ask-pass.
# ########################################################################
my $daemon;
if ( $o->get('daemonize') ) {
$daemon = new Daemon(o=>$o);
@@ -3138,7 +3141,17 @@ sub main {
$daemon->make_PID_file();
}
$oktorun = 1;
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Start finding and logging foreign key errors.
# ########################################################################
while ( # Quit if:
($start == $end || $now < $end) # time is exceeded
&& $oktorun # or instructed to quit

View File

@@ -4229,7 +4229,7 @@ my @dbhs; # Holds slave DBHs if --recurse
my @sths; # Holds [$host, $sth] if --recurse
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
# Reset all global vars between test runs else weird things happen.
@dbhs = ();
@@ -4637,6 +4637,14 @@ sub main {
return 0;
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Setup moving averages for --frames.
# ########################################################################

View File

@@ -5812,7 +5812,7 @@ Transformers->import(qw(make_checksum));
my $oktorun = 1;
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
$oktorun = 1;
@@ -5980,6 +5980,14 @@ sub main {
}
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Populate the IndexUsage object with indexes. Also get a list of all
# databases and tables before going on to parse the queries. This will be

View File

@@ -5818,7 +5818,7 @@ my $o;
# ########################################################################
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
# ########################################################################
# Get configuration information.
@@ -6129,6 +6129,14 @@ sub main {
$daemon->make_PID_file();
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Start working.
# ########################################################################

View File

@@ -6830,7 +6830,7 @@ $OUTPUT_AUTOFLUSH = 1;
sub main {
# Reset global vars else tests will fail.
@ARGV = @_;
local @ARGV = @_;
$oktorun = 1;
@drop_trigger_sqls = ();
@@ -7015,6 +7015,14 @@ sub main {
die "This tool requires MySQL 5.0.10 or newer.\n";
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($cxn->dbh());
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# ########################################################################
# Setup lag and load monitors.
# ########################################################################

View File

@@ -7001,7 +7001,7 @@ use sigtrap 'handler', \&sig_int, 'normal-signals';
my $oktorun = 1; # global for sig handler
sub main {
@ARGV = @_; # set global ARGV for this package
local @ARGV = @_; # set global ARGV for this package
my %seen_id; # already printed rule info (advice)
my %seen_fingerprint; # already seen queries
@@ -7356,6 +7356,14 @@ sub main {
$daemon->make_PID_file();
}
# ########################################################################
# Do the version-check
# ########################################################################
if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) {
Pingback::version_check($dbh);
return 0 if $ENV{PTVCDEBUG} && PTDEBUG;
}
# #########################################################################
# Do it!
# #########################################################################

View File

@@ -81,6 +81,10 @@ eval {
our $can_load_data = can_load_data();
# We do not want every test doing the version-check;
# that would be quite slow.
$ENV{PERCONA_VERSION_CHECK} = 0;
our $dsn_opts = [
{
key => 'A',

View File

@@ -120,6 +120,7 @@ update_tool_header() {
return 1
fi
cat $tool_file-header $tool_file-code > $tool_file
[ $? -eq 0 ] && rm $tool_file-header $tool_file-code
}
# ############################################################################