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
@@ -23,13 +23,6 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
23
23
  }
24
24
  end
25
25
 
26
- before(:each) do
27
- expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
28
- Flapjack::Gateways::Web.instance_variable_set('@config', {})
29
- Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
30
- Flapjack::Gateways::Web.start
31
- end
32
-
33
26
  def expect_stats
34
27
  expect(redis).to receive(:dbsize).and_return(3)
35
28
  expect(redis).to receive(:keys).with('executive_instance:*').and_return(["executive_instance:foo-app-01"])
@@ -69,186 +62,242 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
69
62
  expect(ec).to receive(:in_unscheduled_maintenance?).and_return(false)
70
63
  end
71
64
 
72
- # TODO add data, test that pages contain representations of it
73
- # (for the methods that access redis directly)
65
+ context "Web page design" do
74
66
 
75
- it "shows a page listing all checks" do
76
- #redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}"])
77
- expect(Flapjack::Data::EntityCheck).to receive(:find_all_by_entity).
78
- with(:redis => redis).and_return({entity_name => [check]})
79
- expect_check_stats
67
+ before(:each) do
68
+ expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
69
+ Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
70
+ end
80
71
 
81
- expect_entity_check_status(entity_check)
72
+ it "displays a custom logo if configured" do
73
+ image_path = '/tmp/branding.png'
74
+ config = {"logo_image_path" => image_path}
82
75
 
83
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
84
- with(entity_name, :redis => redis).and_return(entity)
76
+ allow(File).to receive(:file?).and_call_original
77
+ allow(File).to receive(:file?).with(image_path) { true }
85
78
 
86
- expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
87
- with(entity, 'ping', :redis => redis).and_return(entity_check)
79
+ Flapjack::Gateways::Web.instance_variable_set('@config', config)
80
+ Flapjack::Gateways::Web.start
88
81
 
89
- aget '/checks_all'
90
- expect(last_response).to be_ok
91
- end
82
+ # NOTE Reuse enough of the stats specs to be able to build a page quickly
83
+ expect_stats
84
+ expect_check_stats
85
+ expect_entity_stats
86
+
87
+ logo_image_tag = '<img alt="Flapjack" class="logo" src="/img/branding.png">'
92
88
 
93
- it "shows a page listing failing checks" do
94
- #redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
89
+ aget '/self_stats'
95
90
 
96
- expect_check_stats
91
+ expect( last_response.body ).to include(logo_image_tag)
92
+ end
97
93
 
98
- expect_entity_check_status(entity_check)
94
+ it "displays the standard logo if no custom logo configured" do
95
+ Flapjack::Gateways::Web.instance_variable_set('@config', {})
96
+ Flapjack::Gateways::Web.start
97
+ # NOTE Reuse enough of the stats specs to be able to build a page quickly
98
+ expect_stats
99
+ expect_check_stats
100
+ expect_entity_stats
99
101
 
100
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
101
- with(entity_name, :redis => redis).and_return(entity)
102
+ logo_image_tag = '<img alt="Flapjack" class="logo" src="/img/flapjack-2013-notext-transparent-300-300.png">'
102
103
 
103
- expect(Flapjack::Data::EntityCheck).to receive(:find_all_failing_by_entity).
104
- with(:redis => redis).and_return({entity_name => [check]})
104
+ aget '/self_stats'
105
105
 
106
- expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
107
- with(entity, 'ping', :redis => redis).and_return(entity_check)
108
- aget '/checks_failing'
109
- expect(last_response).to be_ok
106
+ expect( last_response.body ).to include(logo_image_tag)
107
+ end
110
108
  end
111
109
 
