flapjack 0.9.6 → 1.0.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +6 -0
  4. data/.travis.yml +20 -16
  5. data/CHANGELOG.md +11 -25
  6. data/Dockerfile +8 -0
  7. data/Gemfile +2 -5
  8. data/bin/flapjack +24 -213
  9. data/etc/flapjack_config.yaml.example +6 -30
  10. data/features/cli.feature +16 -14
  11. data/features/cli_flapjack-feed-events.feature +12 -13
  12. data/features/cli_flapjack-nagios-receiver.feature +14 -15
  13. data/features/cli_flapjack-populator.feature +16 -15
  14. data/features/cli_flapper.feature +12 -12
  15. data/features/cli_receive-events.feature +6 -5
  16. data/features/cli_simulate-failed-check.feature +7 -6
  17. data/features/steps/cli_steps.rb +2 -2
  18. data/features/support/env.rb +1 -0
  19. data/flapjack.gemspec +1 -0
  20. data/lib/flapjack/cli/flapper.rb +200 -0
  21. data/lib/flapjack/cli/import.rb +102 -0
  22. data/lib/flapjack/cli/receiver.rb +656 -0
  23. data/lib/flapjack/cli/server.rb +256 -0
  24. data/lib/flapjack/cli/simulate.rb +180 -0
  25. data/lib/flapjack/configuration.rb +2 -0
  26. data/lib/flapjack/data/entity_check.rb +5 -22
  27. data/lib/flapjack/data/event.rb +7 -12
  28. data/lib/flapjack/gateways/email.rb +4 -1
  29. data/lib/flapjack/gateways/jabber.rb +12 -36
  30. data/lib/flapjack/gateways/jsonapi/check_presenter.rb +6 -6
  31. data/lib/flapjack/gateways/jsonapi/report_methods.rb +5 -3
  32. data/lib/flapjack/gateways/pagerduty.rb +1 -1
  33. data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +1 -1
  34. data/lib/flapjack/gateways/web/public/js/modules/contact.js +2 -2
  35. data/lib/flapjack/gateways/web/public/js/modules/entity.js +2 -2
  36. data/lib/flapjack/gateways/web/public/js/modules/medium.js +4 -4
  37. data/lib/flapjack/gateways/web/public/js/self_stats.js +1 -1
  38. data/lib/flapjack/gateways/web/views/check.html.erb +7 -7
  39. data/lib/flapjack/gateways/web/views/checks.html.erb +2 -3
  40. data/lib/flapjack/gateways/web/views/contact.html.erb +4 -4
  41. data/lib/flapjack/gateways/web/views/contacts.html.erb +2 -2
  42. data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +1 -1
  43. data/lib/flapjack/gateways/web/views/entities.html.erb +1 -1
  44. data/lib/flapjack/gateways/web/views/entity.html.erb +1 -1
  45. data/lib/flapjack/gateways/web/views/index.html.erb +2 -2
  46. data/lib/flapjack/gateways/web/views/layout.erb +10 -10
  47. data/lib/flapjack/gateways/web/views/self_stats.html.erb +1 -1
  48. data/lib/flapjack/gateways/web.rb +36 -7
  49. data/lib/flapjack/pikelet.rb +0 -2
  50. data/lib/flapjack/processor.rb +3 -1
  51. data/lib/flapjack/redis_pool.rb +2 -6
  52. data/lib/flapjack/version.rb +1 -1
  53. data/spec/lib/flapjack/coordinator_spec.rb +3 -3
  54. data/spec/lib/flapjack/data/entity_check_spec.rb +2 -6
  55. data/spec/lib/flapjack/data/event_spec.rb +0 -31
  56. data/spec/lib/flapjack/gateways/email_spec.rb +109 -0
  57. data/spec/lib/flapjack/gateways/jabber_spec.rb +18 -16
  58. data/spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb +12 -24
  59. data/spec/lib/flapjack/gateways/pagerduty_spec.rb +1 -1
  60. data/spec/lib/flapjack/gateways/web/views/check.html.erb_spec.rb +2 -0
  61. data/spec/lib/flapjack/gateways/web/views/contact.html.erb_spec.rb +2 -0
  62. data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +2 -0
  63. data/spec/lib/flapjack/gateways/web_spec.rb +194 -145
  64. data/spec/lib/flapjack/redis_pool_spec.rb +0 -1
  65. data/spec/support/profile_all_formatter.rb +44 -0
  66. data/spec/support/uncolored_doc_formatter.rb +9 -0
  67. data/tasks/benchmarks.rake +0 -4
  68. metadata +28 -38
  69. data/.ruby-version +0 -1
  70. data/Gemfile-ruby1.9 +0 -28
  71. data/Gemfile-ruby1.9.lock +0 -227
  72. data/bin/flapjack-feed-events +0 -124
  73. data/bin/flapjack-nagios-receiver +0 -246
  74. data/bin/flapjack-nsca-receiver +0 -246
  75. data/bin/flapjack-populator +0 -132
  76. data/bin/flapper +0 -152
  77. data/bin/receive-events +0 -179
  78. data/bin/simulate-failed-check +0 -151
  79. data/lib/flapjack/data/migration.rb +0 -36
  80. data/lib/flapjack/gateways/api/contact_methods.rb +0 -369
  81. data/lib/flapjack/gateways/api/entity_check_presenter.rb +0 -218
  82. data/lib/flapjack/gateways/api/entity_methods.rb +0 -361
  83. data/lib/flapjack/gateways/api/entity_presenter.rb +0 -75
  84. data/lib/flapjack/gateways/api/rack/json_params_parser.rb +0 -26
  85. data/lib/flapjack/gateways/api.rb +0 -124
  86. data/spec/lib/flapjack/gateways/api/contact_methods_spec.rb +0 -772
  87. data/spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb +0 -211
  88. data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +0 -863
  89. data/spec/lib/flapjack/gateways/api/entity_presenter_spec.rb +0 -108
  90. 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