mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-16 01:00:38 +08:00
Merged fix-942114-bad-find-usage
This commit is contained in:
@@ -1034,14 +1034,14 @@ purge_samples() {
|
|||||||
local retention_time="$2"
|
local retention_time="$2"
|
||||||
|
|
||||||
# Delete collect files which more than --retention-time days old.
|
# Delete collect files which more than --retention-time days old.
|
||||||
find "$dir" -type f -mtime +$retention_time -exec rm -f '{}' \;
|
find "$dir" -warn -type f -mtime +$retention_time -exec rm -f '{}' \;
|
||||||
|
|
||||||
local oprofile_dir="/var/lib/oprofile/samples"
|
local oprofile_dir="/var/lib/oprofile/samples"
|
||||||
if [ -d "$oprofile_dir" ]; then
|
if [ -d "$oprofile_dir" ]; then
|
||||||
# "pt_collect_" here needs to match $CMD_OPCONTROL --save=pt_collect_$p
|
# "pt_collect_" here needs to match $CMD_OPCONTROL --save=pt_collect_$p
|
||||||
# in collect(). TODO: fix this
|
# in collect(). TODO: fix this
|
||||||
find "$oprofile_dir" -type d -name 'pt_collect_*' \
|
find "$oprofile_dir" -warn -depth -type d -name 'pt_collect_*' \
|
||||||
-depth -mtime +$retention_time -exec rm -rf '{}' \;
|
-mtime +$retention_time -exec rm -rf '{}' \;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
plan tests => 27;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||||
my $pid_file = "/tmp/pt-stalk.pid.$PID";
|
my $pid_file = "/tmp/pt-stalk.pid.$PID";
|
||||||
@@ -282,6 +279,28 @@ ok(
|
|||||||
"Not stalking, pt-stalk is not running"
|
"Not stalking, pt-stalk is not running"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# bad "find" usage in purge_samples gives
|
||||||
|
# https://bugs.launchpad.net/percona-toolkit/+bug/942114
|
||||||
|
# ############################################################################
|
||||||
|
|
||||||
|
use File::Temp qw( tempdir );
|
||||||
|
|
||||||
|
my $tempdir = tempdir( CLEANUP => 1 );
|
||||||
|
|
||||||
|
my $script = <<"EOT";
|
||||||
|
. $trunk/bin/pt-stalk
|
||||||
|
purge_samples $tempdir 10000 2>&1
|
||||||
|
EOT
|
||||||
|
|
||||||
|
$output = `$script`;
|
||||||
|
|
||||||
|
unlike(
|
||||||
|
$output,
|
||||||
|
qr/\Qfind: warning: you have specified the -depth option/,
|
||||||
|
"Bug 942114: no bad find usage"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
@@ -289,4 +308,5 @@ diag(`rm $pid_file 2>/dev/null`);
|
|||||||
diag(`rm $log_file 2>/dev/null`);
|
diag(`rm $log_file 2>/dev/null`);
|
||||||
diag(`rm -rf $dest 2>/dev/null`);
|
diag(`rm -rf $dest 2>/dev/null`);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
exit;
|
|
||||||
|
done_testing;
|
||||||
|
|||||||
Reference in New Issue
Block a user