remote_run 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,20 +3,22 @@ require 'rubygems'
3
3
  require 'bundler/setup'
4
4
  require 'remote_run'
5
5
 
6
- Runner.log("Scanning 10.64.20.* for hosts...", :yellow)
6
+ puts("Scanning 10.64.20.* for hosts...")
7
7
  #hosts = `nmap -p 22 10.64.20.1/24 --open -sV | grep -B3 "Debian" | grep 10.64.20 | cut -f 5 -d " "`.lines.map(&:strip)
8
8
  hosts = %w{ 10.64.20.1 10.64.20.12 10.64.20.15 10.64.20.18 10.64.20.21 10.64.20.26 10.64.20.30 10.64.20.38 10.64.20.43 10.64.20.47 10.64.20.49 10.64.20.50 10.64.20.51 10.64.20.53 10.64.20.56 10.64.20.58 10.64.20.59 10.64.20.61 10.64.20.62 10.64.20.64 10.64.20.66 10.64.20.69 10.64.20.74 10.64.20.76 10.64.20.79 10.64.20.80 10.64.20.93 10.64.20.101 10.64.20.110 10.64.20.111 10.64.20.122 10.64.20.149 10.64.20.164 10.64.20.168 10.64.20.198 10.64.20.209 10.64.20.214 10.64.20.221 10.64.20.244 10.64.20.245 10.64.20.246 10.64.20.247 10.64.20.248 10.64.20.249 10.64.20.250 10.64.20.251 10.64.20.252 10.64.20.253 10.64.20.254 }
9
- Runner.log("With all tasks passing...")
9
+ puts("With all tasks passing...")
10
10
  tasks = []
11
11
  50.times do |n|
12
12
  tasks << "sleep 2; date;"
13
13
  end
14
14
  tasks << "cat /foo/bar"
15
15
 
16
- Runner.run do |config|
16
+ configuration = RemoteRun::Configuration.new do |config|
17
17
  config.tasks = tasks
18
18
  config.login_as = "pivotalcb"
19
19
  config.hosts = hosts
20
20
  end
21
21
 
22
- Runner.log("Expected one failure to test that it still works...")
22
+ RemoteRun::Runner.new(configuration).run
23
+
24
+ puts("Expected one failure to test that it still works...")
@@ -69,6 +69,12 @@ module RemoteRun
69
69
  end
70
70
  @hosts
71
71
  end
72
+
73
+ def start_ssh_master_connections
74
+ hosts.each do |host|
75
+ host.start_ssh_master_connection
76
+ end
77
+ end
72
78
  end
73
79
 
74
80
  class TaskManager
@@ -23,8 +23,6 @@ module RemoteRun
23
23
  handle_results
24
24
  end
25
25
 
26
- private
27
-
28
26
  def setup_unlock_on_exit
29
27
  at_exit do
30
28
  @configuration.hosts.each do |host|
@@ -37,9 +35,7 @@ module RemoteRun
37
35
  end
38
36
 
39
37
  def start_ssh_master_connections
40
- @configuration.hosts.each do |host|
41
- host.start_ssh_master_connection
42
- end
38
+ @host_manager.start_ssh_master_connections
43
39
  end
44
40
 
45
41
  def sync_working_copy_to_temp_location
@@ -84,9 +80,11 @@ module RemoteRun
84
80
 
85
81
  def start_task(host)
86
82
  task = @task_manager.find_task
87
- @children << fork do
83
+ task.pid = fork do
88
84
  start_forked_task(host, task)
89
85
  end
86
+ task.host = host
87
+ @children << task
90
88
  end
91
89
 
92
90
  def start_forked_task(host, task)
@@ -129,11 +127,15 @@ module RemoteRun
129
127
  end
130
128
 
131
129
  def check_for_finished
132
- @children.each do |child_pid|
130
+ @children.each do |task|
131
+ child_pid = task.pid
133
132
  if task_is_finished?(child_pid)
134
- @failed << child_pid unless $?.success?
133
+ unless $?.success?
134
+ @failed << child_pid
135
+ log("Task '#{task.command}' failed on #{task.host.hostname}")
136
+ end
135
137
  @results << $?.exitstatus
136
- @children.delete(child_pid)
138
+ @children.delete(task)
137
139
  end
138
140
  end
139
141
  end
@@ -1,8 +1,8 @@
1
1
  module RemoteRun
2
2
  class Task
3
- attr_accessor :command
3
+ attr_accessor :command, :pid, :host
4
4
 
5
- def initialize(command)
5
+ def initialize(command = nil)
6
6
  @command = command
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module RemoteRun
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,11 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RemoteRun::Configuration::HostManager do
4
+ let(:host) { double(:host, is_up?: true, name: "foobar") }
4
5
  subject { RemoteRun::Configuration::HostManager.new }
