From 0b97bce5bac83885dd7843306e2858ab2429c102 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 18 Dec 2015 14:54:26 +0000 Subject: Modified zset test program to exit if it encounters a test it has already seen. This helps with debugging. We expect it to exit eventually, but only after it has seen all tests. --- queue/zset/add.rb | 8 +++++--- queue/zset/run.rb | 13 ++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/queue/zset/add.rb b/queue/zset/add.rb index cd63503..2c778a4 100755 --- a/queue/zset/add.rb +++ b/queue/zset/add.rb @@ -10,13 +10,15 @@ require "redis" x = [] -x.push( "http://example.com/ must run http otherwise 'fail'" ) -x.push( "1.2.3.4 must run ping otherwise 'fail'" ) -x.push( "https://steve.net/ must run https otherwise 'fail'" ) +x.push( "test 1" ) +x.push( "test 2" ) +x.push( "test 3" ) for i in 0 .. 10 x.each do |test| + puts "adding #{test}" @redis.zadd('zset', Time.now.to_i, test) end + sleep 1 end diff --git a/queue/zset/run.rb b/queue/zset/run.rb index 726e19a..2fc861c 100755 --- a/queue/zset/run.rb +++ b/queue/zset/run.rb @@ -27,12 +27,19 @@ def fetch(timeout = 1) end end - +seen = [] while( x = fetch() ) puts "Got job : #{x}" - if ( x =~ /ping/i ) - puts "PING TEST - sleeping" + if seen.include?(x) + puts "Already seen #{x}" + break + end + + seen << x + + if ( x =~ /test 2/i ) + puts "TEST 2 - sleeping" sleep 5 end end -- cgit v1.2.1