diff --git a/bin/pt-stalk b/bin/pt-stalk index 5809060d..1ee490ca 100755 --- a/bin/pt-stalk +++ b/bin/pt-stalk @@ -1034,14 +1034,14 @@ purge_samples() { local retention_time="$2" # 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" if [ -d "$oprofile_dir" ]; then # "pt_collect_" here needs to match $CMD_OPCONTROL --save=pt_collect_$p # in collect(). TODO: fix this - find "$oprofile_dir" -type d -name 'pt_collect_*' \ - -depth -mtime +$retention_time -exec rm -rf '{}' \; + find "$oprofile_dir" -warn -depth -type d -name 'pt_collect_*' \ + -mtime +$retention_time -exec rm -rf '{}' \; fi } diff --git a/t/pt-stalk/pt-stalk.t b/t/pt-stalk/pt-stalk.t index 50eb46a8..4c3ead15 100644 --- a/t/pt-stalk/pt-stalk.t +++ b/t/pt-stalk/pt-stalk.t @@ -23,9 +23,6 @@ my $dbh = $sb->get_dbh_for('master'); if ( !$dbh ) { plan skip_all => 'Cannot connect to sandbox master'; } -else { - plan tests => 27; -} my $cnf = "/tmp/12345/my.sandbox.cnf"; my $pid_file = "/tmp/pt-stalk.pid.$PID"; @@ -282,6 +279,28 @@ ok( "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. # ############################################################################# @@ -289,4 +308,5 @@ diag(`rm $pid_file 2>/dev/null`); diag(`rm $log_file 2>/dev/null`); diag(`rm -rf $dest 2>/dev/null`); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); -exit; + +done_testing;