112
- it "shows a page listing flapjack statistics" do
113
- #redis.should_receive(:keys).with('check:*').and_return([])
114
- #redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
115
- expect_stats
116
- expect_check_stats
117
- expect_entity_stats
110
+ context "Web page behavior" do
111
+
112
+ before(:each) do
113
+ expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
114
+ Flapjack::Gateways::Web.instance_variable_set('@config', {})
115
+ Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
116
+ Flapjack::Gateways::Web.start
117
+ end
118
+
119
+ # TODO add data, test that pages contain representations of it
120
+ # (for the methods that access redis directly)
121
+
122
+ it "shows a page listing all checks" do
123
+ #redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}"])
124
+ expect(Flapjack::Data::EntityCheck).to receive(:find_all_by_entity).
125
+ with(:redis => redis).and_return({entity_name => [check]})
126
+ expect_check_stats
127
+
128
+ expect_entity_check_status(entity_check)
129
+
130
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
131
+ with(entity_name, :redis => redis).and_return(entity)
132
+
133
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
134
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
135
+
136
+ aget '/checks_all'
137
+ expect(last_response).to be_ok
138
+ end
139
+
140
+ it "shows a page listing failing checks" do
141
+ #redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
142
+
143
+ expect_check_stats
144
+
145
+ expect_entity_check_status(entity_check)
146
+
147
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
148
+ with(entity_name, :redis => redis).and_return(entity)
149
+
150
+ expect(Flapjack::Data::EntityCheck).to receive(:find_all_failing_by_entity).
151
+ with(:redis => redis).and_return({entity_name => [check]})
152
+
153
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
154
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
155
+ aget '/checks_failing'
156
+ expect(last_response).to be_ok
157
+ end
118
158
 
119
- aget '/self_stats'
120
- expect(last_response).to be_ok
121
- end
159
+ it "shows a page listing flapjack statistics" do
160
+ #redis.should_receive(:keys).with('check:*').and_return([])
161
+ #redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}"])
162
+ expect_stats
163
+ expect_check_stats
164
+ expect_entity_stats
122
165
 
123
- it "shows the state of a check for an entity" do
124
- time = Time.now
125
- expect(Time).to receive(:now).exactly(5).times.and_return(time)
126
-
127
- last_notifications = {:problem => {:timestamp => time.to_i - ((3 * 60 * 60) + (5 * 60)), :summary => 'prob'},
128
- :recovery => {:timestamp => time.to_i - (3 * 60 * 60), :summary => nil},
129
- :acknowledgement => {:timestamp => nil, :summary => nil} }
130
-
131
- expect_check_stats
132
- expect(entity_check).to receive(:state).and_return('ok')
133
- expect(entity_check).to receive(:last_update).and_return(time.to_i - (3 * 60 * 60))
134
- expect(entity_check).to receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
135
- expect(entity_check).to receive(:summary).and_return('all good')
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"}])
138
- expect(entity_check).to receive(:last_notifications_of_each_type).and_return(last_notifications)
139
- expect(entity_check).to receive(:maintenances).with(nil, nil, :scheduled => true).and_return([])
140
- expect(entity_check).to receive(:failed?).and_return(false)
141
- expect(entity_check).to receive(:current_maintenance).with(:scheduled => true).and_return(false)
142
- expect(entity_check).to receive(:current_maintenance).with(:scheduled => false).and_return(false)
143
- expect(entity_check).to receive(:contacts).and_return([])
144
- expect(entity_check).to receive(:historical_states).
145
- with(nil, time.to_i, :order => 'desc', :limit => 20).and_return([])
146
- expect(entity_check).to receive(:enabled?).and_return(true)
147
-
148
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
149
- with(entity_name, :redis => redis).and_return(entity)
150
-
151
- expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
152
- with(entity, 'ping', :redis => redis).and_return(entity_check)
153
-
154
- aget "/check?entity=#{entity_name_esc}&check=ping"
155
- expect(last_response).to be_ok
156
- # TODO test instance variables set to appropriate values
157
- end
166
+ aget '/self_stats'
167
+ expect(last_response).to be_ok
168
+ end
158
169
 
159
- it "returns 404 if an unknown entity is requested" do
160
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
161
- with(entity_name_esc, :redis => redis).and_return(nil)
170
+ it "shows the state of a check for an entity" do
171
+ time = Time.now
172
+ expect(Time).to receive(:now).exactly(5).times.and_return(time)
162
173
 
