From 94b73ee426639e9bb4118cbd239c48ada5b52778 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 23 Aug 2011 07:01:48 -0400 Subject: [PATCH] set an rsync timeout, and trying to get the tests to run --- Gemfile | 1 + Gemfile.lock | 24 ++--- Rakefile | 5 +- hydra.gemspec | 203 +++++++++++++++++++++++-------------------- lib/hydra/master.rb | 48 +++++----- lib/hydra/sync.rb | 4 +- test/master_test.rb | 6 +- test/message_test.rb | 2 +- test/pipe_test.rb | 2 +- test/runner_test.rb | 4 +- test/ssh_test.rb | 2 +- test/sync_test.rb | 5 +- test/task_test.rb | 2 +- test/test_helper.rb | 2 - test/worker_test.rb | 2 +- 15 files changed, 172 insertions(+), 140 deletions(-) diff --git a/Gemfile b/Gemfile index a1b93f3..0def5d5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,4 @@ source :rubygems gemspec +gem 'rake', '0.8.7' diff --git a/Gemfile.lock b/Gemfile.lock index 19b4122..6e23e14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,8 @@ PATH remote: . specs: - hydra (0.23.2) + hydra (0.23.3) + hydra GEM remote: http://rubygems.org/ @@ -18,14 +19,15 @@ GEM json (~> 1.4.6) term-ansicolor (~> 1.0.5) json (1.4.6) - rspec (2.0.0.beta.19) - rspec-core (= 2.0.0.beta.19) - rspec-expectations (= 2.0.0.beta.19) - rspec-mocks (= 2.0.0.beta.19) - rspec-core (2.0.0.beta.19) - rspec-expectations (2.0.0.beta.19) - diff-lcs (>= 1.1.2) - rspec-mocks (2.0.0.beta.19) + rake (0.8.7) + rspec (2.6.0) + rspec-core (~> 2.6.0) + rspec-expectations (~> 2.6.0) + rspec-mocks (~> 2.6.0) + rspec-core (2.6.4) + rspec-expectations (2.6.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.6.0) shoulda (2.10.3) term-ansicolor (1.0.6) therubyracer (0.7.4) @@ -36,6 +38,8 @@ PLATFORMS DEPENDENCIES cucumber (= 0.9.2) hydra! - rspec (= 2.0.0.beta.19) + rake (= 0.8.7) + rspec (~> 2.6.0) + rspec-core (>= 2.6.4) shoulda (= 2.10.3) therubyracer (= 0.7.4) diff --git a/Rakefile b/Rakefile index e5e6e67..a010308 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,8 @@ begin gem.homepage = "http://github.com/ngauthier/hydra" gem.authors = ["Nick Gauthier"] 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 "therubyracer", "= 0.7.4" end @@ -22,7 +23,7 @@ end require 'rake/testtask' Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' + test.libs << 'test' test.pattern = 'test/**/*_test.rb' test.verbose = true end diff --git a/hydra.gemspec b/hydra.gemspec index db9b35d..01c9784 100644 --- a/hydra.gemspec +++ b/hydra.gemspec @@ -1,129 +1,146 @@ # Generated by jeweler # 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 -*- Gem::Specification.new do |s| 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.authors = ["Nick Gauthier"] - s.date = %q{2010-11-03} + s.authors = [%q{Nick Gauthier}] + s.date = %q{2011-08-23} s.description = %q{Spread your tests over multiple machines to test your code faster.} s.email = %q{nick@smartlogicsolutions.com} s.extra_rdoc_files = [ "LICENSE", - "README.rdoc", - "TODO" + "README.rdoc", + "TODO" ] s.files = [ ".document", - ".gitignore", - "LICENSE", - "README.rdoc", - "Rakefile", - "TODO", - "VERSION", - "caliper.yml", - "hydra-icon-64x64.png", - "hydra.gemspec", - "hydra_gray.png", - "lib/hydra.rb", - "lib/hydra/cucumber/formatter.rb", - "lib/hydra/hash.rb", - "lib/hydra/js/lint.js", - "lib/hydra/listener/abstract.rb", - "lib/hydra/listener/minimal_output.rb", - "lib/hydra/listener/notifier.rb", - "lib/hydra/listener/progress_bar.rb", - "lib/hydra/listener/report_generator.rb", - "lib/hydra/master.rb", - "lib/hydra/message.rb", - "lib/hydra/message/master_messages.rb", - "lib/hydra/message/runner_messages.rb", - "lib/hydra/message/worker_messages.rb", - "lib/hydra/messaging_io.rb", - "lib/hydra/pipe.rb", - "lib/hydra/runner.rb", - "lib/hydra/safe_fork.rb", - "lib/hydra/spec/autorun_override.rb", - "lib/hydra/spec/hydra_formatter.rb", - "lib/hydra/ssh.rb", - "lib/hydra/stdio.rb", - "lib/hydra/sync.rb", - "lib/hydra/tasks.rb", - "lib/hydra/tmpdir.rb", - "lib/hydra/trace.rb", - "lib/hydra/worker.rb", - "test/fixtures/assert_true.rb", - "test/fixtures/config.yml", - "test/fixtures/conflicting.rb", - "test/fixtures/features/step_definitions.rb", - "test/fixtures/features/write_alternate_file.feature", - "test/fixtures/features/write_file.feature", - "test/fixtures/hello_world.rb", - "test/fixtures/js_file.js", - "test/fixtures/json_data.json", - "test/fixtures/slow.rb", - "test/fixtures/sync_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/test_helper.rb", - "test/worker_test.rb" + "Gemfile", + "Gemfile.lock", + "LICENSE", + "README.rdoc", + "Rakefile", + "TODO", + "VERSION", + "caliper.yml", + "hydra-icon-64x64.png", + "hydra.gemspec", + "hydra_gray.png", + "lib/hydra.rb", + "lib/hydra/cucumber/formatter.rb", + "lib/hydra/cucumber/partial_html.rb", + "lib/hydra/hash.rb", + "lib/hydra/js/lint.js", + "lib/hydra/listener/abstract.rb", + "lib/hydra/listener/cucumber.css", + "lib/hydra/listener/cucumber_html_report.rb", + "lib/hydra/listener/jquery-min.js", + "lib/hydra/listener/minimal_output.rb", + "lib/hydra/listener/notifier.rb", + "lib/hydra/listener/progress_bar.rb", + "lib/hydra/listener/report_generator.rb", + "lib/hydra/master.rb", + "lib/hydra/message.rb", + "lib/hydra/message/master_messages.rb", + "lib/hydra/message/runner_messages.rb", + "lib/hydra/message/worker_messages.rb", + "lib/hydra/messaging_io.rb", + "lib/hydra/pipe.rb", + "lib/hydra/runner.rb", + "lib/hydra/runner_listener/abstract.rb", + "lib/hydra/safe_fork.rb", + "lib/hydra/spec/autorun_override.rb", + "lib/hydra/spec/hydra_formatter.rb", + "lib/hydra/ssh.rb", + "lib/hydra/stdio.rb", + "lib/hydra/sync.rb", + "lib/hydra/tasks.rb", + "lib/hydra/tmpdir.rb", + "lib/hydra/trace.rb", + "lib/hydra/worker.rb", + "test/fixtures/assert_true.rb", + "test/fixtures/config.yml", + "test/fixtures/conflicting.rb", + "test/fixtures/features/step_definitions.rb", + "test/fixtures/features/write_alternate_file.feature", + "test/fixtures/features/write_file.feature", + "test/fixtures/hello_world.rb", + "test/fixtures/hydra_worker_init.rb", + "test/fixtures/js_file.js", + "test/fixtures/json_data.json", + "test/fixtures/many_outputs_to_console.rb", + "test/fixtures/master_listeners.rb", + "test/fixtures/runner_listeners.rb", + "test/fixtures/slow.rb", + "test/fixtures/sync_test.rb", + "test/fixtures/task_test_config.yml", + "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.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.7} + s.require_paths = [%q{lib}] + s.rubygems_version = %q{1.8.6} 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 - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0"]) s.add_development_dependency(%q, ["= 2.10.3"]) - s.add_development_dependency(%q, ["= 2.0.0.beta.19"]) + s.add_development_dependency(%q, ["= 0.9.2"]) + s.add_development_dependency(%q, ["= 0.7.4"]) + s.add_development_dependency(%q, ["= 2.10.3"]) + s.add_development_dependency(%q, ["= 2.6.4"]) + s.add_development_dependency(%q, ["= 0.9.2"]) + s.add_development_dependency(%q, ["= 0.7.4"]) + s.add_development_dependency(%q, ["= 2.10.3"]) + s.add_development_dependency(%q, ["~> 2.6.0"]) + s.add_development_dependency(%q, [">= 2.6.4"]) s.add_development_dependency(%q, ["= 0.9.2"]) s.add_development_dependency(%q, ["= 0.7.4"]) else + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["= 2.10.3"]) - s.add_dependency(%q, ["= 2.0.0.beta.19"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, [">= 2.6.4"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) end else + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["= 2.10.3"]) - s.add_dependency(%q, ["= 2.0.0.beta.19"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, [">= 2.6.4"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) end diff --git a/lib/hydra/master.rb b/lib/hydra/master.rb index c435f6d..a0e6365 100644 --- a/lib/hydra/master.rb +++ b/lib/hydra/master.rb @@ -71,7 +71,7 @@ module Hydra #:nodoc: @verbose = opts.fetch('verbose') { false } @autosort = opts.fetch('autosort') { true } @sync = opts.fetch('sync') { nil } - @environment = opts.fetch('environment') { 'test' } + @environment = opts.fetch('environment') { 'test' } || 'test' @options = opts.fetch('options') { '' } if @autosort @@ -174,15 +174,19 @@ module Hydra #:nodoc: def boot_ssh_worker(worker) 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" } - command = worker.fetch('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}\' );\"" - } - - trace "Booting SSH worker" - ssh = Hydra::SSH.new("#{sync.ssh_opts} #{sync.connect}", sync.remote_dir, command) - return { :io => ssh, :idle => false, :type => :ssh, :connect => sync.connect } + trace "Booting SSH worker" + trace command + ssh = Hydra::SSH.new("#{sync.ssh_opts} #{sync.connect}", sync.remote_dir, command) + return { :io => ssh, :idle => false, :type => :ssh, :connect => sync.connect } + else + false + end end def shutdown_all_workers @@ -204,20 +208,22 @@ module Hydra #:nodoc: trace "Listening to #{worker.inspect}" if worker.fetch('type') { 'local' }.to_s == 'ssh' worker = boot_ssh_worker(worker) - @workers << worker + @workers << worker if worker end - while true - begin - message = worker[:io].gets - trace "got message: #{message}" - # if it exists and its for me. - # SSH gives us back echoes, so we need to ignore our own messages - if message and !message.class.to_s.index("Worker").nil? - message.handle(self, worker) + if worker + while true + begin + message = worker[:io].gets + trace "got message: #{message}" + # if it exists and its for me. + # SSH gives us back echoes, so we need to ignore our own messages + 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 - rescue IOError - trace "lost Worker [#{worker.inspect}]" - Thread.exit end end end diff --git a/lib/hydra/sync.rb b/lib/hydra/sync.rb index ffc9259..c4777f9 100644 --- a/lib/hydra/sync.rb +++ b/lib/hydra/sync.rb @@ -7,7 +7,7 @@ module Hydra #:nodoc: traceable('SYNC') 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 # @@ -47,6 +47,7 @@ module Hydra #:nodoc: 'rsync', '-avz', '--delete', + '--timeout=2', exclude_opts, File.expand_path(@local_dir)+'/', "-e \"ssh #{@ssh_opts}\"", @@ -54,6 +55,7 @@ module Hydra #:nodoc: ].join(" ") trace rsync_command trace `#{rsync_command}` + @result = $?.exitstatus end def self.sync_many opts diff --git a/test/master_test.rb b/test/master_test.rb index 9458ef6..bfc3ac8 100644 --- a/test/master_test.rb +++ b/test/master_test.rb @@ -1,6 +1,6 @@ -require File.join(File.dirname(__FILE__), 'test_helper') -require File.join(File.dirname(__FILE__), 'fixtures', 'runner_listeners') -require File.join(File.dirname(__FILE__), 'fixtures', 'master_listeners') +require 'test_helper' +require 'fixtures/runner_listeners' +require 'fixtures/master_listeners' class MasterTest < Test::Unit::TestCase context "with a file to test and a destination to verify" do diff --git a/test/message_test.rb b/test/message_test.rb index c20a408..33739a2 100644 --- a/test/message_test.rb +++ b/test/message_test.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'test_helper') +require 'test_helper' class MessageTest < Test::Unit::TestCase class MyMessage < Hydra::Message diff --git a/test/pipe_test.rb b/test/pipe_test.rb index ef79721..ea10c91 100644 --- a/test/pipe_test.rb +++ b/test/pipe_test.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'test_helper') +require 'test_helper' class PipeTest < Test::Unit::TestCase context "a pipe" do diff --git a/test/runner_test.rb b/test/runner_test.rb index 381229e..f4e8157 100644 --- a/test/runner_test.rb +++ b/test/runner_test.rb @@ -1,5 +1,5 @@ -require File.join(File.dirname(__FILE__), 'test_helper') -require File.join(File.dirname(__FILE__), 'fixtures', 'runner_listeners') +require 'test_helper' +require 'fixtures/runner_listeners' class RunnerTest < Test::Unit::TestCase context "with a file to test and a destination to verify" do diff --git a/test/ssh_test.rb b/test/ssh_test.rb index eb331ef..ca0f4bf 100644 --- a/test/ssh_test.rb +++ b/test/ssh_test.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'test_helper') +require 'test_helper' class SSHTest < Test::Unit::TestCase should "be able to execute a command over ssh" do diff --git a/test/sync_test.rb b/test/sync_test.rb index 998ab87..11dba90 100644 --- a/test/sync_test.rb +++ b/test/sync_test.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'test_helper') +require 'test_helper' class SyncTest < Test::Unit::TestCase 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 assert File.exists?(File.join(remote, 'test_b.rb')), "B should be on remote" + $stderr.puts local + $stderr.puts remote + Hydra::Sync.new( { :type => :ssh, diff --git a/test/task_test.rb b/test/task_test.rb index fc00be8..a588176 100644 --- a/test/task_test.rb +++ b/test/task_test.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'test_helper') +require 'test_helper' require 'hydra/tasks' require 'rake' diff --git a/test/test_helper.rb b/test/test_helper.rb index c075835..ca08375 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,5 @@ require 'rubygems' require 'test/unit' -gem 'shoulda', '2.10.3' -gem 'rspec', '2.0.0.beta.19' require 'shoulda' require 'tmpdir' require "stringio" diff --git a/test/worker_test.rb b/test/worker_test.rb index 36a930d..74102bb 100644 --- a/test/worker_test.rb +++ b/test/worker_test.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'test_helper') +require 'test_helper' class WorkerTest < Test::Unit::TestCase context "with a file to test and a destination to verify" do