Merge lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-fails-when-variable-or-threshold-is-non-integer-1335322 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.9

Proposed by Frank Cizmich
Status: Merged
Merged at revision: 610
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-fails-when-variable-or-threshold-is-non-integer-1335322
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.9
Diff against target: 60 lines (+27/-2)
3 files modified
bin/pt-stalk (+1/-2)
t/pt-stalk/pt-stalk.t (+21/-0)
t/pt-stalk/samples/plugin003.sh (+5/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-fails-when-variable-or-threshold-is-non-integer-1335322
Reviewer Review Type Date Requested Status
Percona Toolkit developers Pending
Review via email: mp+224900@code.launchpad.net

Description of the change

solves pt-stalk not handling non-integers

To post a comment you must log in.

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 2014-06-05 07:24:48 +0000
+++ bin/pt-stalk 2014-06-27 20:57:34 +0000
@@ -1245,13 +1245,12 @@
1245 if [ "$OPT_STALK" ]; then1245 if [ "$OPT_STALK" ]; then
1246 local value=$($TRIGGER_FUNCTION $OPT_VARIABLE)1246 local value=$($TRIGGER_FUNCTION $OPT_VARIABLE)
1247 local trg_exit_status=$?1247 local trg_exit_status=$?
1248
1249 if [ -z "$value" ]; then1248 if [ -z "$value" ]; then
1250 # No value. Maybe we failed to connect to MySQL?1249 # No value. Maybe we failed to connect to MySQL?
1251 warn "Detected value is empty; something failed? Trigger exit status: $trg_exit_status"1250 warn "Detected value is empty; something failed? Trigger exit status: $trg_exit_status"
1252 matched=""1251 matched=""
1253 cycles_true=01252 cycles_true=0
1254 elif [ $value -gt $OPT_THRESHOLD ]; then1253 elif (( $(echo "$value $OPT_THRESHOLD" | awk '{print ($1 > $2)}') )); then
1255 matched="yes"1254 matched="yes"
1256 cycles_true=$(($cycles_true + 1))1255 cycles_true=$(($cycles_true + 1))
1257 else1256 else
12581257
=== modified file 't/pt-stalk/pt-stalk.t'
--- t/pt-stalk/pt-stalk.t 2013-08-13 03:45:38 +0000
+++ t/pt-stalk/pt-stalk.t 2014-06-27 20:57:34 +0000
@@ -402,6 +402,27 @@
402 "Bug 942114: no bad find usage"402 "Bug 942114: no bad find usage"
403);403);
404404
405
406# ###########################################################################
407# Test that it handles floating point values
408# ###########################################################################
409
410cleanup();
411
412system("$trunk/bin/pt-stalk --daemonize --variable=PI --dest $dest --no-collect --log $log_file --iterations=1 --run-time=2 --cycles=2 --sleep=1 --function $trunk/t/pt-stalk/samples/plugin003.sh --threshold 3.1415 --pid $pid_file --defaults-file=$cnf >$log_file 2>&1");
413
414
415sleep 5;
416PerconaTest::kill_program(pid_file => $pid_file);
417
418$output = `cat $log_file 2>/dev/null`;
419like(
420 $output,
421 qr/matched=yes/,
422 "Accepts floating point values as treshold variable"
423);
424
425
405# #############################################################################426# #############################################################################
406# Done.427# Done.
407# #############################################################################428# #############################################################################
408429
=== added file 't/pt-stalk/samples/plugin003.sh'
--- t/pt-stalk/samples/plugin003.sh 1970-01-01 00:00:00 +0000
+++ t/pt-stalk/samples/plugin003.sh 2014-06-27 20:57:34 +0000
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3trg_plugin() {
4 echo 3.1416
5}

Subscribers

People subscribed via source and target branches

to all changes: