wellness 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -1
- data/README.md +118 -50
- data/Rakefile +24 -3
- data/lib/wellness/detail.rb +6 -7
- data/lib/wellness/detailed_report.rb +64 -0
- data/lib/wellness/middleware.rb +6 -3
- data/lib/wellness/service.rb +17 -0
- data/lib/wellness/services/base.rb +3 -30
- data/lib/wellness/services/postgres_service.rb +18 -20
- data/lib/wellness/services/redis_service.rb +13 -19
- data/lib/wellness/services/sidekiq_service.rb +23 -20
- data/lib/wellness/simple_report.rb +53 -0
- data/lib/wellness/system.rb +9 -38
- data/lib/wellness/version.rb +2 -2
- data/lib/wellness.rb +5 -4
- data/spec/spec_helper.rb +4 -7
- data/test/test_helper.rb +10 -0
- data/test/wellness/detail_test.rb +26 -0
- data/test/wellness/detailed_report_test.rb +127 -0
- data/test/wellness/simple_report_test.rb +127 -0
- data/test/wellness/system_test.rb +54 -0
- data/wellness.gemspec +0 -2
- metadata +32 -69
- data/.rspec +0 -2
- data/lib/wellness/factory.rb +0 -14
- data/lib/wellness/report.rb +0 -59
- data/lib/wellness/services.rb +0 -6
- data/spec/support/services_support.rb +0 -17
- data/spec/wellness/detail_spec.rb +0 -26
- data/spec/wellness/middleware_spec.rb +0 -69
- data/spec/wellness/report_spec.rb +0 -87
- data/spec/wellness/services/base_spec.rb +0 -51
- data/spec/wellness/services/postgres_service_spec.rb +0 -5
- data/spec/wellness/services/redis_service_spec.rb +0 -31
- data/spec/wellness/services/sidekiq_service_spec.rb +0 -5
- data/spec/wellness/system_spec.rb +0 -78
metadata
CHANGED
@@ -1,111 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wellness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: simplecov
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
38
|
+
- - ">="
|
67
39
|
- !ruby/object:Gem::Version
|
68
40
|
version: '0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: pg
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
|
-
- -
|
45
|
+
- - ">="
|
74
46
|
- !ruby/object:Gem::Version
|
75
47
|
version: '0'
|
76
48
|
type: :development
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
|
-
- -
|
52
|
+
- - ">="
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '0'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: sidekiq
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
|
-
- -
|
59
|
+
- - ">="
|
88
60
|
- !ruby/object:Gem::Version
|
89
61
|
version: '0'
|
90
62
|
type: :development
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
|
-
- -
|
66
|
+
- - ">="
|
95
67
|
- !ruby/object:Gem::Version
|
96
68
|
version: '0'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: redis
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
100
72
|
requirements:
|
101
|
-
- -
|
73
|
+
- - ">="
|
102
74
|
- !ruby/object:Gem::Version
|
103
75
|
version: '0'
|
104
76
|
type: :development
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
|
-
- -
|
80
|
+
- - ">="
|
109
81
|
- !ruby/object:Gem::Version
|
110
82
|
version: '0'
|
111
83
|
description: A rack middleware health check
|
@@ -115,11 +87,10 @@ executables: []
|
|
115
87
|
extensions: []
|
116
88
|
extra_rdoc_files: []
|
117
89
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .
|
120
|
-
- .ruby-
|
121
|
-
- .
|
122
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".ruby-gemset"
|
92
|
+
- ".ruby-version"
|
93
|
+
- ".travis.yml"
|
123
94
|
- DOCUMENTATION.md
|
124
95
|
- Gemfile
|
125
96
|
- LICENSE.txt
|
@@ -127,26 +98,22 @@ files:
|
|
127
98
|
- Rakefile
|
128
99
|
- lib/wellness.rb
|
129
100
|
- lib/wellness/detail.rb
|
130
|
-
- lib/wellness/
|
101
|
+
- lib/wellness/detailed_report.rb
|
131
102
|
- lib/wellness/middleware.rb
|
132
|
-
- lib/wellness/
|
133
|
-
- lib/wellness/services.rb
|
103
|
+
- lib/wellness/service.rb
|
134
104
|
- lib/wellness/services/base.rb
|
135
105
|
- lib/wellness/services/postgres_service.rb
|
136
106
|
- lib/wellness/services/redis_service.rb
|
137
107
|
- lib/wellness/services/sidekiq_service.rb
|
108
|
+
- lib/wellness/simple_report.rb
|
138
109
|
- lib/wellness/system.rb
|
139
110
|
- lib/wellness/version.rb
|
140
111
|
- spec/spec_helper.rb
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
- spec/wellness/services/postgres_service_spec.rb
|
147
|
-
- spec/wellness/services/redis_service_spec.rb
|
148
|
-
- spec/wellness/services/sidekiq_service_spec.rb
|
149
|
-
- spec/wellness/system_spec.rb
|
112
|
+
- test/test_helper.rb
|
113
|
+
- test/wellness/detail_test.rb
|
114
|
+
- test/wellness/detailed_report_test.rb
|
115
|
+
- test/wellness/simple_report_test.rb
|
116
|
+
- test/wellness/system_test.rb
|
150
117
|
- wellness.gemspec
|
151
118
|
homepage: https://github.com/warmwaffles/wellness
|
152
119
|
licenses:
|
@@ -158,28 +125,24 @@ require_paths:
|
|
158
125
|
- lib
|
159
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
127
|
requirements:
|
161
|
-
- -
|
128
|
+
- - ">="
|
162
129
|
- !ruby/object:Gem::Version
|
163
130
|
version: '0'
|
164
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
132
|
requirements:
|
166
|
-
- -
|
133
|
+
- - ">="
|
167
134
|
- !ruby/object:Gem::Version
|
168
135
|
version: '0'
|
169
136
|
requirements: []
|
170
137
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.2.
|
138
|
+
rubygems_version: 2.2.2
|
172
139
|
signing_key:
|
173
140
|
specification_version: 4
|
174
141
|
summary: A rack middleware health check
|
175
142
|
test_files:
|
176
143
|
- spec/spec_helper.rb
|
177
|
-
-
|
178
|
-
-
|
179
|
-
-
|
180
|
-
-
|
181
|
-
-
|
182
|
-
- spec/wellness/services/postgres_service_spec.rb
|
183
|
-
- spec/wellness/services/redis_service_spec.rb
|
184
|
-
- spec/wellness/services/sidekiq_service_spec.rb
|
185
|
-
- spec/wellness/system_spec.rb
|
144
|
+
- test/test_helper.rb
|
145
|
+
- test/wellness/detail_test.rb
|
146
|
+
- test/wellness/detailed_report_test.rb
|
147
|
+
- test/wellness/simple_report_test.rb
|
148
|
+
- test/wellness/system_test.rb
|
data/.rspec
DELETED
data/lib/wellness/factory.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Wellness
|
2
|
-
# A simple class that builds the provided class with the provided arguments
|
3
|
-
# @author Matthew A. Johnston (warmwaffles)
|
4
|
-
class Factory
|
5
|
-
def initialize(klass, *args)
|
6
|
-
@klass = klass
|
7
|
-
@args = args
|
8
|
-
end
|
9
|
-
|
10
|
-
def build
|
11
|
-
@klass.new(*@args)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/wellness/report.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
module Wellness
|
2
|
-
# A simple presenter for the services and details of the Wellness System.
|
3
|
-
#
|
4
|
-
# @author Matthew A. Johnston (warmwaffles)
|
5
|
-
class Report
|
6
|
-
# @param services [Hash]
|
7
|
-
# @param details [Hash]
|
8
|
-
def initialize(services, details)
|
9
|
-
@services = services
|
10
|
-
@details = details
|
11
|
-
end
|
12
|
-
|
13
|
-
# @return [Hash]
|
14
|
-
def detailed
|
15
|
-
{
|
16
|
-
status: status,
|
17
|
-
services: services,
|
18
|
-
details: details
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [Hash]
|
23
|
-
def simple
|
24
|
-
{
|
25
|
-
status: status
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
# Returns the {#detailed} hash in json form
|
30
|
-
#
|
31
|
-
# @return [String]
|
32
|
-
def to_json(*)
|
33
|
-
detailed.to_json
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return [String]
|
37
|
-
def status
|
38
|
-
healthy? ? 'HEALTHY' : 'UNHEALTHY'
|
39
|
-
end
|
40
|
-
|
41
|
-
# @return [Integer]
|
42
|
-
def status_code
|
43
|
-
healthy? ? 200 : 500
|
44
|
-
end
|
45
|
-
|
46
|
-
# @return [TrueClass,FalseClass]
|
47
|
-
def healthy?
|
48
|
-
@services.all?(&:healthy?)
|
49
|
-
end
|
50
|
-
|
51
|
-
def services
|
52
|
-
Hash[@services.map { |s| [s.name, s.result] }]
|
53
|
-
end
|
54
|
-
|
55
|
-
def details
|
56
|
-
Hash[@details.map { |d| [d.name, d.result] }]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/lib/wellness/services.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class UnhealthyService < Wellness::Services::Base
|
2
|
-
def check
|
3
|
-
{ status: 'UNHEALTHY' }
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
class HealthyService < Wellness::Services::Base
|
8
|
-
def check
|
9
|
-
{ status: 'HEALTHY' }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class MockedDetail < Wellness::Detail
|
14
|
-
def check
|
15
|
-
{ 'data' => 'here' }
|
16
|
-
end
|
17
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Wellness::Detail do
|
4
|
-
let(:detail) { MockedDetail.new('test_detail') }
|
5
|
-
|
6
|
-
describe '#name' do
|
7
|
-
subject { detail.name }
|
8
|
-
it 'returns "test_detail"' do
|
9
|
-
expect(subject).to eq('test_detail')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#call' do
|
14
|
-
subject { detail.call }
|
15
|
-
it 'sets the result' do
|
16
|
-
expect { subject }.to change(detail, :result)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#check' do
|
21
|
-
subject { detail.check }
|
22
|
-
it 'returns a hash' do
|
23
|
-
expect(subject).to be_a(Hash)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Wellness::Middleware do
|
4
|
-
let(:app) { double('Application') }
|
5
|
-
let(:system) { Wellness::System.new('test_system') }
|
6
|
-
|
7
|
-
describe '#health_status_path' do
|
8
|
-
subject { middleware.health_status_path }
|
9
|
-
context 'when the status_path is not passed' do
|
10
|
-
let(:middleware) { described_class.new(app, system) }
|
11
|
-
it 'returns "/health/status"' do
|
12
|
-
expect(subject).to eq('/health/status')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
context 'when the status_path is passed' do
|
16
|
-
let(:options) { {status_path: '/path/to/status' } }
|
17
|
-
let(:middleware) { described_class.new(app, system, options) }
|
18
|
-
it 'returns "/path/to/status"' do
|
19
|
-
expect(subject).to eq('/path/to/status')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#health_details_path' do
|
25
|
-
context 'when the details_path is not passed' do
|
26
|
-
let(:middleware) { described_class.new(app, system) }
|
27
|
-
subject { middleware.health_details_path }
|
28
|
-
it 'returns "/health/details"' do
|
29
|
-
expect(subject).to eq('/health/details')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
context 'when the details_path is passed' do
|
33
|
-
let(:options) { {details_path: '/path/to/status' } }
|
34
|
-
let(:middleware) { described_class.new(app, system, options) }
|
35
|
-
subject { middleware.health_details_path }
|
36
|
-
it 'returns "/path/to/status"' do
|
37
|
-
expect(subject).to eq('/path/to/status')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#call' do
|
43
|
-
let(:middleware) { described_class.new(app, system) }
|
44
|
-
context 'when the PATH_INFO matches the health_status_path' do
|
45
|
-
let(:env) { { 'PATH_INFO' => '/health/status' } }
|
46
|
-
before { system.stub(simple_check: true) }
|
47
|
-
it 'calls #simple_check on the system' do
|
48
|
-
middleware.call(env)
|
49
|
-
expect(system).to have_received(:simple_check).once
|
50
|
-
end
|
51
|
-
end
|
52
|
-
context 'when the PATH_INFO matches the health_details_path' do
|
53
|
-
let(:env) { { 'PATH_INFO' => '/health/details' } }
|
54
|
-
before { system.stub(detailed_check: true) }
|
55
|
-
it 'calls #detailed_check on the system' do
|
56
|
-
middleware.call(env)
|
57
|
-
expect(system).to have_received(:detailed_check).once
|
58
|
-
end
|
59
|
-
end
|
60
|
-
context 'when the PATH_INFO doesn\'t match any of the paths' do
|
61
|
-
let(:env) { { 'PATH_INFO' => '/different/path' } }
|
62
|
-
before { app.stub(call: true) }
|
63
|
-
it 'calls #detailed_check on the system' do
|
64
|
-
middleware.call(env)
|
65
|
-
expect(app).to have_received(:call).with(env)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Wellness::Report do
|
4
|
-
let(:report) { described_class.new({}, {}) }
|
5
|
-
|
6
|
-
describe '#to_json' do
|
7
|
-
subject { report.to_json }
|
8
|
-
it 'returns a json string' do
|
9
|
-
expect(JSON.parse(subject)).to be_a(Hash)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#detailed' do
|
14
|
-
subject { report.detailed }
|
15
|
-
it 'returns a hash' do
|
16
|
-
expect(subject).to be_a(Hash)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#simple' do
|
21
|
-
subject { report.simple }
|
22
|
-
it 'returns a hash' do
|
23
|
-
expect(subject).to be_a(Hash)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#status' do
|
28
|
-
subject { report.status }
|
29
|
-
context 'when the report is healthy' do
|
30
|
-
before { report.stub(:healthy? => true) }
|
31
|
-
it 'returns HEALTHY' do
|
32
|
-
expect(subject).to eq('HEALTHY')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
context 'when the report is not healthy' do
|
36
|
-
before { report.stub(:healthy? => false) }
|
37
|
-
it 'returns UNHEALTHY' do
|
38
|
-
expect(subject).to eq('UNHEALTHY')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#status_code' do
|
44
|
-
subject { report.status_code }
|
45
|
-
context 'when the report is healthy' do
|
46
|
-
before { report.stub(:healthy? => true) }
|
47
|
-
it 'returns 200' do
|
48
|
-
expect(subject).to eq(200)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
context 'when the report is not healthy' do
|
52
|
-
before { report.stub(:healthy? => false) }
|
53
|
-
it 'returns 500' do
|
54
|
-
expect(subject).to eq(500)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#healthy?' do
|
60
|
-
subject { report.healthy? }
|
61
|
-
context 'when all of the report are healthy' do
|
62
|
-
let(:services) { [HealthyService.new('service-a'), HealthyService.new('service-b')] }
|
63
|
-
let(:report) { described_class.new(services, []) }
|
64
|
-
before { services.collect(&:call) }
|
65
|
-
it 'returns true' do
|
66
|
-
expect(subject).to eq(true)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
context 'when one of the reports are not healthy' do
|
70
|
-
let(:services) { [HealthyService.new('service-a'), UnhealthyService.new('service-b')] }
|
71
|
-
let(:report) { described_class.new(services, []) }
|
72
|
-
before { services.collect(&:call) }
|
73
|
-
it 'returns false' do
|
74
|
-
expect(subject).to eq(false)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
context 'when all of the reports are not healthy' do
|
78
|
-
let(:services) { [UnhealthyService.new('service-a'), UnhealthyService.new('service-b')] }
|
79
|
-
let(:report) { described_class.new(services, []) }
|
80
|
-
before { services.collect(&:call) }
|
81
|
-
it 'returns false' do
|
82
|
-
expect(subject).to eq(false)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Wellness::Services::Base do
|
4
|
-
let(:params) { { foo: 'bar' } }
|
5
|
-
let(:service) { described_class.new(params) }
|
6
|
-
|
7
|
-
describe '#healthy?' do
|
8
|
-
subject { service.healthy? }
|
9
|
-
context 'when the status key is missing' do
|
10
|
-
before { service.result.delete(:status) }
|
11
|
-
it 'returns false' do
|
12
|
-
expect(subject).to eq(false)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
context 'when the status is UNHEALTHY' do
|
16
|
-
before { service.result[:status] = 'UNHEALTHY' }
|
17
|
-
it 'returns false' do
|
18
|
-
expect(subject).to eq(false)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
context 'when the status is HEALTHY' do
|
22
|
-
before { service.result[:status] = 'HEALTHY' }
|
23
|
-
it 'returns true' do
|
24
|
-
expect(subject).to eq(true)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#call' do
|
30
|
-
let(:result) { {status: 'HEALTHY'} }
|
31
|
-
subject { service.call }
|
32
|
-
|
33
|
-
before { service.stub(check: result) }
|
34
|
-
|
35
|
-
it 'receives the #call method' do
|
36
|
-
subject
|
37
|
-
expect(service).to have_received(:check).once
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'sets the result' do
|
41
|
-
expect { subject }.to change { service.result }.to(result)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#check' do
|
46
|
-
subject { service.check }
|
47
|
-
it 'returns a status of UNHEALTHY' do
|
48
|
-
expect(subject).to include(status: 'UNHEALTHY')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Wellness::Services::RedisService do
|
4
|
-
let(:params) {
|
5
|
-
{
|
6
|
-
redis: {
|
7
|
-
url: 'redis://127.0.0.1:6379/0'
|
8
|
-
}
|
9
|
-
}
|
10
|
-
}
|
11
|
-
let(:service) { described_class.new(params) }
|
12
|
-
let(:redis_info) {
|
13
|
-
{
|
14
|
-
'uptime_in_seconds' => '612488',
|
15
|
-
'uptime_in_days' => '7',
|
16
|
-
'connected_clients' => '1',
|
17
|
-
'used_memory_human' => '979.22K',
|
18
|
-
'total_connections_received' => '2',
|
19
|
-
'total_commands_processed' => '1',
|
20
|
-
'rejected_connections' => '0',
|
21
|
-
'sync_full' => '0',
|
22
|
-
'sync_partial_ok' => '0',
|
23
|
-
'sync_partial_err' => '0',
|
24
|
-
'expired_keys' => '0',
|
25
|
-
'evicted_keys' => '0',
|
26
|
-
'keyspace_hits' => '0',
|
27
|
-
'keyspace_misses' => '0'
|
28
|
-
}
|
29
|
-
}
|
30
|
-
pending
|
31
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Wellness::System do
|
4
|
-
let(:system) { described_class.new('test_system') }
|
5
|
-
|
6
|
-
describe '#use' do
|
7
|
-
context 'when a Wellness::Services::Base is provided' do
|
8
|
-
subject { system.use(HealthyService, 'test_service') }
|
9
|
-
it 'adds the service to the list of services' do
|
10
|
-
expect { subject }.to change { system.services.count }.by(1)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
context 'when a Wellness::Detail is provided' do
|
14
|
-
subject { system.use(MockedDetail, 'test_detail') }
|
15
|
-
it 'adds the detail to the list of details' do
|
16
|
-
expect { subject }.to change { system.details.count }.by(1)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#build_report' do
|
22
|
-
subject { system.build_report }
|
23
|
-
it 'returns a Wellness::Report' do
|
24
|
-
expect(subject).to be_a(Wellness::Report)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#detailed_check' do
|
29
|
-
let(:headers) { { 'Content-Type' => 'application/json' } }
|
30
|
-
subject { system.detailed_check }
|
31
|
-
|
32
|
-
context 'when the check is HEALTHY' do
|
33
|
-
before { system.use(HealthyService, 'test_service') }
|
34
|
-
|
35
|
-
it 'responds with a 200' do
|
36
|
-
expect(subject[0]).to eq(200)
|
37
|
-
end
|
38
|
-
it 'sets the "Content-Type" to "application/json"' do
|
39
|
-
expect(subject[1]).to eq(headers)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
context 'when the check is UNHEALTHY' do
|
43
|
-
before { system.use(UnhealthyService, 'test_service') }
|
44
|
-
|
45
|
-
it 'responds with a 500' do
|
46
|
-
expect(subject[0]).to eq(500)
|
47
|
-
end
|
48
|
-
it 'sets the "Content-Type" to "application/json"' do
|
49
|
-
expect(subject[1]).to eq(headers)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#simple_check' do
|
55
|
-
let(:headers) { { 'Content-Type' => 'application/json' } }
|
56
|
-
subject { system.simple_check }
|
57
|
-
context 'when the check is HEALTHY' do
|
58
|
-
before { system.use(HealthyService, 'test_service') }
|
59
|
-
|
60
|
-
it 'responds with a 200' do
|
61
|
-
expect(subject[0]).to eq(200)
|
62
|
-
end
|
63
|
-
it 'sets the "Content-Type" to "application/json"' do
|
64
|
-
expect(subject[1]).to eq(headers)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
context 'when the check is UNHEALTHY' do
|
68
|
-
before { system.use(UnhealthyService, 'test_service') }
|
69
|
-
|
70
|
-
it 'responds with a 500' do
|
71
|
-
expect(subject[0]).to eq(500)
|
72
|
-
end
|
73
|
-
it 'sets the "Content-Type" to "application/json"' do
|
74
|
-
expect(subject[1]).to eq(headers)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|