testbot 0.5.5 → 0.5.6

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/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.5.6
2
+
3
+ Removed CPU usage check before running jobs (issue #25).
4
+
1
5
  0.5.5
2
6
 
3
7
  Added RSpec2 support. Thanks to Bryan Helmkamp, https://github.com/brynary.
data/README.markdown CHANGED
@@ -60,7 +60,7 @@ Running tests:
60
60
 
61
61
  Using testbot with Rails 2:
62
62
 
63
- ruby script/plugin install git://github.com/joakimk/testbot.git -r 'refs/tags/v0.5.5'
63
+ ruby script/plugin install git://github.com/joakimk/testbot.git -r 'refs/tags/v0.5.6'
64
64
  script/generate testbot --connect 192.168.0.100
65
65
 
66
66
  rake testbot:spec (or :rspec, :test, :features)
@@ -122,7 +122,7 @@ You can also contribute by adding to the [wiki](http://github.com/joakimk/testbo
122
122
  How to add support for more test frameworks and/or programming languages
123
123
  ----
124
124
 
125
- Add a **lib/adapters/framework_name_adapter.rb** file, update **lib/adapters/adapter.rb** and this readme.
125
+ Add a **lib/adapters/framework_name_adapter.rb** file and update this readme.
126
126
 
127
127
  More
128
128
  ----
@@ -3,7 +3,6 @@ require 'httparty'
3
3
  require 'macaddr'
4
4
  require 'ostruct'
5
5
  require File.dirname(__FILE__) + '/../shared/ssh_tunnel'
6
- require File.dirname(__FILE__) + '/../shared/adapters/adapter'
7
6
  require File.expand_path(File.dirname(__FILE__) + '/../shared/testbot')
8
7
 
9
8
  class Hash
data/lib/runner/runner.rb CHANGED
@@ -11,16 +11,9 @@ module Testbot::Runner
11
11
  TIME_BETWEEN_QUICK_POLLS = 0.1
12
12
  TIME_BETWEEN_PINGS = 5
13
13
  TIME_BETWEEN_VERSION_CHECKS = Testbot.version.include?('.DEV.') ? 10 : 60
14
- MAX_CPU_USAGE_WHEN_IDLE = 50
15
14
 
16
15
  class CPU
17
16
 
18
- def self.current_usage
19
- process_usages = `ps -eo pcpu`
20
- total_usage = process_usages.split("\n").inject(0) { |sum, usage| sum += usage.strip.to_f }
21
- (total_usage / count).to_i
22
- end
23
-
24
17
  def self.count
25
18
  case RUBY_PLATFORM
26
19
  when /darwin/
@@ -103,7 +96,6 @@ module Testbot::Runner
103
96
 
104
97
  # Makes sure all instances are listed as available after a run
105
98
  clear_completed_instances
106
- next unless cpu_available?
107
99
 
108
100
  next_job = Server.get("/jobs/next", :query => next_params) rescue nil
109
101
  last_check_found_a_job = (next_job != nil)
@@ -143,10 +135,6 @@ module Testbot::Runner
143
135
  @last_requester_mac == nil
144
136
  end
145
137
 
146
- def cpu_available?
147
- @instances.size > 0 || CPU.current_usage < MAX_CPU_USAGE_WHEN_IDLE
148
- end
149
-
150
138
  def time_for_update?
151
139
  time_for_update = ((Time.now - @last_version_check) >= TIME_BETWEEN_VERSION_CHECKS)
152
140
  @last_version_check = Time.now if time_for_update
@@ -1,25 +1,27 @@
1
- require File.dirname(__FILE__) + '/rspec_adapter'
2
- require File.dirname(__FILE__) + '/rspec2_adapter'
3
- require File.dirname(__FILE__) + '/cucumber_adapter'
4
- require File.dirname(__FILE__) + '/test_unit_adapter'
5
-
6
1
  class Adapter
2
+
3
+ FILES = Dir[File.dirname(__FILE__) + "/*_adapter.rb"]
4
+ FILES.each { |file| require(file) }
5
+
7
6
  def self.all
8
- [ RSpecAdapter, RSpec2Adapter, CucumberAdapter, TestUnitAdapter ]
7
+ FILES.map { |file| load_adapter(file) }
9
8
  end
10
9
 
11
10
  def self.find(type)
12
- case type.to_sym
13
- when :rspec
14
- RSpec2Adapter
15
- when :spec
16
- RSpecAdapter
17
- when :features
18
- CucumberAdapter
19
- when :test
20
- TestUnitAdapter
11
+ if adapter = all.find { |adapter| adapter.type == type.to_s }
12
+ adapter
21
13
  else
22
14
  raise "Unknown adapter: #{type}"
23
15
  end
24
16
  end
17
+
18
+ private
19
+
20
+ def self.load_adapter(file)
21
+ eval("::" + File.basename(file).
22
+ gsub(/\.rb/, '').
23
+ gsub(/(?:^|_)(.)/) { $1.upcase })
24
+ end
25
+
25
26
  end
27
+
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "/helpers/ruby_env"))
2
2
 
3
- class RSpec2Adapter
3
+ class Rspec2Adapter
4
4
 