5
6
 
6
7
  describe "#add" do
7
8
  it "adds the given host to a list of hosts" do
8
- subject.add(stub(:host, :is_up? => true, :name => "foobar"))
9
+ subject.add(host)
9
10
  subject.hosts.size.should == 1
10
11
  subject.hosts.first.name.should == "foobar"
11
12
  end
@@ -13,7 +14,6 @@ describe RemoteRun::Configuration::HostManager do
13
14
 
14
15
  describe "#hosts" do
15
16
  it "returns all hosts in the list" do
16
- host = stub(:host, :is_up? => true, :name => "foobar")
17
17
  subject.add(host)
18
18
  subject.hosts.should == [host]
19
19
  end
@@ -21,12 +21,11 @@ describe RemoteRun::Configuration::HostManager do
21
21
 
22
22
  describe "#start_ssh_master_connections" do
23
23
  before do
24
- @host = stub(:host, :is_up? => true, :name => "foobar")
25
- subject.add(@host)
24
+ subject.add(host)
26
25
  end
27
26
 
28
27
  it "asks each host to start their ssh master connection" do
29
- @host.should_receive(:start_ssh_master_connection)
28
+ host.should_receive(:start_ssh_master_connection)
30
29
  subject.start_ssh_master_connections
31
30
  end
32
31
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe RemoteRun::Runner do
4
+ let(:host_manager) { double(:host_manager) }
5
+ let(:task_manager) { double(:task_manager, count: 0) }
6
+ let(:configuration) { double(:configuration, task_manager: task_manager, host_manager: host_manager) }
7
+ let(:runner) { RemoteRun::Runner.new(configuration) }
8
+ subject { runner }
9
+ it { should be }
10
+
11
+ describe "#start_ssh_master_connections" do
12
+ it "should delegate to the host manager" do
13
+ host_manager.should_receive(:start_ssh_master_connections)
14
+ runner.start_ssh_master_connections
15
+ end
16
+ end
17
+
18
+ describe "#start_task" do
19
+ let(:task) { RemoteRun::Task.new }
20
+ let(:host) { double(:host) }
21
+ let(:pid) { double(:pid) }
22
+ before do
23
+ runner.stub(:fork).and_return(pid)
24
+ task_manager.stub(:find_task).and_return(task)
25
+ runner.start_task(host)
26
+ end
27
+ describe "the task" do
28
+ subject { task }
29
+ its(:pid) { should == pid }
30
+ its(:host) { should == host }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe RemoteRun::Task do
4
+ let(:command) { double(:command) }
5
+ subject { RemoteRun::Task.new(command) }
6
+ it { should be }
7
+ its(:command) { should == command }
8
+
9
+ describe "pid attribute" do
10
+ let(:pid) { double(:pid) }
11
+ before { subject.pid = pid }
12
+ its(:pid) { should == pid }
13
+ end
14
+
15
+ describe "host attribute" do
16
+ let(:host) { double(:host) }
17
+ before { subject.host = host }
18
+ its(:host) { should == host }
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_run
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
16
- requirement: &2151951040 !ruby/object:Gem::Requirement
16
+ requirement: &2173524580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151951040
24
+ version_requirements: *2173524580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2151943360 !ruby/object:Gem::Requirement
27
+ requirement: &2173523920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2151943360
35
+ version_requirements: *2173523920
36
36
  description: Can be used as a parallel unit test runner
37
37
  email:
38
38
  - casecommons-dev@googlegroups.com
@@ -57,6 +57,7 @@ files:
57
57
  - spec/remote_run/configuration_spec.rb
58
58
  - spec/remote_run/host_spec.rb
59
59
  - spec/remote_run/runner_spec.rb
60
+ - spec/remote_run/task_spec.rb
60
61
  - spec/spec_helper.rb
61
62
  homepage: https://github.com/Casecommons/remote_run
62
63
  licenses: []
@@ -72,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
73
  version: '0'
73
74
  segments:
74
75
  - 0
75
- hash: 3128109979642869878
76
+ hash: 3135936709983633521
76
77
  required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  none: false
78
79
  requirements:
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  version: '0'
82
83
  segments:
83
84
  - 0
84
- hash: 3128109979642869878
85
+ hash: 3135936709983633521
85
86
  requirements: []
86
87
  rubyforge_project: remote_run
87
88
  rubygems_version: 1.8.10
@@ -92,4 +93,5 @@ test_files:
92
93
  - spec/remote_run/configuration_spec.rb
93
94
  - spec/remote_run/host_spec.rb
94
95
  - spec/remote_run/runner_spec.rb
96
+ - spec/remote_run/task_spec.rb
95
97
  - spec/spec_helper.rb