mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-27 16:12:04 +00:00
Test and fix very small --chunk-time. Report immediately when a slave is stopped. Add short form -q for --quiet. Report very slow checksums once for each table. Use Cxn::name() instead of Cxn::dsn()->{n}; remove n from DSNParser; make cxn's name @@hostname by default, else stringified DSN parts.
This commit is contained in:
16
t/lib/Cxn.t
16
t/lib/Cxn.t
@@ -97,6 +97,12 @@ ok(
|
||||
"New Cxn, dbh not connected yet"
|
||||
);
|
||||
|
||||
is(
|
||||
$cxn->name(),
|
||||
'h=127.1,P=12345',
|
||||
'name() uses DSN if not connected'
|
||||
);
|
||||
|
||||
$cxn->connect();
|
||||
ok(
|
||||
$cxn->dbh()->ping(),
|
||||
@@ -193,11 +199,17 @@ is_deeply(
|
||||
S => undef,
|
||||
D => undef,
|
||||
t => undef,
|
||||
n => 'h=127.1,P=12345',
|
||||
},
|
||||
"cxn->dsn()"
|
||||
);
|
||||
|
||||
my ($hostname) = $master_dbh->selectrow_array('select @@hostname');
|
||||
is(
|
||||
$cxn->name(),
|
||||
$hostname,
|
||||
'name() uses @@hostname'
|
||||
);
|
||||
exit;
|
||||
# ############################################################################
|
||||
# Default cxn, should be equivalent to 'h=localhost'.
|
||||
# ############################################################################
|
||||
@@ -214,7 +226,6 @@ is_deeply(
|
||||
S => undef,
|
||||
D => undef,
|
||||
t => undef,
|
||||
n => 'h=localhost',
|
||||
},
|
||||
"Defaults to h=localhost"
|
||||
);
|
||||
@@ -234,7 +245,6 @@ is_deeply(
|
||||
S => undef,
|
||||
D => undef,
|
||||
t => undef,
|
||||
n => 'h=localhost,P=12345',
|
||||
},
|
||||
"Default cxn inherits default connection options"
|
||||
);
|
||||
|
@@ -137,7 +137,7 @@ is (
|
||||
|
||||
is (
|
||||
$dp->as_string({ h=>'localhost', P=>'3306',p=>'omg'}, [qw(h P)]),
|
||||
'P=3306,h=localhost',
|
||||
'h=localhost,P=3306',
|
||||
'DSN stringifies only requested parts'
|
||||
);
|
||||
|
||||
|
@@ -10,7 +10,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 29;
|
||||
use Test::More tests => 31;
|
||||
|
||||
use Transformers;
|
||||
use Progress;
|
||||
@@ -153,7 +153,7 @@ $pr->set_callback(
|
||||
$callbacks_called++;
|
||||
}
|
||||
);
|
||||
$pr->update(sub{return 60}, 35);
|
||||
$pr->update(sub{return 60}, now => 35);
|
||||
is_deeply(
|
||||
$completion_arr,
|
||||
[.1, 25, 225, 260, 60 ],
|
||||
@@ -175,7 +175,7 @@ eval {
|
||||
interval => 10, # Every ten seconds
|
||||
);
|
||||
$pr->start(10); # Current time is 10 seconds.
|
||||
$pr->update(sub{return 60}, 35);
|
||||
$pr->update(sub{return 60}, now => 35);
|
||||
is($buffer, "Progress: 10% 03:45 remain\n",
|
||||
'Tested the default callback');
|
||||
};
|
||||
@@ -193,12 +193,57 @@ eval {
|
||||
start => 10, # Current time is 10 seconds, alternate interface
|
||||
);
|
||||
is($pr->{start}, 10, 'Custom start time param works');
|
||||
$pr->update(sub{return 60}, 35);
|
||||
$pr->update(sub{return 60}, now => 35);
|
||||
is($buffer, "custom name: 10% 03:45 remain\n",
|
||||
'Tested the default callback with custom name');
|
||||
};
|
||||
is ($EVAL_ERROR, '', "No error in default callback with custom name");
|
||||
|
||||
# ############################################################################
|
||||
# Do a "first report" before the normal interval reports.
|
||||
# ############################################################################
|
||||
$pr = new Progress(
|
||||
jobsize => 600,
|
||||
report => 'time',
|
||||
interval => 10, # Every ten seconds
|
||||
);
|
||||
$pr->start(2); # Current time is 2 seconds.
|
||||
$callbacks_called = 0;
|
||||
my $first_report_called = 0;
|
||||
$pr->set_callback(
|
||||
sub {
|
||||
$completion_arr = [ @_ ];
|
||||
$callbacks_called++;
|
||||
}
|
||||
);
|
||||
$pr->update(
|
||||
sub { return 60 },
|
||||
now => 5,
|
||||
first_report => sub { $first_report_called++ }
|
||||
);
|
||||
$pr->update(
|
||||
sub { return 70 },
|
||||
now => 16,
|
||||
first_report => sub { $first_report_called++ }
|
||||
);
|
||||
$pr->update(
|
||||
sub { return 100 },
|
||||
now => 27,
|
||||
first_report => sub { $first_report_called++ }
|
||||
);
|
||||
|
||||
is(
|
||||
$first_report_called,
|
||||
1,
|
||||
"Called first_report ocne"
|
||||
);
|
||||
|
||||
is(
|
||||
$callbacks_called,
|
||||
2,
|
||||
"Called interval report twice"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
@@ -12,6 +12,8 @@ use English qw(-no_match_vars);
|
||||
use Test::More tests => 7;
|
||||
|
||||
use ReplicaLagWaiter;
|
||||
use OptionParser;
|
||||
use DSNParser;
|
||||
use Cxn;
|
||||
use PerconaTest;
|
||||
|
||||
@@ -38,8 +40,14 @@ sub sleep {
|
||||
sleep $t;
|
||||
}
|
||||
|
||||
my $r1 = new Cxn(dsn=>{n=>'slave1'}, dbh=>1, DSNParser=>1, OptionParser=>1);
|
||||
my $r2 = new Cxn(dsn=>{n=>'slave2'}, dbh=>2, DSNParser=>1, OptionParser=>1);
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $o = new OptionParser(description => 'Cxn');
|
||||
$o->get_specs("$trunk/bin/pt-table-checksum");
|
||||
$o->get_opts();
|
||||
$dp->prop('set-vars', $o->get('set-vars'));
|
||||
|
||||
my $r1 = new Cxn(dsn=>{n=>'slave1'}, dbh=>1, DSNParser=>$dp, OptionParser=>$o);
|
||||
my $r2 = new Cxn(dsn=>{n=>'slave2'}, dbh=>2, DSNParser=>$dp, OptionParser=>$o);
|
||||
|
||||
my $rll = new ReplicaLagWaiter(
|
||||
oktorun => \&oktorun,
|
||||
|
Reference in New Issue
Block a user