summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-01-24 11:52:29 +0000
committerSteve Kemp <steve@steve.org.uk>2013-01-24 11:52:29 +0000
commit15b8c976ddd6401b9f3afaedbcf4af368cd34359 (patch)
tree099b2d91837d625464d914e426f5ebeff14d9da0
parent69a2e1ecbb08f3d1bf6fa779caa94e41f126a589 (diff)
Updated to log duration of test-runs with our alerters, if they
implement a "duration" method.
-rw-r--r--lib/custodian/worker.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index 11aa0e6..5219a5b 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -160,7 +160,7 @@ module Custodian
#
test = Custodian::TestFactory.create( body )
-
+ start_time = Time.now
#
# We'll run no more than MAX times.
@@ -186,6 +186,20 @@ module Custodian
end
#
+ # End time
+ #
+ end_time = Time.now
+
+
+ #
+ # Duration of the test-run, in milliseconds
+ #
+ duration = (( end_time - start_time ) * 1000.0).to_i
+
+ do_duration( test, duration )
+
+
+ #
# If we didn't succeed on any of the attempts raise the alert.
#
if ( ! result )
@@ -254,6 +268,24 @@ module Custodian
end
end
+ #
+ # Log a test duration with each registered alerter.
+ #
+ def do_duration( test, duration )
+ @alerter.split( "," ).each do |alerter|
+ log_message( "Creating alerter: #{alerter}" )
+ alert = Custodian::AlertFactory.create( alerter, test )
+
+ target = @settings.alerter_target( alerter )
+ alert.set_target( target )
+ puts "Target for alert is #{target}"
+
+ # give the alerter a reference to the settings object.
+ alert.set_settings( @settings )
+
+ alert.duration( duration ) if ( alert.respond_to? "duration" )
+ end
+ end
#