From 84341830fbec193df5cf1f728798a5e58feb7434 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Sun, 18 Nov 2012 18:37:52 +0000 Subject: Added --fail flag. --- bin/custodian-dequeue | 16 +++++++++++++++- lib/custodian.rb | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue index 85bc6f3..dd5daa6 100755 --- a/bin/custodian-dequeue +++ b/bin/custodian-dequeue @@ -6,6 +6,7 @@ # SYNOPSIS # custodian-dequeue [ -h | --help ] # [ -m | --manual] +# [ -f | --fail ] # [ -l | --logfile FILE] # [ -S | --server 1.2.3.4:123 ] # [ -s | --single ] @@ -23,6 +24,8 @@ # # -s, --single Run a single test and exit. Don't poll the queue for more. # +# -f, --fail Run tests but stop the first time we see a fail. +# # -v, --verbose Be noisy. # # @@ -72,6 +75,7 @@ if __FILE__ == $0 then opts = GetoptLong.new( [ "--help", "-h", GetoptLong::NO_ARGUMENT ], [ "--manual", "-m", GetoptLong::NO_ARGUMENT ], + [ "--fail", "-f", GetoptLong::NO_ARGUMENT ], [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ], [ "--repeat", "-r", GetoptLong::REQUIRED_ARGUMENT ], [ "--server", "-S", GetoptLong::REQUIRED_ARGUMENT ], @@ -90,6 +94,8 @@ if __FILE__ == $0 then $SERVER = arg when "--single": ENV["SINGLE"] = "1" + when "--fail": + ENV["FAIL"] = "1" when "--help": $help = true when "--manual": @@ -142,7 +148,15 @@ if __FILE__ == $0 then # Single step? # if ( ENV['SINGLE'] ) - worker.process_single_job + worker.process_single_job() + exit(0) + end + + # + # Run until we see a failure? + # + if ( ENV['FAIL'] ) + worker.process_until_fail() exit(0) end diff --git a/lib/custodian.rb b/lib/custodian.rb index 6c0ec81..fec928b 100644 --- a/lib/custodian.rb +++ b/lib/custodian.rb @@ -104,6 +104,8 @@ class Custodian # def process_single_job + result = false + begin job = @queue.reserve() @@ -200,6 +202,7 @@ class Custodian log_message( "Test succeeed - clearing alert" ) success = true alert.clear() + result = true end count += 1 end @@ -228,7 +231,20 @@ class Custodian log_message( "Job ID : #{job.id} - Removed" ) job.delete if ( job ) end + + return result end + + + # + # Process jobs until we see a failure - stop then. + # + def process_until_fail + while( process_single_job() ) + # nop + end + end + end -- cgit v1.2.1