/
run_remote.rb
59 lines (47 loc) · 1.33 KB
/
run_remote.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require "testjour/commands/command"
require "cucumber"
require "uri"
require "daemons/daemonize"
require "testjour/cucumber_extensions/http_formatter"
require "testjour/mysql"
require "testjour/rsync"
require "stringio"
module Testjour
module Commands
class RunRemote < Command
def dir
configuration.in
end
def execute
configuration.parse!
configuration.parse_uri!
Dir.chdir(dir) do
Testjour.setup_logger(dir)
Testjour.logger.info "Starting #{self.class.name}"
rsync
start_additional_slaves
end
end
def start_additional_slaves
1.upto(configuration.max_remote_slaves) do |i|
start_slave
end
end
def start_slave
Testjour.logger.info "Starting slave: #{local_run_command}"
detached_exec(local_run_command)
end
def local_run_command
"testjour run:slave #{configuration.run_slave_args.join(' ')} #{testjour_uri}".squeeze(" ")
end
def testjour_uri
user = Etc.getpwuid.name
host = Testjour.socket_hostname
"rsync://#{user}@#{host}" + File.expand_path(".")
end
def rsync
Rsync.copy_to_current_directory_from(configuration.rsync_uri)
end
end
end
end