set an rsync timeout, and trying to get the tests to run

This commit is contained in:
John Bintz 2011-08-23 07:01:48 -04:00
parent ff803d6d3a
commit 94b73ee426
15 changed files with 172 additions and 140 deletions

View File

@ -1,3 +1,4 @@
source :rubygems source :rubygems
gemspec gemspec
gem 'rake', '0.8.7'

View File

@ -1,7 +1,8 @@
PATH PATH
remote: . remote: .
specs: specs:
hydra (0.23.2) hydra (0.23.3)
hydra
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
@ -18,14 +19,15 @@ GEM
json (~> 1.4.6) json (~> 1.4.6)
term-ansicolor (~> 1.0.5) term-ansicolor (~> 1.0.5)
json (1.4.6) json (1.4.6)
rspec (2.0.0.beta.19) rake (0.8.7)
rspec-core (= 2.0.0.beta.19) rspec (2.6.0)
rspec-expectations (= 2.0.0.beta.19) rspec-core (~> 2.6.0)
rspec-mocks (= 2.0.0.beta.19) rspec-expectations (~> 2.6.0)
rspec-core (2.0.0.beta.19) rspec-mocks (~> 2.6.0)
rspec-expectations (2.0.0.beta.19) rspec-core (2.6.4)
diff-lcs (>= 1.1.2) rspec-expectations (2.6.0)
rspec-mocks (2.0.0.beta.19) diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
shoulda (2.10.3) shoulda (2.10.3)
term-ansicolor (1.0.6) term-ansicolor (1.0.6)
therubyracer (0.7.4) therubyracer (0.7.4)
@ -36,6 +38,8 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
cucumber (= 0.9.2) cucumber (= 0.9.2)
hydra! hydra!
rspec (= 2.0.0.beta.19) rake (= 0.8.7)
rspec (~> 2.6.0)
rspec-core (>= 2.6.4)
shoulda (= 2.10.3) shoulda (= 2.10.3)
therubyracer (= 0.7.4) therubyracer (= 0.7.4)

View File

@ -11,7 +11,8 @@ begin
gem.homepage = "http://github.com/ngauthier/hydra" gem.homepage = "http://github.com/ngauthier/hydra"
gem.authors = ["Nick Gauthier"] gem.authors = ["Nick Gauthier"]
gem.add_development_dependency "shoulda", "= 2.10.3" gem.add_development_dependency "shoulda", "= 2.10.3"
gem.add_development_dependency "rspec", "= 2.0.0.beta.19" gem.add_development_dependency "rspec", "~> 2.6.0"
gem.add_development_dependency "rspec-core", ">= 2.6.4"
gem.add_development_dependency "cucumber", "= 0.9.2" gem.add_development_dependency "cucumber", "= 0.9.2"
gem.add_development_dependency "therubyracer", "= 0.7.4" gem.add_development_dependency "therubyracer", "= 0.7.4"
end end
@ -22,7 +23,7 @@ end
require 'rake/testtask' require 'rake/testtask'
Rake::TestTask.new(:test) do |test| Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test' test.libs << 'test'
test.pattern = 'test/**/*_test.rb' test.pattern = 'test/**/*_test.rb'
test.verbose = true test.verbose = true
end end

View File

