easymon 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of easymon might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/easymon/checks/http_check.rb +16 -9
- data/lib/easymon/testing.rb +6 -4
- data/lib/easymon/version.rb +1 -1
- data/test/unit/checks/http_check_test.rb +17 -7
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a7954525c464810b1c89b990ff7b353c2379f5a
|
4
|
+
data.tar.gz: 694349ce9fb924e1c1e4b789ef9a24742f55e89f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a535bef8ef8df2fcf9184d5b310b020e398f1465e40afe03c9b3491a21aefb86f02584a7bb692b337ac5217e2372d0031e8f85a08dc481c4ac35cfea38f5ec7e
|
7
|
+
data.tar.gz: 797c12bcb3a9ecda8a2a582811e79c172c0425d1784d4d03fa7c813e63f4241f15d7506e378064a58a2f330f3e6f0e2447fd8f31147ef0ed138ca90c81e73ccc
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'net/https'
|
2
2
|
|
3
3
|
module Easymon
|
4
4
|
class HttpCheck
|
@@ -19,15 +19,22 @@ module Easymon
|
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
|
-
def http_up?(
|
23
|
-
|
24
|
-
:method => :head,
|
25
|
-
:url => config_url,
|
26
|
-
:timeout => 5,
|
27
|
-
:open_timeout => 5)
|
28
|
-
true
|
22
|
+
def http_up?(url)
|
23
|
+
http_head(url).is_a?(Net::HTTPSuccess)
|
29
24
|
rescue Exception
|
30
25
|
false
|
31
26
|
end
|
27
|
+
|
28
|
+
def http_head(url)
|
29
|
+
uri = URI.parse(url)
|
30
|
+
|
31
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
32
|
+
http.use_ssl = uri.is_a?(URI::HTTPS)
|
33
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
34
|
+
http.open_timeout = 5
|
35
|
+
http.read_timeout = 5
|
36
|
+
|
37
|
+
http.request Net::HTTP::Head.new(uri.request_uri)
|
38
|
+
end
|
32
39
|
end
|
33
|
-
end
|
40
|
+
end
|
data/lib/easymon/testing.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Easymon
|
2
|
-
|
3
|
-
|
2
|
+
module Testing
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def stub_check(name)
|
4
6
|
Easymon.const_get("#{name.to_s.capitalize}Check").any_instance.stubs(:check)
|
5
7
|
end
|
6
8
|
|
7
|
-
def
|
9
|
+
def stub_service_success(name)
|
8
10
|
stub_check(name).returns([true, "Up"])
|
9
11
|
end
|
10
12
|
|
11
|
-
def
|
13
|
+
def stub_service_failure(name)
|
12
14
|
stub_check(name).returns([false, "Down"])
|
13
15
|
end
|
14
16
|
end
|
data/lib/easymon/version.rb
CHANGED
@@ -1,21 +1,32 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class HttpCheckTest < ActiveSupport::TestCase
|
4
|
-
|
5
4
|
test "#run sets success conditions on successful run" do
|
6
|
-
|
5
|
+
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.1, 200, "OK"))
|
6
|
+
|
7
7
|
check = create_check
|
8
8
|
results = check.check
|
9
|
-
|
9
|
+
|
10
10
|
assert_equal("Up", results[1])
|
11
11
|
assert_equal(true, results[0])
|
12
12
|
end
|
13
13
|
|
14
14
|
test "#run sets failure conditions on a failed run" do
|
15
|
-
|
15
|
+
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPNotFound.new(1.1, 404, "Not Found"))
|
16
|
+
|
17
|
+
check = create_check
|
18
|
+
results = check.check
|
19
|
+
|
20
|
+
assert_equal("Down", results[1])
|
21
|
+
assert_equal(false, results[0])
|
22
|
+
end
|
23
|
+
|
24
|
+
test "#run sets failure conditions on an errored run" do
|
25
|
+
Net::HTTP.any_instance.stubs(:request).raises("boom")
|
26
|
+
|
16
27
|
check = create_check
|
17
28
|
results = check.check
|
18
|
-
|
29
|
+
|
19
30
|
assert_equal("Down", results[1])
|
20
31
|
assert_equal(false, results[0])
|
21
32
|
end
|
@@ -26,8 +37,7 @@ class HttpCheckTest < ActiveSupport::TestCase
|
|
26
37
|
assert_equal("Down", results[1])
|
27
38
|
assert_equal(false, results[0])
|
28
39
|
end
|
29
|
-
|
30
|
-
|
40
|
+
|
31
41
|
private
|
32
42
|
def create_check
|
33
43
|
# Fake URL
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easymon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rest-client
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.6'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.6'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: redis
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|