From 15b8c976ddd6401b9f3afaedbcf4af368cd34359 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 24 Jan 2013 11:52:29 +0000 Subject: Updated to log duration of test-runs with our alerters, if they implement a "duration" method. --- lib/custodian/worker.rb | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'lib') 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. @@ -185,6 +185,20 @@ module Custodian count += 1 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. # @@ -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 # -- cgit v1.2.1