@ -1,129 +1,146 @@
# Generated by jeweler # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY # DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{hydra} s.name = %q{hydra}
s.version = "0.23.2" s.version = "0.23.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nick Gauthier"] s.authors = [%q{Nick Gauthier}]
s.date = %q{2010-11-03} s.date = %q{2011-08-23}
s.description = %q{Spread your tests over multiple machines to test your code faster.} s.description = %q{Spread your tests over multiple machines to test your code faster.}
s.email = %q{nick@smartlogicsolutions.com} s.email = %q{nick@smartlogicsolutions.com}
s.extra_rdoc_files = [ s.extra_rdoc_files = [
"LICENSE", "LICENSE",
"README.rdoc", "README.rdoc",
"TODO" "TODO"
] ]
s.files = [ s.files = [
".document", ".document",
".gitignore", "Gemfile",
"LICENSE", "Gemfile.lock",
"README.rdoc", "LICENSE",
"Rakefile", "README.rdoc",
"TODO", "Rakefile",
"VERSION", "TODO",
"caliper.yml", "VERSION",
"hydra-icon-64x64.png", "caliper.yml",
"hydra.gemspec", "hydra-icon-64x64.png",
"hydra_gray.png", "hydra.gemspec",
"lib/hydra.rb", "hydra_gray.png",
"lib/hydra/cucumber/formatter.rb", "lib/hydra.rb",
"lib/hydra/hash.rb", "lib/hydra/cucumber/formatter.rb",
"lib/hydra/js/lint.js", "lib/hydra/cucumber/partial_html.rb",
"lib/hydra/listener/abstract.rb", "lib/hydra/hash.rb",
"lib/hydra/listener/minimal_output.rb", "lib/hydra/js/lint.js",
"lib/hydra/listener/notifier.rb", "lib/hydra/listener/abstract.rb",
"lib/hydra/listener/progress_bar.rb", "lib/hydra/listener/cucumber.css",
"lib/hydra/listener/report_generator.rb", "lib/hydra/listener/cucumber_html_report.rb",
"lib/hydra/master.rb", "lib/hydra/listener/jquery-min.js",
"lib/hydra/message.rb", "lib/hydra/listener/minimal_output.rb",
"lib/hydra/message/master_messages.rb", "lib/hydra/listener/notifier.rb",
"lib/hydra/message/runner_messages.rb", "lib/hydra/listener/progress_bar.rb",
"lib/hydra/message/worker_messages.rb", "lib/hydra/listener/report_generator.rb",
"lib/hydra/messaging_io.rb", "lib/hydra/master.rb",
"lib/hydra/pipe.rb", "lib/hydra/message.rb",
"lib/hydra/runner.rb", "lib/hydra/message/master_messages.rb",
"lib/hydra/safe_fork.rb", "lib/hydra/message/runner_messages.rb",
"lib/hydra/spec/autorun_override.rb", "lib/hydra/message/worker_messages.rb",
"lib/hydra/spec/hydra_formatter.rb", "lib/hydra/messaging_io.rb",
"lib/hydra/ssh.rb", "lib/hydra/pipe.rb",
"lib/hydra/stdio.rb", "lib/hydra/runner.rb",
"lib/hydra/sync.rb", "lib/hydra/runner_listener/abstract.rb",
"lib/hydra/tasks.rb", "lib/hydra/safe_fork.rb",
"lib/hydra/tmpdir.rb", "lib/hydra/spec/autorun_override.rb",
"lib/hydra/trace.rb", "lib/hydra/spec/hydra_formatter.rb",
"lib/hydra/worker.rb", "lib/hydra/ssh.rb",
"test/fixtures/assert_true.rb", "lib/hydra/stdio.rb",
"test/fixtures/config.yml", "lib/hydra/sync.rb",
"test/fixtures/conflicting.rb", "lib/hydra/tasks.rb",
"test/fixtures/features/step_definitions.rb", "lib/hydra/tmpdir.rb",
"test/fixtures/features/write_alternate_file.feature", "lib/hydra/trace.rb",
"test/fixtures/features/write_file.feature", "lib/hydra/worker.rb",
"test/fixtures/hello_world.rb", "test/fixtures/assert_true.rb",
"test/fixtures/js_file.js", "test/fixtures/config.yml",
"test/fixtures/json_data.json", "test/fixtures/conflicting.rb",
"test/fixtures/slow.rb", "test/fixtures/features/step_definitions.rb",
"test/fixtures/sync_test.rb", "test/fixtures/features/write_alternate_file.feature",
"test/fixtures/write_file.rb", "test/fixtures/features/write_file.feature",
"test/fixtures/write_file_alternate_spec.rb", "test/fixtures/hello_world.rb",
"test/fixtures/write_file_spec.rb", "test/fixtures/hydra_worker_init.rb",
"test/fixtures/write_file_with_pending_spec.rb", "test/fixtures/js_file.js",
"test/master_test.rb", "test/fixtures/json_data.json",
"test/message_test.rb", "test/fixtures/many_outputs_to_console.rb",
"test/pipe_test.rb", "test/fixtures/master_listeners.rb",
"test/runner_test.rb", "test/fixtures/runner_listeners.rb",
"test/ssh_test.rb", "test/fixtures/slow.rb",
"test/sync_test.rb", "test/fixtures/sync_test.rb",
"test/test_helper.rb", "test/fixtures/task_test_config.yml",
"test/worker_test.rb" "test/fixtures/write_file.rb",
"test/fixtures/write_file_alternate_spec.rb",
"test/fixtures/write_file_spec.rb",
"test/fixtures/write_file_with_pending_spec.rb",
"test/master_test.rb",
"test/message_test.rb",
"test/pipe_test.rb",
"test/runner_test.rb",
"test/ssh_test.rb",
"test/sync_test.rb",
"test/task_test.rb",
"test/test_helper.rb",
"test/worker_test.rb"
] ]
s.homepage = %q{http://github.com/ngauthier/hydra} s.homepage = %q{http://github.com/ngauthier/hydra}
s.rdoc_options = ["--charset=UTF-8"] s.require_paths = [%q{lib}]
s.require_paths = ["lib"] s.rubygems_version = %q{1.8.6}
s.rubygems_version = %q{1.3.7}
s.summary = %q{Distributed testing toolkit} s.summary = %q{Distributed testing toolkit}
s.test_files = [
"test/pipe_test.rb",
"test/sync_test.rb",
"test/ssh_test.rb",
"test/fixtures/write_file_alternate_spec.rb",
"test/fixtures/sync_test.rb",
"test/fixtures/hello_world.rb",
"test/fixtures/features/step_definitions.rb",
"test/fixtures/assert_true.rb",
"test/fixtures/slow.rb",
"test/fixtures/write_file_spec.rb",
"test/fixtures/conflicting.rb",
"test/fixtures/write_file_with_pending_spec.rb",
"test/fixtures/write_file.rb",
"test/message_test.rb",
"test/test_helper.rb",
"test/master_test.rb",
"test/runner_test.rb",
"test/worker_test.rb"
]
if s.respond_to? :specification_version then if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3 s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<hydra>, [">= 0"])
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"]) s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_development_dependency(%q<rspec>, ["= 2.0.0.beta.19"]) s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_development_dependency(%q<rspec>, ["= 2.6.4"])
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
s.add_development_dependency(%q<rspec-core>, [">= 2.6.4"])
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"]) s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"]) s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
else else
s.add_dependency(%q<hydra>, [">= 0"])
s.add_dependency(%q<shoulda>, ["= 2.10.3"]) s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"]) s.add_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<rspec>, ["= 2.6.4"])
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
s.add_dependency(%q<rspec-core>, [">= 2.6.4"])
s.add_dependency(%q<cucumber>, ["= 0.9.2"]) s.add_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_dependency(%q<therubyracer>, ["= 0.7.4"]) s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
end end
else else
s.add_dependency(%q<hydra>, [">= 0"])
s.add_dependency(%q<shoulda>, ["= 2.10.3"]) s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"]) s.add_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<rspec>, ["= 2.6.4"])
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
s.add_dependency(%q<rspec-core>, [">= 2.6.4"])
s.add_dependency(%q<cucumber>, ["= 0.9.2"]) s.add_dependency(%q<cucumber>, ["= 0.9.2"])
s.add_dependency(%q<therubyracer>, ["= 0.7.4"]) s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
end end

