diff options
Diffstat (limited to 'lib/custodian/worker.rb')
-rw-r--r-- | lib/custodian/worker.rb | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb index 78e7cf0..87f2c7e 100644 --- a/lib/custodian/worker.rb +++ b/lib/custodian/worker.rb @@ -128,46 +128,54 @@ module Custodian - # - # Fetch a single job from the queue, and process it. + # Fetch a single job from the queue, and dispatch it for + # processing. # def process_single_job - result = false + # + # Acquire a job from our queue. + # + job = @queue.fetch(1) - begin + # + # Ensure that the job is sane. + # + raise ArgumentError, "Job was empty" if (job.nil?) + raise ArgumentError, "Job was not a string" unless job.kind_of?(String) - # - # Acquire a job. - # - job = @queue.fetch(1) - log_message( "Job aquired: #{job}" ) - # - # Get the job body - # - raise ArgumentError, "Job was empty" if (job.nil?) - raise ArgumentError, "Job was not a string" unless job.kind_of?(String) + # + # Create the test-object from our class-factory + # + Custodian::TestFactory.create( job ).each do |test| + puts "CREATED FROM JOB: #{test.class}" + process_single_test( test ) + end + end - # - # The count of times this test has run. - # - count = 1 + # + # Fetch a single job from the queue, and process it. + # + def process_single_test( test ) + + begin + log_message( "Received job: #{test.to_s}" ) # - # Create the test-object. + # The count of times this test has run, the result, and the start-time # - test = Custodian::TestFactory.create( job ) - + count = 1 + result = false start_time = Time.now # - # We'll run no more than MAX times. + # If a job fails we'll repeat it, but no more than MAX times. # - # We stop the execution on a single success. + # We exit here if we receive a single success. # while ( ( count < ( @retry_count + 1 ) ) && ( result == false ) ) @@ -182,11 +190,10 @@ module Custodian if ( result ) log_message( "Test succeeed - clearing alert" ) do_clear( test ) - success = true end # - # Some of our routers don't like being hammered. + # Some of our routers/hosts don't like being hammered. # # We delay before re-testing, but we only do this if # we're not on the last count. @@ -200,7 +207,7 @@ module Custodian end # - # Increase count. + # Increase the log of times we've repeated the test. # count += 1 end @@ -210,12 +217,16 @@ module Custodian # end_time = Time.now - # # Duration of the test-run, in milliseconds # duration = (( end_time - start_time ) * 1000.0).to_i + + # + # Record that, if we have any alerters that are interested + # in run-times. + # do_duration( test, duration ) |