From aab2b13506412b88d0921c528905464f78310123 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 30 Apr 2015 09:28:44 +0100 Subject: If a test is skipped we don't need to sleep. If a test fails then we sleep for a small amount of time, two seconds by default, before repeating it. This delay is not required for tests that explicitly disable themselves. --- lib/custodian/worker.rb | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb index 7910a29..3425881 100644 --- a/lib/custodian/worker.rb +++ b/lib/custodian/worker.rb @@ -198,21 +198,37 @@ module Custodian end # - # Some of our routers/hosts don't like being hammered. + # Some targets won't like being hammed by multiple tests + # in a short period of time. Since we're hitting a failed + # device we're going to give it a little sleep. # - # We delay before re-testing, but we only do this if - # we're not on the last count. + # In theory this stops us from hammering a semi-alive + # device. In practice we only reach this point if at least + # one test has failed, and if a test is failing then it probably + # failed due to a timeout - which is 30 seconds by default - + # so the extra sleep doesn't really gain us much. + # + # + # Anyway: The intention here is that if a test passes then + # there will, things will clear, and all is well. + # + # If the test fails we'll sleep a while and retry + # but no more than "@retry_count" times. # - # The intention here is that if the test passes then there will - # be no delay. If the test fails then we'll sleep. # if (run == true) && (@retry_delay > 0) && (count < @retry_count) - log_message("Sleeping for #{@retry_delay} seconds before retry. Failure was: #{test.error}") - sleep(@retry_delay) + + # + # If the test disabled itself then we don't need to delay + # + unless( result == Custodian::TestResult::TEST_SKIPPED) + log_message("Delaying re-test by #{@retry_delay} seconds due to failure - : #{test.error}") + sleep(@retry_delay) + end end # - # Increase the log of times we've repeated the test. + # Increase the count of times we've repeated the test. # count += 1 end -- cgit v1.2.1