foreman_monitoring 0.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +14 -7
- data/Rakefile +0 -0
- data/app/controllers/api/v2/downtime_controller.rb +63 -0
- data/app/controllers/api/v2/monitoring_results_controller.rb +5 -4
- data/app/controllers/concerns/foreman_monitoring/find_host_by_client_cert.rb +59 -0
- data/app/controllers/concerns/foreman_monitoring/hosts_controller_extensions.rb +7 -5
- data/app/helpers/concerns/foreman_monitoring/hosts_helper_ext.rb +11 -13
- data/app/lib/proxy_api/monitoring.rb +9 -6
- data/app/models/concerns/foreman_monitoring/host_extensions.rb +6 -3
- data/app/models/concerns/foreman_monitoring/hostgroup_extensions.rb +7 -3
- data/app/models/concerns/orchestration/monitoring.rb +22 -15
- data/app/models/host_status/monitoring_status.rb +7 -4
- data/app/models/monitoring_result.rb +13 -6
- data/app/models/setting/monitoring.rb +4 -2
- data/app/overrides/add_host_monitoring_result_tab.rb +8 -6
- data/app/overrides/add_host_multiple_power_set_downtime_checkbox.rb +5 -3
- data/app/overrides/add_host_set_downtime_modal.rb +4 -2
- data/app/services/monitoring.rb +3 -0
- data/app/views/hosts/_downtime_fields.html.erb +2 -2
- data/app/views/monitoring_results/_host_tab_pane.html.erb +2 -2
- data/config/routes.rb +3 -0
- data/db/migrate/20160817135723_create_monitoring_results.rb +5 -1
- data/db/migrate/20161220201510_add_monitoring_proxy_id_to_host_and_hostgroup.rb +3 -1
- data/db/migrate/201910180900_rename_downtime_host_permission.rb +15 -0
- data/db/seeds.d/60-monitoring_proxy_feature.rb +2 -0
- data/lib/foreman_monitoring.rb +2 -0
- data/lib/foreman_monitoring/engine.rb +32 -28
- data/lib/foreman_monitoring/version.rb +3 -1
- data/lib/tasks/foreman_monitoring_tasks.rake +5 -5
- data/locale/gemspec.rb +2 -0
- data/test/controllers/api/v2/downtime_controller_test.rb +73 -0
- data/test/factories/feature.rb +4 -2
- data/test/factories/host.rb +6 -4
- data/test/factories/monitoring_results.rb +9 -7
- data/test/factories/smart_proxy.rb +3 -1
- data/test/functional/hosts_controller_test.rb +65 -52
- data/test/lib/proxy_api/monitoring_test.rb +16 -14
- data/test/test_plugin_helper.rb +5 -3
- data/test/unit/host_status/monitoring_status_test.rb +18 -16
- data/test/unit/host_test.rb +6 -4
- data/test/unit/monitoring_result_test.rb +75 -0
- data/test/unit/monitoring_test.rb +5 -3
- metadata +68 -20
data/test/factories/feature.rb
CHANGED
data/test/factories/host.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.modify do
|
2
4
|
factory :host do
|
3
5
|
trait :with_monitoring do
|
4
6
|
monitoring_proxy do
|
5
|
-
|
7
|
+
FactoryBot.create(:smart_proxy, :monitoring)
|
6
8
|
end
|
7
9
|
end
|
8
10
|
|
9
11
|
trait :with_monitoring_results do
|
10
12
|
transient do
|
11
|
-
monitoring_result_count 20
|
13
|
+
monitoring_result_count { 20 }
|
12
14
|
end
|
13
15
|
after(:create) do |host, evaluator|
|
14
16
|
evaluator.monitoring_result_count.times do
|
15
|
-
|
17
|
+
FactoryBot.create(:monitoring_result, :host => host)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,30 +1,32 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
2
4
|
factory :monitoring_result do
|
3
5
|
sequence(:service) { |n| "Service #{n}" }
|
4
6
|
result { rand(0..3) }
|
5
7
|
|
6
8
|
trait :ok do
|
7
|
-
result 0
|
9
|
+
result { 0 }
|
8
10
|
end
|
9
11
|
|
10
12
|
trait :warning do
|
11
|
-
result 1
|
13
|
+
result { 1 }
|
12
14
|
end
|
13
15
|
|
14
16
|
trait :critical do
|
15
|
-
result 2
|
17
|
+
result { 2 }
|
16
18
|
end
|
17
19
|
|
18
20
|
trait :unknown do
|
19
|
-
result 3
|
21
|
+
result { 3 }
|
20
22
|
end
|
21
23
|
|
22
24
|
trait :downtime do
|
23
|
-
downtime true
|
25
|
+
downtime { true }
|
24
26
|
end
|
25
27
|
|
26
28
|
trait :acknowledged do
|
27
|
-
acknowledged true
|
29
|
+
acknowledged { true }
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
class HostsControllerExtensionsTest < ActionController::TestCase
|
@@ -8,7 +10,7 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
8
10
|
ProxyAPI::Monitoring.stubs(:create_host).returns(true)
|
9
11
|
ProxyAPI::Monitoring.stubs(:update_host).returns(true)
|
10
12
|
ProxyAPI::Monitoring.stubs(:delete_host).returns(true)
|
11
|
-
@host =
|
13
|
+
@host = FactoryBot.create(:host, :managed)
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when setting a host downtime' do
|
@@ -18,23 +20,25 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
18
20
|
|
19
21
|
test 'the flash should inform it' do
|
20
22
|
Host::Managed.any_instance.stubs(:downtime_host).returns(true)
|
21
|
-
put :downtime,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
put :downtime,
|
24
|
+
params: {
|
25
|
+
:id => @host.name,
|
26
|
+
:downtime => {
|
27
|
+
:comment => 'Maintenance work.',
|
28
|
+
:starttime => Time.current,
|
29
|
+
:endtime => Time.current.advance(:hours => 2)
|
30
|
+
}
|
31
|
+
},
|
32
|
+
session: set_session_user
|
29
33
|
assert_response :found
|
30
34
|
assert_redirected_to host_path(:id => @host)
|
31
35
|
assert_nil flash[:error]
|
32
|
-
assert_not_nil flash[:
|
33
|
-
assert_equal "Created downtime for #{@host}", flash[:
|
36
|
+
assert_not_nil flash[:success]
|
37
|
+
assert_equal "Created downtime for #{@host}", flash[:success]
|
34
38
|
end
|
35
39
|
|
36
40
|
test 'with missing comment param the flash should inform it' do
|
37
|
-
put :downtime, { :id => @host.name }, set_session_user
|
41
|
+
put :downtime, params: { :id => @host.name }, session: set_session_user
|
38
42
|
assert_response :found
|
39
43
|
assert_redirected_to host_path(:id => @host)
|
40
44
|
assert_not_nil flash[:error]
|
@@ -42,7 +46,9 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
42
46
|
end
|
43
47
|
|
44
48
|
test 'with missing date params the flash should inform it' do
|
45
|
-
put :downtime,
|
49
|
+
put :downtime,
|
50
|
+
params: { :id => @host.name, :downtime => { :comment => 'Maintenance work.' } },
|
51
|
+
session: set_session_user
|
46
52
|
assert_response :found
|
47
53
|
assert_redirected_to host_path(:id => @host)
|
48
54
|
assert_not_nil flash[:error]
|
@@ -50,14 +56,16 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
50
56
|
end
|
51
57
|
|
52
58
|
test 'with invalid starttime the flash should inform it' do
|
53
|
-
put :downtime,
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
put :downtime,
|
60
|
+
params: {
|
61
|
+
:id => @host.name,
|
62
|
+
:downtime => {
|
63
|
+
:comment => 'Maintenance work.',
|
64
|
+
:starttime => 'invalid',
|
65
|
+
:endtime => 'invalid'
|
66
|
+
}
|
67
|
+
},
|
68
|
+
session: set_session_user
|
61
69
|
assert_response :found
|
62
70
|
assert_redirected_to host_path(:id => @host)
|
63
71
|
assert_not_nil flash[:error]
|
@@ -65,28 +73,34 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
65
73
|
end
|
66
74
|
|
67
75
|
test 'should parse the times in the correct time zone' do
|
68
|
-
User.current.
|
76
|
+
User.current.timezone = 'Berlin'
|
77
|
+
User.current.save
|
69
78
|
Host::Managed.any_instance.expects(:downtime_host).with(has_entries(:start_time => 1_492_676_100, :end_time => 1_492_683_300))
|
70
|
-
put :downtime,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
put :downtime,
|
80
|
+
params: {
|
81
|
+
:id => @host.name,
|
82
|
+
:downtime => {
|
83
|
+
:comment => 'Maintenance work.',
|
84
|
+
:starttime => '2017-04-20T10:15',
|
85
|
+
:endtime => '2017-04-20T12:15'
|
86
|
+
}
|
87
|
+
},
|
88
|
+
session: set_session_user
|
78
89
|
end
|
79
90
|
end
|
80
91
|
|
81
92
|
describe 'setting a downtime on multiple hosts' do
|
82
93
|
before do
|
83
|
-
@hosts =
|
94
|
+
@hosts = FactoryBot.create_list(:host, 2, :with_monitoring)
|
84
95
|
@request.env['HTTP_REFERER'] = hosts_path
|
85
96
|
end
|
86
97
|
|
87
98
|
test 'show a host selection' do
|
88
99
|
host_ids = @hosts.map(&:id)
|
89
|
-
|
100
|
+
post :select_multiple_downtime,
|
101
|
+
params: { :host_ids => host_ids },
|
102
|
+
session: set_session_user,
|
103
|
+
xhr: true
|
90
104
|
assert_response :success
|
91
105
|
assert_includes response.body, @hosts.first.name
|
92
106
|
assert_includes response.body, @hosts.last.name
|
@@ -103,20 +117,19 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
103
117
|
}
|
104
118
|
}
|
105
119
|
|
106
|
-
post :update_multiple_downtime, params,
|
107
|
-
set_session_user
|
120
|
+
post :update_multiple_downtime, params: params, session: set_session_user
|
108
121
|
|
109
122
|
assert_response :found
|
110
123
|
assert_redirected_to hosts_path
|
111
124
|
assert_nil flash[:error]
|
112
|
-
assert_not_nil flash[:
|
113
|
-
assert_equal 'A downtime was set for the selected hosts.', flash[:
|
125
|
+
assert_not_nil flash[:success]
|
126
|
+
assert_equal 'A downtime was set for the selected hosts.', flash[:success]
|
114
127
|
end
|
115
128
|
end
|
116
129
|
|
117
130
|
describe 'changing the power state on multiple hosts' do
|
118
131
|
before do
|
119
|
-
@hosts =
|
132
|
+
@hosts = FactoryBot.create_list(:host, 2, :with_monitoring)
|
120
133
|
@request.env['HTTP_REFERER'] = hosts_path
|
121
134
|
|
122
135
|
power_mock = mock('power')
|
@@ -135,14 +148,13 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
135
148
|
}
|
136
149
|
}
|
137
150
|
|
138
|
-
post :update_multiple_power_state, params,
|
139
|
-
set_session_user
|
151
|
+
post :update_multiple_power_state, params: params, session: set_session_user
|
140
152
|
|
141
153
|
assert_response :found
|
142
154
|
assert_redirected_to hosts_path
|
143
155
|
assert_nil flash[:error]
|
144
|
-
assert_not_nil flash[:
|
145
|
-
assert_equal 'The power state of the selected hosts will be set to poweroff', flash[:
|
156
|
+
assert_not_nil flash[:success]
|
157
|
+
assert_equal 'The power state of the selected hosts will be set to poweroff', flash[:success]
|
146
158
|
end
|
147
159
|
|
148
160
|
test 'should not set a downtime if not selected' do
|
@@ -155,27 +167,29 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
155
167
|
}
|
156
168
|
}
|
157
169
|
|
158
|
-
post :update_multiple_power_state, params,
|
159
|
-
set_session_user
|
170
|
+
post :update_multiple_power_state, params: params, session: set_session_user
|
160
171
|
|
161
172
|
assert_response :found
|
162
173
|
assert_redirected_to hosts_path
|
163
174
|
assert_nil flash[:error]
|
164
|
-
assert_not_nil flash[:
|
165
|
-
assert_equal 'The power state of the selected hosts will be set to poweroff', flash[:
|
175
|
+
assert_not_nil flash[:success]
|
176
|
+
assert_equal 'The power state of the selected hosts will be set to poweroff', flash[:success]
|
166
177
|
end
|
167
178
|
end
|
168
179
|
|
169
180
|
describe 'changing the monitoring proxy of multiple hosts' do
|
170
|
-
let(:hosts) {
|
171
|
-
let(:monitoring_proxy) {
|
181
|
+
let(:hosts) { FactoryBot.create_list(:host, 2, :with_monitoring) }
|
182
|
+
let(:monitoring_proxy) { FactoryBot.create(:smart_proxy, :monitoring, :organizations => [hosts.first.organization], :locations => [hosts.first.location]) }
|
172
183
|
before do
|
173
184
|
@request.env['HTTP_REFERER'] = hosts_path
|
174
185
|
end
|
175
186
|
|
176
187
|
test 'show a host selection' do
|
177
188
|
host_ids = hosts.map(&:id)
|
178
|
-
|
189
|
+
post :select_multiple_monitoring_proxy,
|
190
|
+
params: { :host_ids => host_ids },
|
191
|
+
session: set_session_user,
|
192
|
+
xhr: true
|
179
193
|
assert_response :success
|
180
194
|
hosts.each do |host|
|
181
195
|
assert response.body =~ /#{host.name}/m
|
@@ -184,7 +198,7 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
184
198
|
|
185
199
|
test 'should change the proxy' do
|
186
200
|
hosts.each do |host|
|
187
|
-
|
201
|
+
assert_not_equal monitoring_proxy, host.monitoring_proxy
|
188
202
|
end
|
189
203
|
|
190
204
|
params = {
|
@@ -192,13 +206,12 @@ class HostsControllerExtensionsTest < ActionController::TestCase
|
|
192
206
|
:proxy => { :proxy_id => monitoring_proxy.id }
|
193
207
|
}
|
194
208
|
|
195
|
-
post :update_multiple_monitoring_proxy, params,
|
196
|
-
set_session_user
|
209
|
+
post :update_multiple_monitoring_proxy, params: params, session: set_session_user
|
197
210
|
|
198
211
|
assert_response :found
|
199
212
|
assert_redirected_to hosts_path
|
200
213
|
assert_nil flash[:error]
|
201
|
-
assert_equal "The Monitoring proxy of the selected hosts was set to #{monitoring_proxy.name}", flash[:
|
214
|
+
assert_equal "The Monitoring proxy of the selected hosts was set to #{monitoring_proxy.name}", flash[:success]
|
202
215
|
|
203
216
|
hosts.each do |host|
|
204
217
|
as_admin do
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
|
3
|
-
class
|
5
|
+
class ProxyApiMonitoringTest < ActiveSupport::TestCase
|
4
6
|
def setup
|
5
7
|
@url = 'http://localhost:8443'
|
6
|
-
@monitoring = ProxyAPI::Monitoring.new(
|
8
|
+
@monitoring = ProxyAPI::Monitoring.new(:url => @url)
|
7
9
|
end
|
8
10
|
|
9
11
|
test 'constructor should complete' do
|
@@ -15,38 +17,38 @@ class ProxyApiDhcpTest < ActiveSupport::TestCase
|
|
15
17
|
end
|
16
18
|
|
17
19
|
test 'create_host_downtime should do post' do
|
18
|
-
@monitoring.expects(:post).with({}, 'downtime/host/example.com')
|
19
|
-
|
20
|
+
@monitoring.expects(:post).with({}, 'downtime/host/example.com')
|
21
|
+
.returns(fake_rest_client_response('result' => {}))
|
20
22
|
assert_equal({ 'result' => {} }, @monitoring.create_host_downtime('example.com'))
|
21
23
|
end
|
22
24
|
|
23
25
|
test 'remove_host_downtime should do delete' do
|
24
|
-
@monitoring.expects(:delete).with('downtime/host/example.com?comment=bla')
|
25
|
-
|
26
|
+
@monitoring.expects(:delete).with('downtime/host/example.com?comment=bla')
|
27
|
+
.returns(fake_rest_client_response('result' => {}))
|
26
28
|
assert_equal({ 'result' => {} }, @monitoring.remove_host_downtime('example.com', :comment => 'bla'))
|
27
29
|
end
|
28
30
|
|
29
31
|
test 'create_host should do put' do
|
30
|
-
@monitoring.expects(:put).with({ :attributes => { :ip => '1.1.1.1' } }, 'host/example.com')
|
31
|
-
|
32
|
+
@monitoring.expects(:put).with({ :attributes => { :ip => '1.1.1.1' } }, 'host/example.com')
|
33
|
+
.returns(fake_rest_client_response('result' => {}))
|
32
34
|
assert_equal({ 'result' => {} }, @monitoring.create_host('example.com', :ip => '1.1.1.1'))
|
33
35
|
end
|
34
36
|
|
35
37
|
test 'update_host should do post' do
|
36
|
-
@monitoring.expects(:post).with({ :attributes => { :ip => '1.1.1.1' } }, 'host/example.com')
|
37
|
-
|
38
|
+
@monitoring.expects(:post).with({ :attributes => { :ip => '1.1.1.1' } }, 'host/example.com')
|
39
|
+
.returns(fake_rest_client_response('result' => {}))
|
38
40
|
assert_equal({ 'result' => {} }, @monitoring.update_host('example.com', :ip => '1.1.1.1'))
|
39
41
|
end
|
40
42
|
|
41
43
|
test 'delete_host should do delete' do
|
42
|
-
@monitoring.expects(:delete).with('host/example.com')
|
43
|
-
|
44
|
+
@monitoring.expects(:delete).with('host/example.com')
|
45
|
+
.returns(fake_rest_client_response('result' => {}))
|
44
46
|
assert_equal({ 'result' => {} }, @monitoring.delete_host('example.com'))
|
45
47
|
end
|
46
48
|
|
47
49
|
test 'query_host should do get' do
|
48
|
-
@monitoring.expects(:get).with('host/example.com')
|
49
|
-
|
50
|
+
@monitoring.expects(:get).with('host/example.com')
|
51
|
+
.returns(fake_rest_client_response('result' => {}))
|
50
52
|
assert_equal({ 'result' => {} }, @monitoring.query_host('example.com'))
|
51
53
|
end
|
52
54
|
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This calls the main test_helper in Foreman-core
|
2
4
|
require 'test_helper'
|
3
5
|
require 'database_cleaner'
|
4
6
|
|
5
|
-
# Add plugin to
|
6
|
-
|
7
|
-
|
7
|
+
# Add plugin to FactoryBot's paths
|
8
|
+
FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
|
9
|
+
FactoryBot.reload
|
8
10
|
|
9
11
|
# Foreman's setup doesn't handle cleaning up for Minitest::Spec
|
10
12
|
DatabaseCleaner.strategy = :transaction
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
class MonitoringStatusTest < ActiveSupport::TestCase
|
@@ -6,62 +8,62 @@ class MonitoringStatusTest < ActiveSupport::TestCase
|
|
6
8
|
disable_monitoring_orchestration
|
7
9
|
end
|
8
10
|
|
9
|
-
let(:host) {
|
11
|
+
let(:host) { FactoryBot.create(:host, :with_monitoring) }
|
10
12
|
let(:status) { HostStatus::MonitoringStatus.new(:host => host) }
|
11
13
|
|
12
14
|
context 'status changes' do
|
13
15
|
test '#to_status should change when monitoring results change' do
|
14
|
-
|
16
|
+
FactoryBot.create(:monitoring_result, :ok, :host => host)
|
15
17
|
assert_equal HostStatus::MonitoringStatus::OK, status.to_status
|
16
18
|
|
17
|
-
|
19
|
+
FactoryBot.create(:monitoring_result, :warning, :host => host)
|
18
20
|
assert_equal HostStatus::MonitoringStatus::WARNING, status.to_status
|
19
21
|
|
20
|
-
|
22
|
+
FactoryBot.create(:monitoring_result, :unknown, :host => host)
|
21
23
|
assert_equal HostStatus::MonitoringStatus::WARNING, status.to_status
|
22
24
|
|
23
|
-
|
25
|
+
FactoryBot.create(:monitoring_result, :critical, :host => host)
|
24
26
|
assert_equal HostStatus::MonitoringStatus::CRITICAL, status.to_status
|
25
27
|
end
|
26
28
|
|
27
29
|
test '#to_status should be warning with critical acknowledged' do
|
28
|
-
|
30
|
+
FactoryBot.create(:monitoring_result, :critical, :acknowledged, :host => host)
|
29
31
|
assert_equal HostStatus::MonitoringStatus::WARNING, status.to_status
|
30
32
|
end
|
31
33
|
|
32
34
|
test '#to_status should be ok with critical in downtime' do
|
33
|
-
|
35
|
+
FactoryBot.create(:monitoring_result, :critical, :downtime, :host => host)
|
34
36
|
assert_equal HostStatus::MonitoringStatus::OK, status.to_status
|
35
37
|
end
|
36
38
|
|
37
39
|
test '#to_global should change when monitoring results change' do
|
38
|
-
|
40
|
+
FactoryBot.create(:monitoring_result, :ok, :host => host)
|
39
41
|
status.refresh
|
40
42
|
assert_equal HostStatus::Global::OK, status.to_global
|
41
43
|
|
42
|
-
|
44
|
+
FactoryBot.create(:monitoring_result, :warning, :host => host)
|
43
45
|
status.refresh
|
44
46
|
assert_equal HostStatus::Global::WARN, status.to_global
|
45
47
|
|
46
|
-
|
48
|
+
FactoryBot.create(:monitoring_result, :unknown, :host => host)
|
47
49
|
status.refresh
|
48
50
|
assert_equal HostStatus::Global::WARN, status.to_global
|
49
51
|
|
50
|
-
|
52
|
+
FactoryBot.create(:monitoring_result, :critical, :host => host)
|
51
53
|
status.refresh
|
52
54
|
assert_equal HostStatus::Global::ERROR, status.to_global
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
58
|
context 'status with host with monitoring results' do
|
57
|
-
let(:host) {
|
59
|
+
let(:host) { FactoryBot.create(:host, :with_monitoring, :with_monitoring_results) }
|
58
60
|
|
59
61
|
test '#relevant? is only for hosts not in build mode' do
|
60
62
|
host.build = false
|
61
63
|
assert status.relevant?
|
62
64
|
|
63
65
|
host.build = true
|
64
|
-
|
66
|
+
assert_not status.relevant?
|
65
67
|
end
|
66
68
|
|
67
69
|
test '#host_known_in_monitoring? should be true' do
|
@@ -76,10 +78,10 @@ class MonitoringStatusTest < ActiveSupport::TestCase
|
|
76
78
|
context 'status with host without monitoring results' do
|
77
79
|
test '#relevant? is always false when build changes' do
|
78
80
|
host.build = false
|
79
|
-
|
81
|
+
assert_not status.relevant?
|
80
82
|
|
81
83
|
host.build = true
|
82
|
-
|
84
|
+
assert_not status.relevant?
|
83
85
|
end
|
84
86
|
|
85
87
|
test '#refresh! refreshes the date and persists the record' do
|
@@ -90,7 +92,7 @@ class MonitoringStatusTest < ActiveSupport::TestCase
|
|
90
92
|
end
|
91
93
|
|
92
94
|
test '#host_known_in_monitoring? should be false' do
|
93
|
-
|
95
|
+
assert_not status.host_known_in_monitoring?
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|