View File

@ -71,7 +71,7 @@ module Hydra #:nodoc:
@verbose = opts.fetch('verbose') { false } @verbose = opts.fetch('verbose') { false }
@autosort = opts.fetch('autosort') { true } @autosort = opts.fetch('autosort') { true }
@sync = opts.fetch('sync') { nil } @sync = opts.fetch('sync') { nil }
@environment = opts.fetch('environment') { 'test' } @environment = opts.fetch('environment') { 'test' } || 'test'
@options = opts.fetch('options') { '' } @options = opts.fetch('options') { '' }
if @autosort if @autosort
@ -174,15 +174,19 @@ module Hydra #:nodoc:
def boot_ssh_worker(worker) def boot_ssh_worker(worker)
sync = Sync.new(worker, @sync, @verbose) sync = Sync.new(worker, @sync, @verbose)
if sync.result == 0
runners = worker.fetch('runners') { raise "You must specify the number of runners" }
command = worker.fetch('command') {
"RAILS_ENV=#{@environment} bundle exec ruby -e \"load 'config/application.rb'; require 'hydra'; Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose}, :runner_listeners => \'#{@string_runner_event_listeners}\', :runner_log_file => \'#{@runner_log_file}\', :options => {} );\""
}
runners = worker.fetch('runners') { raise "You must specify the number of runners" } trace "Booting SSH worker"
command = worker.fetch('command') { trace command
"RAILS_ENV=#{@environment} ruby -e \"require 'rubygems'; require 'hydra'; Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose}, :runner_listeners => \'#{@string_runner_event_listeners}\', :runner_log_file => \'#{@runner_log_file}\' );\"" ssh = Hydra::SSH.new("#{sync.ssh_opts} #{sync.connect}", sync.remote_dir, command)
} return { :io => ssh, :idle => false, :type => :ssh, :connect => sync.connect }
else
trace "Booting SSH worker" false
ssh = Hydra::SSH.new("#{sync.ssh_opts} #{sync.connect}", sync.remote_dir, command) end
return { :io => ssh, :idle => false, :type => :ssh, :connect => sync.connect }
end end
def shutdown_all_workers def shutdown_all_workers
@ -204,20 +208,22 @@ module Hydra #:nodoc:
trace "Listening to #{worker.inspect}" trace "Listening to #{worker.inspect}"
if worker.fetch('type') { 'local' }.to_s == 'ssh' if worker.fetch('type') { 'local' }.to_s == 'ssh'
worker = boot_ssh_worker(worker) worker = boot_ssh_worker(worker)
@workers << worker @workers << worker if worker
end end
while true if worker
begin while true
message = worker[:io].gets begin
trace "got message: #{message}" message = worker[:io].gets
# if it exists and its for me. trace "got message: #{message}"
# SSH gives us back echoes, so we need to ignore our own messages # if it exists and its for me.
if message and !message.class.to_s.index("Worker").nil? # SSH gives us back echoes, so we need to ignore our own messages
message.handle(self, worker) if message and !message.class.to_s.index("Worker").nil?
message.handle(self, worker)
end
rescue IOError
trace "lost Worker [#{worker.inspect}]"
Thread.exit
end end
rescue IOError
trace "lost Worker [#{worker.inspect}]"
Thread.exit
end end
end end
end end

