Merge lp:~percona-toolkit-dev/percona-toolkit/fix-942114-bad-find-usage into lp:percona-toolkit/2.1

Proposed by Brian Fraser
Status: Merged
Approved by: Daniel Nichter
Approved revision: 355
Merged at revision: 381
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-942114-bad-find-usage
Merge into: lp:percona-toolkit/2.1
Diff against target: 71 lines (+27/-7)
2 files modified
bin/pt-stalk (+3/-3)
t/pt-stalk/pt-stalk.t (+24/-4)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-942114-bad-find-usage
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+120920@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Do we want -warn? The man page says "The default behaviour corresponds to -warn if standard input is a tty, and to -nowarn otherwise." pt-stalk is often run as a daemon, so STDIN won't be a tty.

Revision history for this message
Brian Fraser (fraserbn) wrote :

That's to trigger the warning during the tests, otherwise we could have a regression and never notice. And also, a slightly less valid and rather more paranoid reason, I've learnt not to trust defaults in shell commands : D

Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-stalk'
--- bin/pt-stalk 2012-08-14 15:11:41 +0000
+++ bin/pt-stalk 2012-08-23 06:39:00 +0000
@@ -1031,14 +1031,14 @@
1031 local retention_time="$2"1031 local retention_time="$2"
10321032
1033 # Delete collect files which more than --retention-time days old.1033 # Delete collect files which more than --retention-time days old.
1034 find "$dir" -type f -mtime +$retention_time -exec rm -f '{}' \;1034 find "$dir" -warn -type f -mtime +$retention_time -exec rm -f '{}' \;
10351035
1036 local oprofile_dir="/var/lib/oprofile/samples"1036 local oprofile_dir="/var/lib/oprofile/samples"
1037 if [ -d "$oprofile_dir" ]; then1037 if [ -d "$oprofile_dir" ]; then
1038 # "pt_collect_" here needs to match $CMD_OPCONTROL --save=pt_collect_$p1038 # "pt_collect_" here needs to match $CMD_OPCONTROL --save=pt_collect_$p
1039 # in collect(). TODO: fix this1039 # in collect(). TODO: fix this
1040 find "$oprofile_dir" -type d -name 'pt_collect_*' \1040 find "$oprofile_dir" -warn -depth -type d -name 'pt_collect_*' \
1041 -depth -mtime +$retention_time -exec rm -rf '{}' \;1041 -mtime +$retention_time -exec rm -rf '{}' \;
1042 fi1042 fi
1043}1043}
10441044
10451045
=== modified file 't/pt-stalk/pt-stalk.t'
--- t/pt-stalk/pt-stalk.t 2012-06-04 15:53:44 +0000
+++ t/pt-stalk/pt-stalk.t 2012-08-23 06:39:00 +0000
@@ -23,9 +23,6 @@
23if ( !$dbh ) {23if ( !$dbh ) {
24 plan skip_all => 'Cannot connect to sandbox master';24 plan skip_all => 'Cannot connect to sandbox master';
25}25}
26else {
27 plan tests => 27;
28}
2926
30my $cnf = "/tmp/12345/my.sandbox.cnf";27my $cnf = "/tmp/12345/my.sandbox.cnf";
31my $pid_file = "/tmp/pt-stalk.pid.$PID";28my $pid_file = "/tmp/pt-stalk.pid.$PID";
@@ -282,6 +279,28 @@
282 "Not stalking, pt-stalk is not running"279 "Not stalking, pt-stalk is not running"
283);280);
284281
282# ############################################################################
283# bad "find" usage in purge_samples gives
284# https://bugs.launchpad.net/percona-toolkit/+bug/942114
285# ############################################################################
286
287use File::Temp qw( tempdir );
288
289my $tempdir = tempdir( CLEANUP => 1 );
290
291my $script = <<"EOT";
292. $trunk/bin/pt-stalk
293purge_samples $tempdir 10000 2>&1
294EOT
295
296$output = `$script`;
297
298unlike(
299 $output,
300 qr/\Qfind: warning: you have specified the -depth option/,
301 "Bug 942114: no bad find usage"
302);
303
285# #############################################################################304# #############################################################################
286# Done.305# Done.
287# #############################################################################306# #############################################################################
@@ -289,4 +308,5 @@
289diag(`rm $log_file 2>/dev/null`);308diag(`rm $log_file 2>/dev/null`);
290diag(`rm -rf $dest 2>/dev/null`);309diag(`rm -rf $dest 2>/dev/null`);
291ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");310ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
292exit;311
312done_testing;

Subscribers

People subscribed via source and target branches