flapjack 0.8.10 → 0.8.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/bin/flapjack +10 -1
- data/bin/flapjack-nagios-receiver +1 -2
- data/bin/simulate-failed-check +12 -4
- data/etc/flapjack_config.yaml.example +2 -1
- data/flapjack.gemspec +1 -0
- data/lib/flapjack/data/contact.rb +46 -26
- data/lib/flapjack/data/entity.rb +28 -0
- data/lib/flapjack/data/entity_check.rb +52 -11
- data/lib/flapjack/data/event.rb +9 -3
- data/lib/flapjack/data/notification_rule.rb +8 -0
- data/lib/flapjack/gateways/api.rb +0 -1
- data/lib/flapjack/gateways/api/entity_check_presenter.rb +2 -1
- data/lib/flapjack/gateways/email.rb +1 -2
- data/lib/flapjack/gateways/jabber.rb +3 -3
- data/lib/flapjack/gateways/jsonapi.rb +186 -38
- data/lib/flapjack/gateways/jsonapi/check_methods.rb +120 -0
- data/lib/flapjack/gateways/jsonapi/{entity_check_presenter.rb → check_presenter.rb} +7 -6
- data/lib/flapjack/gateways/jsonapi/contact_methods.rb +61 -352
- data/lib/flapjack/gateways/jsonapi/entity_methods.rb +117 -248
- data/lib/flapjack/gateways/jsonapi/medium_methods.rb +179 -0
- data/lib/flapjack/gateways/jsonapi/notification_rule_methods.rb +124 -0
- data/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods.rb +128 -0
- data/lib/flapjack/gateways/jsonapi/rack/json_params_parser.rb +4 -5
- data/lib/flapjack/gateways/jsonapi/report_methods.rb +143 -0
- data/lib/flapjack/gateways/web.rb +1 -0
- data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +165 -101
- data/lib/flapjack/gateways/web/public/js/contacts.js +34 -46
- data/lib/flapjack/gateways/web/public/js/select2.js +232 -90
- data/lib/flapjack/gateways/web/public/js/select2.min.js +4 -4
- data/lib/flapjack/gateways/web/views/check.html.erb +11 -2
- data/lib/flapjack/processor.rb +6 -6
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/data/entity_check_spec.rb +1 -1
- data/spec/lib/flapjack/data/event_spec.rb +10 -9
- data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +25 -25
- data/spec/lib/flapjack/gateways/api_spec.rb +23 -1
- data/spec/lib/flapjack/gateways/email_spec.rb +40 -2
- data/spec/lib/flapjack/gateways/jabber_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb +134 -0
- data/spec/lib/flapjack/gateways/jsonapi/{entity_check_presenter_spec.rb → check_presenter_spec.rb} +17 -17
- data/spec/lib/flapjack/gateways/jsonapi/contact_methods_spec.rb +27 -232
- data/spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb +217 -687
- data/spec/lib/flapjack/gateways/jsonapi/medium_methods_spec.rb +232 -0
- data/spec/lib/flapjack/gateways/jsonapi/notification_rule_methods_spec.rb +131 -0
- data/spec/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods_spec.rb +113 -0
- data/spec/lib/flapjack/gateways/jsonapi/report_methods_spec.rb +546 -0
- data/spec/lib/flapjack/gateways/jsonapi_spec.rb +10 -1
- data/spec/lib/flapjack/gateways/web_spec.rb +1 -0
- data/spec/support/jsonapi_helper.rb +62 -0
- metadata +36 -8
- data/lib/flapjack/gateways/jsonapi/entity_presenter.rb +0 -75
- data/spec/lib/flapjack/gateways/jsonapi/entity_presenter_spec.rb +0 -108
@@ -3,6 +3,15 @@ require 'flapjack/gateways/jsonapi'
|
|
3
3
|
|
4
4
|
describe 'Flapjack::Gateways::JSONAPI', :sinatra => true, :logger => true do
|
5
5
|
|
6
|
-
|
6
|
+
include_context "jsonapi"
|
7
|
+
|
8
|
+
it "handles a route matching failure" do
|
9
|
+
aget "/this/route/doesn't/exist"
|
10
|
+
expect(last_response.status).to eq(404)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "rejects a POST request with invalid content type"
|
14
|
+
|
15
|
+
it "rejects a PATCH request with invalid content type"
|
7
16
|
|
8
17
|
end
|
@@ -134,6 +134,7 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
|
|
134
134
|
expect(entity_check).to receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
|
135
135
|
expect(entity_check).to receive(:summary).and_return('all good')
|
136
136
|
expect(entity_check).to receive(:details).and_return('seriously, all very wonderful')
|
137
|
+
expect(entity_check).to receive(:perfdata).and_return([{"key" => "foo", "value" => "bar"}])
|
137
138
|
expect(entity_check).to receive(:last_notifications_of_each_type).and_return(last_notifications)
|
138
139
|
expect(entity_check).to receive(:maintenances).with(nil, nil, :scheduled => true).and_return([])
|
139
140
|
expect(entity_check).to receive(:failed?).and_return(false)
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module JsonapiHelper
|
2
|
+
|
3
|
+
shared_context "jsonapi" do
|
4
|
+
|
5
|
+
def app
|
6
|
+
Flapjack::Gateways::JSONAPI
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:contact) { double(Flapjack::Data::Contact, :id => '21') }
|
10
|
+
let(:contact_core) {
|
11
|
+
{'id' => contact.id,
|
12
|
+
'first_name' => "Ada",
|
13
|
+
'last_name' => "Lovelace",
|
14
|
+
'email' => "ada@example.com",
|
15
|
+
'tags' => ["legend", "first computer programmer"]
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
let(:redis) { double(::Redis) }
|
20
|
+
|
21
|
+
let(:semaphore) {
|
22
|
+
double(Flapjack::Data::Semaphore, :resource => 'folly',
|
23
|
+
:key => 'semaphores:folly', :expiry => 30, :token => 'spatulas-R-us')
|
24
|
+
}
|
25
|
+
|
26
|
+
let(:jsonapi_post_env) {
|
27
|
+
{'CONTENT_TYPE' => 'application/json',
|
28
|
+
'HTTP_ACCEPT' => 'application/json; q=0.8, application/vnd.api+json'}
|
29
|
+
}
|
30
|
+
|
31
|
+
let(:jsonapi_patch_env) {
|
32
|
+
{'CONTENT_TYPE' => 'application/json-patch+json',
|
33
|
+
'HTTP_ACCEPT' => 'application/json; q=0.8, application/vnd.api+json'}
|
34
|
+
}
|
35
|
+
|
36
|
+
before(:all) do
|
37
|
+
Flapjack::Gateways::JSONAPI.class_eval {
|
38
|
+
set :raise_errors, true
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
|
44
|
+
Flapjack::Gateways::JSONAPI.instance_variable_set('@config', {})
|
45
|
+
Flapjack::Gateways::JSONAPI.instance_variable_set('@logger', @logger)
|
46
|
+
Flapjack::Gateways::JSONAPI.start
|
47
|
+
end
|
48
|
+
|
49
|
+
after(:each) do
|
50
|
+
if last_response.status >= 200 && last_response.status < 300
|
51
|
+
expect(last_response.headers.keys).to include('Access-Control-Allow-Methods')
|
52
|
+
expect(last_response.headers['Access-Control-Allow-Origin']).to eq("*")
|
53
|
+
unless last_response.status == 204
|
54
|
+
expect(Oj.load(last_response.body)).to be_a(Enumerable)
|
55
|
+
expect(last_response.headers['Content-Type']).to eq(Flapjack::Gateways::JSONAPI::JSONAPI_MEDIA_TYPE)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flapjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: dante
|
@@ -292,6 +292,20 @@ dependencies:
|
|
292
292
|
- - ">="
|
293
293
|
- !ruby/object:Gem::Version
|
294
294
|
version: '0'
|
295
|
+
- !ruby/object:Gem::Dependency
|
296
|
+
name: rbtrace
|
297
|
+
requirement: !ruby/object:Gem::Requirement
|
298
|
+
requirements:
|
299
|
+
- - ">="
|
300
|
+
- !ruby/object:Gem::Version
|
301
|
+
version: '0'
|
302
|
+
type: :runtime
|
303
|
+
prerelease: false
|
304
|
+
version_requirements: !ruby/object:Gem::Requirement
|
305
|
+
requirements:
|
306
|
+
- - ">="
|
307
|
+
- !ruby/object:Gem::Version
|
308
|
+
version: '0'
|
295
309
|
- !ruby/object:Gem::Dependency
|
296
310
|
name: rake
|
297
311
|
requirement: !ruby/object:Gem::Requirement
|
@@ -401,11 +415,15 @@ files:
|
|
401
415
|
- lib/flapjack/gateways/jabber/alert.text.erb
|
402
416
|
- lib/flapjack/gateways/jabber/rollup.text.erb
|
403
417
|
- lib/flapjack/gateways/jsonapi.rb
|
418
|
+
- lib/flapjack/gateways/jsonapi/check_methods.rb
|
419
|
+
- lib/flapjack/gateways/jsonapi/check_presenter.rb
|
404
420
|
- lib/flapjack/gateways/jsonapi/contact_methods.rb
|
405
|
-
- lib/flapjack/gateways/jsonapi/entity_check_presenter.rb
|
406
421
|
- lib/flapjack/gateways/jsonapi/entity_methods.rb
|
407
|
-
- lib/flapjack/gateways/jsonapi/
|
422
|
+
- lib/flapjack/gateways/jsonapi/medium_methods.rb
|
423
|
+
- lib/flapjack/gateways/jsonapi/notification_rule_methods.rb
|
424
|
+
- lib/flapjack/gateways/jsonapi/pagerduty_credential_methods.rb
|
408
425
|
- lib/flapjack/gateways/jsonapi/rack/json_params_parser.rb
|
426
|
+
- lib/flapjack/gateways/jsonapi/report_methods.rb
|
409
427
|
- lib/flapjack/gateways/oobetet.rb
|
410
428
|
- lib/flapjack/gateways/pagerduty.rb
|
411
429
|
- lib/flapjack/gateways/pagerduty/alert.text.erb
|
@@ -504,10 +522,14 @@ files:
|
|
504
522
|
- spec/lib/flapjack/gateways/api_spec.rb
|
505
523
|
- spec/lib/flapjack/gateways/email_spec.rb
|
506
524
|
- spec/lib/flapjack/gateways/jabber_spec.rb
|
525
|
+
- spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb
|
526
|
+
- spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb
|
507
527
|
- spec/lib/flapjack/gateways/jsonapi/contact_methods_spec.rb
|
508
|
-
- spec/lib/flapjack/gateways/jsonapi/entity_check_presenter_spec.rb
|
509
528
|
- spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb
|
510
|
-
- spec/lib/flapjack/gateways/jsonapi/
|
529
|
+
- spec/lib/flapjack/gateways/jsonapi/medium_methods_spec.rb
|
530
|
+
- spec/lib/flapjack/gateways/jsonapi/notification_rule_methods_spec.rb
|
531
|
+
- spec/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods_spec.rb
|
532
|
+
- spec/lib/flapjack/gateways/jsonapi/report_methods_spec.rb
|
511
533
|
- spec/lib/flapjack/gateways/jsonapi_spec.rb
|
512
534
|
- spec/lib/flapjack/gateways/oobetet_spec.rb
|
513
535
|
- spec/lib/flapjack/gateways/pagerduty_spec.rb
|
@@ -524,6 +546,7 @@ files:
|
|
524
546
|
- spec/lib/flapjack/utility_spec.rb
|
525
547
|
- spec/spec_helper.rb
|
526
548
|
- spec/support/erb_view_helper.rb
|
549
|
+
- spec/support/jsonapi_helper.rb
|
527
550
|
- spec/support/profile_all_formatter.rb
|
528
551
|
- spec/support/uncolored_doc_formatter.rb
|
529
552
|
- tasks/benchmarks.rake
|
@@ -615,10 +638,14 @@ test_files:
|
|
615
638
|
- spec/lib/flapjack/gateways/api_spec.rb
|
616
639
|
- spec/lib/flapjack/gateways/email_spec.rb
|
617
640
|
- spec/lib/flapjack/gateways/jabber_spec.rb
|
641
|
+
- spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb
|
642
|
+
- spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb
|
618
643
|
- spec/lib/flapjack/gateways/jsonapi/contact_methods_spec.rb
|
619
|
-
- spec/lib/flapjack/gateways/jsonapi/entity_check_presenter_spec.rb
|
620
644
|
- spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb
|
621
|
-
- spec/lib/flapjack/gateways/jsonapi/
|
645
|
+
- spec/lib/flapjack/gateways/jsonapi/medium_methods_spec.rb
|
646
|
+
- spec/lib/flapjack/gateways/jsonapi/notification_rule_methods_spec.rb
|
647
|
+
- spec/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods_spec.rb
|
648
|
+
- spec/lib/flapjack/gateways/jsonapi/report_methods_spec.rb
|
622
649
|
- spec/lib/flapjack/gateways/jsonapi_spec.rb
|
623
650
|
- spec/lib/flapjack/gateways/oobetet_spec.rb
|
624
651
|
- spec/lib/flapjack/gateways/pagerduty_spec.rb
|
@@ -635,5 +662,6 @@ test_files:
|
|
635
662
|
- spec/lib/flapjack/utility_spec.rb
|
636
663
|
- spec/spec_helper.rb
|
637
664
|
- spec/support/erb_view_helper.rb
|
665
|
+
- spec/support/jsonapi_helper.rb
|
638
666
|
- spec/support/profile_all_formatter.rb
|
639
667
|
- spec/support/uncolored_doc_formatter.rb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Formats entity data for presentation by the API methods in Flapjack::Gateways::API.
|
4
|
-
# Currently this just aggregates all of the check data for an entity, leaving
|
5
|
-
# clients to make any further calculations for themselves.
|
6
|
-
|
7
|
-
require 'sinatra/base'
|
8
|
-
|
9
|
-
require 'flapjack/gateways/jsonapi/entity_check_presenter'
|
10
|
-
require 'flapjack/data/entity_check'
|
11
|
-
|
12
|
-
module Flapjack
|
13
|
-
|
14
|
-
module Gateways
|
15
|
-
|
16
|
-
class JSONAPI < Sinatra::Base
|
17
|
-
|
18
|
-
class EntityPresenter
|
19
|
-
|
20
|
-
def initialize(entity, options = {})
|
21
|
-
@entity = entity
|
22
|
-
@redis = options[:redis]
|
23
|
-
end
|
24
|
-
|
25
|
-
def status
|
26
|
-
checks.collect {|c| {:entity => @entity.name, :check => c,
|
27
|
-
:status => check_presenter(c).status } }
|
28
|
-
end
|
29
|
-
|
30
|
-
def outages(start_time, end_time)
|
31
|
-
checks.collect {|c|
|
32
|
-
{:entity => @entity.name, :check => c, :outages => check_presenter(c).outages(start_time, end_time)}
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def unscheduled_maintenances(start_time, end_time)
|
37
|
-
checks.collect {|c|
|
38
|
-
{:entity => @entity.name, :check => c, :unscheduled_maintenances =>
|
39
|
-
check_presenter(c).unscheduled_maintenances(start_time, end_time)}
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def scheduled_maintenances(start_time, end_time)
|
44
|
-
checks.collect {|c|
|
45
|
-
{:entity => @entity.name, :check => c, :scheduled_maintenances =>
|
46
|
-
check_presenter(c).scheduled_maintenances(start_time, end_time)}
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
def downtime(start_time, end_time)
|
51
|
-
checks.collect {|c|
|
52
|
-
{:entity => @entity.name, :check => c, :downtime =>
|
53
|
-
check_presenter(c).downtime(start_time, end_time)}
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def checks
|
60
|
-
@check_list ||= @entity.check_list.sort
|
61
|
-
end
|
62
|
-
|
63
|
-
def check_presenter(check)
|
64
|
-
entity_check = Flapjack::Data::EntityCheck.for_entity(@entity, check,
|
65
|
-
:redis => @redis)
|
66
|
-
presenter = Flapjack::Gateways::JSONAPI::EntityCheckPresenter.new(entity_check)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack/gateways/jsonapi/entity_presenter'
|
3
|
-
|
4
|
-
describe 'Flapjack::Gateways::JSONAPI::EntityPresenter' do
|
5
|
-
|
6
|
-
let(:entity) { double(Flapjack::Data::Entity) }
|
7
|
-
|
8
|
-
let(:check_a) { double(Flapjack::Data::EntityCheck) }
|
9
|
-
let(:check_b) { double(Flapjack::Data::EntityCheck) }
|
10
|
-
|
11
|
-
let(:checkpres_a) { double(Flapjack::Gateways::JSONAPI::EntityCheckPresenter) }
|
12
|
-
let(:checkpres_b) { double(Flapjack::Gateways::JSONAPI::EntityCheckPresenter) }
|
13
|
-
|
14
|
-
let(:time) { Time.now.to_i }
|
15
|
-
|
16
|
-
let(:start_time) { time - (6 * 60 * 60) }
|
17
|
-
let(:end_time) { time - (2 * 60 * 60) }
|
18
|
-
|
19
|
-
def expect_check_presenters
|
20
|
-
expect(entity).to receive(:name).exactly(4).times.and_return('foo')
|
21
|
-
expect(entity).to receive(:check_list).and_return(['ping', 'ssh'])
|
22
|
-
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
23
|
-
with(entity, 'ssh', anything).and_return(check_a)
|
24
|
-
expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
|
25
|
-
with(entity, 'ping', anything).and_return(check_b)
|
26
|
-
|
27
|
-
expect(Flapjack::Gateways::JSONAPI::EntityCheckPresenter).to receive(:new).
|
28
|
-
with(check_a).and_return(checkpres_a)
|
29
|
-
expect(Flapjack::Gateways::JSONAPI::EntityCheckPresenter).to receive(:new).
|
30
|
-
with(check_b).and_return(checkpres_b)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'returns a list of status hashes for each check on an entity' do
|
34
|
-
expect_check_presenters
|
35
|
-
|
36
|
-
status_a = double('status_a')
|
37
|
-
status_b = double('status_b')
|
38
|
-
expect(checkpres_a).to receive(:status).and_return(status_a)
|
39
|
-
expect(checkpres_b).to receive(:status).and_return(status_b)
|
40
|
-
|
41
|
-
ep = Flapjack::Gateways::JSONAPI::EntityPresenter.new(entity)
|
42
|
-
status = ep.status
|
43
|
-
expect(status).to eq([{:entity => entity.name, :check => 'ping', :status => status_b},
|
44
|
-
{:entity => entity.name, :check => 'ssh', :status => status_a}])
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns a list of outage hashes for each check on an entity" do
|
49
|
-
expect_check_presenters
|
50
|
-
outages_a = double('outages_a')
|
51
|
-
outages_b = double('outages_b')
|
52
|
-
expect(checkpres_a).to receive(:outages).with(start_time, end_time).
|
53
|
-
and_return(outages_a)
|
54
|
-
expect(checkpres_b).to receive(:outages).with(start_time, end_time).
|
55
|
-
and_return(outages_b)
|
56
|
-
|
57
|
-
ep = Flapjack::Gateways::JSONAPI::EntityPresenter.new(entity)
|
58
|
-
outages = ep.outages(start_time, end_time)
|
59
|
-
expect(outages).to eq([{:entity => entity.name, :check => 'ping', :outages => outages_b},
|
60
|
-
{:entity => entity.name, :check => 'ssh', :outages => outages_a}])
|
61
|
-
end
|
62
|
-
|
63
|
-
it "returns a list of unscheduled maintenance periods for each check on an entity" do
|
64
|
-
expect_check_presenters
|
65
|
-
unsched_maint_a = double('unsched_maint_a')
|
66
|
-
unsched_maint_b = double('unsched_maint_b')
|
67
|
-
expect(checkpres_a).to receive(:unscheduled_maintenances).with(start_time, end_time).
|
68
|
-
and_return(unsched_maint_a)
|
69
|
-
expect(checkpres_b).to receive(:unscheduled_maintenances).with(start_time, end_time).
|
70
|
-
and_return(unsched_maint_b)
|
71
|
-
|
72
|
-
ep = Flapjack::Gateways::JSONAPI::EntityPresenter.new(entity)
|
73
|
-
unsched_maint = ep.unscheduled_maintenances(start_time, end_time)
|
74
|
-
expect(unsched_maint).to eq([{:entity => entity.name, :check => 'ping', :unscheduled_maintenances => unsched_maint_b},
|
75
|
-
{:entity => entity.name, :check => 'ssh', :unscheduled_maintenances => unsched_maint_a}])
|
76
|
-
end
|
77
|
-
|
78
|
-
it "returns a list of scheduled maintenance periods for each check on an entity" do
|
79
|
-
expect_check_presenters
|
80
|
-
sched_maint_a = double('sched_maint_a')
|
81
|
-
sched_maint_b = double('sched_maint_b')
|
82
|
-
expect(checkpres_a).to receive(:scheduled_maintenances).with(start_time, end_time).
|
83
|
-
and_return(sched_maint_a)
|
84
|
-
expect(checkpres_b).to receive(:scheduled_maintenances).with(start_time, end_time).
|
85
|
-
and_return(sched_maint_b)
|
86
|
-
|
87
|
-
ep = Flapjack::Gateways::JSONAPI::EntityPresenter.new(entity)
|
88
|
-
sched_maint = ep.scheduled_maintenances(start_time, end_time)
|
89
|
-
expect(sched_maint).to eq([{:entity => entity.name, :check => 'ping', :scheduled_maintenances => sched_maint_b},
|
90
|
-
{:entity => entity.name, :check => 'ssh', :scheduled_maintenances => sched_maint_a}])
|
91
|
-
end
|
92
|
-
|
93
|
-
it "returns a list of downtime for each check on an entity" do
|
94
|
-
expect_check_presenters
|
95
|
-
downtime_a = double('downtime_a')
|
96
|
-
downtime_b = double('downtime_b')
|
97
|
-
expect(checkpres_a).to receive(:downtime).with(start_time, end_time).
|
98
|
-
and_return(downtime_a)
|
99
|
-
expect(checkpres_b).to receive(:downtime).with(start_time, end_time).
|
100
|
-
and_return(downtime_b)
|
101
|
-
|
102
|
-
ep = Flapjack::Gateways::JSONAPI::EntityPresenter.new(entity)
|
103
|
-
downtime = ep.downtime(start_time, end_time)
|
104
|
-
expect(downtime).to eq([{:entity => entity.name, :check => 'ping', :downtime => downtime_b},
|
105
|
-
{:entity => entity.name, :check => 'ssh', :downtime => downtime_a}])
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|