Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…e runs.
  • Loading branch information...
commit 911fbd01228bf1e1d182c95fc34329c3d923c5c5 1 parent 3288881
@lukemelia lukemelia authored
View
11 features/distributed_run.feature
@@ -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
View
11 features/step_definitions/testjour_steps.rb
@@ -10,6 +10,15 @@
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
@@ -17,7 +26,7 @@
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
View
4 lib/testjour/commands/run.rb
@@ -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))
View
4 lib/testjour/commands/run_slave.rb
@@ -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..."
View
9 lib/testjour/configuration.rb
@@ -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
View
6 lib/testjour/cucumber_extensions/http_formatter.rb
@@ -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
14 lib/testjour/http_queue.rb
@@ -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))
Please sign in to comment.
Something went wrong with that request. Please try again.