163
- aget "/check?entity=#{entity_name_esc}&check=ping"
164
- expect(last_response).to be_not_found
165
- end
174
+ last_notifications = {:problem => {:timestamp => time.to_i - ((3 * 60 * 60) + (5 * 60)), :summary => 'prob'},
175
+ :recovery => {:timestamp => time.to_i - (3 * 60 * 60), :summary => nil},
176
+ :acknowledgement => {:timestamp => nil, :summary => nil} }
166
177
 
167
- # TODO shouldn't create actual entity record
168
- it "returns 404 if no entity check is passed" do
169
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
170
- with(entity_name, :redis => redis).and_return(entity)
178
+ expect_check_stats
179
+ expect(entity_check).to receive(:state).and_return('ok')
180
+ expect(entity_check).to receive(:last_update).and_return(time.to_i - (3 * 60 * 60))
181
+ expect(entity_check).to receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
182
+ expect(entity_check).to receive(:summary).and_return('all good')
183
+ expect(entity_check).to receive(:details).and_return('seriously, all very wonderful')
184
+ expect(entity_check).to receive(:perfdata).and_return([{"key" => "foo", "value" => "bar"}])
185
+ expect(entity_check).to receive(:last_notifications_of_each_type).and_return(last_notifications)
186
+ expect(entity_check).to receive(:maintenances).with(nil, nil, :scheduled => true).and_return([])
187
+ expect(entity_check).to receive(:failed?).and_return(false)
188
+ expect(entity_check).to receive(:current_maintenance).with(:scheduled => true).and_return(false)
189
+ expect(entity_check).to receive(:current_maintenance).with(:scheduled => false).and_return(false)
190
+ expect(entity_check).to receive(:contacts).and_return([])
191
+ expect(entity_check).to receive(:historical_states).
192
+ with(nil, time.to_i, :order => 'desc', :limit => 20).and_return([])
193
+ expect(entity_check).to receive(:enabled?).and_return(true)
171
194
 
172
- aget "/check?entity=#{entity_name_esc}"
173
- expect(last_response).to be_not_found
174
- end
195
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
196
+ with(entity_name, :redis => redis).and_return(entity)
175
197
 
176
- it "creates an acknowledgement for an entity check" do
177
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
178
- with(entity_name, :redis => redis).and_return(entity)
198
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
199
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
179
200
 
180
- expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
181
- with(entity, 'ping', :redis => redis).and_return(entity_check)
201
+ aget "/check?entity=#{entity_name_esc}&check=ping"
202
+ expect(last_response).to be_ok
203
+ # TODO test instance variables set to appropriate values
204
+ end
182
205
 
183
- expect(Flapjack::Data::Event).to receive(:create_acknowledgement).
184
- with(entity_name, 'ping', :summary => "", :duration => (4 * 60 * 60),
185
- :acknowledgement_id => '1234', :redis => redis)
206
+ it "returns 404 if an unknown entity is requested" do
207
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
208
+ with(entity_name_esc, :redis => redis).and_return(nil)
186
209
 
187
- apost "/acknowledgements/#{entity_name_esc}/ping?acknowledgement_id=1234"
188
- expect(last_response.status).to eq(302)
189
- end
210
+ aget "/check?entity=#{entity_name_esc}&check=ping"
211
+ expect(last_response).to be_not_found
212
+ end
190
213
 
191
- it "creates a scheduled maintenance period for an entity check" do
192
- t = Time.now.to_i
214
+ # TODO shouldn't create actual entity record
215
+ it "returns 404 if no entity check is passed" do
216
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
217
+ with(entity_name, :redis => redis).and_return(entity)
193
218
 
194
- start_time = Time.at(t - (24 * 60 * 60))
195
- duration = 30 * 60
196
- summary = 'wow'
219
+ aget "/check?entity=#{entity_name_esc}"
220
+ expect(last_response).to be_not_found
221
+ end
197
222
 
