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.
Files changed (57) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +39 -0
  5. data/Rakefile +55 -0
  6. data/TODO +18 -0
  7. data/VERSION +1 -0
  8. data/caliper.yml +6 -0
  9. data/hydra-icon-64x64.png +0 -0
  10. data/hydra.gemspec +122 -0
  11. data/hydra_gray.png +0 -0
  12. data/lib/hydra/cucumber/formatter.rb +30 -0
  13. data/lib/hydra/hash.rb +16 -0
  14. data/lib/hydra/listener/abstract.rb +30 -0
  15. data/lib/hydra/listener/minimal_output.rb +24 -0
  16. data/lib/hydra/listener/notifier.rb +17 -0
  17. data/lib/hydra/listener/progress_bar.rb +48 -0
  18. data/lib/hydra/listener/report_generator.rb +30 -0
  19. data/lib/hydra/master.rb +224 -0
  20. data/lib/hydra/message/master_messages.rb +19 -0
  21. data/lib/hydra/message/runner_messages.rb +46 -0
  22. data/lib/hydra/message/worker_messages.rb +46 -0
  23. data/lib/hydra/message.rb +47 -0
  24. data/lib/hydra/messaging_io.rb +48 -0
  25. data/lib/hydra/pipe.rb +61 -0
  26. data/lib/hydra/runner.rb +214 -0
  27. data/lib/hydra/safe_fork.rb +31 -0
  28. data/lib/hydra/spec/autorun_override.rb +12 -0
  29. data/lib/hydra/spec/hydra_formatter.rb +17 -0
  30. data/lib/hydra/ssh.rb +40 -0
  31. data/lib/hydra/stdio.rb +16 -0
  32. data/lib/hydra/sync.rb +99 -0
  33. data/lib/hydra/tasks.rb +256 -0
  34. data/lib/hydra/trace.rb +24 -0
  35. data/lib/hydra/worker.rb +146 -0
  36. data/lib/hydra.rb +16 -0
  37. data/test/fixtures/assert_true.rb +7 -0
  38. data/test/fixtures/config.yml +4 -0
  39. data/test/fixtures/features/step_definitions.rb +21 -0
  40. data/test/fixtures/features/write_alternate_file.feature +7 -0
  41. data/test/fixtures/features/write_file.feature +7 -0
  42. data/test/fixtures/hello_world.rb +3 -0
  43. data/test/fixtures/slow.rb +9 -0
  44. data/test/fixtures/sync_test.rb +8 -0
  45. data/test/fixtures/write_file.rb +10 -0
  46. data/test/fixtures/write_file_alternate_spec.rb +10 -0
  47. data/test/fixtures/write_file_spec.rb +9 -0
  48. data/test/fixtures/write_file_with_pending_spec.rb +11 -0
  49. data/test/master_test.rb +152 -0
  50. data/test/message_test.rb +31 -0
  51. data/test/pipe_test.rb +38 -0
  52. data/test/runner_test.rb +144 -0
  53. data/test/ssh_test.rb +14 -0
  54. data/test/sync_test.rb +113 -0
  55. data/test/test_helper.rb +60 -0
  56. data/test/worker_test.rb +58 -0
  57. metadata +179 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ tags
21
+
22
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Nick Gauthier
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ = Hydra
2
+
3
+ Spread your tests over processors and/or multiple machines to test your code faster.
4
+
5
+ == Description
6
+
7
+ Hydra is a distributed testing framework. It allows you to distribute
8
+ your tests locally across multiple cores and processors, as well as
9
+ run your tests remotely over SSH.
10
+
11
+ Hydra's goals are to make distributed testing easy. So as long as
12
+ you can ssh into a computer and run the tests, you can automate
13
+ the distribution with Hydra.
14
+
15
+ == Usage and Configuration
16
+
17
+ Check out the wiki for usage and configuration information:
18
+
19
+ http://wiki.github.com/ngauthier/hydra/
20
+
21
+ I've tried hard to keep accurate documentation via RDoc as well:
22
+
23
+ http://rdoc.info/projects/ngauthier/hydra
24
+
25
+ == Supported frameworks
26
+
27
+ Right now hydra only supports a few frameworks:
28
+
29
+ * Test::Unit
30
+ * Cucumber
31
+ * RSpec
32
+
33
+ We're working on adding more frameworks, and if you'd like to help, please
34
+ send me a message and I'll show you where to code!
35
+
36
+ == Copyright
37
+
38
+ Copyright (c) 2010 Nick Gauthier. See LICENSE for details.
39
+
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "sskirby-hydra"
8
+ gem.summary = %Q{Distributed testing toolkit}
9
+ gem.description = %Q{Spread your tests over multiple machines to test your code faster.}
10
+ gem.email = "sskirby@gmail.com"
11
+ gem.homepage = "http://github.com/sskirby/hydra"
12
+ gem.authors = ["Nick Gauthier", "Sean Kirby", "Tanzeeb Khalili", "Matt Briggs"]
13
+ gem.add_development_dependency "shoulda", "= 2.10.3"
14
+ gem.add_development_dependency "rspec", "= 1.3.0"
15
+ gem.add_development_dependency "cucumber", "= 0.6.4"
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/*_test.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/*_test.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: gem install rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "hydra #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ rdoc.options << '--charset=utf-8'
55
+ end
data/TODO ADDED
@@ -0,0 +1,18 @@
1
+ = Hydra TODO
2
+
3
+ * hydra:sync task that runs the SSH syncing for remote workers
4
+ * ensure same version is running remotely (gem directive)
5
+ * on a crash, bubble up error messages
6
+ * send workers a "boot" message with all the files that will be tested so that it
7
+ can boot the environment before forking runners
8
+ * named configurations (i.e. 'local', 'remote', 'myconfig') so users can swap configs with an
9
+ environment variable or with a hydra testtask option
10
+
11
+ == Reporting
12
+
13
+ Refactor reporting into an event listening system. Add in a default listener that messages:
14
+
15
+ * Files at start
16
+ * Progress status "50% (10/20 files)"
17
+ * Time report at the end
18
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.16.9
data/caliper.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ directories_to_calculate: ---
3
+ - lib
4
+
5
+ test_directories_to_calculate: ---
6
+ - test
Binary file
data/hydra.gemspec ADDED
@@ -0,0 +1,122 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{hydra}
8
+ s.version = "0.16.7"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Nick Gauthier", "Sean Kirby", "Tanzeeb Khalili", "Matt Briggs"]
12
+ s.date = %q{2010-05-10}
13
+ s.description = %q{Spread your tests over multiple machines to test your code faster.}
14
+ s.email = %q{nick@smartlogicsolutions.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "TODO",
27
+ "VERSION",
28
+ "caliper.yml",
29
+ "hydra-icon-64x64.png",
30
+ "hydra.gemspec",
31
+ "hydra_gray.png",
32
+ "lib/hydra.rb",
33
+ "lib/hydra/cucumber/formatter.rb",
34
+ "lib/hydra/hash.rb",
35
+ "lib/hydra/listener/abstract.rb",
36
+ "lib/hydra/listener/minimal_output.rb",
37
+ "lib/hydra/listener/notifier.rb",
38
+ "lib/hydra/listener/progress_bar.rb",
39
+ "lib/hydra/listener/report_generator.rb",
40
+ "lib/hydra/master.rb",
41
+ "lib/hydra/message.rb",
42
+ "lib/hydra/message/master_messages.rb",
43
+ "lib/hydra/message/runner_messages.rb",
44
+ "lib/hydra/message/worker_messages.rb",
45
+ "lib/hydra/messaging_io.rb",
46
+ "lib/hydra/pipe.rb",
47
+ "lib/hydra/runner.rb",
48
+ "lib/hydra/safe_fork.rb",
49
+ "lib/hydra/spec/autorun_override.rb",
50
+ "lib/hydra/spec/hydra_formatter.rb",
51
+ "lib/hydra/ssh.rb",
52
+ "lib/hydra/stdio.rb",
53
+ "lib/hydra/sync.rb",
54
+ "lib/hydra/tasks.rb",
55
+ "lib/hydra/trace.rb",
56
+ "lib/hydra/worker.rb",
57
+ "test/fixtures/assert_true.rb",
58
+ "test/fixtures/config.yml",
59
+ "test/fixtures/features/step_definitions.rb",
60
+ "test/fixtures/features/write_alternate_file.feature",
61
+ "test/fixtures/features/write_file.feature",
62
+ "test/fixtures/hello_world.rb",
63
+ "test/fixtures/slow.rb",
64
+ "test/fixtures/sync_test.rb",
65
+ "test/fixtures/write_file.rb",
66
+ "test/fixtures/write_file_alternate_spec.rb",
67
+ "test/fixtures/write_file_spec.rb",
68
+ "test/fixtures/write_file_with_pending_spec.rb",
69
+ "test/master_test.rb",
70
+ "test/message_test.rb",
71
+ "test/pipe_test.rb",
72
+ "test/runner_test.rb",
73
+ "test/ssh_test.rb",
74
+ "test/sync_test.rb",
75
+ "test/test_helper.rb",
76
+ "test/worker_test.rb"
77
+ ]
78
+ s.homepage = %q{http://github.com/ngauthier/hydra}
79
+ s.rdoc_options = ["--charset=UTF-8"]
80
+ s.require_paths = ["lib"]
81
+ s.rubygems_version = %q{1.3.6}
82
+ s.summary = %q{Distributed testing toolkit}
83
+ s.test_files = [
84
+ "test/sync_test.rb",
85
+ "test/test_helper.rb",
86
+ "test/message_test.rb",
87
+ "test/runner_test.rb",
88
+ "test/fixtures/write_file.rb",
89
+ "test/fixtures/sync_test.rb",
90
+ "test/fixtures/hello_world.rb",
91
+ "test/fixtures/write_file_alternate_spec.rb",
92
+ "test/fixtures/write_file_with_pending_spec.rb",
93
+ "test/fixtures/slow.rb",
94
+ "test/fixtures/assert_true.rb",
95
+ "test/fixtures/write_file_spec.rb",
96
+ "test/fixtures/features/step_definitions.rb",
97
+ "test/ssh_test.rb",
98
+ "test/pipe_test.rb",
99
+ "test/master_test.rb",
100
+ "test/worker_test.rb"
101
+ ]
102
+
103
+ if s.respond_to? :specification_version then
104
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
105
+ s.specification_version = 3
106
+
107
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
108
+ s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
109
+ s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
110
+ s.add_development_dependency(%q<cucumber>, ["= 0.6.4"])
111
+ else
112
+ s.add_dependency(%q<shoulda>, ["= 2.10.3"])
113
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
114
+ s.add_dependency(%q<cucumber>, ["= 0.6.4"])
115
+ end
116
+ else
117
+ s.add_dependency(%q<shoulda>, ["= 2.10.3"])
118
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
119
+ s.add_dependency(%q<cucumber>, ["= 0.6.4"])
120
+ end
121
+ end
122
+
data/hydra_gray.png ADDED
Binary file
@@ -0,0 +1,30 @@
1
+ require 'cucumber/formatter/progress'
2
+
3
+ module Cucumber #:nodoc:
4
+ module Formatter #:nodoc:
5
+ # Hydra formatter for cucumber.
6
+ # Stifles all output except error messages
7
+ # Based on the
8
+ class Hydra < Cucumber::Formatter::Progress
9
+ # Removed the extra newlines here
10
+ def after_features(features)
11
+ print_summary(features)
12
+ end
13
+
14
+ private
15
+
16
+ # Removed the file statistics
17
+ def print_summary(features)
18
+ print_steps(:pending)
19
+ print_steps(:failed)
20
+ print_snippets(@options)
21
+ print_passing_wip(@options)
22
+ print_tag_limit_warnings(features)
23
+ end
24
+
25
+ # Removed all progress output
26
+ def progress(status)
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/hydra/hash.rb ADDED
@@ -0,0 +1,16 @@
1
+ class Hash
2
+ # Stringify the keys in the hash. Returns a new hash.
3
+ def stringify_keys
4
+ inject({}) do |options, (key, value)|
5
+ options[key.to_s] = value
6
+ options
7
+ end
8
+ end
9
+ # Stringify the keys in the hash in place.
10
+ def stringify_keys!
11
+ keys.each do |key|
12
+ self[key.to_s] = delete(key)
13
+ end
14
+ self
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ module Hydra #:nodoc:
2
+ module Listener #:nodoc:
3
+ # Abstract listener that implements all the events
4
+ # but does nothing.
5
+ class Abstract
6
+ # Create a new listener.
7
+ #
8
+ # Output: The IO object for outputting any information.
9
+ # Defaults to STDOUT, but you could pass a file in, or STDERR
10
+ def initialize(output = $stdout)
11
+ @output = output
12
+ end
13
+ # Fired when testing has started
14
+ def testing_begin(files)
15
+ end
16
+
17
+ # Fired when testing finishes
18
+ def testing_end
19
+ end
20
+
21
+ # Fired when a file is started
22
+ def file_begin(file)
23
+ end
24
+
25
+ # Fired when a file is finished
26
+ def file_end(file, output)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module Hydra #:nodoc:
2
+ module Listener #:nodoc:
3
+ # Minimal output listener. Outputs all the files at the start
4
+ # of testing and outputs a ./F/E per file. As well as
5
+ # full error output, if any.
6
+ class MinimalOutput < Hydra::Listener::Abstract
7
+ # output a starting message
8
+ def testing_begin(files)
9
+ @output.write "Hydra Testing:\n#{files.inspect}\n"
10
+ end
11
+
12
+ # output a finished message
13
+ def testing_end
14
+ @output.write "\nHydra Completed\n"
15
+ end
16
+
17
+ # For each file, just output a . for a successful file, or the
18
+ # Failure/Error output from the tests
19
+ def file_end(file, output)
20
+ @output.write output
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ module Hydra #:nodoc:
2
+ module Listener #:nodoc:
3
+ # Sends a command to Notifier when the testing has finished
4
+ # http://manpages.ubuntu.com/manpages/gutsy/man1/notify-send.1.html
5
+ class Notifier < Hydra::Listener::Abstract
6
+ # output a finished notification
7
+ def testing_end
8
+ icon_path = File.join(
9
+ File.dirname(__FILE__), '..', '..', '..',
10
+ 'hydra-icon-64x64.png'
11
+ )
12
+ `notify-send -i #{icon_path} "Hydra" "Testing Completed"`
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,48 @@
1
+ module Hydra #:nodoc:
2
+ module Listener #:nodoc:
3
+ # Output a progress bar as files are completed
4
+ class ProgressBar < Hydra::Listener::Abstract
5
+ # Store the total number of files
6
+ def testing_begin(files)
7
+ @total_files = files.size
8
+ @files_completed = 0
9
+ @test_output = ""
10
+ @errors = false
11
+ render_progress_bar
12
+ end
13
+
14
+ # Increment completed files count and update bar
15
+ def file_end(file, output)
16
+ unless output == '.'
17
+ @output.write "\r#{' '*60}\r#{output}\n"
18
+ @errors = true
19
+ end
20
+ @files_completed += 1
21
+ render_progress_bar
22
+ end
23
+
24
+ # Break the line
25
+ def testing_end
26
+ render_progress_bar
27
+ @output.write "\n"
28
+ end
29
+
30
+ private
31
+
32
+ def render_progress_bar
33
+ width = 30
34
+ complete = ((@files_completed.to_f / @total_files.to_f) * width).to_i
35
+ @output.write "\r" # move to beginning
36
+ @output.write 'Hydra Testing ['
37
+ @output.write @errors ? "\033[1;31m" : "\033[1;32m"
38
+ complete.times{@output.write '#'}
39
+ @output.write '>'
40
+ (width-complete).times{@output.write ' '}
41
+ @output.write "\033[0m"
42
+ @output.write "] #{@files_completed}/#{@total_files}"
43
+ @output.flush
44
+ end
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,30 @@
1
+ module Hydra #:nodoc:
2
+ module Listener #:nodoc:
3
+ # Output a textual report at the end of testing
4
+ class ReportGenerator < Hydra::Listener::Abstract
5
+ # Initialize a new report
6
+ def testing_begin(files)
7
+ @report = { }
8
+ end
9
+
10
+ # Log the start time of a file
11
+ def file_begin(file)
12
+ @report[file] ||= { }
13
+ @report[file]['start'] = Time.now.to_f
14
+ end
15
+
16
+ # Log the end time of a file and compute the file's testing
17
+ # duration
18
+ def file_end(file, output)
19
+ @report[file]['end'] = Time.now.to_f
20
+ @report[file]['duration'] = @report[file]['end'] - @report[file]['start']
21
+ end
22
+
23
+ # output the report
24
+ def testing_end
25
+ YAML.dump(@report, @output)
26
+ @output.close
27
+ end
28
+ end
29
+ end
30
+ end