Browse files

Add a CLI option for queue-prefix, to allow for separate simultaneous…

…ly executing testjour suites.
  • Loading branch information...
1 parent efa1442 commit 69698d92eea7878164782dba3ad1509e36cc5e6a @lukemelia lukemelia committed Jan 3, 2010
View
6 lib/testjour/commands/run.rb
@@ -21,7 +21,7 @@ def execute
configuration.setup
if configuration.feature_files.any?
- RedisQueue.reset_all
+ RedisQueue.new(configuration.queue_host, configuration.queue_prefix).reset_all
queue_features
@started_slaves = 0
@@ -38,7 +38,7 @@ def execute
def queue_features
Testjour.logger.info("Queuing features...")
- queue = RedisQueue.new(configuration.queue_host)
+ queue = RedisQueue.new(configuration.queue_host, configuration.queue_prefix)
configuration.feature_files.each do |feature_file|
queue.push(:feature_files, feature_file)
@@ -88,7 +88,7 @@ def start_slave
def print_results
results_formatter = ResultsFormatter.new(step_counter, configuration.options)
- queue = RedisQueue.new(configuration.queue_host)
+ queue = RedisQueue.new(configuration.queue_host, configuration.queue_prefix)
step_counter.count.times do
results_formatter.result(queue.blocking_pop(:results))
View
2 lib/testjour/commands/run_slave.rb
@@ -49,7 +49,7 @@ def before_require
end
def work
- queue = RedisQueue.new(configuration.queue_host)
+ queue = RedisQueue.new(configuration.queue_host, configuration.queue_prefix)
feature_file = true
while feature_file
View
11 lib/testjour/configuration.rb
@@ -39,6 +39,10 @@ def external_rsync_uri
def queue_host
@queue_host || @options[:queue_host] || Testjour.socket_hostname
end
+
+ def queue_prefix
+ @options[:queue_prefix] || 'default'
+ end
def remote_slaves
@options[:slaves] || []
@@ -173,6 +177,9 @@ def testjour_args
if @options[:queue_host]
args_from_options << "--queue-host=#{@options[:queue_host]}"
end
+ if @options[:queue_prefix]
+ args_from_options << "--queue-prefix=#{@options[:queue_prefix]}"
+ end
return args_from_options
end
@@ -209,6 +216,10 @@ def option_parser
@options[:queue_host] = queue_host
end
+ opts.on("--queue-prefix=QUEUE_PREFIX", "Provide a prefix to uniquely identify this testjour run (Default is 'default')") do |queue_prefix|
+ @options[:queue_prefix] = queue_prefix
+ end
+
opts.on("--rsync-uri=RSYNC_URI", "Use another location to host the codebase for slave rsync (master will rsync to this URI first)") do |rsync_uri|
@options[:rsync_uri] = rsync_uri
end
View
2 lib/testjour/cucumber_extensions/http_formatter.rb
@@ -43,7 +43,7 @@ def table_cell_value(value, status)
private
def progress(time, status, step_match = nil, exception = nil)
- queue = RedisQueue.new(@configuration.queue_host)
+ queue = RedisQueue.new(@configuration.queue_host, @configuration.queue_prefix)
queue.push(:results, Result.new(time, status, step_match, exception))
end
View
27 lib/testjour/redis_queue.rb
@@ -4,28 +4,20 @@
module Testjour
class RedisQueue
-
- def self.reset_all
- local_redis.del "testjour:feature_files"
- local_redis.del "testjour:results"
- end
-
- def self.local_redis
- @redis ||= Redis.new(:db => 11)
- end
- def initialize(redis_host)
+ def initialize(redis_host, queue_namespace)
@redis = Redis.new(:db => 11, :host => redis_host)
+ @queue_namespace = queue_namespace
end
attr_reader :redis
def push(queue_name, data)
- redis.lpush("testjour:#{queue_name}", Marshal.dump(data))
+ redis.lpush("testjour:#{queue_namespace}:#{queue_name}", Marshal.dump(data))
end
def pop(queue_name)
- result = redis.rpop("testjour:#{queue_name}")
+ result = redis.rpop("testjour:#{queue_namespace}:#{queue_name}")
result ? Marshal.load(result) : nil
end
@@ -41,6 +33,17 @@ def blocking_pop(queue_name)
result
end
end
+
+ def reset_all
+ redis.del "testjour:#{queue_namespace}:feature_files"
+ redis.del "testjour:#{queue_namespace}:results"
+ end
+
+ protected
+
+ def queue_namespace
+ @queue_namespace
+ end
end

0 comments on commit 69698d9

Please sign in to comment.