198
- expect(Chronic).to receive(:parse).with('1 day ago').and_return(start_time)
199
- expect(ChronicDuration).to receive(:parse).with('30 minutes').and_return(duration)
223
+ it "creates an acknowledgement for an entity check" do
224
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
225
+ with(entity_name, :redis => redis).and_return(entity)
200
226
 
201
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
202
- with(entity_name, :redis => redis).and_return(entity)
227
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
228
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
203
229
 
204
- expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
205
- with(entity, 'ping', :redis => redis).and_return(entity_check)
230
+ expect(Flapjack::Data::Event).to receive(:create_acknowledgement).
231
+ with(entity_name, 'ping', :summary => "", :duration => (4 * 60 * 60),
232
+ :acknowledgement_id => '1234', :redis => redis)
206
233
 
207
- expect(entity_check).to receive(:create_scheduled_maintenance).
208
- with(start_time.to_i, duration, :summary => summary)
234
+ apost "/acknowledgements/#{entity_name_esc}/ping?acknowledgement_id=1234"
235
+ expect(last_response.status).to eq(302)
236
+ end
209
237
 
210
- apost "/scheduled_maintenances/#{entity_name_esc}/ping?"+
211
- "start_time=1+day+ago&duration=30+minutes&summary=wow"
238
+ it "creates a scheduled maintenance period for an entity check" do
239
+ t = Time.now.to_i
212
240
 
213
- expect(last_response.status).to eq(302)
214
- end
241
+ start_time = Time.at(t - (24 * 60 * 60))
242
+ duration = 30 * 60
243
+ summary = 'wow'
215
244
 
216
- it "deletes a scheduled maintenance period for an entity check" do
217
- t = Time.now.to_i
245
+ expect(Chronic).to receive(:parse).with('1 day ago').and_return(start_time)
246
+ expect(ChronicDuration).to receive(:parse).with('30 minutes').and_return(duration)
247
+
248
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
249
+ with(entity_name, :redis => redis).and_return(entity)
250
+
251
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
252
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
253
+
254
+ expect(entity_check).to receive(:create_scheduled_maintenance).
255
+ with(start_time.to_i, duration, :summary => summary)
256
+
257
+ apost "/scheduled_maintenances/#{entity_name_esc}/ping?"+
258
+ "start_time=1+day+ago&duration=30+minutes&summary=wow"
259
+
260
+ expect(last_response.status).to eq(302)
261
+ end
218
262
 
219
- start_time = t - (24 * 60 * 60)
263
+ it "deletes a scheduled maintenance period for an entity check" do
264
+ t = Time.now.to_i
220
265
 
221
- expect(Flapjack::Data::Entity).to receive(:find_by_name).
222
- with(entity_name, :redis => redis).and_return(entity)
266
+ start_time = t - (24 * 60 * 60)
223
267
 
224
- expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
225
- with(entity, 'ping', :redis => redis).and_return(entity_check)
268
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
269
+ with(entity_name, :redis => redis).and_return(entity)
226
270
 
227
- expect(entity_check).to receive(:end_scheduled_maintenance).with(start_time)
271
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
272
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
228
273
 
229
- adelete "/scheduled_maintenances/#{entity_name_esc}/ping?start_time=#{start_time}"
230
- expect(last_response.status).to eq(302)
231
- end
274
+ expect(entity_check).to receive(:end_scheduled_maintenance).with(start_time)
232
275
 
233
- it "shows a list of all known contacts" do
234
- expect(Flapjack::Data::Contact).to receive(:all)
276
+ adelete "/scheduled_maintenances/#{entity_name_esc}/ping?start_time=#{start_time}"
277
+ expect(last_response.status).to eq(302)
278
+ end
235
279
 
236
- aget "/contacts"
237
- expect(last_response).to be_ok
238
- end
280
+ it "shows a list of all known contacts" do
281
+ expect(Flapjack::Data::Contact).to receive(:all)
282
+
283
+ aget "/contacts"
284
+ expect(last_response).to be_ok
285
+ end
239
286
 
