hey_doctor 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/hey_doctor/check_application_health_service.rb +4 -4
- data/app/services/hey_doctor/check_database_health_service.rb +6 -6
- data/app/services/hey_doctor/check_redis_health_service.rb +4 -4
- data/app/services/hey_doctor/check_sidekiq_health_service.rb +43 -0
- data/lib/hey_doctor.rb +6 -0
- data/lib/hey_doctor/version.rb +1 -1
- data/spec/dummy/log/development.log +224 -0
- data/spec/dummy/log/test.log +753 -0
- data/spec/lib/hey_doctor/hey_doctor_spec.rb +30 -10
- data/spec/services/hey_doctor/check_application_health_service_spec.rb +4 -4
- data/spec/services/hey_doctor/check_database_health_service_spec.rb +6 -6
- data/spec/services/hey_doctor/check_redis_health_service_spec.rb +4 -4
- data/spec/services/hey_doctor/check_sidekiq_health_service_spec.rb +71 -0
- data/spec/spec_helper.rb +1 -0
- metadata +19 -2
@@ -6,17 +6,29 @@ RSpec.describe '.Rack HealthCheck endpoint' do
|
|
6
6
|
let(:expected_response) do
|
7
7
|
{
|
8
8
|
app: {
|
9
|
-
|
10
|
-
|
9
|
+
success: true,
|
10
|
+
message: 'foo'
|
11
11
|
},
|
12
12
|
database: {
|
13
|
-
|
14
|
-
|
13
|
+
success: true,
|
14
|
+
message: 'foo'
|
15
15
|
},
|
16
16
|
redis: {
|
17
|
-
|
18
|
-
|
19
|
-
}
|
17
|
+
success: true,
|
18
|
+
message: 'foo'
|
19
|
+
},
|
20
|
+
sidekiq: [
|
21
|
+
{
|
22
|
+
success: true,
|
23
|
+
message: 'Sidekiq is connected',
|
24
|
+
host: 'sidekiq_1'
|
25
|
+
},
|
26
|
+
{
|
27
|
+
success: false,
|
28
|
+
message: 'Error sidekiq',
|
29
|
+
host: 'sidekiq_2'
|
30
|
+
}
|
31
|
+
]
|
20
32
|
}.to_json
|
21
33
|
end
|
22
34
|
|
@@ -24,13 +36,21 @@ RSpec.describe '.Rack HealthCheck endpoint' do
|
|
24
36
|
|
25
37
|
before do
|
26
38
|
allow(HeyDoctor::CheckApplicationHealthService).to receive(:call)
|
27
|
-
.and_return({ message: 'foo'
|
39
|
+
.and_return({ success: true, message: 'foo' })
|
28
40
|
|
29
41
|
allow(HeyDoctor::CheckDatabaseHealthService).to receive(:call)
|
30
|
-
.and_return({ message: 'foo'
|
42
|
+
.and_return({ success: true, message: 'foo' })
|
31
43
|
|
32
44
|
allow(HeyDoctor::CheckRedisHealthService).to receive(:call)
|
33
|
-
.and_return({ message: 'foo'
|
45
|
+
.and_return({ success: true, message: 'foo' })
|
46
|
+
|
47
|
+
allow(HeyDoctor::CheckSidekiqHealthService).to receive(:call)
|
48
|
+
.and_return(
|
49
|
+
[
|
50
|
+
{ success: true, message: 'Sidekiq is connected', host: 'sidekiq_1' },
|
51
|
+
{ success: false, message: 'Error sidekiq', host: 'sidekiq_2' }
|
52
|
+
]
|
53
|
+
)
|
34
54
|
end
|
35
55
|
|
36
56
|
it 'build the json response' do
|
@@ -16,8 +16,8 @@ RSpec.describe HeyDoctor::CheckApplicationHealthService do
|
|
16
16
|
context 'When app is running' do
|
17
17
|
let(:expected_response) do
|
18
18
|
{
|
19
|
-
|
20
|
-
|
19
|
+
success: true,
|
20
|
+
message: 'Application is running'
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
@@ -31,8 +31,8 @@ RSpec.describe HeyDoctor::CheckApplicationHealthService do
|
|
31
31
|
context 'When app is down' do
|
32
32
|
let(:expected_response) do
|
33
33
|
{
|
34
|
-
|
35
|
-
|
34
|
+
success: false,
|
35
|
+
message: 'Application down, call the firefighters'
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
@@ -7,8 +7,8 @@ RSpec.describe HeyDoctor::CheckDatabaseHealthService do
|
|
7
7
|
context 'when it is connected' do
|
8
8
|
let(:expected_response) do
|
9
9
|
{
|
10
|
-
|
11
|
-
|
10
|
+
success: true,
|
11
|
+
message: 'Database is connected'
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
@@ -20,8 +20,8 @@ RSpec.describe HeyDoctor::CheckDatabaseHealthService do
|
|
20
20
|
context 'when it is not connected' do
|
21
21
|
let(:expected_response) do
|
22
22
|
{
|
23
|
-
|
24
|
-
|
23
|
+
success: false,
|
24
|
+
message: 'Error connecting to database'
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
@@ -38,8 +38,8 @@ RSpec.describe HeyDoctor::CheckDatabaseHealthService do
|
|
38
38
|
context 'When migration is Pending' do
|
39
39
|
let(:expected_response) do
|
40
40
|
{
|
41
|
-
|
42
|
-
|
41
|
+
success: true,
|
42
|
+
message: 'Pending migrations detected'
|
43
43
|
}
|
44
44
|
end
|
45
45
|
|
@@ -7,8 +7,8 @@ RSpec.describe HeyDoctor::CheckRedisHealthService do
|
|
7
7
|
context 'when it is connected' do
|
8
8
|
let(:expected_response) do
|
9
9
|
{
|
10
|
-
|
11
|
-
|
10
|
+
success: true,
|
11
|
+
message: 'Redis is connected'
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
@@ -20,8 +20,8 @@ RSpec.describe HeyDoctor::CheckRedisHealthService do
|
|
20
20
|
context 'when it is not connected' do
|
21
21
|
let(:expected_response) do
|
22
22
|
{
|
23
|
-
|
24
|
-
|
23
|
+
success: false,
|
24
|
+
message: 'Error connecting to redis'
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe HeyDoctor::CheckSidekiqHealthService do
|
6
|
+
describe '.call' do
|
7
|
+
context 'when it is connected' do
|
8
|
+
let(:expected_response) do
|
9
|
+
[
|
10
|
+
{
|
11
|
+
success: true,
|
12
|
+
message: 'Sidekiq is connected',
|
13
|
+
host: 'dcsiloifoodcatalogimporter_sidekiq_1'
|
14
|
+
}
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
before do
|
19
|
+
allow(described_class).to receive(:hosts)
|
20
|
+
.and_return(['dcsiloifoodcatalogimporter_sidekiq_1'])
|
21
|
+
|
22
|
+
allow(described_class).to receive(:connected?)
|
23
|
+
.with('dcsiloifoodcatalogimporter_sidekiq_1').and_return(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'respond with success' do
|
27
|
+
expect(described_class.call).to eq(expected_response)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when it is not connected' do
|
32
|
+
let(:expected_response) do
|
33
|
+
[
|
34
|
+
{
|
35
|
+
success: false,
|
36
|
+
message: 'Error connecting to sidekiq',
|
37
|
+
host: 'dcsiloifoodcatalogimporter_sidekiq_2'
|
38
|
+
}
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
before do
|
43
|
+
allow(described_class).to receive(:hosts)
|
44
|
+
.and_return(['dcsiloifoodcatalogimporter_sidekiq_2'])
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'respond with error' do
|
48
|
+
expect(described_class.call).to eq(expected_response)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when there is no executor machine' do
|
54
|
+
let(:expected_response) do
|
55
|
+
{
|
56
|
+
success: false,
|
57
|
+
message: 'None sidekiq host was found, add it to the ' \
|
58
|
+
'ENV SIDEKIQ_HOSTS listing your machine(s) ip or' \
|
59
|
+
' dns using ; for each host'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
before do
|
64
|
+
allow(described_class).to receive(:hosts).and_return(nil)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'respond with error' do
|
68
|
+
expect(described_class.call).to eq(expected_response)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hey_doctor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matheus Acosta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dotenv-rails
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: pry
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: redis
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +137,7 @@ files:
|
|
123
137
|
- app/services/hey_doctor/check_application_health_service.rb
|
124
138
|
- app/services/hey_doctor/check_database_health_service.rb
|
125
139
|
- app/services/hey_doctor/check_redis_health_service.rb
|
140
|
+
- app/services/hey_doctor/check_sidekiq_health_service.rb
|
126
141
|
- config/routes.rb
|
127
142
|
- lib/hey_doctor.rb
|
128
143
|
- lib/hey_doctor/engine.rb
|
@@ -176,6 +191,7 @@ files:
|
|
176
191
|
- spec/services/hey_doctor/check_application_health_service_spec.rb
|
177
192
|
- spec/services/hey_doctor/check_database_health_service_spec.rb
|
178
193
|
- spec/services/hey_doctor/check_redis_health_service_spec.rb
|
194
|
+
- spec/services/hey_doctor/check_sidekiq_health_service_spec.rb
|
179
195
|
- spec/spec_helper.rb
|
180
196
|
homepage: https://github.com/deliverycenter/hey_doctor
|
181
197
|
licenses:
|
@@ -252,4 +268,5 @@ test_files:
|
|
252
268
|
- spec/services/hey_doctor/check_application_health_service_spec.rb
|
253
269
|
- spec/services/hey_doctor/check_database_health_service_spec.rb
|
254
270
|
- spec/services/hey_doctor/check_redis_health_service_spec.rb
|
271
|
+
- spec/services/hey_doctor/check_sidekiq_health_service_spec.rb
|
255
272
|
- spec/spec_helper.rb
|