Permalink
Browse files

Starting to add run:remote, accessible via --on option

  • Loading branch information...
1 parent 13143db commit 1a179bd2c4a14ee82c9952e76aacbde51288c527 @brynary committed Feb 10, 2009
View
@@ -23,6 +23,9 @@ def command_class(args)
elsif args.first == "run:slave"
@args_for_command = @args[1..-1]
Commands::RunSlave
+ elsif args.first == "run:remote"
+ @args_for_command = @args[1..-1]
+ Commands::RunRemote
elsif args.first == "mysql:load_schema"
@args_for_command = @args[1..-1]
Commands::LoadSchema
@@ -2,4 +2,5 @@
require "testjour/commands/version"
require "testjour/commands/run"
require "testjour/commands/run_slave"
+require "testjour/commands/run_remote"
require "testjour/commands/load_schema"
@@ -31,11 +31,33 @@ def queue_features
end
def start_slaves
+ start_local_slaves
+ start_remote_slaves
+ end
+
+ def start_local_slaves
configuration.local_slave_count.times do
start_slave
end
end
+ def start_remote_slaves
+ configuration.remote_slaves.each do |remote_slave|
+ start_remote_slave(remote_slave)
+ end
+ end
+
+ def start_remote_slave(remote_slave)
+ uri = URI.parse(remote_slave)
+ cmd = remote_slave_run_command(uri.host, uri.path)
+ Testjour.logger.info "Starting remote slave: #{cmd}"
+ detached_exec(cmd)
+ end
+
+ def remote_slave_run_command(host, path)
+ "ssh #{host} testjour run:remote --in=#{path} #{configuration.run_slave_args.join(' ')} #{testjour_uri}".squeeze(" ")
+ end
+
def start_slave
Testjour.logger.info "Starting slave: #{local_run_command}"
detached_exec(local_run_command)
@@ -0,0 +1,16 @@
+require "testjour/commands/command"
+require "cucumber"
+require "uri"
+require "daemons/daemonize"
+require "testjour/cucumber_extensions/http_formatter"
+require "testjour/mysql"
+require "stringio"
+
+module Testjour
+module Commands
+
+ class RunRemote < RunSlave
+ end
+
+end
+end
@@ -23,6 +23,10 @@ def language_incomplete?
setup_mysql if mysql_mode?
end
+ def remote_slaves
+ @options[:slaves] || []
+ end
+
def setup_mysql
mysql = MysqlDatabaseSetup.new
mysql.create_database
@@ -59,6 +63,7 @@ def mysql_mode?
end
def local_slave_count
+ return 0 if remote_slaves.any?
[feature_files.size, @max_local_slaves].min
end
@@ -125,6 +130,10 @@ def option_parser
@options[:slaves] << slave
end
+ opts.on("--in=DIR", "Working directory to use (for run:remote only)") do |directory|
+ @options[:in] = directory
+ end
+
opts.on("--create-mysql-db", "Create MySQL for each slave") do |server|
@options[:create_mysql_db] = true
end

0 comments on commit 1a179bd

Please sign in to comment.