240
- it "shows details of an individual contact found by id" do
241
- contact = double('contact')
242
- expect(contact).to receive(:name).and_return("Smithson Smith")
243
- expect(contact).to receive(:media).exactly(3).times.and_return({})
244
- expect(contact).to receive(:entities).with(:checks => true).and_return([])
245
- expect(contact).to receive(:notification_rules).and_return([])
287
+ it "shows details of an individual contact found by id" do
288
+ contact = double('contact')
289
+ expect(contact).to receive(:name).and_return("Smithson Smith")
290
+ expect(contact).to receive(:media).exactly(3).times.and_return({})
291
+ expect(contact).to receive(:entities).with(:checks => true).and_return([])
292
+ expect(contact).to receive(:notification_rules).and_return([])
246
293
 
247
- expect(Flapjack::Data::Contact).to receive(:find_by_id).
248
- with('0362', :redis => redis).and_return(contact)
294
+ expect(Flapjack::Data::Contact).to receive(:find_by_id).
295
+ with('0362', :redis => redis).and_return(contact)
249
296
 
250
- aget "/contacts/0362"
251
- expect(last_response).to be_ok
297
+ aget "/contacts/0362"
298
+ expect(last_response).to be_ok
299
+ end
252
300
  end
253
301
 
302
+
254
303
  end
@@ -12,7 +12,6 @@ describe Flapjack::RedisPool do
12
12
  redis
13
13
  }
14
14
  expect(::Redis).to receive(:new).exactly(redis_count).times.and_return(*redis_conns)
15
- expect(Flapjack::Data::Migration).to receive(:refresh_archive_index).exactly(redis_count).times
16
15
 
17
16
  frp = Flapjack::RedisPool.new(:size => redis_count)
18
17
 
@@ -0,0 +1,44 @@
1
+ require 'rspec/core/formatters/base_formatter'
2
+
3
+ class ProfileAllFormatter < RSpec::Core::Formatters::BaseFormatter
4
+
5
+ def initialize(output)
6
+ super(output)
7
+ @example_times = []
8
+ end
9
+
10
+ def start(count)
11
+ super(count)
12
+ @output.puts "Profiling enabled."
13
+ end
14
+
15
+ def example_started(example)
16
+ super(example)
17
+ @time = ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now)
18
+ end
19
+
20
+ def example_passed(example)
21
+ @example_times << [
22
+ example_group.description,
23
+ example.description,
24
+ ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now) - @time
25
+ ]
26
+ super(example)
27
+ end
28
+
29
+ def start_dump
30
+ super
31
+ @output.puts "\n\nExample times:\n"
32
+
33
+ @example_times = @example_times.sort_by do |description, example, time|
34
+ time
35
+ end.reverse
36
+
37
+ @example_times.each do |description, example, time|
38
+ @output.print sprintf("%.7f", time)
39
+ @output.puts " #{description} #{example}"
40
+ end
41
+ @output.flush
42
+ end
43
+
44
+ end
@@ -0,0 +1,9 @@
1
+ require 'rspec/core/formatters/documentation_formatter'
2
+
3
+ class UncoloredDocFormatter < RSpec::Core::Formatters::DocumentationFormatter
4
+
5
+ def color(text, color_code)
6
+ text
7
+ end
8
+
9
+ end
@@ -94,10 +94,6 @@ namespace :benchmarks do
94
94
  # - time to failure varies evenly between 1 hour and 1 month
95
95
  # - time to recovery varies evenly between 10 seconds and 1 week
96
96
  task :benchmark do
97
- unless RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
98
- # Flapjack doesn't support 1.8 or below, so just checking for 1.9 is OK
99
- raise "perftools.rb doesn't work on Ruby 2.0 or greater"
100
- end
101
97
 
102
98
  num_checks_per_entity = (ENV['CHECKS_PER_ENTITY'] || 5).to_i