View File

@ -7,7 +7,7 @@ module Hydra #:nodoc:
traceable('SYNC') traceable('SYNC')
self.class.traceable('SYNC MANY') self.class.traceable('SYNC MANY')
attr_reader :connect, :ssh_opts, :remote_dir attr_reader :connect, :ssh_opts, :remote_dir, :result
# Create a new Sync instance to rsync source from the local machine to a remote worker # Create a new Sync instance to rsync source from the local machine to a remote worker
# #
@ -47,6 +47,7 @@ module Hydra #:nodoc:
'rsync', 'rsync',
'-avz', '-avz',
'--delete', '--delete',
'--timeout=2',
exclude_opts, exclude_opts,
File.expand_path(@local_dir)+'/', File.expand_path(@local_dir)+'/',
"-e \"ssh #{@ssh_opts}\"", "-e \"ssh #{@ssh_opts}\"",
@ -54,6 +55,7 @@ module Hydra #:nodoc:
].join(" ") ].join(" ")
trace rsync_command trace rsync_command
trace `#{rsync_command}` trace `#{rsync_command}`
@result = $?.exitstatus
end end
def self.sync_many opts def self.sync_many opts

View File

@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
require File.join(File.dirname(__FILE__), 'fixtures', 'runner_listeners') require 'fixtures/runner_listeners'
require File.join(File.dirname(__FILE__), 'fixtures', 'master_listeners') require 'fixtures/master_listeners'
class MasterTest < Test::Unit::TestCase class MasterTest < Test::Unit::TestCase
context "with a file to test and a destination to verify" do context "with a file to test and a destination to verify" do

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
class MessageTest < Test::Unit::TestCase class MessageTest < Test::Unit::TestCase
class MyMessage < Hydra::Message class MyMessage < Hydra::Message

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
class PipeTest < Test::Unit::TestCase class PipeTest < Test::Unit::TestCase
context "a pipe" do context "a pipe" do

View File

@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
require File.join(File.dirname(__FILE__), 'fixtures', 'runner_listeners') require 'fixtures/runner_listeners'
class RunnerTest < Test::Unit::TestCase class RunnerTest < Test::Unit::TestCase
context "with a file to test and a destination to verify" do context "with a file to test and a destination to verify" do

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
class SSHTest < Test::Unit::TestCase class SSHTest < Test::Unit::TestCase
should "be able to execute a command over ssh" do should "be able to execute a command over ssh" do

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
class SyncTest < Test::Unit::TestCase class SyncTest < Test::Unit::TestCase
context "with a file to test and a destination to verify" do context "with a file to test and a destination to verify" do
@ -37,6 +37,9 @@ class SyncTest < Test::Unit::TestCase
# ensure b is on remote # ensure b is on remote
assert File.exists?(File.join(remote, 'test_b.rb')), "B should be on remote" assert File.exists?(File.join(remote, 'test_b.rb')), "B should be on remote"
$stderr.puts local
$stderr.puts remote
Hydra::Sync.new( Hydra::Sync.new(
{ {
:type => :ssh, :type => :ssh,

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
require 'hydra/tasks' require 'hydra/tasks'
require 'rake' require 'rake'

View File

@ -1,7 +1,5 @@
require 'rubygems' require 'rubygems'
require 'test/unit' require 'test/unit'
gem 'shoulda', '2.10.3'
gem 'rspec', '2.0.0.beta.19'
require 'shoulda' require 'shoulda'
require 'tmpdir' require 'tmpdir'
require "stringio" require "stringio"

View File

@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'test_helper') require 'test_helper'
class WorkerTest < Test::Unit::TestCase class WorkerTest < Test::Unit::TestCase
context "with a file to test and a destination to verify" do context "with a file to test and a destination to verify" do