hydra 0.21.0 → 0.22.0
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/LICENSE +1 -1
- data/VERSION +1 -1
- data/bin/warmsnake.rb +68 -56
- data/hydra.gemspec +13 -12
- data/lib/hydra/master.rb +2 -2
- data/lib/hydra/tmpdir.rb +11 -0
- data/lib/hydra/worker.rb +10 -1
- data/test/fixtures/features/step_definitions.rb +2 -2
- data/test/fixtures/write_file.rb +1 -1
- data/test/fixtures/write_file_alternate_spec.rb +2 -2
- data/test/fixtures/write_file_spec.rb +2 -2
- data/test/fixtures/write_file_with_pending_spec.rb +1 -1
- data/test/master_test.rb +3 -3
- data/test/runner_test.rb +2 -6
- data/test/sync_test.rb +5 -5
- data/test/test_helper.rb +2 -2
- metadata +14 -13
data/LICENSE
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.22.0
|
data/bin/warmsnake.rb
CHANGED
@@ -1,64 +1,76 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
2
|
+
#
|
3
|
+
# warmsnake.rb
|
4
|
+
#
|
5
|
+
# This is a first attempt at making a hydra binary.
|
6
|
+
#
|
7
|
+
# Currently, all it does is run the files you pass into it. When you
|
8
|
+
# press Enter it will run them again, maintaining your rails environment.
|
9
|
+
# When you type 'r' and hit Enter it will reboot the rails environment.
|
10
|
+
#
|
11
|
+
# It is extremely specific about its behavior and only works in rails.
|
12
|
+
#
|
13
|
+
# It is not really ready for any kind of release, but it is useful, so
|
14
|
+
# it's included.
|
15
|
+
#
|
16
|
+
require 'rubygems'
|
17
|
+
require 'hydra'
|
18
|
+
|
19
|
+
@files = ARGV.inject([]){|memo,f| memo += Dir.glob f}
|
20
|
+
|
21
|
+
if @files.empty?
|
22
|
+
puts "You must specify a list of files to run"
|
23
|
+
puts "If you specify a pattern, it must be in quotes"
|
24
|
+
puts %{USAGE: #{$0} test/unit/my_test.rb "test/functional/**/*_test.rb"}
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
|
28
|
+
Signal.trap("TERM", "KILL") do
|
29
|
+
puts "Warm Snake says bye bye"
|
30
|
+
exit(0)
|
31
|
+
end
|
32
|
+
|
33
|
+
bold_yellow = "\033[1;33m"
|
34
|
+
reset = "\033[0m"
|
35
|
+
|
36
|
+
|
37
|
+
loop do
|
38
|
+
env_proc = Process.fork do
|
39
|
+
puts "#{bold_yellow}Booting Environment#{reset}"
|
40
|
+
start = Time.now
|
41
|
+
ENV['RAILS_ENV']='test'
|
42
|
+
require 'config/environment'
|
43
|
+
require 'test/test_helper'
|
44
|
+
finish = Time.now
|
45
|
+
puts "#{bold_yellow}Environment Booted (#{finish-start})#{reset}"
|
46
|
+
|
47
|
+
loop do
|
48
|
+
puts "#{bold_yellow}Running#{reset} [#{@files.inspect}]"
|
27
49
|
start = Time.now
|
28
|
-
|
29
|
-
|
30
|
-
|
50
|
+
Hydra::Master.new(
|
51
|
+
:files => @files.dup,
|
52
|
+
:listeners => Hydra::Listener::ProgressBar.new(STDOUT),
|
53
|
+
:workers => [{:type => :local, :runners => 4}]
|
54
|
+
)
|
31
55
|
finish = Time.now
|
32
|
-
puts "#{bold_yellow}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
)
|
42
|
-
finish = Time.now
|
43
|
-
puts "#{bold_yellow}Tests finished#{reset} (#{finish-start})"
|
44
|
-
|
45
|
-
puts ""
|
46
|
-
|
47
|
-
$stdout.write "Press #{bold_yellow}ENTER#{reset} to retest. Type #{bold_yellow}r#{reset} then hit enter to reboot environment. #{bold_yellow}CTRL-C#{reset} to quit\n> "
|
48
|
-
begin
|
49
|
-
command = $stdin.gets
|
50
|
-
rescue Interrupt
|
51
|
-
exit(0)
|
52
|
-
end
|
53
|
-
break if !command.nil? and command.chomp == "r"
|
56
|
+
puts "#{bold_yellow}Tests finished#{reset} (#{finish-start})"
|
57
|
+
|
58
|
+
puts ""
|
59
|
+
|
60
|
+
$stdout.write "Press #{bold_yellow}ENTER#{reset} to retest. Type #{bold_yellow}r#{reset} then hit enter to reboot environment. #{bold_yellow}CTRL-C#{reset} to quit\n> "
|
61
|
+
begin
|
62
|
+
command = $stdin.gets
|
63
|
+
rescue Interrupt
|
64
|
+
exit(0)
|
54
65
|
end
|
66
|
+
break if !command.nil? and command.chomp == "r"
|
55
67
|
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
68
|
+
end
|
69
|
+
begin
|
70
|
+
Process.wait env_proc
|
71
|
+
rescue Interrupt
|
72
|
+
puts "\n#{bold_yellow}SSsssSsssSSssSs#{reset}"
|
73
|
+
break
|
62
74
|
end
|
63
75
|
end
|
64
76
|
|
data/hydra.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hydra}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.22.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nick Gauthier"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-02}
|
13
13
|
s.default_executable = %q{warmsnake.rb}
|
14
14
|
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
15
15
|
s.email = %q{nick@smartlogicsolutions.com}
|
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
|
|
56
56
|
"lib/hydra/stdio.rb",
|
57
57
|
"lib/hydra/sync.rb",
|
58
58
|
"lib/hydra/tasks.rb",
|
59
|
+
"lib/hydra/tmpdir.rb",
|
59
60
|
"lib/hydra/trace.rb",
|
60
61
|
"lib/hydra/worker.rb",
|
61
62
|
"test/fixtures/assert_true.rb",
|
@@ -88,21 +89,21 @@ Gem::Specification.new do |s|
|
|
88
89
|
s.summary = %q{Distributed testing toolkit}
|
89
90
|
s.test_files = [
|
90
91
|
"test/pipe_test.rb",
|
91
|
-
"test/
|
92
|
+
"test/test_helper.rb",
|
92
93
|
"test/ssh_test.rb",
|
94
|
+
"test/message_test.rb",
|
95
|
+
"test/master_test.rb",
|
96
|
+
"test/fixtures/write_file.rb",
|
97
|
+
"test/fixtures/slow.rb",
|
98
|
+
"test/fixtures/write_file_with_pending_spec.rb",
|
99
|
+
"test/fixtures/write_file_spec.rb",
|
100
|
+
"test/fixtures/features/step_definitions.rb",
|
101
|
+
"test/fixtures/hello_world.rb",
|
93
102
|
"test/fixtures/write_file_alternate_spec.rb",
|
94
103
|
"test/fixtures/sync_test.rb",
|
95
|
-
"test/fixtures/hello_world.rb",
|
96
|
-
"test/fixtures/features/step_definitions.rb",
|
97
104
|
"test/fixtures/assert_true.rb",
|
98
|
-
"test/fixtures/slow.rb",
|
99
|
-
"test/fixtures/write_file_spec.rb",
|
100
|
-
"test/fixtures/write_file_with_pending_spec.rb",
|
101
|
-
"test/fixtures/write_file.rb",
|
102
|
-
"test/message_test.rb",
|
103
|
-
"test/test_helper.rb",
|
104
|
-
"test/master_test.rb",
|
105
105
|
"test/runner_test.rb",
|
106
|
+
"test/sync_test.rb",
|
106
107
|
"test/worker_test.rb"
|
107
108
|
]
|
108
109
|
|
data/lib/hydra/master.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'hydra/hash'
|
2
2
|
require 'open3'
|
3
|
-
require 'tmpdir'
|
3
|
+
require 'hydra/tmpdir'
|
4
4
|
require 'erb'
|
5
5
|
require 'yaml'
|
6
6
|
|
@@ -232,7 +232,7 @@ module Hydra #:nodoc:
|
|
232
232
|
end
|
233
233
|
|
234
234
|
def heuristic_file
|
235
|
-
@heuristic_file ||= File.join(Dir.
|
235
|
+
@heuristic_file ||= File.join(Dir.consistent_tmpdir, 'hydra_heuristics.yml')
|
236
236
|
end
|
237
237
|
end
|
238
238
|
end
|
data/lib/hydra/tmpdir.rb
ADDED
data/lib/hydra/worker.rb
CHANGED
@@ -20,6 +20,7 @@ module Hydra #:nodoc:
|
|
20
20
|
@runners = []
|
21
21
|
@listeners = []
|
22
22
|
|
23
|
+
load_worker_initializer
|
23
24
|
boot_runners(opts.fetch(:runners) { 1 })
|
24
25
|
@io.write(Hydra::Messages::Worker::WorkerBegin.new)
|
25
26
|
|
@@ -28,7 +29,15 @@ module Hydra #:nodoc:
|
|
28
29
|
@runners.each{|r| Process.wait r[:pid] }
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
+
def load_worker_initializer
|
33
|
+
if File.exist?('./hydra_worker_init.rb')
|
34
|
+
trace('Requiring hydra_worker_init.rb')
|
35
|
+
require 'hydra_worker_init'
|
36
|
+
else
|
37
|
+
trace('hydra_worker_init.rb not present')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
32
41
|
# message handling methods
|
33
42
|
|
34
43
|
# When a runner wants a file, it hits this method with a message.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Given /^a target file$/ do
|
2
|
-
@target_file = File.expand_path(File.join(Dir.
|
2
|
+
@target_file = File.expand_path(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'))
|
3
3
|
end
|
4
4
|
|
5
5
|
Given /^an alternate target file$/ do
|
6
|
-
@target_file = File.expand_path(File.join(Dir.
|
6
|
+
@target_file = File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'))
|
7
7
|
end
|
8
8
|
|
9
9
|
When /^I write "([^\"]*)" to the file$/ do |text|
|
data/test/fixtures/write_file.rb
CHANGED
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
|
2
2
|
|
3
3
|
class WriteFileTest < Test::Unit::TestCase
|
4
4
|
def test_write_a_file
|
5
|
-
File.open(File.join(Dir.
|
5
|
+
File.open(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'), 'a') do |f|
|
6
6
|
f.write "HYDRA"
|
7
7
|
end
|
8
8
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'tmpdir'
|
2
1
|
require 'rspec'
|
2
|
+
require 'hydra/tmpdir'
|
3
3
|
context "file writing" do
|
4
4
|
it "writes to a file" do
|
5
|
-
File.open(File.join(Dir.
|
5
|
+
File.open(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'), 'a') do |f|
|
6
6
|
f.write "HYDRA"
|
7
7
|
end
|
8
8
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'tmpdir'
|
2
1
|
require 'rspec'
|
2
|
+
require 'hydra/tmpdir'
|
3
3
|
context "file writing" do
|
4
4
|
it "writes to a file" do
|
5
|
-
File.open(File.join(Dir.
|
5
|
+
File.open(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'), 'a') do |f|
|
6
6
|
f.write "HYDRA"
|
7
7
|
end
|
8
8
|
end
|
data/test/master_test.rb
CHANGED
@@ -35,7 +35,7 @@ class MasterTest < Test::Unit::TestCase
|
|
35
35
|
Hydra::Master.new(:files => [test_file])
|
36
36
|
assert File.exists?(target_file)
|
37
37
|
assert_equal "HYDRA", File.read(target_file)
|
38
|
-
report_file = File.join(Dir.
|
38
|
+
report_file = File.join(Dir.consistent_tmpdir, 'hydra_heuristics.yml')
|
39
39
|
assert File.exists?(report_file)
|
40
40
|
assert report = YAML.load_file(report_file)
|
41
41
|
assert_not_nil report[test_file]
|
@@ -104,8 +104,8 @@ class MasterTest < Test::Unit::TestCase
|
|
104
104
|
end
|
105
105
|
|
106
106
|
should "synchronize a test file over ssh with rsync" do
|
107
|
-
local = File.join(Dir.
|
108
|
-
remote = File.join(Dir.
|
107
|
+
local = File.join(Dir.consistent_tmpdir, 'hydra', 'local')
|
108
|
+
remote = File.join(Dir.consistent_tmpdir, 'hydra', 'remote')
|
109
109
|
sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
|
110
110
|
[local, remote].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
|
111
111
|
|
data/test/runner_test.rb
CHANGED
@@ -50,7 +50,6 @@ class RunnerTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
should "run two rspec tests" do
|
53
|
-
puts "First test"
|
54
53
|
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
55
54
|
runner.run_file(rspec_file)
|
56
55
|
assert File.exists?(target_file)
|
@@ -81,8 +80,8 @@ class RunnerTest < Test::Unit::TestCase
|
|
81
80
|
# we run this in a fork to not contaminate
|
82
81
|
# the main test environment
|
83
82
|
pid = Process.fork do
|
84
|
-
|
85
|
-
|
83
|
+
# need to get into the fixtures directory so cucumber doesn't load up the whole project
|
84
|
+
Dir.chdir(File.join(File.dirname(__FILE__), 'fixtures'))
|
86
85
|
|
87
86
|
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
88
87
|
runner.run_file(cucumber_feature_file)
|
@@ -95,8 +94,6 @@ class RunnerTest < Test::Unit::TestCase
|
|
95
94
|
assert File.exists?(alternate_target_file)
|
96
95
|
assert_equal "HYDRA", File.read(alternate_target_file)
|
97
96
|
assert !File.exists?(target_file)
|
98
|
-
|
99
|
-
puts "END IGNORABLE OUTPUT"
|
100
97
|
end
|
101
98
|
Process.wait pid
|
102
99
|
end
|
@@ -137,7 +134,6 @@ class RunnerTest < Test::Unit::TestCase
|
|
137
134
|
|
138
135
|
# grab its response. This makes us wait for it to finish
|
139
136
|
response = pipe.gets
|
140
|
-
puts response.output
|
141
137
|
|
142
138
|
# tell it to shut down
|
143
139
|
pipe.write(Hydra::Messages::Worker::Shutdown.new)
|
data/test/sync_test.rb
CHANGED
@@ -13,8 +13,8 @@ class SyncTest < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
should "synchronize a test file over ssh with rsync" do
|
16
|
-
local = File.join(Dir.
|
17
|
-
remote = File.join(Dir.
|
16
|
+
local = File.join(Dir.consistent_tmpdir, 'hydra', 'local')
|
17
|
+
remote = File.join(Dir.consistent_tmpdir, 'hydra', 'remote')
|
18
18
|
sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
|
19
19
|
[local, remote].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
|
20
20
|
|
@@ -58,9 +58,9 @@ class SyncTest < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
should "synchronize a test file over ssh with rsync to multiple workers" do
|
61
|
-
local = File.join(Dir.
|
62
|
-
remote_a = File.join(Dir.
|
63
|
-
remote_b = File.join(Dir.
|
61
|
+
local = File.join(Dir.consistent_tmpdir, 'hydra', 'local')
|
62
|
+
remote_a = File.join(Dir.consistent_tmpdir, 'hydra', 'remote_a')
|
63
|
+
remote_b = File.join(Dir.consistent_tmpdir, 'hydra', 'remote_b')
|
64
64
|
sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
|
65
65
|
[local, remote_a, remote_b].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
|
66
66
|
|
data/test/test_helper.rb
CHANGED
@@ -12,11 +12,11 @@ Test::Unit.run = false
|
|
12
12
|
|
13
13
|
class Test::Unit::TestCase
|
14
14
|
def target_file
|
15
|
-
File.expand_path(File.join(Dir.
|
15
|
+
File.expand_path(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'))
|
16
16
|
end
|
17
17
|
|
18
18
|
def alternate_target_file
|
19
|
-
File.expand_path(File.join(Dir.
|
19
|
+
File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'))
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_file
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 22
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.22.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Gauthier
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-02 00:00:00 -05:00
|
18
18
|
default_executable: warmsnake.rb
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/hydra/stdio.rb
|
123
123
|
- lib/hydra/sync.rb
|
124
124
|
- lib/hydra/tasks.rb
|
125
|
+
- lib/hydra/tmpdir.rb
|
125
126
|
- lib/hydra/trace.rb
|
126
127
|
- lib/hydra/worker.rb
|
127
128
|
- test/fixtures/assert_true.rb
|
@@ -178,19 +179,19 @@ specification_version: 3
|
|
178
179
|
summary: Distributed testing toolkit
|
179
180
|
test_files:
|
180
181
|
- test/pipe_test.rb
|
181
|
-
- test/
|
182
|
+
- test/test_helper.rb
|
182
183
|
- test/ssh_test.rb
|
184
|
+
- test/message_test.rb
|
185
|
+
- test/master_test.rb
|
186
|
+
- test/fixtures/write_file.rb
|
187
|
+
- test/fixtures/slow.rb
|
188
|
+
- test/fixtures/write_file_with_pending_spec.rb
|
189
|
+
- test/fixtures/write_file_spec.rb
|
190
|
+
- test/fixtures/features/step_definitions.rb
|
191
|
+
- test/fixtures/hello_world.rb
|
183
192
|
- test/fixtures/write_file_alternate_spec.rb
|
184
193
|
- test/fixtures/sync_test.rb
|
185
|
-
- test/fixtures/hello_world.rb
|
186
|
-
- test/fixtures/features/step_definitions.rb
|
187
194
|
- test/fixtures/assert_true.rb
|
188
|
-
- test/fixtures/slow.rb
|
189
|
-
- test/fixtures/write_file_spec.rb
|
190
|
-
- test/fixtures/write_file_with_pending_spec.rb
|
191
|
-
- test/fixtures/write_file.rb
|
192
|
-
- test/message_test.rb
|
193
|
-
- test/test_helper.rb
|
194
|
-
- test/master_test.rb
|
195
195
|
- test/runner_test.rb
|
196
|
+
- test/sync_test.rb
|
196
197
|
- test/worker_test.rb
|