103
99
  num_entities = (ENV['ENTITIES'] || 100).to_i
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.9.6
4
+ version: 1.0.0rc1
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-10-21 00:00:00.000000000 Z
13
+ date: 2014-06-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: dante
@@ -320,44 +320,42 @@ dependencies:
320
320
  - - ">="
321
321
  - !ruby/object:Gem::Version
322
322
  version: '0'
323
+ - !ruby/object:Gem::Dependency
324
+ name: gli
325
+ requirement: !ruby/object:Gem::Requirement
326
+ requirements:
327
+ - - ">="
328
+ - !ruby/object:Gem::Version
329
+ version: '0'
330
+ type: :runtime
331
+ prerelease: false
332
+ version_requirements: !ruby/object:Gem::Requirement
333
+ requirements:
334
+ - - ">="
335
+ - !ruby/object:Gem::Version
336
+ version: '0'
323
337
  description: Flapjack is a distributed monitoring notification system that provides
324
338
  a scalable method for processing streams of events from Nagios and deciding who
325
339
  should be notified
326
340
  email: lindsay@holmwood.id.au
327
341
  executables:
328
342
  - flapjack
329
- - flapjack-feed-events
330
- - flapjack-nagios-receiver
331
- - flapjack-nsca-receiver
332
- - flapjack-populator
333
- - flapper
334
- - receive-events
335
- - simulate-failed-check
336
343
  extensions: []
337
344
  extra_rdoc_files: []
338
345
  files:
339
346
  - ".gitignore"
340
347
  - ".gitmodules"
341
348
  - ".rspec"
342
- - ".ruby-version"
343
349
  - ".travis.yml"
344
350
  - CHANGELOG.md
345
351
  - CONTRIBUTING.md
352
+ - Dockerfile
346
353
  - Gemfile
347
- - Gemfile-ruby1.9
348
- - Gemfile-ruby1.9.lock
349
354
  - Guardfile
350
355
  - LICENCE
351
356
  - README.md
352
357
  - Rakefile
353
358
  - bin/flapjack
354
- - bin/flapjack-feed-events
355
- - bin/flapjack-nagios-receiver
356
- - bin/flapjack-nsca-receiver
357
- - bin/flapjack-populator
358
- - bin/flapper
359
- - bin/receive-events
360
- - bin/simulate-failed-check
361
359
  - dist/etc/init.d/flapjack
362
360
  - dist/etc/init.d/flapjack-nagios-receiver
363
361
  - dist/etc/init.d/flapper
@@ -386,6 +384,11 @@ files:
386
384
  - features/support/silent_system.rb
387
385
  - flapjack.gemspec
388
386
  - lib/flapjack.rb
387
+ - lib/flapjack/cli/flapper.rb
388
+ - lib/flapjack/cli/import.rb
389
+ - lib/flapjack/cli/receiver.rb
390
+ - lib/flapjack/cli/server.rb
391
+ - lib/flapjack/cli/simulate.rb
389
392
  - lib/flapjack/configuration.rb
390
393
  - lib/flapjack/coordinator.rb
391
394
  - lib/flapjack/data/alert.rb
@@ -394,7 +397,6 @@ files:
394
397
  - lib/flapjack/data/entity_check.rb
395
398
  - lib/flapjack/data/event.rb
396
399
  - lib/flapjack/data/message.rb
397
- - lib/flapjack/data/migration.rb
398
400
  - lib/flapjack/data/notification.rb
399
401
  - lib/flapjack/data/notification_rule.rb
400
402
  - lib/flapjack/data/semaphore.rb
@@ -406,12 +408,6 @@ files:
406
408
  - lib/flapjack/filters/ok.rb
407
409
  - lib/flapjack/filters/scheduled_maintenance.rb
408
410
  - lib/flapjack/filters/unscheduled_maintenance.rb
