testbot 0.7.2 → 0.7.3

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,10 @@
1
+ 0.7.3
2
+
3
+ Increased time between updates to avoid timeouts. Allow timeout when posting
4
+ incremental build results (but not when posting the final results).
5
+
6
+ Should make testbot more stable for some people.
7
+
1
8
  0.7.2
2
9
 
3
10
  Increased timeout on http requests to the server to 10 seconds.
@@ -6,6 +6,8 @@ module Testbot::Runner
6
6
  class Job
7
7
  attr_reader :root, :project, :build_id
8
8
 
9
+ TIME_TO_WAIT_BETWEEN_POSTING_RESULTS = 5
10
+
9
11
  def initialize(runner, id, build_id, project, root, type, ruby_interpreter, files)
10
12
  @runner, @id, @build_id, @project, @root, @type, @ruby_interpreter, @files =
11
13
  runner, id, build_id, project, root, type, ruby_interpreter, files
@@ -58,17 +60,19 @@ module Testbot::Runner
58
60
 
59
61
  def post_results(output)
60
62
  Server.put("/jobs/#{@id}", :body => { :result => SafeResultText.clean(output), :status => "building" })
63
+ rescue Timeout::Error
64
+ puts "Got a timeout when posting an job result update. This can happen when the server is busy and is not a critical error."
61
65
  end
62
66
 
63
67
  def run_and_return_result(command)
64
68
  read_pipe = spawn_process(command)
65
-
69
+
66
70
  output = ""
67
71
  last_post_time = Time.now
68
72
  while char = read_pipe.getc
69
73
  char = (char.is_a?(Fixnum) ? char.chr : char) # 1.8 <-> 1.9
70
74
  output << char
71
- if Time.now - last_post_time > 0.5
75
+ if Time.now - last_post_time > TIME_TO_WAIT_BETWEEN_POSTING_RESULTS
72
76
  post_results(output)
73
77
  last_post_time = Time.now
74
78
  end
@@ -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.7.2"
4
+ version = "0.7.3"
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)
@@ -15,8 +15,16 @@ module Testbot::Runner
15
15
  { :result => expected_result, :status => status, :time => time })
16
16
  end
17
17
 
18
+ def expect_put
19
+ flexmock(Server).should_receive(:put).once
20
+ end
21
+
22
+ def expect_put_to_timeout
23
+ flexmock(Server).should_receive(:put).and_raise(Timeout::Error)
24
+ end
25
+
18
26
  def stub_duration(seconds)
19
- time ||= Time.now
27
+ time ||= Time.now
20
28
  flexmock(Time).should_receive(:now).and_return(time, time + seconds)
21
29
  end
22
30
 
@@ -34,7 +42,19 @@ module Testbot::Runner
34
42
  job.run(0)
35
43
  end
36
44
 
37
- should "return false on success if the job fails" do
45
+ should "not raise an error when posting results time out" do
46
+ job = Job.new(Runner.new({}), 10, "00:00", "project", "/tmp/testbot/user", "spec", "ruby", "spec/foo_spec.rb spec/bar_spec.rb")
47
+ flexmock(job).should_receive(:puts)
48
+
49
+ # We're using send here because triggering post_results though the rest of the
50
+ # code requires very complex setup. The code need to be refactored to be more testable.
51
+ expect_put
52
+ job.send(:post_results, "result text")
53
+ expect_put_to_timeout
54
+ job.send(:post_results, "result text")
55
+ end
56
+
57
+ should "not be successful when the job fails" do
38
58
  job = Job.new(Runner.new({}), 10, "00:00", "project", "/tmp/testbot/user", "spec", "ruby", "spec/foo_spec.rb spec/bar_spec.rb")
39
59
  flexmock(job).should_receive(:puts)
40
60
  stub_duration(0)
@@ -62,7 +82,7 @@ module Testbot::Runner
62
82
  job = Job.new(Runner.new({}), 10, "00:00", "project", "/tmp/testbot/user", "spec", "ruby", "spec/foo_spec.rb spec/bar_spec.rb")
63
83
  flexmock(job).should_receive(:puts)
64
84
 
65
- stub_duration(10.55)
85
+ stub_duration(10.55)
66
86
  expect_put_with(10, "result text", "successful", 1055)
67
87
  flexmock(job).should_receive(:run_and_return_result).and_return('result text')
68
88
  flexmock(RubyEnv).should_receive(:rvm?).returns(false)
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 2
10
- version: 0.7.2
9
+ - 3
10
+ version: 0.7.3
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: 2013-02-28 00:00:00 +01:00
18
+ date: 2013-06-04 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency