Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add optional configuration for rsync-host, used as a place for the ma…

…ster to rsync *to*, and then slaves can rsync *from*.
  • Loading branch information...
commit 27b6b5a02fcfc0b5b28f0f44a5b62b501d3c82b9 1 parent bc7aacd
@lukemelia lukemelia authored
View
13 features/distributed_run.feature
@@ -16,9 +16,20 @@ Feature: Distributed runs
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
+
+ Scenario: Distribute runs (using named host, queue_host and rsync_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
And Testjour is configured to use this machine as the queue host
+ And Testjour is configured to use this machine as the rsync host
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
+ And it should run on 2 remote slaves
+
View
9 features/step_definitions/testjour_steps.rb
@@ -24,6 +24,11 @@
@args << "--queue-host=#{Socket.gethostname}"
end
+Given /^Testjour is configured to use this machine as the rsync host$/ do
+ @args ||= []
+ @args << "--rsync-host=#{Socket.gethostname}"
+end
+
Given /^a file testjour_preload.rb at the root of the project that logs "Hello, world"$/ do
File.open(File.join(@full_dir, 'testjour_preload.rb'), 'w') do |file|
file.puts "Testjour.logger.info 'Hello, world'"
@@ -37,10 +42,10 @@
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
- # puts @stderr.to_s
+ puts @stderr.to_s
end
end
View
11 lib/testjour/commands/run.rb
@@ -59,9 +59,14 @@ def start_local_slaves
end
def start_remote_slaves
- configuration.remote_slaves.each do |remote_slave|
- @started_slaves += 1
- start_remote_slave(remote_slave)
+ if configuration.remote_slaves.any?
+ if configuration.external_rsync_uri
+ Rsync.copy_from_current_directory_to(configuration.external_rsync_uri)
+ end
+ configuration.remote_slaves.each do |remote_slave|
+ @started_slaves += 1
+ start_remote_slave(remote_slave)
+ end
end
end
View
12 lib/testjour/configuration.rb
@@ -29,7 +29,13 @@ def in
end
def rsync_uri
- full_uri.user + "@" + full_uri.host + ":" + full_uri.path
+ external_rsync_uri || (full_uri.user + "@" + full_uri.host + ":" + full_uri.path)
+ end
+
+ def external_rsync_uri
+ if @options[:rsync_host]
+ @options[:rsync_host] + ":/tmp/testjour"
+ end
end
def queue_host
@@ -176,6 +182,10 @@ def option_parser
@options[:queue_host] = queue_host
end
+ opts.on("--rsync-host=RSYNC_HOST", "Use another server to host the codebase for slave rsync") do |rsync_host|
+ @options[:rsync_host] = rsync_host
+ end
+
opts.on("--max-local-slaves=MAX", "Maximum number of local slaves") do |max|
@options[:max_local_slaves] = max.to_i
end
View
16 lib/testjour/rsync.rb
@@ -10,11 +10,16 @@ class RsyncFailed < StandardError
class Rsync
def self.copy_to_current_directory_from(source_uri)
- new(source_uri).copy_with_retry
+ new(source_uri, File.expand_path(".")).copy_with_retry
end
- def initialize(source_uri)
+ def self.copy_from_current_directory_to(destination_uri)
+ new(File.expand_path("."), destination_uri).copy_with_retry
+ end
+
+ def initialize(source_uri, destination_uri)
@source_uri = source_uri
+ @destination_uri = destination_uri
end
def copy_with_retry
@@ -49,12 +54,7 @@ def successful?
end
def command
- "rsync -az -e \"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\" --delete --exclude=.git --exclude=*.log --exclude=*.pid #{@source_uri}/ #{destination_dir}"
+ "rsync -az -e \"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no\" --delete --exclude=.git --exclude=*.log --exclude=*.pid #{@source_uri}/ #{@destination_uri}"
end
-
- def destination_dir
- File.expand_path(".")
- end
-
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.