409
- - lib/flapjack/gateways/api.rb
410
- - lib/flapjack/gateways/api/contact_methods.rb
411
- - lib/flapjack/gateways/api/entity_check_presenter.rb
412
- - lib/flapjack/gateways/api/entity_methods.rb
413
- - lib/flapjack/gateways/api/entity_presenter.rb
414
- - lib/flapjack/gateways/api/rack/json_params_parser.rb
415
411
  - lib/flapjack/gateways/email.rb
416
412
  - lib/flapjack/gateways/email/alert.html.erb
417
413
  - lib/flapjack/gateways/email/alert.text.erb
@@ -521,11 +517,6 @@ files:
521
517
  - spec/lib/flapjack/filters/ok_spec.rb
522
518
  - spec/lib/flapjack/filters/scheduled_maintenance_spec.rb
523
519
  - spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb
524
- - spec/lib/flapjack/gateways/api/contact_methods_spec.rb
525
- - spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb
526
- - spec/lib/flapjack/gateways/api/entity_methods_spec.rb
527
- - spec/lib/flapjack/gateways/api/entity_presenter_spec.rb
528
- - spec/lib/flapjack/gateways/api_spec.rb
529
520
  - spec/lib/flapjack/gateways/email_spec.rb
530
521
  - spec/lib/flapjack/gateways/jabber_spec.rb
531
522
  - spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb
@@ -553,6 +544,8 @@ files:
553
544
  - spec/spec_helper.rb
554
545
  - spec/support/erb_view_helper.rb
555
546
  - spec/support/jsonapi_helper.rb
547
+ - spec/support/profile_all_formatter.rb
548
+ - spec/support/uncolored_doc_formatter.rb
556
549
  - tasks/benchmarks.rake
557
550
  - tasks/events.rake
558
551
  - tasks/profile.rake
@@ -589,9 +582,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
589
582
  version: '0'
590
583
  required_rubygems_version: !ruby/object:Gem::Requirement
591
584
  requirements:
592
- - - ">="
585
+ - - ">"
593
586
  - !ruby/object:Gem::Version
594
- version: '0'
587
+ version: 1.3.1
595
588
  requirements: []
596
589
  rubyforge_project:
597
590
  rubygems_version: 2.2.2
@@ -636,11 +629,6 @@ test_files:
636
629
  - spec/lib/flapjack/filters/ok_spec.rb
637
630
  - spec/lib/flapjack/filters/scheduled_maintenance_spec.rb
638
631
  - spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb
639
- - spec/lib/flapjack/gateways/api/contact_methods_spec.rb
640
- - spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb
641
- - spec/lib/flapjack/gateways/api/entity_methods_spec.rb
642
- - spec/lib/flapjack/gateways/api/entity_presenter_spec.rb
643
- - spec/lib/flapjack/gateways/api_spec.rb
644
632
  - spec/lib/flapjack/gateways/email_spec.rb
645
633
  - spec/lib/flapjack/gateways/jabber_spec.rb
646
634
  - spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb
@@ -668,3 +656,5 @@ test_files:
668
656
  - spec/spec_helper.rb
669
657
  - spec/support/erb_view_helper.rb
670
658
  - spec/support/jsonapi_helper.rb
659
+ - spec/support/profile_all_formatter.rb
660
+ - spec/support/uncolored_doc_formatter.rb
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 1.9.3-p125
data/Gemfile-ruby1.9 DELETED
@@ -1,28 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :name => 'flapjack'
4
-
5
- group :development do
6
- gem 'ruby-prof'
7
- end
8
-
9
- group :test do
10
- gem 'rspec', '~> 3.0.0.beta1'
11
- gem 'cucumber'
12
- gem 'delorean'
13
- gem 'rack-test'
14
- gem 'async_rack_test', '>= 0.0.5'
15
- gem 'resque_spec'
16
- gem 'webmock'
17
- gem 'guard'
18
- gem 'rb-fsevent'
19
- gem 'guard-rspec'
20
- gem 'guard-cucumber'
21
- gem 'fuubar'
22
- gem 'simplecov', :require => false
23
-
24
- if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
25
- gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools.rb
26
- gem 'perftools.rb'
27
- end
28
- end