build_status_server 0.14 → 0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +14 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/build_status_server/cli.rb +7 -1
- data/lib/build_status_server/server.rb +4 -2
- data/lib/build_status_server/version.rb +1 -1
- data/spec/lib/build_status_server/server_spec.rb +25 -19
- metadata +3 -2
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -7,13 +7,13 @@ gem "json"
|
|
7
7
|
group :test do
|
8
8
|
gem "rspec"
|
9
9
|
gem "ci_reporter"
|
10
|
-
gem "ruby-debug19"
|
11
10
|
gem "simplecov", :require => false
|
12
11
|
gem "simplecov-rcov"
|
13
12
|
end
|
14
13
|
|
15
14
|
group :development do
|
16
15
|
gem "sinatra"
|
16
|
+
gem "ruby-debug19"
|
17
17
|
end
|
18
18
|
|
19
19
|
group :development, :test do
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Build Notifier
|
2
|
+
[![Build Status](https://secure.travis-ci.org/jcmuller/build_status_server.png?branch=master)](http://travis-ci.org/jcmuller/build_status_server)
|
3
|
+
[![Dependency Status](https://gemnasium.com/pluginaweek/state_machine.png "Dependency Status")](https://gemnasium.com/jcmuller/build_status_server)
|
2
4
|
|
3
|
-
This utility is part of an XFD (
|
5
|
+
This utility is part of an XFD (eXtreme Feedback Device) solution designed and
|
4
6
|
built for my employer [ChallengePost](http://challengepost.com). It works in
|
5
7
|
conjunction with our [Jenkins](http://jenkins-ci.org) Continuous Integration
|
6
8
|
server (and its
|
@@ -5,7 +5,13 @@ module BuildStatusServer
|
|
5
5
|
attr_reader :options
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
|
8
|
+
begin
|
9
|
+
process_command_line_options
|
10
|
+
rescue GetoptLong::MissingArgument
|
11
|
+
puts
|
12
|
+
show_help_and_exit
|
13
|
+
end
|
14
|
+
|
9
15
|
BuildStatusServer::Server.new(options).listen
|
10
16
|
end
|
11
17
|
|
@@ -45,7 +45,7 @@ is listening on the same port (#{address}:#{port})
|
|
45
45
|
|
46
46
|
EOT
|
47
47
|
exit
|
48
|
-
rescue Errno::EADDRNOTAVAIL
|
48
|
+
rescue Errno::EADDRNOTAVAIL, SocketError
|
49
49
|
STDERR.puts <<-EOT
|
50
50
|
The address configured is not available (#{address})
|
51
51
|
|
@@ -151,13 +151,15 @@ The address configured is not available (#{address})
|
|
151
151
|
rescue Timeout::Error => ex
|
152
152
|
STDERR.puts "Error: #{ex} while trying to send #{light}"
|
153
153
|
retry unless attempts > tcp_client["attempts"]
|
154
|
-
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH => ex
|
154
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ENETUNREACH => ex
|
155
155
|
wait = wait_for(attempts)
|
156
156
|
STDERR.puts "Error: #{ex} while trying to send #{light}"
|
157
157
|
STDERR.puts "Will wait for #{wait} seconds and try again..."
|
158
158
|
# sleep 2 seconds the first attempt, 4 the next, 8 the following...
|
159
159
|
sleep wait
|
160
160
|
retry unless attempts > tcp_client["attempts"]
|
161
|
+
rescue StandardError => ex
|
162
|
+
STDERR.puts "There was an error, but we don't know how to handle it: (#{ex.class}) #{ex}"
|
161
163
|
ensure
|
162
164
|
client.close if client
|
163
165
|
end
|
@@ -38,12 +38,13 @@ describe BuildStatusServer::Server do
|
|
38
38
|
socket = mock(:udp_socket)
|
39
39
|
socket.should_receive(:bind).with("address", "port")
|
40
40
|
UDPSocket.should_receive(:new).and_return(socket)
|
41
|
+
server.stub!(:udp_server).and_return(socket)
|
41
42
|
|
42
43
|
server.send(:setup_udp_server)
|
43
44
|
end
|
44
45
|
|
45
46
|
it "instantiates a UDPSocket object and binds it to address and port" do
|
46
|
-
server.config.stub!(:udp_server).and_return({"address" => "127.0.0.1", "port" =>
|
47
|
+
server.config.stub!(:udp_server).and_return({"address" => "127.0.0.1", "port" => 9999})
|
47
48
|
|
48
49
|
server.send(:setup_udp_server)
|
49
50
|
|
@@ -59,7 +60,7 @@ describe BuildStatusServer::Server do
|
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should show message and exit when connecting to address not available" do
|
62
|
-
server.config.stub!(:udp_server).and_return({"address" => "192.192.192.192", "port" =>
|
63
|
+
server.config.stub!(:udp_server).and_return({"address" => "192.192.192.192", "port" => 9999})
|
63
64
|
|
64
65
|
STDERR.should_receive(:puts).with("The address configured is not available (192.192.192.192)\n\n")
|
65
66
|
server.should_receive(:exit)
|
@@ -68,14 +69,15 @@ describe BuildStatusServer::Server do
|
|
68
69
|
end
|
69
70
|
|
70
71
|
it "it recovers from an address in use exception" do
|
71
|
-
server.config.stub!(:udp_server).and_return({"address" => "127.0.0.1", "port" =>
|
72
|
+
server.config.stub!(:udp_server).and_return({"address" => "127.0.0.1", "port" => 9999})
|
72
73
|
|
73
74
|
socket = mock(:udp_socket)
|
74
|
-
socket.should_receive(:bind).and_raise(Errno::EADDRINUSE)
|
75
|
+
socket.should_receive(:bind).and_raise(Errno::EADDRINUSE.new)
|
75
76
|
UDPSocket.should_receive(:new).and_return(socket)
|
76
77
|
|
77
78
|
STDERR.should_receive(:puts).with("There appears that another instance is running, or another process\nis listening on the same port (127.0.0.1:9999)\n\n")
|
78
79
|
server.should_receive(:exit)
|
80
|
+
|
79
81
|
server.send(:setup_udp_server)
|
80
82
|
end
|
81
83
|
|
@@ -303,17 +305,17 @@ describe BuildStatusServer::Server do
|
|
303
305
|
"port" => "port"
|
304
306
|
}
|
305
307
|
config = mock(:config)
|
306
|
-
config.
|
307
|
-
config.
|
308
|
+
config.stub(:tcp_client).and_return(options)
|
309
|
+
config.stub(:verbose).and_return(true)
|
308
310
|
|
309
|
-
server.
|
311
|
+
server.stub(:config).and_return(config)
|
310
312
|
|
311
313
|
STDOUT.should_receive(:puts).with("answer")
|
312
314
|
|
313
|
-
client.
|
314
|
-
client.
|
315
|
+
client.stub(:gets).and_return("answer")
|
316
|
+
client.stub(:close)
|
315
317
|
|
316
|
-
TCPSocket.
|
318
|
+
TCPSocket.stub(:new).with("host", "port").and_return(client)
|
317
319
|
end
|
318
320
|
|
319
321
|
it "should send passing packet to tcp socket when status is true" do
|
@@ -333,16 +335,16 @@ describe BuildStatusServer::Server do
|
|
333
335
|
"fail" => "fail",
|
334
336
|
"host" => "host",
|
335
337
|
"port" => "port",
|
336
|
-
"attempts" =>
|
338
|
+
"attempts" => 4
|
337
339
|
}
|
338
340
|
config = mock(:config)
|
339
|
-
config.
|
340
|
-
config.
|
341
|
+
config.stub(:tcp_client).and_return(options)
|
342
|
+
config.stub(:verbose).and_return(false)
|
341
343
|
|
342
|
-
server.
|
343
|
-
client.
|
344
|
+
server.stub(:config).and_return(config)
|
345
|
+
client.stub(:close)
|
344
346
|
|
345
|
-
client.
|
347
|
+
client.stub(:gets).and_return("answer")
|
346
348
|
end
|
347
349
|
|
348
350
|
it "should time out and retry 2 times" do
|
@@ -354,18 +356,22 @@ describe BuildStatusServer::Server do
|
|
354
356
|
server.send(:notify, false)
|
355
357
|
end
|
356
358
|
|
357
|
-
it "should not connect and retry
|
359
|
+
it "should not connect and retry 3 times" do
|
358
360
|
STDERR.should_receive(:puts).with("Error: Connection refused while trying to send fail")
|
359
361
|
STDERR.should_receive(:puts).with("Error: No route to host while trying to send fail")
|
362
|
+
STDERR.should_receive(:puts).with("Error: Network is unreachable while trying to send fail")
|
360
363
|
STDERR.should_receive(:puts).with("Will wait for 2 seconds and try again...")
|
361
364
|
STDERR.should_receive(:puts).with("Will wait for 4 seconds and try again...")
|
365
|
+
STDERR.should_receive(:puts).with("Will wait for 8 seconds and try again...")
|
362
366
|
|
363
|
-
TCPSocket.should_receive(:new).with("host", "port").and_raise(Errno::ECONNREFUSED)
|
364
|
-
TCPSocket.should_receive(:new).with("host", "port").and_raise(Errno::EHOSTUNREACH)
|
367
|
+
TCPSocket.should_receive(:new).with("host", "port").and_raise(Errno::ECONNREFUSED.new)
|
368
|
+
TCPSocket.should_receive(:new).with("host", "port").and_raise(Errno::EHOSTUNREACH.new)
|
369
|
+
TCPSocket.should_receive(:new).with("host", "port").and_raise(Errno::ENETUNREACH.new)
|
365
370
|
TCPSocket.should_receive(:new).with("host", "port").and_return(client)
|
366
371
|
|
367
372
|
server.should_receive(:sleep).with(2)
|
368
373
|
server.should_receive(:sleep).with(4)
|
374
|
+
server.should_receive(:sleep).with(8)
|
369
375
|
|
370
376
|
client.should_receive(:print).with("GET fail HTTP/1.0\n\n")
|
371
377
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build_status_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.15'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -83,6 +83,7 @@ extensions: []
|
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
85
|
- .gitignore
|
86
|
+
- .travis.yml
|
86
87
|
- Gemfile
|
87
88
|
- Gemfile.lock
|
88
89
|
- LICENSE
|