causes-hydra 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) 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 +56 -0
  6. data/TODO +18 -0
  7. data/VERSION +1 -0
  8. data/bin/warmsnake.rb +76 -0
  9. data/caliper.yml +6 -0
  10. data/hydra-icon-64x64.png +0 -0
  11. data/hydra.gemspec +130 -0
  12. data/hydra_gray.png +0 -0
  13. data/lib/hydra.rb +16 -0
  14. data/lib/hydra/cucumber/formatter.rb +29 -0
  15. data/lib/hydra/hash.rb +16 -0
  16. data/lib/hydra/js/lint.js +5150 -0
  17. data/lib/hydra/listener/abstract.rb +39 -0
  18. data/lib/hydra/listener/minimal_output.rb +24 -0
  19. data/lib/hydra/listener/notifier.rb +17 -0
  20. data/lib/hydra/listener/progress_bar.rb +48 -0
  21. data/lib/hydra/listener/report_generator.rb +30 -0
  22. data/lib/hydra/master.rb +249 -0
  23. data/lib/hydra/message.rb +47 -0
  24. data/lib/hydra/message/master_messages.rb +19 -0
  25. data/lib/hydra/message/runner_messages.rb +52 -0
  26. data/lib/hydra/message/worker_messages.rb +52 -0
  27. data/lib/hydra/messaging_io.rb +46 -0
  28. data/lib/hydra/pipe.rb +61 -0
  29. data/lib/hydra/runner.rb +305 -0
  30. data/lib/hydra/safe_fork.rb +31 -0
  31. data/lib/hydra/spec/autorun_override.rb +3 -0
  32. data/lib/hydra/spec/hydra_formatter.rb +26 -0
  33. data/lib/hydra/ssh.rb +41 -0
  34. data/lib/hydra/stdio.rb +16 -0
  35. data/lib/hydra/sync.rb +99 -0
  36. data/lib/hydra/tasks.rb +342 -0
  37. data/lib/hydra/trace.rb +24 -0
  38. data/lib/hydra/worker.rb +150 -0
  39. data/test/fixtures/assert_true.rb +7 -0
  40. data/test/fixtures/config.yml +4 -0
  41. data/test/fixtures/features/step_definitions.rb +21 -0
  42. data/test/fixtures/features/write_alternate_file.feature +7 -0
  43. data/test/fixtures/features/write_file.feature +7 -0
  44. data/test/fixtures/hello_world.rb +3 -0
  45. data/test/fixtures/js_file.js +4 -0
  46. data/test/fixtures/json_data.json +4 -0
  47. data/test/fixtures/slow.rb +9 -0
  48. data/test/fixtures/sync_test.rb +8 -0
  49. data/test/fixtures/write_file.rb +10 -0
  50. data/test/fixtures/write_file_alternate_spec.rb +10 -0
  51. data/test/fixtures/write_file_spec.rb +9 -0
  52. data/test/fixtures/write_file_with_pending_spec.rb +11 -0
  53. data/test/master_test.rb +152 -0
  54. data/test/message_test.rb +31 -0
  55. data/test/pipe_test.rb +38 -0
  56. data/test/runner_test.rb +153 -0
  57. data/test/ssh_test.rb +14 -0
  58. data/test/sync_test.rb +113 -0
  59. data/test/test_helper.rb +68 -0
  60. data/test/worker_test.rb +60 -0
  61. metadata +209 -0
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -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.
@@ -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
+
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "causes-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 = "nick@smartlogicsolutions.com"
11
+ gem.homepage = "http://github.com/ngauthier/hydra"
12
+ gem.authors = ["Nick Gauthier"]
13
+ gem.add_development_dependency "shoulda", "= 2.10.3"
14
+ gem.add_development_dependency "rspec", "= 2.0.0.beta.19"
15
+ gem.add_development_dependency "cucumber", "= 0.8.5"
16
+ gem.add_development_dependency "therubyracer", "= 0.7.4"
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/*_test.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/*_test.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: gem install rcov"
40
+ end
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "hydra #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ rdoc.options << '--charset=utf-8'
56
+ 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.21.0
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
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}]"
49
+ start = Time.now
50
+ Hydra::Master.new(
51
+ :files => @files.dup,
52
+ :listeners => Hydra::Listener::ProgressBar.new(STDOUT),
53
+ :workers => [{:type => :local, :runners => 4}]
54
+ )
55
+ finish = Time.now
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)
65
+ end
66
+ break if !command.nil? and command.chomp == "r"
67
+ end
68
+ end
69
+ begin
70
+ Process.wait env_proc
71
+ rescue Interrupt
72
+ puts "\n#{bold_yellow}SSsssSsssSSssSs#{reset}"
73
+ break
74
+ end
75
+ end
76
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ directories_to_calculate: ---
3
+ - lib
4
+
5
+ test_directories_to_calculate: ---
6
+ - test
Binary file
@@ -0,0 +1,130 @@
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.21.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Nick Gauthier"]
12
+ s.date = %q{2011-03-07}
13
+ s.default_executable = %q{warmsnake.rb}
14
+ s.description = %q{Spread your tests over multiple machines to test your code faster.}
15
+ s.email = %q{nick@smartlogicsolutions.com}
16
+ s.executables = ["warmsnake.rb"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "TODO"
21
+ ]
22
+ s.files = [
23
+ ".document",
24
+ ".gitignore",
25
+ "LICENSE",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "TODO",
29
+ "VERSION",
30
+ "bin/warmsnake.rb",
31
+ "caliper.yml",
32
+ "hydra-icon-64x64.png",
33
+ "hydra.gemspec",
34
+ "hydra_gray.png",
35
+ "lib/hydra.rb",
36
+ "lib/hydra/cucumber/formatter.rb",
37
+ "lib/hydra/hash.rb",
38
+ "lib/hydra/js/lint.js",
39
+ "lib/hydra/listener/abstract.rb",
40
+ "lib/hydra/listener/minimal_output.rb",
41
+ "lib/hydra/listener/notifier.rb",
42
+ "lib/hydra/listener/progress_bar.rb",
43
+ "lib/hydra/listener/report_generator.rb",
44
+ "lib/hydra/master.rb",
45
+ "lib/hydra/message.rb",
46
+ "lib/hydra/message/master_messages.rb",
47
+ "lib/hydra/message/runner_messages.rb",
48
+ "lib/hydra/message/worker_messages.rb",
49
+ "lib/hydra/messaging_io.rb",
50
+ "lib/hydra/pipe.rb",
51
+ "lib/hydra/runner.rb",
52
+ "lib/hydra/safe_fork.rb",
53
+ "lib/hydra/spec/autorun_override.rb",
54
+ "lib/hydra/spec/hydra_formatter.rb",
55
+ "lib/hydra/ssh.rb",
56
+ "lib/hydra/stdio.rb",
57
+ "lib/hydra/sync.rb",
58
+ "lib/hydra/tasks.rb",
59
+ "lib/hydra/trace.rb",
60
+ "lib/hydra/worker.rb",
61
+ "test/fixtures/assert_true.rb",
62
+ "test/fixtures/config.yml",
63
+ "test/fixtures/features/step_definitions.rb",
64
+ "test/fixtures/features/write_alternate_file.feature",
65
+ "test/fixtures/features/write_file.feature",
66
+ "test/fixtures/hello_world.rb",
67
+ "test/fixtures/js_file.js",
68
+ "test/fixtures/json_data.json",
69
+ "test/fixtures/slow.rb",
70
+ "test/fixtures/sync_test.rb",
71
+ "test/fixtures/write_file.rb",
72
+ "test/fixtures/write_file_alternate_spec.rb",
73
+ "test/fixtures/write_file_spec.rb",
74
+ "test/fixtures/write_file_with_pending_spec.rb",
75
+ "test/master_test.rb",
76
+ "test/message_test.rb",
77
+ "test/pipe_test.rb",
78
+ "test/runner_test.rb",
79
+ "test/ssh_test.rb",
80
+ "test/sync_test.rb",
81
+ "test/test_helper.rb",
82
+ "test/worker_test.rb"
83
+ ]
84
+ s.homepage = %q{http://github.com/ngauthier/hydra}
85
+ s.rdoc_options = ["--charset=UTF-8"]
86
+ s.require_paths = ["lib"]
87
+ s.rubygems_version = %q{1.6.1}
88
+ s.summary = %q{Distributed testing toolkit}
89
+ s.test_files = [
90
+ "test/runner_test.rb",
91
+ "test/test_helper.rb",
92
+ "test/message_test.rb",
93
+ "test/pipe_test.rb",
94
+ "test/ssh_test.rb",
95
+ "test/fixtures/assert_true.rb",
96
+ "test/fixtures/write_file_spec.rb",
97
+ "test/fixtures/write_file_alternate_spec.rb",
98
+ "test/fixtures/write_file.rb",
99
+ "test/fixtures/hello_world.rb",
100
+ "test/fixtures/slow.rb",
101
+ "test/fixtures/sync_test.rb",
102
+ "test/fixtures/write_file_with_pending_spec.rb",
103
+ "test/fixtures/features/step_definitions.rb",
104
+ "test/worker_test.rb",
105
+ "test/sync_test.rb",
106
+ "test/master_test.rb"
107
+ ]
108
+
109
+ if s.respond_to? :specification_version then
110
+ s.specification_version = 3
111
+
112
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
113
+ s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
114
+ s.add_development_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
115
+ s.add_development_dependency(%q<cucumber>, ["= 0.8.5"])
116
+ s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
117
+ else
118
+ s.add_dependency(%q<shoulda>, ["= 2.10.3"])
119
+ s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
120
+ s.add_dependency(%q<cucumber>, ["= 0.8.5"])
121
+ s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
122
+ end
123
+ else
124
+ s.add_dependency(%q<shoulda>, ["= 2.10.3"])
125
+ s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
126
+ s.add_dependency(%q<cucumber>, ["= 0.8.5"])
127
+ s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
128
+ end
129
+ end
130
+
Binary file
@@ -0,0 +1,16 @@
1
+ require 'hydra/trace'
2
+ require 'hydra/pipe'
3
+ require 'hydra/ssh'
4
+ require 'hydra/stdio'
5
+ require 'hydra/message'
6
+ require 'hydra/safe_fork'
7
+ require 'hydra/runner'
8
+ require 'hydra/worker'
9
+ require 'hydra/master'
10
+ require 'hydra/sync'
11
+ require 'hydra/listener/abstract'
12
+ require 'hydra/listener/minimal_output'
13
+ require 'hydra/listener/report_generator'
14
+ require 'hydra/listener/notifier'
15
+ require 'hydra/listener/progress_bar'
16
+
@@ -0,0 +1,29 @@
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
+ end
23
+
24
+ # Removed all progress output
25
+ def progress(status)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -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