mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 09:40:38 +00:00
Rewrite t/pt-archiver/standard_options.t to make it reliable.
This commit is contained in:
@@ -126,12 +126,13 @@ sub create_dbs {
|
||||
}
|
||||
|
||||
sub get_dbh_for {
|
||||
my ( $self, $server, $cxn_ops ) = @_;
|
||||
my ( $self, $server, $cxn_ops, $user ) = @_;
|
||||
_check_server($server);
|
||||
$cxn_ops ||= { AutoCommit => 1 };
|
||||
$user ||= 'msandbox';
|
||||
PTDEBUG && _d('dbh for', $server, 'on port', $port_for{$server});
|
||||
my $dp = $self->{DSNParser};
|
||||
my $dsn = $dp->parse('h=127.0.0.1,u=msandbox,p=msandbox,P=' . $port_for{$server});
|
||||
my $dsn = $dp->parse("h=127.0.0.1,u=$user,p=msandbox,P=" . $port_for{$server});
|
||||
my $dbh;
|
||||
# This is primarily for the benefit of CompareResults, but it's
|
||||
# also quite convenient when using an affected OS
|
||||
@@ -542,6 +543,23 @@ sub config_file_for {
|
||||
return "/tmp/$port/my.sandbox.cnf"
|
||||
}
|
||||
|
||||
sub do_as_root {
|
||||
my ($self, $server, @queries) = @_;
|
||||
my $dbh = $self->get_dbh_for($server, undef, 'root');
|
||||
my $ok = 1;
|
||||
eval {
|
||||
foreach my $query ( @queries ) {
|
||||
$dbh->do($query);
|
||||
}
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
$ok = 0;
|
||||
warn $EVAL_ERROR;
|
||||
}
|
||||
$dbh->disconnect;
|
||||
return $ok;
|
||||
}
|
||||
|
||||
sub _d {
|
||||
my ($package, undef, $line) = caller 0;
|
||||
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
||||
|
Reference in New Issue
Block a user