5
5
  def self.command(project_path, ruby_interpreter, files)
6
6
  spec_command = RubyEnv.ruby_command(project_path,
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "/helpers/ruby_env"))
2
2
 
3
- class RSpecAdapter
3
+ class RspecAdapter
4
4
 
5
5
  def self.command(project_path, ruby_interpreter, files)
6
6
  spec_command = RubyEnv.ruby_command(project_path, :script => "script/spec", :bin => "rspec",
@@ -1,7 +1,7 @@
1
1
  module Testbot
2
2
  # Don't forget to update readme and changelog
3
3
  def self.version
4
- version = "0.5.5"
4
+ version = "0.5.6"
5
5
  dev_version_file = File.join(File.dirname(__FILE__), '..', '..', 'DEV_VERSION')
6
6
  if File.exists?(dev_version_file)
7
7
  version += File.read(dev_version_file)
@@ -27,7 +27,7 @@ module Testbot::Requester
27
27
  end
28
28
 
29
29
  def build_with_result(results)
30
- requester_with_result(results).run_tests(RSpecAdapter, 'spec')
30
+ requester_with_result(results).run_tests(RspecAdapter, 'spec')
31
31
  end
32
32
 
33
33
  def setup
@@ -77,7 +77,7 @@ module Testbot::Requester
77
77
  should "should be able to create a build" do
78
78
  flexmock(Mac).should_receive(:addr).and_return('aa:aa:aa:aa:aa:aa')
79
79
  requester = Requester.new(:server_host => "192.168.1.100", :rsync_path => '/path', :available_runner_usage => '60%', :project => 'things', :server_user => "cruise")
80
- flexmock(RSpecAdapter).should_receive(:test_files).with('spec').once.and_return([ 'spec/models/house_spec.rb', 'spec/models/car_spec.rb' ])
80
+ flexmock(RspecAdapter).should_receive(:test_files).with('spec').once.and_return([ 'spec/models/house_spec.rb', 'spec/models/car_spec.rb' ])
81
81
 
82
82
  flexmock(File).should_receive(:stat).once.with("spec/models/house_spec.rb").and_return(mock = Object.new); flexmock(mock).should_receive(:size).and_return(10)
83
83
  flexmock(File).should_receive(:stat).once.with("spec/models/car_spec.rb").and_return(mock = Object.new); flexmock(mock).should_receive(:size).and_return(20)
@@ -98,7 +98,7 @@ module Testbot::Requester
98
98
  flexmock(requester).should_receive(:puts)
99
99
  flexmock(requester).should_receive(:system)
100
100
 
101
- assert_equal true, requester.run_tests(RSpecAdapter, 'spec')
101
+ assert_equal true, requester.run_tests(RspecAdapter, 'spec')
102
102
  end
103
103
 
104
104
  should "keep calling the server for results until done" do
@@ -118,7 +118,7 @@ module Testbot::Requester
118
118
  flexmock(requester).should_receive(:puts).once.with("job 2 done: ....")
119
119
  flexmock(requester).should_receive(:puts).once.with("job 1 done: ....")
120
120
 
121
- requester.run_tests(RSpecAdapter, 'spec')
121
+ requester.run_tests(RspecAdapter, 'spec')
122
122
  end
123
123
 
124
124
  should "return false if not successful" do
@@ -136,7 +136,7 @@ module Testbot::Requester
136
136
  flexmock(requester).should_receive(:puts).once.with("job 2 done: ....job 1 done: ....")
137
137
  mock_file_sizes
138
138
 
139
- assert_equal false, requester.run_tests(RSpecAdapter, 'spec')
139
+ assert_equal false, requester.run_tests(RspecAdapter, 'spec')
140
140
  end
141
141
 
142
142
  should "not print empty lines when there is no result" do
@@ -155,7 +155,7 @@ module Testbot::Requester
155
155
  flexmock(requester).should_receive(:puts).once.with("job 2 done: ....job 1 done: ....")
156
156
  mock_file_sizes
157
157
 
158
- requester.run_tests(RSpecAdapter, 'spec')
158
+ requester.run_tests(RspecAdapter, 'spec')
159
159
  end
160
160
 
161
161
  should "sync the files to the server" do
@@ -172,7 +172,7 @@ module Testbot::Requester
172
172
  flexmock(requester).should_receive('system').with("rsync -az --delete -e ssh --exclude='.git' --exclude='tmp' . testbot@192.168.1.100:/path")
173
173
  mock_file_sizes
174
174
 
175
- requester.run_tests(RSpecAdapter, 'spec')
175
+ requester.run_tests(RspecAdapter, 'spec')
176
176
  end
177
177
 
178
178
  should "just try again if the request encounters an error while running and print on the fith time" do
@@ -193,7 +193,7 @@ module Testbot::Requester
193
193
  flexmock(requester).should_receive(:puts).once.with("job 2 done: ....job 1 done: ....")
194
194
  mock_file_sizes
195
195
 
196
- requester.run_tests(RSpecAdapter, 'spec')
196
+ requester.run_tests(RspecAdapter, 'spec')
197
197
  end
198
198
 
199
199
  should "just try again if the status returns as nil" do
@@ -212,7 +212,7 @@ module Testbot::Requester
212
212
  flexmock(requester).should_receive(:puts).once.with("job 2 done: ....job 1 done: ....")
213
213
  mock_file_sizes
214
214
 
215
- requester.run_tests(RSpecAdapter, 'spec')
215
+ requester.run_tests(RspecAdapter, 'spec')
216
216
  end
217
217
 
218
218
  should "remove unnessesary output from rspec when told to do so" do
@@ -234,7 +234,7 @@ module Testbot::Requester
234
234
  flexmock(requester).should_receive(:puts)
235
235
  mock_file_sizes
236
236
 
237
- requester.run_tests(RSpecAdapter, 'spec')
237
+ requester.run_tests(RspecAdapter, 'spec')
238
238
  end
239
239
 
240
240
  should "use SSHTunnel when specified (with a port that does not collide with the runner)" do
@@ -251,7 +251,7 @@ module Testbot::Requester
251
251
  flexmock(requester).should_receive(:puts)
252
252
  mock_file_sizes
253
253
 
254
- requester.run_tests(RSpecAdapter, 'spec')
254
+ requester.run_tests(RspecAdapter, 'spec')
255
255
  end
256
256
 
257
257
  should "use another user for rsync and ssh_tunnel when specified" do
@@ -270,7 +270,7 @@ module Testbot::Requester
270
270
  flexmock(requester).should_receive('system').with("rsync -az --delete -e ssh . cruise@somewhere:/tmp/testbot/foo")
271
271
  mock_file_sizes
272
272
 
273
- requester.run_tests(RSpecAdapter, 'spec')
273
+ requester.run_tests(RspecAdapter, 'spec')
274
274
  end
275
275
 
276
276
  should "use another port for cucumber to be able to run at the same time as rspec" do
@@ -335,7 +335,7 @@ module Testbot::Requester
335
335
  should "return all lines with results in them" do
336
336
  results = "one\ntwo..\n... 0 failures\nthree"
337
337
  requester = requester_with_result(results)
338
- requester.run_tests(RSpecAdapter, 'spec')
338
+ requester.run_tests(RspecAdapter, 'spec')
339
339
  assert_equal [ '... 0 failures' ], requester.result_lines
340
340
  end
341
341
 
@@ -4,19 +4,19 @@ require 'shoulda'
4
4
 
5
5
  class AdapterTest < Test::Unit::TestCase
6
6
 
7
- should "be able to find the adapters" do
8
- assert_equal RSpec2Adapter, Adapter.find(:rspec)
9
- assert_equal RSpecAdapter, Adapter.find(:spec)
10
- assert_equal CucumberAdapter, Adapter.find(:features)
7
+ should "be able to find adapters" do
8
+ assert_equal RspecAdapter, Adapter.find(:spec)
11
9
  assert_equal TestUnitAdapter, Adapter.find(:test)
12
10
  end
13
11
 
14
12
  should "find be able to find an adapter by string" do
15
- assert_equal RSpecAdapter, Adapter.find("spec")
13
+ assert_equal RspecAdapter, Adapter.find("spec")
14
+ assert_equal TestUnitAdapter, Adapter.find("test")
16
15
  end
17
16
 
18
- should "return be able to all types" do
19
- assert_equal [ RSpecAdapter, RSpec2Adapter, CucumberAdapter, TestUnitAdapter ], Adapter.all
17
+ should "be able to return a list of adapters" do
18
+ assert Adapter.all.include?(RspecAdapter)
19
+ assert Adapter.all.include?(TestUnitAdapter)
20
20
  end
21
21
 
22
22
  end
data/testbot.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.email = ["joakim.kolsjo@gmail.com"]
9
9
  s.homepage = "http://github.com/joakimk/testbot"
10
10
  s.summary = %q{A test distribution tool.}
11
- s.description = %q{Testbot is a test distribution tool that works with Rails, RSpec, Test::Unit and Cucumber.}
11
+ s.description = %q{Testbot is a test distribution tool that works with Rails, RSpec, RSpec2, Test::Unit and Cucumber.}
12
12
  s.bindir = "bin"
13
13
  s.executables = [ "testbot" ]
14
14
  s.files = Dir.glob("lib/**/*") + Dir.glob("test/**/*") + %w(Gemfile .gemtest Rakefile testbot.gemspec CHANGELOG README.markdown bin/testbot) +
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testbot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 5
10
- version: 0.5.5
9
+ - 6
10
+ version: 0.5.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Joakim Kolsj\xC3\xB6"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-08 00:00:00 +02:00
18
+ date: 2011-04-11 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -226,7 +226,7 @@ dependencies:
226
226
  version: "0"
227
227
  type: :development
228
228
  version_requirements: *id014
229
- description: Testbot is a test distribution tool that works with Rails, RSpec, Test::Unit and Cucumber.
229
+ description: Testbot is a test distribution tool that works with Rails, RSpec, RSpec2, Test::Unit and Cucumber.
230
230
  email:
231
231
  - joakim.kolsjo@gmail.com
232
232
  executables: