flapjack 0.9.6 → 1.0.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +6 -0
- data/.travis.yml +20 -16
- data/CHANGELOG.md +11 -25
- data/Dockerfile +8 -0
- data/Gemfile +2 -5
- data/bin/flapjack +24 -213
- data/etc/flapjack_config.yaml.example +6 -30
- data/features/cli.feature +16 -14
- data/features/cli_flapjack-feed-events.feature +12 -13
- data/features/cli_flapjack-nagios-receiver.feature +14 -15
- data/features/cli_flapjack-populator.feature +16 -15
- data/features/cli_flapper.feature +12 -12
- data/features/cli_receive-events.feature +6 -5
- data/features/cli_simulate-failed-check.feature +7 -6
- data/features/steps/cli_steps.rb +2 -2
- data/features/support/env.rb +1 -0
- data/flapjack.gemspec +1 -0
- data/lib/flapjack/cli/flapper.rb +200 -0
- data/lib/flapjack/cli/import.rb +102 -0
- data/lib/flapjack/cli/receiver.rb +656 -0
- data/lib/flapjack/cli/server.rb +256 -0
- data/lib/flapjack/cli/simulate.rb +180 -0
- data/lib/flapjack/configuration.rb +2 -0
- data/lib/flapjack/data/entity_check.rb +5 -22
- data/lib/flapjack/data/event.rb +7 -12
- data/lib/flapjack/gateways/email.rb +4 -1
- data/lib/flapjack/gateways/jabber.rb +12 -36
- data/lib/flapjack/gateways/jsonapi/check_presenter.rb +6 -6
- data/lib/flapjack/gateways/jsonapi/report_methods.rb +5 -3
- data/lib/flapjack/gateways/pagerduty.rb +1 -1
- data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +1 -1
- data/lib/flapjack/gateways/web/public/js/modules/contact.js +2 -2
- data/lib/flapjack/gateways/web/public/js/modules/entity.js +2 -2
- data/lib/flapjack/gateways/web/public/js/modules/medium.js +4 -4
- data/lib/flapjack/gateways/web/public/js/self_stats.js +1 -1
- data/lib/flapjack/gateways/web/views/check.html.erb +7 -7
- data/lib/flapjack/gateways/web/views/checks.html.erb +2 -3
- data/lib/flapjack/gateways/web/views/contact.html.erb +4 -4
- data/lib/flapjack/gateways/web/views/contacts.html.erb +2 -2
- data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/entities.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/entity.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/index.html.erb +2 -2
- data/lib/flapjack/gateways/web/views/layout.erb +10 -10
- data/lib/flapjack/gateways/web/views/self_stats.html.erb +1 -1
- data/lib/flapjack/gateways/web.rb +36 -7
- data/lib/flapjack/pikelet.rb +0 -2
- data/lib/flapjack/processor.rb +3 -1
- data/lib/flapjack/redis_pool.rb +2 -6
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +3 -3
- data/spec/lib/flapjack/data/entity_check_spec.rb +2 -6
- data/spec/lib/flapjack/data/event_spec.rb +0 -31
- data/spec/lib/flapjack/gateways/email_spec.rb +109 -0
- data/spec/lib/flapjack/gateways/jabber_spec.rb +18 -16
- data/spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb +12 -24
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/web/views/check.html.erb_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/web/views/contact.html.erb_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/web_spec.rb +194 -145
- data/spec/lib/flapjack/redis_pool_spec.rb +0 -1
- data/spec/support/profile_all_formatter.rb +44 -0
- data/spec/support/uncolored_doc_formatter.rb +9 -0
- data/tasks/benchmarks.rake +0 -4
- metadata +28 -38
- data/.ruby-version +0 -1
- data/Gemfile-ruby1.9 +0 -28
- data/Gemfile-ruby1.9.lock +0 -227
- data/bin/flapjack-feed-events +0 -124
- data/bin/flapjack-nagios-receiver +0 -246
- data/bin/flapjack-nsca-receiver +0 -246
- data/bin/flapjack-populator +0 -132
- data/bin/flapper +0 -152
- data/bin/receive-events +0 -179
- data/bin/simulate-failed-check +0 -151
- data/lib/flapjack/data/migration.rb +0 -36
- data/lib/flapjack/gateways/api/contact_methods.rb +0 -369
- data/lib/flapjack/gateways/api/entity_check_presenter.rb +0 -218
- data/lib/flapjack/gateways/api/entity_methods.rb +0 -361
- data/lib/flapjack/gateways/api/entity_presenter.rb +0 -75
- data/lib/flapjack/gateways/api/rack/json_params_parser.rb +0 -26
- data/lib/flapjack/gateways/api.rb +0 -124
- data/spec/lib/flapjack/gateways/api/contact_methods_spec.rb +0 -772
- data/spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb +0 -211
- data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +0 -863
- data/spec/lib/flapjack/gateways/api/entity_presenter_spec.rb +0 -108
- data/spec/lib/flapjack/gateways/api_spec.rb +0 -30
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack/gateways/api/entity_presenter'
|
3
|
-
|
4
|
-
describe 'Flapjack::Gateways::API::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::API::EntityCheckPresenter) }
|
12
|
-
let(:checkpres_b) { double(Flapjack::Gateways::API::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::API::EntityCheckPresenter).to receive(:new).
|
28
|
-
with(check_a).and_return(checkpres_a)
|
29
|
-
expect(Flapjack::Gateways::API::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::API::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::API::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::API::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::API::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::API::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
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack/gateways/api'
|
3
|
-
|
4
|
-
describe 'Flapjack::Gateways::API', :sinatra => true, :logger => true do
|
5
|
-
|
6
|
-
def app
|
7
|
-
Flapjack::Gateways::API
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:redis) { double(::Redis) }
|
11
|
-
|
12
|
-
before(:all) do
|
13
|
-
Flapjack::Gateways::API.class_eval {
|
14
|
-
set :raise_errors, true
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
before(:each) do
|
19
|
-
expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
|
20
|
-
Flapjack::Gateways::API.instance_variable_set('@config', {})
|
21
|
-
Flapjack::Gateways::API.instance_variable_set('@logger', @logger)
|
22
|
-
Flapjack::Gateways::API.start
|
23
|
-
end
|
24
|
-
|
25
|
-
it "handles a route matching failure" do
|
26
|
-
aget "/this/route/doesn't/exist"
|
27
|
-
expect(last_response.status).to eq(404)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|