outpost 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +1 -1
- data/Gemfile +3 -6
- data/Gemfile.lock +39 -43
- data/README.markdown +1 -1
- data/lib/outpost/notifiers/email.rb +3 -0
- data/lib/outpost/scouts/http.rb +22 -5
- data/lib/outpost/version.rb +1 -1
- data/test/integration/basic_application_test.rb +0 -6
- data/test/integration/more_complex_test.rb +0 -6
- data/test/integration/no_subclassing_test.rb +1 -5
- data/test/integration/reporting_test.rb +0 -4
- data/test/outpost/notifiers/email_test.rb +28 -0
- data/test/outpost/scouts/http_test.rb +42 -2
- data/test/outpost/scouts/tcp_test.rb +14 -5
- data/test/support/requests.rb +6 -0
- data/test/test_helper.rb +2 -4
- metadata +16 -17
- data/test/support/server.rb +0 -29
- data/test/support/test_app.rb +0 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9bc0f3503cbedc0a68018342b7caba9f595b3c4e
|
4
|
+
data.tar.gz: a5f5a87728d0c4d0eb8c84bb7bc24bf65f3deaf7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ccad69413b0968d0a3e485324a9b9e789b82406508b89fc5f9011d8cfd9dcf004e36989ddeaa8d7566ab0e396af74f3dc3300957bac026db987b5633549130c
|
7
|
+
data.tar.gz: 50ffd6928a6aa8a441d83063ef253c5680994bddfdefa6eacb541c12ab570037935d5e767cda1e36d36573444988923420856d26ba233efc39d4b5d4c358fabc
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
group :test do
|
4
4
|
gem 'mail', :require => false
|
@@ -6,12 +6,9 @@ group :test do
|
|
6
6
|
gem 'tinder', :require => false
|
7
7
|
|
8
8
|
gem 'rake'
|
9
|
-
|
10
|
-
gem '
|
11
|
-
gem 'sinatra'
|
9
|
+
|
10
|
+
gem 'fakeweb'
|
12
11
|
|
13
12
|
gem 'minitest', '~> 2.0.2', :platforms => :ruby_18
|
14
13
|
gem 'ruby-debug', :platforms => :ruby_18
|
15
|
-
|
16
|
-
# gem 'ruby-debug19', :platforms => :ruby_19
|
17
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,66 +1,62 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
columnize (0.3.6)
|
5
|
+
eventmachine (1.0.3)
|
6
|
+
fakeweb (1.3.0)
|
7
|
+
faraday (0.8.7)
|
8
|
+
multipart-post (~> 1.1)
|
9
|
+
faraday_middleware (0.9.0)
|
10
|
+
faraday (>= 0.7.4, < 0.9)
|
11
|
+
ffi (1.9.0)
|
12
|
+
hashie (1.2.0)
|
13
|
+
http_parser.rb (0.5.3)
|
14
|
+
json (1.7.7)
|
15
|
+
linecache (0.46)
|
16
|
+
rbx-require-relative (> 0.0.4)
|
17
|
+
mail (2.5.4)
|
18
18
|
mime-types (~> 1.16)
|
19
19
|
treetop (~> 1.4.8)
|
20
|
-
mime-types (1.
|
20
|
+
mime-types (1.23)
|
21
21
|
minitest (2.0.2)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
multi_json (1.7.7)
|
23
|
+
multipart-post (1.2.0)
|
24
|
+
net-ping (1.6.1)
|
25
|
+
ffi (>= 1.0.0)
|
26
|
+
polyglot (0.3.3)
|
27
|
+
rake (10.1.0)
|
28
|
+
rbx-require-relative (0.0.9)
|
28
29
|
ruby-debug (0.10.4)
|
29
30
|
columnize (>= 0.1)
|
30
31
|
ruby-debug-base (~> 0.10.4.0)
|
31
32
|
ruby-debug-base (0.10.4)
|
32
33
|
linecache (>= 0.3)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
mime-types
|
46
|
-
multipart-post
|
47
|
-
twitter-stream
|
48
|
-
treetop (1.4.9)
|
34
|
+
simple_oauth (0.1.9)
|
35
|
+
tinder (1.9.2)
|
36
|
+
eventmachine (~> 1.0)
|
37
|
+
faraday (~> 0.8)
|
38
|
+
faraday_middleware (~> 0.9)
|
39
|
+
hashie (~> 1.0)
|
40
|
+
json (~> 1.7.5)
|
41
|
+
mime-types (~> 1.19)
|
42
|
+
multi_json (~> 1.5)
|
43
|
+
twitter-stream (~> 0.1)
|
44
|
+
treetop (1.4.14)
|
45
|
+
polyglot
|
49
46
|
polyglot (>= 0.3.1)
|
50
|
-
twitter-stream (0.1.
|
47
|
+
twitter-stream (0.1.16)
|
51
48
|
eventmachine (>= 0.12.8)
|
52
|
-
|
49
|
+
http_parser.rb (~> 0.5.1)
|
50
|
+
simple_oauth (~> 0.1.4)
|
53
51
|
|
54
52
|
PLATFORMS
|
55
53
|
ruby
|
56
54
|
|
57
55
|
DEPENDENCIES
|
56
|
+
fakeweb
|
58
57
|
mail
|
59
58
|
minitest (~> 2.0.2)
|
60
59
|
net-ping
|
61
|
-
rack
|
62
60
|
rake
|
63
61
|
ruby-debug
|
64
|
-
sinatra
|
65
|
-
thin
|
66
62
|
tinder
|
data/README.markdown
CHANGED
@@ -23,6 +23,7 @@ module Outpost
|
|
23
23
|
@from = options[:from]
|
24
24
|
@to = options[:to]
|
25
25
|
@subject = options[:subject] || 'Outpost notification'
|
26
|
+
@delivery_method = options[:delivery_method] || []
|
26
27
|
|
27
28
|
unless @from && @to
|
28
29
|
raise ArgumentError, 'You need to set :from and :to to send emails.'
|
@@ -41,6 +42,8 @@ module Outpost
|
|
41
42
|
mail.subject = @subject
|
42
43
|
mail.body = build_message(outpost)
|
43
44
|
|
45
|
+
mail.send(:delivery_method, *@delivery_method) unless @delivery_method.empty?
|
46
|
+
|
44
47
|
mail.deliver
|
45
48
|
end
|
46
49
|
|
data/lib/outpost/scouts/http.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'net/https'
|
2
3
|
require 'outpost/expectations'
|
3
4
|
|
4
5
|
module Outpost
|
@@ -26,21 +27,37 @@ module Outpost
|
|
26
27
|
# @option options [String] :host The host that will be connected to.
|
27
28
|
# @option options [Number] :port The port that will be used to.
|
28
29
|
# @option options [String] :path The path that will be fetched from the
|
30
|
+
# @option options [Boolean] :ssl Should we use ssl?
|
29
31
|
# host.
|
30
32
|
# @option options [String] :http_class The class that will be used to
|
31
33
|
# fetch the page, defaults to Net::HTTP
|
32
34
|
def setup(options)
|
33
|
-
@host
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
35
|
+
@host = options.fetch(:host)
|
36
|
+
@path = options.fetch(:path, '/')
|
37
|
+
@ssl = options.fetch(:ssl, false)
|
38
|
+
@port = options.fetch(:port, (@ssl ? 443 : 80))
|
39
|
+
@http_class = options.fetch(:http_class, Net::HTTP)
|
40
|
+
@request_head = options.fetch(:request_head, false)
|
37
41
|
end
|
38
42
|
|
39
43
|
# Runs the scout, connecting to the host and getting the response code,
|
40
44
|
# body and time.
|
41
45
|
def execute
|
42
46
|
previous_time = Time.now
|
43
|
-
|
47
|
+
if @request_head
|
48
|
+
response = @http_class.request_head(@host, @path, @port)
|
49
|
+
else
|
50
|
+
uri = (@ssl ? URI::HTTPS : URI::HTTP).build({
|
51
|
+
host: @host,
|
52
|
+
port: @port,
|
53
|
+
path: @path
|
54
|
+
})
|
55
|
+
http = @http_class.new(uri.host, uri.port)
|
56
|
+
http.use_ssl = @ssl
|
57
|
+
|
58
|
+
request = @http_class::Get.new(uri.request_uri)
|
59
|
+
response = http.request(request)
|
60
|
+
end
|
44
61
|
|
45
62
|
@response_time = (Time.now - previous_time) * 1000 # Miliseconds
|
46
63
|
@response_code = response.code.to_i
|
data/lib/outpost/version.rb
CHANGED
@@ -3,12 +3,6 @@ require 'test_helper'
|
|
3
3
|
require 'outpost/scouts/http'
|
4
4
|
|
5
5
|
describe "basic application integration test" do
|
6
|
-
before(:each) do
|
7
|
-
@server = Server.new
|
8
|
-
@server.boot(TestApp)
|
9
|
-
@server.wait_until_booted
|
10
|
-
end
|
11
|
-
|
12
6
|
class ExampleSuccess < Outpost::Application
|
13
7
|
using Outpost::Scouts::Http => 'master http server' do
|
14
8
|
options :host => 'localhost', :port => 9595
|
@@ -3,12 +3,6 @@ require 'test_helper'
|
|
3
3
|
require 'outpost/scouts'
|
4
4
|
|
5
5
|
describe "using more complex application integration test" do
|
6
|
-
before(:each) do
|
7
|
-
@server = Server.new
|
8
|
-
@server.boot(TestApp)
|
9
|
-
@server.wait_until_booted
|
10
|
-
end
|
11
|
-
|
12
6
|
class ExamplePingAndHttp < Outpost::Application
|
13
7
|
using Outpost::Scouts::Http => 'master http server' do
|
14
8
|
options :host => 'localhost', :port => 9595, :path => '/'
|
@@ -4,11 +4,7 @@ require 'outpost/scouts/http'
|
|
4
4
|
require 'outpost/notifiers/email'
|
5
5
|
|
6
6
|
describe "creating outpost apps without subclassing" do
|
7
|
-
before
|
8
|
-
@server = Server.new
|
9
|
-
@server.boot(TestApp)
|
10
|
-
@server.wait_until_booted
|
11
|
-
|
7
|
+
before do
|
12
8
|
Mail.defaults do
|
13
9
|
delivery_method :test
|
14
10
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
+
require 'tmpdir'
|
4
|
+
|
3
5
|
describe Outpost::Notifiers::Email do
|
4
6
|
before(:each) do
|
5
7
|
Mail.defaults do
|
@@ -40,6 +42,32 @@ describe Outpost::Notifiers::Email do
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
45
|
+
describe "#delivery_method" do
|
46
|
+
it "should use other delivery method if present" do
|
47
|
+
subject = Outpost::Notifiers::Email.new(
|
48
|
+
:from => 'mail@localhost',
|
49
|
+
:to => 'mailer@example.com',
|
50
|
+
#using file_delivery send method for testing
|
51
|
+
:delivery_method => [:file, {:location => Dir.tmpdir}]
|
52
|
+
)
|
53
|
+
|
54
|
+
subject.notify(outpost_stub)
|
55
|
+
|
56
|
+
assert_equal Mail::TestMailer.deliveries, []
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should use default if not present" do
|
60
|
+
subject = Outpost::Notifiers::Email.new(
|
61
|
+
:from => 'mail@example.com',
|
62
|
+
:to => 'mailer@example.com'
|
63
|
+
)
|
64
|
+
|
65
|
+
subject.notify(outpost_stub)
|
66
|
+
|
67
|
+
assert_equal ["mail@example.com"], Mail::TestMailer.deliveries.first.from
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
43
71
|
describe "#notify" do
|
44
72
|
it "should send a simple email" do
|
45
73
|
subject = Outpost::Notifiers::Email.new(
|
@@ -1,12 +1,42 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'ostruct'
|
2
3
|
|
3
4
|
describe Outpost::Scouts::Http do
|
4
5
|
class NetHttpStub
|
6
|
+
class Get
|
7
|
+
def initialize(*args); end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize *args; end
|
11
|
+
def use_ssl= *args; end
|
12
|
+
|
13
|
+
def request(*args, &block)
|
14
|
+
self.class.response
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def response(*args, &block)
|
19
|
+
if (block)
|
20
|
+
@response = block
|
21
|
+
else
|
22
|
+
@response.call
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def request_head(*args)
|
27
|
+
throw "Unexpected call"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class NetHttpHeadStub < NetHttpStub
|
5
33
|
class << self
|
6
|
-
def
|
34
|
+
def request_head(*args)
|
35
|
+
OpenStruct.new :code => 200, :body => 'Body'
|
36
|
+
end
|
7
37
|
|
8
38
|
def get_response(*args)
|
9
|
-
|
39
|
+
throw "Unexpected call"
|
10
40
|
end
|
11
41
|
end
|
12
42
|
end
|
@@ -47,6 +77,16 @@ describe Outpost::Scouts::Http do
|
|
47
77
|
refute @subject.response_body
|
48
78
|
end
|
49
79
|
|
80
|
+
it "should make HEAD request if option is passed" do
|
81
|
+
config_stub = config_stub(:host => 'localhost', :http_class => NetHttpHeadStub, :request_head => true)
|
82
|
+
@subject = Outpost::Scouts::Http.new("description", config_stub)
|
83
|
+
|
84
|
+
@subject.run
|
85
|
+
|
86
|
+
assert_equal 200 , @subject.response_code
|
87
|
+
assert_equal 'Body', @subject.response_body
|
88
|
+
end
|
89
|
+
|
50
90
|
private
|
51
91
|
|
52
92
|
def config_stub(options={})
|
@@ -2,15 +2,24 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
describe Outpost::Scouts::Tcp do
|
4
4
|
it "should set the time of ping in milliseconds" do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
cls = Class.new do
|
6
|
+
def initialize(host, port, timeout)
|
7
|
+
end
|
8
8
|
|
9
|
-
|
9
|
+
def duration
|
10
|
+
0.01
|
11
|
+
end
|
12
|
+
|
13
|
+
def ping?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config = config_stub(:port => 9595, :pinger => cls)
|
10
19
|
subject = Outpost::Scouts::Tcp.new "test", config
|
11
20
|
subject.execute
|
12
21
|
|
13
|
-
assert subject.response_time < 100
|
22
|
+
assert subject.response_time.to_i < 100
|
14
23
|
end
|
15
24
|
|
16
25
|
it "should set the time to nil when it fails" do
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'fakeweb'
|
2
|
+
|
3
|
+
FakeWeb.allow_net_connect = false
|
4
|
+
FakeWeb.register_uri(:get, "http://localhost:9595", :body => 'Up and running!', :status => 200)
|
5
|
+
FakeWeb.register_uri(:get, "http://localhost:9595/fail", :body => 'Omg fail', :status => 500)
|
6
|
+
FakeWeb.register_uri(:get, "http://localhost:9595/warning", :body => 'Omg need payment', :status => 402)
|
data/test/test_helper.rb
CHANGED
@@ -8,8 +8,7 @@ require 'minitest/spec'
|
|
8
8
|
require 'minitest/autorun'
|
9
9
|
|
10
10
|
# Integration test helpers
|
11
|
-
require 'support/
|
12
|
-
require 'support/server'
|
11
|
+
require 'support/requests'
|
13
12
|
require 'support/stubs'
|
14
13
|
require 'support/nothing_raised'
|
15
14
|
|
@@ -19,5 +18,4 @@ require 'outpost/notifiers'
|
|
19
18
|
require 'outpost/scouts'
|
20
19
|
|
21
20
|
include Support::Stubs
|
22
|
-
include Support::NothingRaised
|
23
|
-
|
21
|
+
include Support::NothingRaised
|
metadata
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outpost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Vinicius Baggio Fuentes
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: net-ping
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
description: Simple service monitoring with a clean DSL for configuration.
|
26
28
|
email: vinibaggio@gmail.com
|
27
29
|
executables: []
|
@@ -73,33 +75,31 @@ files:
|
|
73
75
|
- test/outpost/scouts/ping_test.rb
|
74
76
|
- test/outpost/scouts/tcp_test.rb
|
75
77
|
- test/support/nothing_raised.rb
|
76
|
-
- test/support/
|
78
|
+
- test/support/requests.rb
|
77
79
|
- test/support/stubs.rb
|
78
|
-
- test/support/test_app.rb
|
79
80
|
- test/test_helper.rb
|
80
81
|
homepage: http://www.github.com/vinibaggio/outpost
|
81
82
|
licenses: []
|
83
|
+
metadata: {}
|
82
84
|
post_install_message:
|
83
85
|
rdoc_options: []
|
84
86
|
require_paths:
|
85
87
|
- lib
|
86
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
89
|
requirements:
|
89
|
-
- -
|
90
|
+
- - '>='
|
90
91
|
- !ruby/object:Gem::Version
|
91
92
|
version: '0'
|
92
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - '>='
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project: outpost
|
100
|
-
rubygems_version:
|
100
|
+
rubygems_version: 2.0.3
|
101
101
|
signing_key:
|
102
|
-
specification_version:
|
102
|
+
specification_version: 4
|
103
103
|
summary: Simple service monitoring with a clean DSL for configuration.
|
104
104
|
test_files:
|
105
105
|
- test/integration/basic_application_test.rb
|
@@ -120,7 +120,6 @@ test_files:
|
|
120
120
|
- test/outpost/scouts/ping_test.rb
|
121
121
|
- test/outpost/scouts/tcp_test.rb
|
122
122
|
- test/support/nothing_raised.rb
|
123
|
-
- test/support/
|
123
|
+
- test/support/requests.rb
|
124
124
|
- test/support/stubs.rb
|
125
|
-
- test/support/test_app.rb
|
126
125
|
- test/test_helper.rb
|
data/test/support/server.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rack/handler/thin'
|
2
|
-
require 'net/http'
|
3
|
-
|
4
|
-
class Server
|
5
|
-
def wait_until_booted
|
6
|
-
while !responsive?
|
7
|
-
sleep 0.1
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# Got it from Capybara, but simplified it a bit.
|
12
|
-
# lib/capybara/server.rb
|
13
|
-
def responsive?
|
14
|
-
res = Net::HTTP.start('localhost', 9595) { |http| http.get('/') }
|
15
|
-
|
16
|
-
res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection)
|
17
|
-
rescue Errno::ECONNREFUSED, Errno::EBADF
|
18
|
-
return false
|
19
|
-
end
|
20
|
-
|
21
|
-
def boot(app)
|
22
|
-
if not responsive?
|
23
|
-
Thread.new do
|
24
|
-
Thin::Logging.silent = true
|
25
|
-
Rack::Handler::Thin.run(app, :Port => 9595)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/test/support/test_app.rb
DELETED