flapjack 0.8.12 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/flapjack/gateways/jsonapi/report_methods.rb +36 -40
- data/lib/flapjack/gateways/web/public/js/d3.v3.js +9263 -0
- data/lib/flapjack/gateways/web/public/js/nv.d3.js +14368 -0
- data/lib/flapjack/gateways/web/views/layout.erb +3 -3
- data/lib/flapjack/gateways/web/views/self_stats.html.erb +2 -2
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/gateways/jsonapi/report_methods_spec.rb +247 -201
- metadata +4 -4
- data/lib/flapjack/gateways/web/public/js/d3.v3.min.js +0 -5
- data/lib/flapjack/gateways/web/public/js/nv.d3.min.js +0 -6
@@ -1,4 +1,7 @@
|
|
1
1
|
<%
|
2
|
+
require_css 'bootstrap'
|
3
|
+
require_css 'screen'
|
4
|
+
require_css 'font-awesome'
|
2
5
|
require_css 'tablesort'
|
3
6
|
|
4
7
|
require_js 'jquery-1.10.2'
|
@@ -13,9 +16,6 @@
|
|
13
16
|
<head>
|
14
17
|
<title><%= h include_page_title %></title>
|
15
18
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
16
|
-
<link rel="stylesheet" href="/css/bootstrap.css" media="screen">
|
17
|
-
<link rel="stylesheet" href="/css/screen.css" media="screen">
|
18
|
-
<link rel="stylesheet" href="/css/font-awesome.css">
|
19
19
|
<link rel="shortcut icon" href="/img/flapjack-favicon-64-32-24-16.ico"> <!-- thank you http://xiconeditor.com/ -->
|
20
20
|
<%= include_required_css %>
|
21
21
|
<%= include_required_js %>
|
@@ -2,8 +2,8 @@
|
|
2
2
|
page_title 'Internal Statistics'
|
3
3
|
require_css 'nv.d3'
|
4
4
|
require_js 'jquery-1.10.2'
|
5
|
-
require_js 'd3.v3
|
6
|
-
require_js 'nv.d3
|
5
|
+
require_js 'd3.v3'
|
6
|
+
require_js 'nv.d3'
|
7
7
|
require_js 'self_stats'
|
8
8
|
%>
|
9
9
|
<div id="data-api-url" data-api-url="<%= @api_url %>">
|
data/lib/flapjack/version.rb
CHANGED
@@ -16,42 +16,46 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
16
16
|
let(:check_presenter) { double(Flapjack::Gateways::JSONAPI::CheckPresenter) }
|
17
17
|
|
18
18
|
it "returns the status for all entities" do
|
19
|
-
status =
|
20
|
-
expect(status).to receive(:as_json).and_return({:status => 'data'})
|
19
|
+
status = {'status' => 'data'}
|
21
20
|
expect(check_presenter).to receive(:status).and_return(status)
|
22
21
|
|
23
22
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
24
23
|
with(entity_check).and_return(check_presenter)
|
25
24
|
|
26
|
-
expect(Flapjack::Data::EntityCheck).to receive(:
|
27
|
-
with(
|
25
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
26
|
+
with(entity, 'SSH', :redis => redis).and_return(entity_check)
|
28
27
|
|
29
28
|
expect(entity).to receive(:check_list).and_return(['SSH'])
|
30
29
|
|
31
30
|
expect(Flapjack::Data::Entity).to receive(:all).
|
32
31
|
with(:redis => redis).and_return([entity])
|
33
32
|
|
34
|
-
expect(entity).to receive(:name).
|
35
|
-
expect(entity).to receive(:id).and_return(entity_id)
|
33
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
34
|
+
expect(entity).to receive(:id).twice.and_return(entity_id)
|
36
35
|
|
37
|
-
expect(entity_check).to receive(:check).
|
36
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
38
37
|
|
39
38
|
result = {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
:status_reports => [{
|
40
|
+
:status => 'data',
|
41
|
+
:links => {
|
42
|
+
:entity => [entity_id],
|
43
|
+
:check => ["#{entity_name}:SSH"]
|
44
|
+
}}],
|
45
|
+
:linked => {
|
46
|
+
:entities => [{
|
47
|
+
:id => entity_id,
|
48
|
+
:name => entity_name,
|
49
|
+
:links => {
|
50
|
+
:checks => ["#{entity_name}:SSH"],
|
45
51
|
}
|
46
52
|
}],
|
47
|
-
:
|
48
|
-
:
|
49
|
-
|
50
|
-
|
51
|
-
:statuses => {'status' => 'data'}
|
52
|
-
}]
|
53
|
-
}
|
53
|
+
:checks => [{
|
54
|
+
:id => "#{entity_name}:SSH",
|
55
|
+
:name => 'SSH',
|
56
|
+
}]
|
54
57
|
}
|
58
|
+
}
|
55
59
|
|
56
60
|
aget "/status_report/entities"
|
57
61
|
expect(last_response).to be_ok
|
@@ -59,40 +63,44 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
59
63
|
end
|
60
64
|
|
61
65
|
it "returns the status for all checks on an entity" do
|
62
|
-
status =
|
63
|
-
expect(status).to receive(:as_json).and_return({:status => 'data'})
|
66
|
+
status = {'status' => 'data'}
|
64
67
|
expect(check_presenter).to receive(:status).and_return(status)
|
65
68
|
|
66
69
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
67
70
|
with(entity_check).and_return(check_presenter)
|
68
71
|
|
69
|
-
expect(Flapjack::Data::EntityCheck).to receive(:
|
70
|
-
with(
|
72
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
73
|
+
with(entity, 'SSH', :redis => redis).and_return(entity_check)
|
71
74
|
|
72
75
|
expect(entity).to receive(:check_list).and_return(['SSH'])
|
73
76
|
|
74
77
|
expect(Flapjack::Data::Entity).to receive(:find_by_id).
|
75
78
|
with(entity_id, :redis => redis).and_return(entity)
|
76
79
|
|
77
|
-
expect(entity).to receive(:name).
|
78
|
-
expect(entity).to receive(:id).and_return(entity_id)
|
80
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
81
|
+
expect(entity).to receive(:id).twice.and_return(entity_id)
|
79
82
|
|
80
|
-
expect(entity_check).to receive(:check).
|
83
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
81
84
|
|
82
85
|
result = {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
:status_reports => [{
|
87
|
+
:status => 'data',
|
88
|
+
:links => {
|
89
|
+
:entity => [entity_id],
|
90
|
+
:check => ["#{entity_name}:SSH"]
|
91
|
+
}}],
|
92
|
+
:linked => {
|
93
|
+
:entities => [{
|
94
|
+
:id => entity_id,
|
95
|
+
:name => entity_name,
|
96
|
+
:links => {
|
97
|
+
:checks => ["#{entity_name}:SSH"],
|
88
98
|
}
|
89
99
|
}],
|
90
|
-
:
|
91
|
-
:
|
92
|
-
|
93
|
-
|
94
|
-
:statuses => {'status' => 'data'}
|
95
|
-
}]
|
100
|
+
:checks => [{
|
101
|
+
:id => "#{entity_name}:SSH",
|
102
|
+
:name => 'SSH',
|
103
|
+
}]
|
96
104
|
}
|
97
105
|
}
|
98
106
|
|
@@ -110,8 +118,7 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
110
118
|
end
|
111
119
|
|
112
120
|
it "returns the status for an entity check" do
|
113
|
-
status =
|
114
|
-
expect(status).to receive(:as_json).and_return({:status => 'data'})
|
121
|
+
status = {'status' => 'data'}
|
115
122
|
expect(check_presenter).to receive(:status).and_return(status)
|
116
123
|
|
117
124
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
@@ -120,26 +127,31 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
120
127
|
expect(Flapjack::Data::EntityCheck).to receive(:for_entity_name).
|
121
128
|
with(entity_name, 'SSH', :redis => redis).and_return(entity_check)
|
122
129
|
|
130
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
123
131
|
expect(entity).to receive(:id).and_return(entity_id)
|
124
132
|
|
125
|
-
expect(entity).to receive(:name).and_return(entity_name)
|
126
133
|
expect(entity_check).to receive(:entity).and_return(entity)
|
127
|
-
expect(entity_check).to receive(:check).
|
134
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
128
135
|
|
129
136
|
result = {
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
137
|
+
:status_reports => [{
|
138
|
+
:status => 'data',
|
139
|
+
:links => {
|
140
|
+
:entity => [entity_id],
|
141
|
+
:check => ["#{entity_name}:SSH"]
|
142
|
+
}}],
|
143
|
+
:linked => {
|
144
|
+
:entities => [{
|
145
|
+
:id => entity_id,
|
146
|
+
:name => entity_name,
|
147
|
+
:links => {
|
148
|
+
:checks => ["#{entity_name}:SSH"],
|
135
149
|
}
|
136
150
|
}],
|
137
|
-
:
|
138
|
-
:
|
139
|
-
|
140
|
-
|
141
|
-
:statuses => {'status' => 'data'}
|
142
|
-
}]
|
151
|
+
:checks => [{
|
152
|
+
:id => "#{entity_name}:SSH",
|
153
|
+
:name => 'SSH',
|
154
|
+
}]
|
143
155
|
}
|
144
156
|
}
|
145
157
|
|
@@ -165,40 +177,44 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
165
177
|
end
|
166
178
|
|
167
179
|
it "returns a list of scheduled maintenance periods for an entity" do
|
168
|
-
sched_maint =
|
169
|
-
expect(sched_maint).to receive(:as_json).and_return({:scheduled_maintenances => 'data'})
|
180
|
+
sched_maint = {:scheduled_maintenances => 'data'}
|
170
181
|
expect(check_presenter).to receive(:scheduled_maintenance).and_return(sched_maint)
|
171
182
|
|
172
183
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
173
184
|
with(entity_check).and_return(check_presenter)
|
174
185
|
|
175
|
-
expect(Flapjack::Data::EntityCheck).to receive(:
|
176
|
-
with(
|
186
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
187
|
+
with(entity, 'SSH', :redis => redis).and_return(entity_check)
|
177
188
|
|
178
189
|
expect(entity).to receive(:check_list).and_return(['SSH'])
|
179
190
|
|
180
191
|
expect(Flapjack::Data::Entity).to receive(:find_by_id).
|
181
192
|
with(entity_id, :redis => redis).and_return(entity)
|
182
193
|
|
183
|
-
expect(entity).to receive(:name).
|
184
|
-
expect(entity).to receive(:id).and_return(entity_id)
|
194
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
195
|
+
expect(entity).to receive(:id).twice.and_return(entity_id)
|
185
196
|
|
186
|
-
expect(entity_check).to receive(:check).
|
197
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
187
198
|
|
188
199
|
result = {
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
200
|
+
:scheduled_maintenance_reports => [{
|
201
|
+
:scheduled_maintenances => 'data',
|
202
|
+
:links => {
|
203
|
+
:entity => [entity_id],
|
204
|
+
:check => ["#{entity_name}:SSH"]
|
205
|
+
}}],
|
206
|
+
:linked => {
|
207
|
+
:entities => [{
|
208
|
+
:id => entity_id,
|
209
|
+
:name => entity_name,
|
210
|
+
:links => {
|
211
|
+
:checks => ["#{entity_name}:SSH"],
|
194
212
|
}
|
195
213
|
}],
|
196
|
-
:
|
197
|
-
:
|
198
|
-
|
199
|
-
|
200
|
-
:scheduled_maintenances => {'scheduled_maintenances' => 'data'}
|
201
|
-
}]
|
214
|
+
:checks => [{
|
215
|
+
:id => "#{entity_name}:SSH",
|
216
|
+
:name => 'SSH',
|
217
|
+
}]
|
202
218
|
}
|
203
219
|
}
|
204
220
|
|
@@ -211,41 +227,45 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
211
227
|
start = Time.parse('1 Jan 2012')
|
212
228
|
finish = Time.parse('6 Jan 2012')
|
213
229
|
|
214
|
-
sched_maint =
|
215
|
-
expect(sched_maint).to receive(:as_json).and_return({:scheduled_maintenances => 'data'})
|
230
|
+
sched_maint = {:scheduled_maintenances => 'data'}
|
216
231
|
expect(check_presenter).to receive(:scheduled_maintenance).
|
217
232
|
with(start.to_i, finish.to_i).and_return(sched_maint)
|
218
233
|
|
219
234
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
220
235
|
with(entity_check).and_return(check_presenter)
|
221
236
|
|
222
|
-
expect(Flapjack::Data::EntityCheck).to receive(:
|
223
|
-
with(
|
237
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
238
|
+
with(entity, 'SSH', :redis => redis).and_return(entity_check)
|
224
239
|
|
225
240
|
expect(entity).to receive(:check_list).and_return(['SSH'])
|
226
241
|
|
227
242
|
expect(Flapjack::Data::Entity).to receive(:find_by_id).
|
228
243
|
with(entity_id, :redis => redis).and_return(entity)
|
229
244
|
|
230
|
-
expect(entity).to receive(:name).
|
231
|
-
expect(entity).to receive(:id).and_return(entity_id)
|
245
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
246
|
+
expect(entity).to receive(:id).twice.and_return(entity_id)
|
232
247
|
|
233
|
-
expect(entity_check).to receive(:check).
|
248
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
234
249
|
|
235
250
|
result = {
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
251
|
+
:scheduled_maintenance_reports => [{
|
252
|
+
:scheduled_maintenances => 'data',
|
253
|
+
:links => {
|
254
|
+
:entity => [entity_id],
|
255
|
+
:check => ["#{entity_name}:SSH"]
|
256
|
+
}}],
|
257
|
+
:linked => {
|
258
|
+
:entities => [{
|
259
|
+
:id => entity_id,
|
260
|
+
:name => entity_name,
|
261
|
+
:links => {
|
262
|
+
:checks => ["#{entity_name}:SSH"],
|
241
263
|
}
|
242
264
|
}],
|
243
|
-
:
|
244
|
-
:
|
245
|
-
|
246
|
-
|
247
|
-
:scheduled_maintenances => {'scheduled_maintenances' => 'data'}
|
248
|
-
}]
|
265
|
+
:checks => [{
|
266
|
+
:id => "#{entity_name}:SSH",
|
267
|
+
:name => 'SSH',
|
268
|
+
}]
|
249
269
|
}
|
250
270
|
}
|
251
271
|
|
@@ -256,8 +276,7 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
256
276
|
end
|
257
277
|
|
258
278
|
it "returns a list of scheduled maintenance periods for a check on an entity" do
|
259
|
-
sched_maint =
|
260
|
-
expect(sched_maint).to receive(:as_json).and_return({:scheduled_maintenances => 'data'})
|
279
|
+
sched_maint = {:scheduled_maintenances => 'data'}
|
261
280
|
expect(check_presenter).to receive(:scheduled_maintenance).and_return(sched_maint)
|
262
281
|
|
263
282
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
@@ -266,26 +285,31 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
266
285
|
expect(Flapjack::Data::EntityCheck).to receive(:for_entity_name).
|
267
286
|
with(entity_name, 'SSH', :redis => redis).and_return(entity_check)
|
268
287
|
|
288
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
269
289
|
expect(entity).to receive(:id).and_return(entity_id)
|
270
290
|
|
271
|
-
expect(entity).to receive(:name).and_return(entity_name)
|
272
291
|
expect(entity_check).to receive(:entity).and_return(entity)
|
273
|
-
expect(entity_check).to receive(:check).
|
292
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
274
293
|
|
275
294
|
result = {
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
295
|
+
:scheduled_maintenance_reports => [{
|
296
|
+
:scheduled_maintenances => 'data',
|
297
|
+
:links => {
|
298
|
+
:entity => [entity_id],
|
299
|
+
:check => ["#{entity_name}:SSH"]
|
300
|
+
}}],
|
301
|
+
:linked => {
|
302
|
+
:entities => [{
|
303
|
+
:id => entity_id,
|
304
|
+
:name => entity_name,
|
305
|
+
:links => {
|
306
|
+
:checks => ["#{entity_name}:SSH"],
|
281
307
|
}
|
282
308
|
}],
|
283
|
-
:
|
284
|
-
:
|
285
|
-
|
286
|
-
|
287
|
-
:scheduled_maintenances => {'scheduled_maintenances' => 'data'}
|
288
|
-
}]
|
309
|
+
:checks => [{
|
310
|
+
:id => "#{entity_name}:SSH",
|
311
|
+
:name => 'SSH',
|
312
|
+
}]
|
289
313
|
}
|
290
314
|
}
|
291
315
|
|
@@ -295,40 +319,44 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
295
319
|
end
|
296
320
|
|
297
321
|
it "returns a list of unscheduled maintenance periods for an entity" do
|
298
|
-
unsched_maint =
|
299
|
-
expect(unsched_maint).to receive(:as_json).and_return({:unscheduled_maintenances => 'data'})
|
322
|
+
unsched_maint = {:unscheduled_maintenances => 'data'}
|
300
323
|
expect(check_presenter).to receive(:unscheduled_maintenance).and_return(unsched_maint)
|
301
324
|
|
302
325
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
303
326
|
with(entity_check).and_return(check_presenter)
|
304
327
|
|
305
|
-
expect(Flapjack::Data::EntityCheck).to receive(:
|
306
|
-
with(
|
328
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
329
|
+
with(entity, 'SSH', :redis => redis).and_return(entity_check)
|
307
330
|
|
308
331
|
expect(entity).to receive(:check_list).and_return(['SSH'])
|
309
332
|
|
310
333
|
expect(Flapjack::Data::Entity).to receive(:find_by_id).
|
311
334
|
with(entity_id, :redis => redis).and_return(entity)
|
312
335
|
|
313
|
-
expect(entity).to receive(:name).
|
314
|
-
expect(entity).to receive(:id).and_return(entity_id)
|
336
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
337
|
+
expect(entity).to receive(:id).twice.and_return(entity_id)
|
315
338
|
|
316
|
-
expect(entity_check).to receive(:check).
|
339
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
317
340
|
|
318
341
|
result = {
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
342
|
+
:unscheduled_maintenance_reports => [{
|
343
|
+
:unscheduled_maintenances => 'data',
|
344
|
+
:links => {
|
345
|
+
:entity => [entity_id],
|
346
|
+
:check => ["#{entity_name}:SSH"]
|
347
|
+
}}],
|
348
|
+
:linked => {
|
349
|
+
:entities => [{
|
350
|
+
:id => entity_id,
|
351
|
+
:name => entity_name,
|
352
|
+
:links => {
|
353
|
+
:checks => ["#{entity_name}:SSH"],
|
324
354
|
}
|
325
355
|
}],
|
326
|
-
:
|
327
|
-
:
|
328
|
-
|
329
|
-
|
330
|
-
:unscheduled_maintenances => {'unscheduled_maintenances' => 'data'}
|
331
|
-
}]
|
356
|
+
:checks => [{
|
357
|
+
:id => "#{entity_name}:SSH",
|
358
|
+
:name => 'SSH',
|
359
|
+
}]
|
332
360
|
}
|
333
361
|
}
|
334
362
|
|
@@ -338,8 +366,7 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
338
366
|
end
|
339
367
|
|
340
368
|
it "returns a list of unscheduled maintenance periods for a check on an entity" do
|
341
|
-
unsched_maint =
|
342
|
-
expect(unsched_maint).to receive(:as_json).and_return({:unscheduled_maintenances => 'data'})
|
369
|
+
unsched_maint = {:unscheduled_maintenances => 'data'}
|
343
370
|
expect(check_presenter).to receive(:unscheduled_maintenance).and_return(unsched_maint)
|
344
371
|
|
345
372
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
@@ -348,27 +375,31 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
348
375
|
expect(Flapjack::Data::EntityCheck).to receive(:for_entity_name).
|
349
376
|
with(entity_name, 'SSH', :redis => redis).and_return(entity_check)
|
350
377
|
|
351
|
-
|
378
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
352
379
|
expect(entity).to receive(:id).and_return(entity_id)
|
353
380
|
|
354
|
-
expect(entity).to receive(:name).and_return(entity_name)
|
355
381
|
expect(entity_check).to receive(:entity).and_return(entity)
|
356
|
-
expect(entity_check).to receive(:check).
|
382
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
357
383
|
|
358
384
|
result = {
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
385
|
+
:unscheduled_maintenance_reports => [{
|
386
|
+
:unscheduled_maintenances => 'data',
|
387
|
+
:links => {
|
388
|
+
:entity => [entity_id],
|
389
|
+
:check => ["#{entity_name}:SSH"]
|
390
|
+
}}],
|
391
|
+
:linked => {
|
392
|
+
:entities => [{
|
393
|
+
:id => entity_id,
|
394
|
+
:name => entity_name,
|
395
|
+
:links => {
|
396
|
+
:checks => ["#{entity_name}:SSH"],
|
364
397
|
}
|
365
398
|
}],
|
366
|
-
:
|
367
|
-
:
|
368
|
-
|
369
|
-
|
370
|
-
:unscheduled_maintenances => {'unscheduled_maintenances' => 'data'}
|
371
|
-
}]
|
399
|
+
:checks => [{
|
400
|
+
:id => "#{entity_name}:SSH",
|
401
|
+
:name => 'SSH',
|
402
|
+
}]
|
372
403
|
}
|
373
404
|
}
|
374
405
|
|
@@ -381,8 +412,7 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
381
412
|
start = Time.parse('1 Jan 2012')
|
382
413
|
finish = Time.parse('6 Jan 2012')
|
383
414
|
|
384
|
-
unsched_maint =
|
385
|
-
expect(unsched_maint).to receive(:as_json).and_return({:unscheduled_maintenances => 'data'})
|
415
|
+
unsched_maint = {:unscheduled_maintenances => 'data'}
|
386
416
|
expect(check_presenter).to receive(:unscheduled_maintenance).
|
387
417
|
with(start.to_i, finish.to_i).and_return(unsched_maint)
|
388
418
|
|
@@ -392,26 +422,31 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
392
422
|
expect(Flapjack::Data::EntityCheck).to receive(:for_entity_name).
|
393
423
|
with(entity_name, 'SSH', :redis => redis).and_return(entity_check)
|
394
424
|
|
425
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
395
426
|
expect(entity).to receive(:id).and_return(entity_id)
|
396
427
|
|
397
|
-
expect(entity).to receive(:name).and_return(entity_name)
|
398
428
|
expect(entity_check).to receive(:entity).and_return(entity)
|
399
|
-
expect(entity_check).to receive(:check).
|
429
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
400
430
|
|
401
431
|
result = {
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
432
|
+
:unscheduled_maintenance_reports => [{
|
433
|
+
:unscheduled_maintenances => 'data',
|
434
|
+
:links => {
|
435
|
+
:entity => [entity_id],
|
436
|
+
:check => ["#{entity_name}:SSH"]
|
437
|
+
}}],
|
438
|
+
:linked => {
|
439
|
+
:entities => [{
|
440
|
+
:id => entity_id,
|
441
|
+
:name => entity_name,
|
442
|
+
:links => {
|
443
|
+
:checks => ["#{entity_name}:SSH"],
|
407
444
|
}
|
408
445
|
}],
|
409
|
-
:
|
410
|
-
:
|
411
|
-
|
412
|
-
|
413
|
-
:unscheduled_maintenances => {'unscheduled_maintenances' => 'data'}
|
414
|
-
}]
|
446
|
+
:checks => [{
|
447
|
+
:id => "#{entity_name}:SSH",
|
448
|
+
:name => 'SSH',
|
449
|
+
}]
|
415
450
|
}
|
416
451
|
}
|
417
452
|
|
@@ -422,8 +457,7 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
422
457
|
end
|
423
458
|
|
424
459
|
it "returns a list of outages for a check on an entity" do
|
425
|
-
outages =
|
426
|
-
expect(outages).to receive(:as_json).and_return({:outages => 'data'})
|
460
|
+
outages = {:outages => 'data'}
|
427
461
|
expect(check_presenter).to receive(:outage).and_return(outages)
|
428
462
|
|
429
463
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
@@ -432,26 +466,31 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
432
466
|
expect(Flapjack::Data::EntityCheck).to receive(:for_entity_name).
|
433
467
|
with(entity_name, 'SSH', :redis => redis).and_return(entity_check)
|
434
468
|
|
469
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
435
470
|
expect(entity).to receive(:id).and_return(entity_id)
|
436
471
|
|
437
|
-
expect(entity).to receive(:name).and_return(entity_name)
|
438
472
|
expect(entity_check).to receive(:entity).and_return(entity)
|
439
|
-
expect(entity_check).to receive(:check).
|
473
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
440
474
|
|
441
475
|
result = {
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
476
|
+
:outage_reports => [{
|
477
|
+
:outages => 'data',
|
478
|
+
:links => {
|
479
|
+
:entity => [entity_id],
|
480
|
+
:check => ["#{entity_name}:SSH"]
|
481
|
+
}}],
|
482
|
+
:linked => {
|
483
|
+
:entities => [{
|
484
|
+
:id => entity_id,
|
485
|
+
:name => entity_name,
|
486
|
+
:links => {
|
487
|
+
:checks => ["#{entity_name}:SSH"],
|
447
488
|
}
|
448
489
|
}],
|
449
|
-
:
|
450
|
-
:
|
451
|
-
|
452
|
-
|
453
|
-
:outages => {'outages' => 'data'}
|
454
|
-
}]
|
490
|
+
:checks => [{
|
491
|
+
:id => "#{entity_name}:SSH",
|
492
|
+
:name => 'SSH',
|
493
|
+
}]
|
455
494
|
}
|
456
495
|
}
|
457
496
|
|
@@ -461,41 +500,44 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
461
500
|
end
|
462
501
|
|
463
502
|
it "returns a list of downtimes for an entity" do
|
464
|
-
downtime =
|
465
|
-
expect(downtime).to receive(:as_json).and_return({:downtime => 'data'})
|
503
|
+
downtime = {:downtime => 'data'}
|
466
504
|
expect(check_presenter).to receive(:downtime).and_return(downtime)
|
467
505
|
|
468
506
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
469
507
|
with(entity_check).and_return(check_presenter)
|
470
508
|
|
471
|
-
expect(Flapjack::Data::EntityCheck).to receive(:
|
472
|
-
with(
|
509
|
+
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
510
|
+
with(entity, 'SSH', :redis => redis).and_return(entity_check)
|
473
511
|
|
474
512
|
expect(entity).to receive(:check_list).and_return(['SSH'])
|
475
513
|
|
476
514
|
expect(Flapjack::Data::Entity).to receive(:find_by_id).
|
477
515
|
with(entity_id, :redis => redis).and_return(entity)
|
478
516
|
|
479
|
-
expect(entity).to receive(:name).
|
480
|
-
|
481
|
-
expect(entity).to receive(:id).and_return(entity_id)
|
517
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
518
|
+
expect(entity).to receive(:id).twice.and_return(entity_id)
|
482
519
|
|
483
|
-
expect(entity_check).to receive(:check).
|
520
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
484
521
|
|
485
522
|
result = {
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
523
|
+
:downtime_reports => [{
|
524
|
+
:downtime => 'data',
|
525
|
+
:links => {
|
526
|
+
:entity => [entity_id],
|
527
|
+
:check => ["#{entity_name}:SSH"]
|
528
|
+
}}],
|
529
|
+
:linked => {
|
530
|
+
:entities => [{
|
531
|
+
:id => entity_id,
|
532
|
+
:name => entity_name,
|
533
|
+
:links => {
|
534
|
+
:checks => ["#{entity_name}:SSH"],
|
491
535
|
}
|
492
536
|
}],
|
493
|
-
:
|
494
|
-
:
|
495
|
-
|
496
|
-
|
497
|
-
:downtimes => {'downtime' => 'data'}
|
498
|
-
}]
|
537
|
+
:checks => [{
|
538
|
+
:id => "#{entity_name}:SSH",
|
539
|
+
:name => 'SSH',
|
540
|
+
}]
|
499
541
|
}
|
500
542
|
}
|
501
543
|
|
@@ -505,8 +547,7 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
505
547
|
end
|
506
548
|
|
507
549
|
it "returns a list of downtimes for a check on an entity" do
|
508
|
-
downtime =
|
509
|
-
expect(downtime).to receive(:as_json).and_return({:downtime => 'data'})
|
550
|
+
downtime = {:downtime => 'data'}
|
510
551
|
expect(check_presenter).to receive(:downtime).and_return(downtime)
|
511
552
|
|
512
553
|
expect(Flapjack::Gateways::JSONAPI::CheckPresenter).to receive(:new).
|
@@ -515,26 +556,31 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
|
|
515
556
|
expect(Flapjack::Data::EntityCheck).to receive(:for_entity_name).
|
516
557
|
with(entity_name, 'SSH', :redis => redis).and_return(entity_check)
|
517
558
|
|
559
|
+
expect(entity).to receive(:name).twice.and_return(entity_name)
|
518
560
|
expect(entity).to receive(:id).and_return(entity_id)
|
519
561
|
|
520
|
-
expect(entity).to receive(:name).and_return(entity_name)
|
521
562
|
expect(entity_check).to receive(:entity).and_return(entity)
|
522
|
-
expect(entity_check).to receive(:check).
|
563
|
+
expect(entity_check).to receive(:check).exactly(3).times.and_return('SSH')
|
523
564
|
|
524
565
|
result = {
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
566
|
+
:downtime_reports => [{
|
567
|
+
:downtime => 'data',
|
568
|
+
:links => {
|
569
|
+
:entity => [entity_id],
|
570
|
+
:check => ["#{entity_name}:SSH"]
|
571
|
+
}}],
|
572
|
+
:linked => {
|
573
|
+
:entities => [{
|
574
|
+
:id => entity_id,
|
575
|
+
:name => entity_name,
|
576
|
+
:links => {
|
577
|
+
:checks => ["#{entity_name}:SSH"],
|
530
578
|
}
|
531
579
|
}],
|
532
|
-
:
|
533
|
-
:
|
534
|
-
|
535
|
-
|
536
|
-
:downtimes => {'downtime' => 'data'}
|
537
|
-
}]
|
580
|
+
:checks => [{
|
581
|
+
:id => "#{entity_name}:SSH",
|
582
|
+
:name => 'SSH',
|
583
|
+
}]
|
538
584
|
}
|
539
585
|
}
|
540
586
|
|