flapjack 1.1.0 → 1.2.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +12 -7
- data/CHANGELOG.md +12 -0
- data/Gemfile +6 -2
- data/Gemfile-ruby1.9 +29 -0
- data/Gemfile-ruby1.9.lock +251 -0
- data/README.md +2 -2
- data/Rakefile +1 -0
- data/etc/flapjack_config.yaml.example +2 -2
- data/features/steps/events_steps.rb +2 -2
- data/features/steps/flapjack-netsaint-parser_steps.rb +1 -1
- data/features/support/env.rb +1 -6
- data/lib/flapjack/cli/import.rb +2 -5
- data/lib/flapjack/cli/purge.rb +4 -4
- data/lib/flapjack/cli/receiver.rb +122 -54
- data/lib/flapjack/cli/server.rb +0 -5
- data/lib/flapjack/coordinator.rb +6 -0
- data/lib/flapjack/data/contact.rb +10 -62
- data/lib/flapjack/data/entity.rb +36 -52
- data/lib/flapjack/data/entity_check.rb +90 -21
- data/lib/flapjack/data/event.rb +4 -5
- data/lib/flapjack/data/notification.rb +8 -10
- data/lib/flapjack/data/notification_rule.rb +32 -35
- data/lib/flapjack/data/tagged.rb +48 -0
- data/lib/flapjack/gateways/jabber.rb +4 -5
- data/lib/flapjack/gateways/jsonapi/check_methods.rb +45 -7
- data/lib/flapjack/gateways/jsonapi/check_presenter.rb +1 -1
- data/lib/flapjack/gateways/jsonapi/contact_methods.rb +8 -2
- data/lib/flapjack/gateways/jsonapi/entity_methods.rb +26 -8
- data/lib/flapjack/gateways/jsonapi/medium_methods.rb +13 -9
- data/lib/flapjack/gateways/jsonapi/metrics_methods.rb +2 -2
- data/lib/flapjack/gateways/jsonapi/notification_rule_methods.rb +1 -1
- data/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods.rb +24 -17
- data/lib/flapjack/gateways/jsonapi/rack/json_params_parser.rb +1 -1
- data/lib/flapjack/gateways/jsonapi/report_methods.rb +4 -4
- data/lib/flapjack/gateways/jsonapi.rb +52 -31
- data/lib/flapjack/gateways/oobetet.rb +2 -3
- data/lib/flapjack/gateways/pagerduty.rb +9 -8
- data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +19 -0
- data/lib/flapjack/gateways/web/public/js/flapjack.js +6 -2
- data/lib/flapjack/gateways/web/public/js/modules/contact.js +9 -14
- data/lib/flapjack/gateways/web/public/js/modules/medium.js +1 -0
- data/lib/flapjack/gateways/web/public/js/self_stats.js +1 -1
- data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +3 -3
- data/lib/flapjack/gateways/web.rb +8 -7
- data/lib/flapjack/notifier.rb +2 -4
- data/lib/flapjack/processor.rb +2 -2
- data/lib/flapjack/version.rb +1 -1
- data/lib/flapjack.rb +10 -0
- data/spec/lib/flapjack/coordinator_spec.rb +18 -0
- data/spec/lib/flapjack/data/contact_spec.rb +4 -12
- data/spec/lib/flapjack/data/entity_check_spec.rb +56 -3
- data/spec/lib/flapjack/data/entity_spec.rb +79 -67
- data/spec/lib/flapjack/data/event_spec.rb +78 -78
- data/spec/lib/flapjack/data/notification_rule_spec.rb +4 -2
- data/spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb +94 -11
- data/spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb +84 -0
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +5 -3
- data/spec/lib/flapjack/gateways/web_spec.rb +3 -3
- data/spec/service_consumers/pact_helper.rb +74 -0
- data/spec/service_consumers/pacts/flapjack-diner_v1.0.json +4522 -0
- data/spec/service_consumers/provider_states_for_flapjack-diner.rb +356 -0
- data/spec/spec_helper.rb +0 -8
- data/spec/support/jsonapi_helper.rb +1 -1
- data/tasks/benchmarks.rake +6 -3
- data/tasks/profile.rake +1 -1
- data/tmp/acknowledge.rb +0 -3
- data/tmp/create_event_ok.rb +0 -3
- data/tmp/create_event_unknown.rb +0 -3
- data/tmp/create_events_failure.rb +0 -3
- data/tmp/create_events_ok.rb +0 -3
- data/tmp/create_events_ok_fail_ack_ok.rb +0 -3
- data/tmp/create_events_ok_failure.rb +2 -5
- data/tmp/create_events_ok_failure_ack.rb +0 -3
- data/tmp/test_json_post.rb +4 -3
- data/tmp/test_notification_rules_api.rb +2 -3
- metadata +13 -8
- data/lib/flapjack/data/tag.rb +0 -61
- data/lib/flapjack/data/tag_set.rb +0 -16
- data/spec/lib/flapjack/data/tag_spec.rb +0 -36
@@ -0,0 +1,356 @@
|
|
1
|
+
Pact.provider_states_for "flapjack-diner" do
|
2
|
+
|
3
|
+
provider_state "no contact exists" do
|
4
|
+
tear_down do
|
5
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
6
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
7
|
+
redis.flushdb
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
provider_state "no entity exists" do
|
12
|
+
tear_down do
|
13
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
14
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
15
|
+
redis.flushdb
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
provider_state "no check exists" do
|
20
|
+
tear_down do
|
21
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
22
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
23
|
+
redis.flushdb
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
provider_state "no notification rule exists" do
|
28
|
+
tear_down do
|
29
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
30
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
31
|
+
redis.flushdb
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
provider_state "an entity 'www.example.com' with id '1234' exists" do
|
36
|
+
set_up do
|
37
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
38
|
+
|
39
|
+
entity_data = {'id' => '1234', 'name' => 'www.example.com'}
|
40
|
+
Flapjack::Data::Entity.add(entity_data, :redis => redis)
|
41
|
+
end
|
42
|
+
|
43
|
+
tear_down do
|
44
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
45
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
46
|
+
redis.flushdb
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
provider_state "entities 'www.example.com', id '1234' and 'www2.example.com', id '5678' exist" do
|
51
|
+
set_up do
|
52
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
53
|
+
|
54
|
+
entity_data = {'id' => '1234', 'name' => 'www.example.com'}
|
55
|
+
Flapjack::Data::Entity.add(entity_data, :redis => redis)
|
56
|
+
entity_data_2 = {'id' => '5678', 'name' => 'www2.example.com'}
|
57
|
+
Flapjack::Data::Entity.add(entity_data_2, :redis => redis)
|
58
|
+
end
|
59
|
+
|
60
|
+
tear_down do
|
61
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
62
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
63
|
+
redis.flushdb
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
provider_state "a check 'www.example.com:SSH' exists" do
|
68
|
+
set_up do
|
69
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
70
|
+
|
71
|
+
entity_data = {'id' => '1234', 'name' => 'www.example.com'}
|
72
|
+
Flapjack::Data::Entity.add(entity_data, :redis => redis)
|
73
|
+
check_data = {'entity_id' => '1234', 'name' => 'SSH'}
|
74
|
+
Flapjack::Data::EntityCheck.add(check_data, :redis => redis)
|
75
|
+
end
|
76
|
+
|
77
|
+
tear_down do
|
78
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
79
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
80
|
+
redis.flushdb
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
provider_state "checks 'www.example.com:SSH' and 'www2.example.com:PING' exist" do
|
85
|
+
set_up do
|
86
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
87
|
+
|
88
|
+
entity_data = {'id' => '1234', 'name' => 'www.example.com'}
|
89
|
+
Flapjack::Data::Entity.add(entity_data, :redis => redis)
|
90
|
+
entity_data_2 = {'id' => '5678', 'name' => 'www2.example.com'}
|
91
|
+
Flapjack::Data::Entity.add(entity_data_2, :redis => redis)
|
92
|
+
|
93
|
+
check_data = {'entity_id' => '1234', 'name' => 'SSH'}
|
94
|
+
Flapjack::Data::EntityCheck.add(check_data, :redis => redis)
|
95
|
+
check_data_2 = {'entity_id' => '5678', 'name' => 'PING'}
|
96
|
+
Flapjack::Data::EntityCheck.add(check_data_2, :redis => redis)
|
97
|
+
end
|
98
|
+
|
99
|
+
tear_down do
|
100
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
101
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
102
|
+
redis.flushdb
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
provider_state "a contact with id 'abc' exists" do
|
107
|
+
set_up do
|
108
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
109
|
+
contact_data = {'id' => 'abc',
|
110
|
+
'first_name' => 'Jim',
|
111
|
+
'last_name' => 'Smith',
|
112
|
+
'email' => 'jims@example.com',
|
113
|
+
'timezone' => 'UTC',
|
114
|
+
'tags' => ['admin', 'night_shift']}
|
115
|
+
Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
116
|
+
end
|
117
|
+
|
118
|
+
tear_down do
|
119
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
120
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
121
|
+
redis.flushdb
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
provider_state "a contact with id 'abc' has email and sms media" do
|
126
|
+
set_up do
|
127
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
128
|
+
contact_data = {'id' => 'abc',
|
129
|
+
'first_name' => 'Jim',
|
130
|
+
'last_name' => 'Smith',
|
131
|
+
'email' => 'jims@example.com',
|
132
|
+
'timezone' => 'UTC',
|
133
|
+
'tags' => ['admin', 'night_shift']}
|
134
|
+
contact = Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
135
|
+
|
136
|
+
email_data = {
|
137
|
+
'type' => 'email',
|
138
|
+
'address' => 'ablated@example.org',
|
139
|
+
'interval' => 180,
|
140
|
+
'rollup_threshold' => 3
|
141
|
+
}
|
142
|
+
|
143
|
+
sms_data = {
|
144
|
+
'type' => 'sms',
|
145
|
+
'address' => '0123456789',
|
146
|
+
'interval' => 300,
|
147
|
+
'rollup_threshold' => 5
|
148
|
+
}
|
149
|
+
|
150
|
+
[email_data, sms_data].each do |medium_data|
|
151
|
+
type = medium_data['type']
|
152
|
+
contact.set_address_for_media(type, medium_data['address'])
|
153
|
+
contact.set_interval_for_media(type, medium_data['interval'])
|
154
|
+
contact.set_rollup_threshold_for_media(type, medium_data['rollup_threshold'])
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
tear_down do
|
159
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
160
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
161
|
+
redis.flushdb
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
provider_state "a contact with id '872' exists" do
|
166
|
+
set_up do
|
167
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
168
|
+
contact_data = {'id' => '872', 'first_name' => 'John',
|
169
|
+
'last_name' => 'Smith', 'email' => 'jsmith@example.com'}
|
170
|
+
Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
171
|
+
end
|
172
|
+
|
173
|
+
tear_down do
|
174
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
175
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
176
|
+
redis.flushdb
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
provider_state "contacts with ids 'abc' and '872' exist" do
|
181
|
+
set_up do
|
182
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
183
|
+
contact_data = {'id' => 'abc',
|
184
|
+
'first_name' => 'Jim',
|
185
|
+
'last_name' => 'Smith',
|
186
|
+
'email' => 'jims@example.com',
|
187
|
+
'timezone' => 'UTC',
|
188
|
+
'tags' => ['admin', 'night_shift']}
|
189
|
+
Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
190
|
+
contact_data_2 = {'id' => '872',
|
191
|
+
'first_name' => 'John',
|
192
|
+
'last_name' => 'Smith',
|
193
|
+
'email' => 'jsmith@example.com'}
|
194
|
+
Flapjack::Data::Contact.add(contact_data_2, :redis => redis)
|
195
|
+
end
|
196
|
+
|
197
|
+
tear_down do
|
198
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
199
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
200
|
+
redis.flushdb
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
provider_state "a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' exists" do
|
205
|
+
set_up do
|
206
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
207
|
+
|
208
|
+
contact_data = {'id' => 'abc',
|
209
|
+
'first_name' => 'Jim',
|
210
|
+
'last_name' => 'Smith',
|
211
|
+
'email' => 'jims@example.com',
|
212
|
+
'timezone' => 'UTC',
|
213
|
+
'tags' => ['admin', 'night_shift']}
|
214
|
+
contact = Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
215
|
+
existing_nr = contact.notification_rules.first
|
216
|
+
|
217
|
+
nr_data = {
|
218
|
+
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
219
|
+
:tags => [],
|
220
|
+
:regex_tags => [],
|
221
|
+
:entities => [],
|
222
|
+
:regex_entities => [],
|
223
|
+
:time_restrictions => [],
|
224
|
+
:warning_media => ["email"],
|
225
|
+
:critical_media => ["sms", "email"],
|
226
|
+
:warning_blackhole => false,
|
227
|
+
:critical_blackhole => false
|
228
|
+
}
|
229
|
+
contact.add_notification_rule(nr_data)
|
230
|
+
contact.delete_notification_rule(existing_nr)
|
231
|
+
end
|
232
|
+
|
233
|
+
tear_down do
|
234
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
235
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
236
|
+
redis.flushdb
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
provider_state "a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' and notification rule '20f182fc-6e32-4794-9007-97366d162c51' exists" do
|
241
|
+
set_up do
|
242
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
243
|
+
|
244
|
+
contact_data = {'id' => 'abc',
|
245
|
+
'first_name' => 'Jim',
|
246
|
+
'last_name' => 'Smith',
|
247
|
+
'email' => 'jims@example.com',
|
248
|
+
'timezone' => 'UTC',
|
249
|
+
'tags' => ['admin', 'night_shift']}
|
250
|
+
contact = Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
251
|
+
existing_nr = contact.notification_rules.first
|
252
|
+
|
253
|
+
nr_data = {
|
254
|
+
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
255
|
+
:tags => [],
|
256
|
+
:regex_tags => [],
|
257
|
+
:entities => [],
|
258
|
+
:regex_entities => [],
|
259
|
+
:time_restrictions => [],
|
260
|
+
:warning_media => ["email"],
|
261
|
+
:critical_media => ["sms", "email"],
|
262
|
+
:warning_blackhole => false,
|
263
|
+
:critical_blackhole => false
|
264
|
+
}
|
265
|
+
contact.add_notification_rule(nr_data)
|
266
|
+
|
267
|
+
nr_data_2 = {
|
268
|
+
:id => '20f182fc-6e32-4794-9007-97366d162c51',
|
269
|
+
:tags => ['physical'],
|
270
|
+
:regex_tags => [],
|
271
|
+
:entities => ['example.com'],
|
272
|
+
:regex_entities => [],
|
273
|
+
:time_restrictions => [],
|
274
|
+
:warning_media => ["email"],
|
275
|
+
:critical_media => ["sms", "email"],
|
276
|
+
:warning_blackhole => true,
|
277
|
+
:critical_blackhole => true
|
278
|
+
}
|
279
|
+
contact.add_notification_rule(nr_data_2)
|
280
|
+
contact.delete_notification_rule(existing_nr)
|
281
|
+
end
|
282
|
+
|
283
|
+
tear_down do
|
284
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
285
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
286
|
+
redis.flushdb
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
provider_state "a contact with id 'abc' has pagerduty credentials" do
|
291
|
+
set_up do
|
292
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
293
|
+
contact_data = {'id' => 'abc',
|
294
|
+
'first_name' => 'Jim',
|
295
|
+
'last_name' => 'Smith',
|
296
|
+
'email' => 'jims@example.com',
|
297
|
+
'timezone' => 'UTC',
|
298
|
+
'tags' => ['admin', 'night_shift']}
|
299
|
+
contact = Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
300
|
+
|
301
|
+
pdc_data = {
|
302
|
+
'service_key' => 'abc',
|
303
|
+
'subdomain' => 'def',
|
304
|
+
'username' => 'ghi',
|
305
|
+
'password' => 'jkl',
|
306
|
+
}
|
307
|
+
contact.set_pagerduty_credentials(pdc_data)
|
308
|
+
end
|
309
|
+
|
310
|
+
tear_down do
|
311
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
312
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
313
|
+
redis.flushdb
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
provider_state "contacts with ids 'abc' and '872' have pagerduty credentials" do
|
318
|
+
set_up do
|
319
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
320
|
+
contact_data = {'id' => 'abc',
|
321
|
+
'first_name' => 'Jim',
|
322
|
+
'last_name' => 'Smith',
|
323
|
+
'email' => 'jims@example.com',
|
324
|
+
'timezone' => 'UTC',
|
325
|
+
'tags' => ['admin', 'night_shift']}
|
326
|
+
contact = Flapjack::Data::Contact.add(contact_data, :redis => redis)
|
327
|
+
contact_data_2 = {'id' => '872',
|
328
|
+
'first_name' => 'John',
|
329
|
+
'last_name' => 'Smith',
|
330
|
+
'email' => 'jsmith@example.com'}
|
331
|
+
contact_2 = Flapjack::Data::Contact.add(contact_data_2, :redis => redis)
|
332
|
+
|
333
|
+
pdc_data = {
|
334
|
+
'service_key' => 'abc',
|
335
|
+
'subdomain' => 'def',
|
336
|
+
'username' => 'ghi',
|
337
|
+
'password' => 'jkl',
|
338
|
+
}
|
339
|
+
contact.set_pagerduty_credentials(pdc_data)
|
340
|
+
pdc_data_2 = {
|
341
|
+
'service_key' => 'mno',
|
342
|
+
'subdomain' => 'pqr',
|
343
|
+
'username' => 'stu',
|
344
|
+
'password' => 'vwx',
|
345
|
+
}
|
346
|
+
contact_2.set_pagerduty_credentials(pdc_data_2)
|
347
|
+
end
|
348
|
+
|
349
|
+
tear_down do
|
350
|
+
Flapjack::Gateways::JSONAPI.instance_variable_get('@logger').messages.clear
|
351
|
+
redis = Flapjack::Gateways::JSONAPI.instance_variable_get('@redis')
|
352
|
+
redis.flushdb
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,6 @@ if ENV['COVERAGE']
|
|
4
4
|
add_filter '/spec/'
|
5
5
|
end
|
6
6
|
SimpleCov.at_exit do
|
7
|
-
Oj.default_options = { :mode => :compat }
|
8
7
|
SimpleCov.result.format!
|
9
8
|
end
|
10
9
|
end
|
@@ -19,11 +18,6 @@ ENV['RACK_ENV'] = ENV["FLAPJACK_ENV"]
|
|
19
18
|
require 'bundler'
|
20
19
|
Bundler.require(:default, :test)
|
21
20
|
|
22
|
-
require 'oj'
|
23
|
-
Oj.default_options = { :indent => 0, :mode => :strict }
|
24
|
-
Oj.mimic_JSON
|
25
|
-
require 'active_support/json'
|
26
|
-
|
27
21
|
require 'webmock/rspec'
|
28
22
|
WebMock.disable_net_connect!
|
29
23
|
|
@@ -70,8 +64,6 @@ class MockLogger
|
|
70
64
|
|
71
65
|
end
|
72
66
|
|
73
|
-
|
74
|
-
|
75
67
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
76
68
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
77
69
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
@@ -51,7 +51,7 @@ module JsonapiHelper
|
|
51
51
|
expect(last_response.headers.keys).to include('Access-Control-Allow-Methods')
|
52
52
|
expect(last_response.headers['Access-Control-Allow-Origin']).to eq("*")
|
53
53
|
unless last_response.status == 204
|
54
|
-
expect(
|
54
|
+
expect(Flapjack.load_json(last_response.body)).to be_a(Enumerable)
|
55
55
|
expect(last_response.headers['Content-Type']).to eq(Flapjack::Gateways::JSONAPI::JSONAPI_MEDIA_TYPE)
|
56
56
|
end
|
57
57
|
end
|
data/tasks/benchmarks.rake
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'redis'
|
2
|
-
require 'oj'
|
3
2
|
require 'time'
|
4
3
|
|
5
4
|
# add lib to the default include path
|
@@ -36,7 +35,7 @@ namespace :benchmarks do
|
|
36
35
|
|
37
36
|
desc "nukes the redis db, generates the events, runs and shuts down flapjack, generates perftools reports"
|
38
37
|
task :run => [:setup, :reset_redis, :benchmark, :run_flapjack, :reports] do
|
39
|
-
puts
|
38
|
+
puts Flapjack.dump_json(@benchmark_data, :indent => 2)
|
40
39
|
end
|
41
40
|
|
42
41
|
desc "reset the redis database"
|
@@ -76,7 +75,7 @@ namespace :benchmarks do
|
|
76
75
|
@benchmark_data = { 'events_created' => @events_created,
|
77
76
|
'flapjack_runtime' => @timer_flapjack,
|
78
77
|
'processing_rate' => @events_created.to_f / @timer_flapjack }.merge(@benchmark_parameters)
|
79
|
-
bytes_written = IO.write('artifacts/benchmark_data.json',
|
78
|
+
bytes_written = IO.write('artifacts/benchmark_data.json', Flapjack.dump_json(@benchmark_data, :indent => 2))
|
80
79
|
puts "benchmark data written to artifacts/benchmark_data.json (#{bytes_written} bytes)"
|
81
80
|
|
82
81
|
if system("pprof.rb --text artifacts/flapjack-perftools-cpuprofile > artifacts/flapjack-perftools-cpuprofile.txt")
|
@@ -98,6 +97,10 @@ namespace :benchmarks do
|
|
98
97
|
# - time to failure varies evenly between 1 hour and 1 month
|
99
98
|
# - time to recovery varies evenly between 10 seconds and 1 week
|
100
99
|
task :benchmark do
|
100
|
+
unless RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '8'
|
101
|
+
# Flapjack doesn't support 1.8 or below, so just checking for 1.9 is OK
|
102
|
+
raise "perftools.rb doesn't work on Ruby 2.0 or greater"
|
103
|
+
end
|
101
104
|
|
102
105
|
num_checks_per_entity = (ENV['CHECKS_PER_ENTITY'] || 5).to_i
|
103
106
|
num_entities = (ENV['ENTITIES'] || 100).to_i
|
data/tasks/profile.rake
CHANGED
data/tmp/acknowledge.rb
CHANGED
data/tmp/create_event_ok.rb
CHANGED
data/tmp/create_event_unknown.rb
CHANGED
data/tmp/create_events_ok.rb
CHANGED
@@ -2,14 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'redis'
|
4
4
|
|
5
|
-
require 'oj'
|
6
|
-
Oj.default_options = { :indent => 0, :mode => :compat }
|
7
|
-
|
8
5
|
id = "%.2d" % (1..10).to_a[rand(9)]
|
9
6
|
|
10
7
|
events = []
|
11
8
|
|
12
|
-
events <<
|
9
|
+
events << Flapjack.dump_json({
|
13
10
|
'entity' => "app-#{id}",
|
14
11
|
'check' => 'http',
|
15
12
|
'type' => 'service',
|
@@ -17,7 +14,7 @@ events << Oj.dump({
|
|
17
14
|
'summary' => 'well i don\'t know',
|
18
15
|
})
|
19
16
|
|
20
|
-
events <<
|
17
|
+
events << Flapjack.dump_json({
|
21
18
|
'entity' => "app-#{id}",
|
22
19
|
'check' => 'http',
|
23
20
|
'type' => 'host',
|
data/tmp/test_json_post.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'httparty'
|
4
4
|
|
5
|
-
require '
|
6
|
-
Oj.default_options = { :indent => 0, :mode => :strict }
|
5
|
+
require 'flapjack'
|
7
6
|
|
8
7
|
@payload ={
|
9
8
|
"email" => "phil@gmail.com",
|
@@ -14,5 +13,7 @@ Oj.default_options = { :indent => 0, :mode => :strict }
|
|
14
13
|
"auto_action" => "true"
|
15
14
|
}
|
16
15
|
|
17
|
-
HTTParty.post( 'http://localhost:4091/notification_rules',
|
16
|
+
HTTParty.post( 'http://localhost:4091/notification_rules',
|
17
|
+
:body => Flapjack.dump_json(@payload),
|
18
|
+
:options => { :headers => { 'ContentType' => 'application/json' } })
|
18
19
|
|
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'httparty'
|
4
4
|
|
5
|
-
require '
|
6
|
-
Oj.default_options = { :indent => 0, :mode => :strict }
|
5
|
+
require 'flapjack'
|
7
6
|
|
8
7
|
class Foo
|
9
8
|
|
@@ -155,7 +154,7 @@ class Foo
|
|
155
154
|
do_post(url, data)
|
156
155
|
end
|
157
156
|
|
158
|
-
rule =
|
157
|
+
rule = Flapjack.load_json(get('/contacts/21/notification_rules').body).last
|
159
158
|
rule_id = rule['id']
|
160
159
|
raise RuntimeError unless rule_id
|
161
160
|
puts "****** NOTIFICATION RULE ID TO PICK ON (PUT, DELETE) IS: #{rule_id} ******"
|
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: 1.
|
4
|
+
version: 1.2.0rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: dante
|
@@ -381,6 +381,8 @@ files:
|
|
381
381
|
- CONTRIBUTING.md
|
382
382
|
- Dockerfile
|
383
383
|
- Gemfile
|
384
|
+
- Gemfile-ruby1.9
|
385
|
+
- Gemfile-ruby1.9.lock
|
384
386
|
- Guardfile
|
385
387
|
- LICENCE
|
386
388
|
- README.md
|
@@ -434,8 +436,7 @@ files:
|
|
434
436
|
- lib/flapjack/data/notification.rb
|
435
437
|
- lib/flapjack/data/notification_rule.rb
|
436
438
|
- lib/flapjack/data/semaphore.rb
|
437
|
-
- lib/flapjack/data/
|
438
|
-
- lib/flapjack/data/tag_set.rb
|
439
|
+
- lib/flapjack/data/tagged.rb
|
439
440
|
- lib/flapjack/filters/acknowledgement.rb
|
440
441
|
- lib/flapjack/filters/base.rb
|
441
442
|
- lib/flapjack/filters/delays.rb
|
@@ -553,7 +554,6 @@ files:
|
|
553
554
|
- spec/lib/flapjack/data/notification_rule_spec.rb
|
554
555
|
- spec/lib/flapjack/data/notification_spec.rb
|
555
556
|
- spec/lib/flapjack/data/semaphore_spec.rb
|
556
|
-
- spec/lib/flapjack/data/tag_spec.rb
|
557
557
|
- spec/lib/flapjack/filters/acknowledgement_spec.rb
|
558
558
|
- spec/lib/flapjack/filters/delays_spec.rb
|
559
559
|
- spec/lib/flapjack/filters/ok_spec.rb
|
@@ -585,6 +585,9 @@ files:
|
|
585
585
|
- spec/lib/flapjack/processor_spec.rb
|
586
586
|
- spec/lib/flapjack/redis_pool_spec.rb
|
587
587
|
- spec/lib/flapjack/utility_spec.rb
|
588
|
+
- spec/service_consumers/pact_helper.rb
|
589
|
+
- spec/service_consumers/pacts/flapjack-diner_v1.0.json
|
590
|
+
- spec/service_consumers/provider_states_for_flapjack-diner.rb
|
588
591
|
- spec/spec_helper.rb
|
589
592
|
- spec/support/erb_view_helper.rb
|
590
593
|
- spec/support/jsonapi_helper.rb
|
@@ -631,9 +634,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
631
634
|
version: '0'
|
632
635
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
633
636
|
requirements:
|
634
|
-
- - "
|
637
|
+
- - ">"
|
635
638
|
- !ruby/object:Gem::Version
|
636
|
-
version:
|
639
|
+
version: 1.3.1
|
637
640
|
requirements: []
|
638
641
|
rubyforge_project:
|
639
642
|
rubygems_version: 2.2.2
|
@@ -673,7 +676,6 @@ test_files:
|
|
673
676
|
- spec/lib/flapjack/data/notification_rule_spec.rb
|
674
677
|
- spec/lib/flapjack/data/notification_spec.rb
|
675
678
|
- spec/lib/flapjack/data/semaphore_spec.rb
|
676
|
-
- spec/lib/flapjack/data/tag_spec.rb
|
677
679
|
- spec/lib/flapjack/filters/acknowledgement_spec.rb
|
678
680
|
- spec/lib/flapjack/filters/delays_spec.rb
|
679
681
|
- spec/lib/flapjack/filters/ok_spec.rb
|
@@ -705,6 +707,9 @@ test_files:
|
|
705
707
|
- spec/lib/flapjack/processor_spec.rb
|
706
708
|
- spec/lib/flapjack/redis_pool_spec.rb
|
707
709
|
- spec/lib/flapjack/utility_spec.rb
|
710
|
+
- spec/service_consumers/pact_helper.rb
|
711
|
+
- spec/service_consumers/pacts/flapjack-diner_v1.0.json
|
712
|
+
- spec/service_consumers/provider_states_for_flapjack-diner.rb
|
708
713
|
- spec/spec_helper.rb
|
709
714
|
- spec/support/erb_view_helper.rb
|
710
715
|
- spec/support/jsonapi_helper.rb
|