Permalink
Browse files

Changes to resolve the host for the redis queue properly during remot…

…e runs.
  • Loading branch information...
1 parent 3288881 commit 911fbd01228bf1e1d182c95fc34329c3d923c5c5 @lukemelia lukemelia committed Oct 22, 2009
@@ -4,11 +4,20 @@ Feature: Distributed runs
As a software engineer
I want to run my Cucumber features distributed across hardware
- Scenario: Distribute runs
+ Scenario: Distribute runs (localhost)
Given Testjour is configured to run on localhost in a temp1 directory
And Testjour is configured to run on localhost in a temp2 directory
When I run `testjour sleep1.feature sleep2.feature`
Then it should fail with "2 steps passed"
And the output should contain "FAIL"
And the output should contain "1 steps failed"
+ And it should run on 2 remote slaves
+
+ Scenario: Distribute runs (using named host)
+ Given Testjour is configured to run on this machine in a temp1 directory
+ And Testjour is configured to run on this machine in a temp2 directory
+ When I run `testjour sleep1.feature sleep2.feature`
+ Then it should fail with "2 steps passed"
+ And the output should contain "FAIL"
+ And the output should contain "1 steps failed"
And it should run on 2 remote slaves
@@ -10,14 +10,23 @@
FileUtils.mkdir_p full_path
end
+Given /^Testjour is configured to run on this machine in a (\w+) directory$/ do |dir_name|
+ @args ||= []
+ full_path = File.expand_path("./tmp/#{dir_name}")
+ @args << "--on=testjour://#{`hostname`.chomp}#{full_path}"
+
+ FileUtils.rm_rf full_path
+ FileUtils.mkdir_p full_path
+end
+
When /^I run `testjour (.+)`$/ do |args|
@args ||= []
@args += args.split
Dir.chdir(@full_dir) do
testjour_path = File.expand_path(File.dirname(__FILE__) + "/../../../../bin/testjour")
cmd = "#{testjour_path} #{@args.join(" ")}"
- # puts cmd
+ #puts cmd
status, @stdout, @stderr = systemu(cmd)
@exit_code = status.exitstatus
end
@@ -37,7 +37,7 @@ def execute
def queue_features
Testjour.logger.info("Queuing features...")
- queue = RedisQueue.new
+ queue = RedisQueue.new(configuration.queue_host)
configuration.feature_files.each do |feature_file|
queue.push(:feature_files, feature_file)
@@ -92,7 +92,7 @@ def testjour_yml_args
def print_results
results_formatter = ResultsFormatter.new(step_counter, configuration.options)
- queue = RedisQueue.new
+ queue = RedisQueue.new(configuration.queue_host)
step_counter.count.times do
results_formatter.result(queue.blocking_pop(:results))
@@ -31,7 +31,7 @@ def execute
end
def work
- queue = RedisQueue.new
+ queue = RedisQueue.new(configuration.queue_host)
feature_file = true
while feature_file
@@ -48,7 +48,7 @@ def work
end
def execute_features(features)
- http_formatter = Testjour::HttpFormatter.new
+ http_formatter = Testjour::HttpFormatter.new(configuration)
tree_walker = Cucumber::Ast::TreeWalker.new(step_mother, [http_formatter])
tree_walker.options = configuration.cucumber_configuration.options
Testjour.logger.info "Visiting..."
@@ -1,7 +1,7 @@
module Testjour
class Configuration
- attr_reader :unknown_args, :options, :path, :queue_uri, :full_uri
+ attr_reader :unknown_args, :options, :path, :full_uri
def initialize(args)
@options = {}
@@ -31,6 +31,10 @@ def in
def rsync_uri
full_uri.user + "@" + full_uri.host + ":" + full_uri.path
end
+
+ def queue_host
+ @queue_host || `hostname`.chomp
+ end
def remote_slaves
@options[:slaves] || []
@@ -128,8 +132,7 @@ def parse_uri!
full_uri = URI.parse(@args.shift)
@path = full_uri.path
@full_uri = full_uri.dup
- full_uri.path = "/"
- @queue_uri = full_uri.to_s
+ @queue_host = full_uri.host
end
def run_slave_args
@@ -6,6 +6,10 @@
module Testjour
class HttpFormatter
+
+ def initialize(configuration)
+ @configuration = configuration
+ end
def before_multiline_arg(multiline_arg)
@multiline_arg = true
@@ -39,7 +43,7 @@ def table_cell_value(value, status)
private
def progress(time, status, step_match = nil, exception = nil)
- queue = RedisQueue.new
+ queue = RedisQueue.new(@configuration.queue_host)
queue.push(:results, Result.new(time, status, step_match, exception))
end
View
@@ -6,17 +6,19 @@ module Testjour
class RedisQueue
def self.reset_all
- redis.del "testjour:feature_files"
- redis.del "testjour:results"
+ local_redis.del "testjour:feature_files"
+ local_redis.del "testjour:results"
end
- def self.redis
+ def self.local_redis
@redis ||= Redis.new(:db => 11)
end
-
- def redis
- self.class.redis
+
+ def initialize(redis_host)
+ @redis = Redis.new(:db => 11, :host => redis_host)
end
+
+ attr_reader :redis
def push(queue_name, data)
redis.lpush("testjour:#{queue_name}", Marshal.dump(data))

0 comments on commit 911fbd0

Please sign in to comment.