sskirby-hydra 0.16.9
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.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +39 -0
- data/Rakefile +55 -0
- data/TODO +18 -0
- data/VERSION +1 -0
- data/caliper.yml +6 -0
- data/hydra-icon-64x64.png +0 -0
- data/hydra.gemspec +122 -0
- data/hydra_gray.png +0 -0
- data/lib/hydra/cucumber/formatter.rb +30 -0
- data/lib/hydra/hash.rb +16 -0
- data/lib/hydra/listener/abstract.rb +30 -0
- data/lib/hydra/listener/minimal_output.rb +24 -0
- data/lib/hydra/listener/notifier.rb +17 -0
- data/lib/hydra/listener/progress_bar.rb +48 -0
- data/lib/hydra/listener/report_generator.rb +30 -0
- data/lib/hydra/master.rb +224 -0
- data/lib/hydra/message/master_messages.rb +19 -0
- data/lib/hydra/message/runner_messages.rb +46 -0
- data/lib/hydra/message/worker_messages.rb +46 -0
- data/lib/hydra/message.rb +47 -0
- data/lib/hydra/messaging_io.rb +48 -0
- data/lib/hydra/pipe.rb +61 -0
- data/lib/hydra/runner.rb +214 -0
- data/lib/hydra/safe_fork.rb +31 -0
- data/lib/hydra/spec/autorun_override.rb +12 -0
- data/lib/hydra/spec/hydra_formatter.rb +17 -0
- data/lib/hydra/ssh.rb +40 -0
- data/lib/hydra/stdio.rb +16 -0
- data/lib/hydra/sync.rb +99 -0
- data/lib/hydra/tasks.rb +256 -0
- data/lib/hydra/trace.rb +24 -0
- data/lib/hydra/worker.rb +146 -0
- data/lib/hydra.rb +16 -0
- data/test/fixtures/assert_true.rb +7 -0
- data/test/fixtures/config.yml +4 -0
- data/test/fixtures/features/step_definitions.rb +21 -0
- data/test/fixtures/features/write_alternate_file.feature +7 -0
- data/test/fixtures/features/write_file.feature +7 -0
- data/test/fixtures/hello_world.rb +3 -0
- data/test/fixtures/slow.rb +9 -0
- data/test/fixtures/sync_test.rb +8 -0
- data/test/fixtures/write_file.rb +10 -0
- data/test/fixtures/write_file_alternate_spec.rb +10 -0
- data/test/fixtures/write_file_spec.rb +9 -0
- data/test/fixtures/write_file_with_pending_spec.rb +11 -0
- data/test/master_test.rb +152 -0
- data/test/message_test.rb +31 -0
- data/test/pipe_test.rb +38 -0
- data/test/runner_test.rb +144 -0
- data/test/ssh_test.rb +14 -0
- data/test/sync_test.rb +113 -0
- data/test/test_helper.rb +60 -0
- data/test/worker_test.rb +58 -0
- metadata +179 -0
data/test/ssh_test.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class SSHTest < Test::Unit::TestCase
|
4
|
+
should "be able to execute a command over ssh" do
|
5
|
+
ssh = Hydra::SSH.new(
|
6
|
+
'localhost', # connect to this machine
|
7
|
+
File.expand_path(File.join(File.dirname(__FILE__))), # move to the test directory
|
8
|
+
"ruby fixtures/hello_world.rb"
|
9
|
+
)
|
10
|
+
response = ssh.gets
|
11
|
+
assert_equal "Hello World", response.text
|
12
|
+
ssh.close
|
13
|
+
end
|
14
|
+
end
|
data/test/sync_test.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class SyncTest < Test::Unit::TestCase
|
4
|
+
context "with a file to test and a destination to verify" do
|
5
|
+
setup do
|
6
|
+
# avoid having other tests interfering with us
|
7
|
+
sleep(0.2)
|
8
|
+
#FileUtils.rm_f(target_file)
|
9
|
+
end
|
10
|
+
|
11
|
+
teardown do
|
12
|
+
#FileUtils.rm_f(target_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "synchronize a test file over ssh with rsync" do
|
16
|
+
local = File.join(Dir.tmpdir, 'hydra', 'local')
|
17
|
+
remote = File.join(Dir.tmpdir, 'hydra', 'remote')
|
18
|
+
sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
|
19
|
+
[local, remote].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
|
20
|
+
|
21
|
+
# setup the folders:
|
22
|
+
# local:
|
23
|
+
# - test_a
|
24
|
+
# - test_c
|
25
|
+
# remote:
|
26
|
+
# - test_b
|
27
|
+
#
|
28
|
+
# add test_c to exludes
|
29
|
+
FileUtils.cp(sync_test, File.join(local, 'test_a.rb'))
|
30
|
+
FileUtils.cp(sync_test, File.join(local, 'test_c.rb'))
|
31
|
+
FileUtils.cp(sync_test, File.join(remote, 'test_b.rb'))
|
32
|
+
|
33
|
+
# ensure a is not on remote
|
34
|
+
assert !File.exists?(File.join(remote, 'test_a.rb')), "A should not be on remote"
|
35
|
+
# ensure c is not on remote
|
36
|
+
assert !File.exists?(File.join(remote, 'test_c.rb')), "C should not be on remote"
|
37
|
+
# ensure b is on remote
|
38
|
+
assert File.exists?(File.join(remote, 'test_b.rb')), "B should be on remote"
|
39
|
+
|
40
|
+
Hydra::Sync.new(
|
41
|
+
{
|
42
|
+
:type => :ssh,
|
43
|
+
:connect => 'localhost',
|
44
|
+
:directory => remote,
|
45
|
+
:runners => 1
|
46
|
+
},
|
47
|
+
{
|
48
|
+
:directory => local,
|
49
|
+
:exclude => ['test_c.rb']
|
50
|
+
}
|
51
|
+
)
|
52
|
+
# ensure a is copied
|
53
|
+
assert File.exists?(File.join(remote, 'test_a.rb')), "A was not copied"
|
54
|
+
# ensure c is not copied
|
55
|
+
assert !File.exists?(File.join(remote, 'test_c.rb')), "C was copied, should be excluded"
|
56
|
+
# ensure b is deleted
|
57
|
+
assert !File.exists?(File.join(remote, 'test_b.rb')), "B was not deleted"
|
58
|
+
end
|
59
|
+
|
60
|
+
should "synchronize a test file over ssh with rsync to multiple workers" do
|
61
|
+
local = File.join(Dir.tmpdir, 'hydra', 'local')
|
62
|
+
remote_a = File.join(Dir.tmpdir, 'hydra', 'remote_a')
|
63
|
+
remote_b = File.join(Dir.tmpdir, 'hydra', 'remote_b')
|
64
|
+
sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
|
65
|
+
[local, remote_a, remote_b].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
|
66
|
+
|
67
|
+
# setup the folders:
|
68
|
+
# local:
|
69
|
+
# - test_a
|
70
|
+
# remote_a:
|
71
|
+
# - test_b
|
72
|
+
# remote_b:
|
73
|
+
# - test_c
|
74
|
+
#
|
75
|
+
# add test_c to exludes
|
76
|
+
FileUtils.cp(sync_test, File.join(local, 'test_a.rb'))
|
77
|
+
FileUtils.cp(sync_test, File.join(remote_a, 'test_b.rb'))
|
78
|
+
FileUtils.cp(sync_test, File.join(remote_b, 'test_c.rb'))
|
79
|
+
|
80
|
+
# ensure a is not on remotes
|
81
|
+
assert !File.exists?(File.join(remote_a, 'test_a.rb')), "A should not be on remote_a"
|
82
|
+
assert !File.exists?(File.join(remote_b, 'test_a.rb')), "A should not be on remote_b"
|
83
|
+
# ensure b is on remote_a
|
84
|
+
assert File.exists?(File.join(remote_a, 'test_b.rb')), "B should be on remote_a"
|
85
|
+
# ensure c is on remote_b
|
86
|
+
assert File.exists?(File.join(remote_b, 'test_c.rb')), "C should be on remote_b"
|
87
|
+
|
88
|
+
Hydra::Sync.sync_many(
|
89
|
+
:workers => [{
|
90
|
+
:type => :ssh,
|
91
|
+
:connect => 'localhost',
|
92
|
+
:directory => remote_a,
|
93
|
+
:runners => 1
|
94
|
+
},
|
95
|
+
{
|
96
|
+
:type => :ssh,
|
97
|
+
:connect => 'localhost',
|
98
|
+
:directory => remote_b,
|
99
|
+
:runners => 1
|
100
|
+
}],
|
101
|
+
:sync => {
|
102
|
+
:directory => local
|
103
|
+
}
|
104
|
+
)
|
105
|
+
# ensure a is copied to both remotes
|
106
|
+
assert File.exists?(File.join(remote_a, 'test_a.rb')), "A was not copied to remote_a"
|
107
|
+
assert File.exists?(File.join(remote_b, 'test_a.rb')), "A was not copied to remote_b"
|
108
|
+
# ensure b and c are deleted from remotes
|
109
|
+
assert !File.exists?(File.join(remote_a, 'test_b.rb')), "B was not deleted from remote_a"
|
110
|
+
assert !File.exists?(File.join(remote_b, 'test_c.rb')), "C was not deleted from remote_b"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
require 'hydra'
|
9
|
+
|
10
|
+
# Since Hydra turns off testing, we have to turn it back on
|
11
|
+
Test::Unit.run = false
|
12
|
+
|
13
|
+
class Test::Unit::TestCase
|
14
|
+
def target_file
|
15
|
+
File.expand_path(File.join(Dir.tmpdir, 'hydra_test.txt'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def alternate_target_file
|
19
|
+
File.expand_path(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'))
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_file
|
23
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file.rb'))
|
24
|
+
end
|
25
|
+
|
26
|
+
def rspec_file
|
27
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file_spec.rb'))
|
28
|
+
end
|
29
|
+
|
30
|
+
def alternate_rspec_file
|
31
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file_alternate_spec.rb'))
|
32
|
+
end
|
33
|
+
|
34
|
+
def rspec_file_with_pending
|
35
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file_with_pending_spec.rb'))
|
36
|
+
end
|
37
|
+
|
38
|
+
def cucumber_feature_file
|
39
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'features', 'write_file.feature'))
|
40
|
+
end
|
41
|
+
|
42
|
+
def alternate_cucumber_feature_file
|
43
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'features', 'write_alternate_file.feature'))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module Hydra #:nodoc:
|
48
|
+
module Messages #:nodoc:
|
49
|
+
class TestMessage < Hydra::Message
|
50
|
+
attr_accessor :text
|
51
|
+
def initialize(opts = {})
|
52
|
+
@text = opts.fetch(:text){ "test" }
|
53
|
+
end
|
54
|
+
def serialize
|
55
|
+
super(:text => @text)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/test/worker_test.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class WorkerTest < Test::Unit::TestCase
|
4
|
+
context "with a file to test and a destination to verify" do
|
5
|
+
setup do
|
6
|
+
FileUtils.rm_f(target_file)
|
7
|
+
end
|
8
|
+
|
9
|
+
teardown do
|
10
|
+
FileUtils.rm_f(target_file)
|
11
|
+
end
|
12
|
+
|
13
|
+
# run the worker in the foreground and the requests in the background
|
14
|
+
should "run a test in the foreground" do
|
15
|
+
num_runners = 4
|
16
|
+
pipe = Hydra::Pipe.new
|
17
|
+
child = Process.fork do
|
18
|
+
request_a_file_and_verify_completion(pipe, num_runners)
|
19
|
+
end
|
20
|
+
run_the_worker(pipe, num_runners)
|
21
|
+
Process.wait(child)
|
22
|
+
end
|
23
|
+
|
24
|
+
# inverse of the above test to run the worker in the background
|
25
|
+
should "run a test in the background" do
|
26
|
+
num_runners = 4
|
27
|
+
pipe = Hydra::Pipe.new
|
28
|
+
child = Process.fork do
|
29
|
+
run_the_worker(pipe, num_runners)
|
30
|
+
end
|
31
|
+
request_a_file_and_verify_completion(pipe, num_runners)
|
32
|
+
Process.wait(child)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module WorkerTestHelper
|
37
|
+
def run_the_worker(pipe, num_runners)
|
38
|
+
pipe.identify_as_child
|
39
|
+
Hydra::Worker.new({:io => pipe, :runners => num_runners})
|
40
|
+
end
|
41
|
+
|
42
|
+
def request_a_file_and_verify_completion(pipe, num_runners)
|
43
|
+
pipe.identify_as_parent
|
44
|
+
num_runners.times do
|
45
|
+
assert pipe.gets.is_a?(Hydra::Messages::Worker::RequestFile)
|
46
|
+
end
|
47
|
+
pipe.write(Hydra::Messages::Master::RunFile.new(:file => test_file))
|
48
|
+
|
49
|
+
assert pipe.gets.is_a?(Hydra::Messages::Worker::Results)
|
50
|
+
|
51
|
+
pipe.write(Hydra::Messages::Master::Shutdown.new)
|
52
|
+
|
53
|
+
assert File.exists?(target_file)
|
54
|
+
assert_equal "HYDRA", File.read(target_file)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
include WorkerTestHelper
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sskirby-hydra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 16
|
8
|
+
- 9
|
9
|
+
version: 0.16.9
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Nick Gauthier
|
13
|
+
- Sean Kirby
|
14
|
+
- Tanzeeb Khalili
|
15
|
+
- Matt Briggs
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2010-05-10 00:00:00 -04:00
|
21
|
+
default_executable:
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: shoulda
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - "="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 10
|
33
|
+
- 3
|
34
|
+
version: 2.10.3
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - "="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 3
|
47
|
+
- 0
|
48
|
+
version: 1.3.0
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: cucumber
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - "="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
- 6
|
61
|
+
- 4
|
62
|
+
version: 0.6.4
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
description: Spread your tests over multiple machines to test your code faster.
|
66
|
+
email: sskirby@gmail.com
|
67
|
+
executables: []
|
68
|
+
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- LICENSE
|
73
|
+
- README.rdoc
|
74
|
+
- TODO
|
75
|
+
files:
|
76
|
+
- .document
|
77
|
+
- .gitignore
|
78
|
+
- LICENSE
|
79
|
+
- README.rdoc
|
80
|
+
- Rakefile
|
81
|
+
- TODO
|
82
|
+
- VERSION
|
83
|
+
- caliper.yml
|
84
|
+
- hydra-icon-64x64.png
|
85
|
+
- hydra.gemspec
|
86
|
+
- hydra_gray.png
|
87
|
+
- lib/hydra.rb
|
88
|
+
- lib/hydra/cucumber/formatter.rb
|
89
|
+
- lib/hydra/hash.rb
|
90
|
+
- lib/hydra/listener/abstract.rb
|
91
|
+
- lib/hydra/listener/minimal_output.rb
|
92
|
+
- lib/hydra/listener/notifier.rb
|
93
|
+
- lib/hydra/listener/progress_bar.rb
|
94
|
+
- lib/hydra/listener/report_generator.rb
|
95
|
+
- lib/hydra/master.rb
|
96
|
+
- lib/hydra/message.rb
|
97
|
+
- lib/hydra/message/master_messages.rb
|
98
|
+
- lib/hydra/message/runner_messages.rb
|
99
|
+
- lib/hydra/message/worker_messages.rb
|
100
|
+
- lib/hydra/messaging_io.rb
|
101
|
+
- lib/hydra/pipe.rb
|
102
|
+
- lib/hydra/runner.rb
|
103
|
+
- lib/hydra/safe_fork.rb
|
104
|
+
- lib/hydra/spec/autorun_override.rb
|
105
|
+
- lib/hydra/spec/hydra_formatter.rb
|
106
|
+
- lib/hydra/ssh.rb
|
107
|
+
- lib/hydra/stdio.rb
|
108
|
+
- lib/hydra/sync.rb
|
109
|
+
- lib/hydra/tasks.rb
|
110
|
+
- lib/hydra/trace.rb
|
111
|
+
- lib/hydra/worker.rb
|
112
|
+
- test/fixtures/assert_true.rb
|
113
|
+
- test/fixtures/config.yml
|
114
|
+
- test/fixtures/features/step_definitions.rb
|
115
|
+
- test/fixtures/features/write_alternate_file.feature
|
116
|
+
- test/fixtures/features/write_file.feature
|
117
|
+
- test/fixtures/hello_world.rb
|
118
|
+
- test/fixtures/slow.rb
|
119
|
+
- test/fixtures/sync_test.rb
|
120
|
+
- test/fixtures/write_file.rb
|
121
|
+
- test/fixtures/write_file_alternate_spec.rb
|
122
|
+
- test/fixtures/write_file_spec.rb
|
123
|
+
- test/fixtures/write_file_with_pending_spec.rb
|
124
|
+
- test/master_test.rb
|
125
|
+
- test/message_test.rb
|
126
|
+
- test/pipe_test.rb
|
127
|
+
- test/runner_test.rb
|
128
|
+
- test/ssh_test.rb
|
129
|
+
- test/sync_test.rb
|
130
|
+
- test/test_helper.rb
|
131
|
+
- test/worker_test.rb
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://github.com/sskirby/hydra
|
134
|
+
licenses: []
|
135
|
+
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options:
|
138
|
+
- --charset=UTF-8
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
155
|
+
requirements: []
|
156
|
+
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 1.3.6
|
159
|
+
signing_key:
|
160
|
+
specification_version: 3
|
161
|
+
summary: Distributed testing toolkit
|
162
|
+
test_files:
|
163
|
+
- test/sync_test.rb
|
164
|
+
- test/test_helper.rb
|
165
|
+
- test/message_test.rb
|
166
|
+
- test/runner_test.rb
|
167
|
+
- test/fixtures/write_file.rb
|
168
|
+
- test/fixtures/sync_test.rb
|
169
|
+
- test/fixtures/hello_world.rb
|
170
|
+
- test/fixtures/write_file_alternate_spec.rb
|
171
|
+
- test/fixtures/write_file_with_pending_spec.rb
|
172
|
+
- test/fixtures/slow.rb
|
173
|
+
- test/fixtures/assert_true.rb
|
174
|
+
- test/fixtures/write_file_spec.rb
|
175
|
+
- test/fixtures/features/step_definitions.rb
|
176
|
+
- test/ssh_test.rb
|
177
|
+
- test/pipe_test.rb
|
178
|
+
- test/master_test.rb
|
179
|
+
- test/worker_test.rb
|