flapjack 1.6.0 → 2.0.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -6
- data/.gitmodules +1 -1
- data/.rspec +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +12 -13
- data/CHANGELOG.md +2 -9
- data/CONTRIBUTING.md +7 -2
- data/Gemfile +4 -13
- data/LICENCE +1 -0
- data/README.md +8 -2
- data/Rakefile +2 -2
- data/bin/flapjack +3 -12
- data/build.sh +4 -2
- data/etc/flapjack_config.toml.example +273 -0
- data/features/ack_after_sched_maint.feature +18 -21
- data/features/cli.feature +11 -71
- data/features/cli_flapjack-feed-events.feature +14 -15
- data/features/cli_flapjack-nagios-receiver.feature +12 -41
- data/features/cli_flapper.feature +12 -41
- data/features/cli_purge.feature +5 -6
- data/features/cli_receive-events.feature +6 -7
- data/features/cli_simulate-failed-check.feature +5 -6
- data/features/events.feature +206 -181
- data/features/events_check_names.feature +4 -7
- data/features/notification_rules.feature +144 -223
- data/features/notifications.feature +65 -57
- data/features/rollup.feature +45 -47
- data/features/steps/cli_steps.rb +4 -5
- data/features/steps/events_steps.rb +163 -373
- data/features/steps/notifications_steps.rb +408 -264
- data/features/steps/packaging-lintian_steps.rb +0 -4
- data/features/steps/time_travel_steps.rb +0 -26
- data/features/support/daemons.rb +6 -31
- data/features/support/env.rb +65 -74
- data/flapjack.gemspec +22 -24
- data/lib/flapjack.rb +14 -7
- data/lib/flapjack/cli/flapper.rb +74 -173
- data/lib/flapjack/cli/maintenance.rb +278 -109
- data/lib/flapjack/cli/migrate.rb +950 -0
- data/lib/flapjack/cli/purge.rb +19 -22
- data/lib/flapjack/cli/receiver.rb +150 -326
- data/lib/flapjack/cli/server.rb +8 -235
- data/lib/flapjack/cli/simulate.rb +42 -57
- data/lib/flapjack/configuration.rb +51 -37
- data/lib/flapjack/coordinator.rb +138 -129
- data/lib/flapjack/data/acknowledgement.rb +177 -0
- data/lib/flapjack/data/alert.rb +97 -158
- data/lib/flapjack/data/check.rb +611 -0
- data/lib/flapjack/data/condition.rb +70 -0
- data/lib/flapjack/data/contact.rb +226 -456
- data/lib/flapjack/data/event.rb +96 -184
- data/lib/flapjack/data/extensions/associations.rb +59 -0
- data/lib/flapjack/data/extensions/short_name.rb +25 -0
- data/lib/flapjack/data/medium.rb +428 -0
- data/lib/flapjack/data/metrics.rb +194 -0
- data/lib/flapjack/data/notification.rb +22 -281
- data/lib/flapjack/data/rule.rb +473 -0
- data/lib/flapjack/data/scheduled_maintenance.rb +244 -0
- data/lib/flapjack/data/state.rb +221 -0
- data/lib/flapjack/data/statistic.rb +112 -0
- data/lib/flapjack/data/tag.rb +277 -0
- data/lib/flapjack/data/test_notification.rb +182 -0
- data/lib/flapjack/data/unscheduled_maintenance.rb +159 -0
- data/lib/flapjack/data/validators/id_validator.rb +20 -0
- data/lib/flapjack/exceptions.rb +6 -0
- data/lib/flapjack/filters/acknowledgement.rb +23 -16
- data/lib/flapjack/filters/base.rb +0 -5
- data/lib/flapjack/filters/delays.rb +53 -43
- data/lib/flapjack/filters/ok.rb +23 -14
- data/lib/flapjack/filters/scheduled_maintenance.rb +3 -3
- data/lib/flapjack/filters/unscheduled_maintenance.rb +12 -3
- data/lib/flapjack/gateways/aws_sns.rb +65 -49
- data/lib/flapjack/gateways/aws_sns/alert.text.erb +2 -2
- data/lib/flapjack/gateways/aws_sns/alert_subject.text.erb +2 -2
- data/lib/flapjack/gateways/aws_sns/rollup_subject.text.erb +1 -1
- data/lib/flapjack/gateways/email.rb +107 -90
- data/lib/flapjack/gateways/email/alert.html.erb +19 -18
- data/lib/flapjack/gateways/email/alert.text.erb +20 -14
- data/lib/flapjack/gateways/email/alert_subject.text.erb +2 -1
- data/lib/flapjack/gateways/email/rollup.html.erb +14 -13
- data/lib/flapjack/gateways/email/rollup.text.erb +13 -10
- data/lib/flapjack/gateways/jabber.rb +679 -671
- data/lib/flapjack/gateways/jabber/alert.text.erb +9 -6
- data/lib/flapjack/gateways/jsonapi.rb +164 -350
- data/lib/flapjack/gateways/jsonapi/data/join_descriptor.rb +44 -0
- data/lib/flapjack/gateways/jsonapi/data/method_descriptor.rb +21 -0
- data/lib/flapjack/gateways/jsonapi/helpers/headers.rb +63 -0
- data/lib/flapjack/gateways/jsonapi/helpers/miscellaneous.rb +136 -0
- data/lib/flapjack/gateways/jsonapi/helpers/resources.rb +227 -0
- data/lib/flapjack/gateways/jsonapi/helpers/serialiser.rb +313 -0
- data/lib/flapjack/gateways/jsonapi/helpers/swagger_docs.rb +322 -0
- data/lib/flapjack/gateways/jsonapi/methods/association_delete.rb +115 -0
- data/lib/flapjack/gateways/jsonapi/methods/association_get.rb +288 -0
- data/lib/flapjack/gateways/jsonapi/methods/association_patch.rb +178 -0
- data/lib/flapjack/gateways/jsonapi/methods/association_post.rb +116 -0
- data/lib/flapjack/gateways/jsonapi/methods/metrics.rb +71 -0
- data/lib/flapjack/gateways/jsonapi/methods/resource_delete.rb +119 -0
- data/lib/flapjack/gateways/jsonapi/methods/resource_get.rb +186 -0
- data/lib/flapjack/gateways/jsonapi/methods/resource_patch.rb +239 -0
- data/lib/flapjack/gateways/jsonapi/methods/resource_post.rb +197 -0
- data/lib/flapjack/gateways/jsonapi/middleware/array_param_fixer.rb +27 -0
- data/lib/flapjack/gateways/jsonapi/{rack → middleware}/json_params_parser.rb +7 -6
- data/lib/flapjack/gateways/jsonapi/middleware/request_timestamp.rb +18 -0
- data/lib/flapjack/gateways/oobetet.rb +222 -170
- data/lib/flapjack/gateways/pager_duty.rb +388 -0
- data/lib/flapjack/gateways/pager_duty/alert.text.erb +13 -0
- data/lib/flapjack/gateways/slack.rb +56 -48
- data/lib/flapjack/gateways/slack/alert.text.erb +1 -1
- data/lib/flapjack/gateways/slack/rollup.text.erb +1 -1
- data/lib/flapjack/gateways/sms_aspsms.rb +155 -0
- data/lib/flapjack/gateways/sms_aspsms/alert.text.erb +7 -0
- data/lib/flapjack/gateways/sms_aspsms/rollup.text.erb +2 -0
- data/lib/flapjack/gateways/sms_messagenet.rb +77 -57
- data/lib/flapjack/gateways/sms_messagenet/alert.text.erb +3 -2
- data/lib/flapjack/gateways/sms_nexmo.rb +53 -51
- data/lib/flapjack/gateways/sms_nexmo/alert.text.erb +2 -2
- data/lib/flapjack/gateways/sms_nexmo/rollup.text.erb +1 -1
- data/lib/flapjack/gateways/sms_twilio.rb +79 -62
- data/lib/flapjack/gateways/sms_twilio/alert.text.erb +3 -2
- data/lib/flapjack/gateways/web.rb +437 -345
- data/lib/flapjack/gateways/web/middleware/request_timestamp.rb +18 -0
- data/lib/flapjack/gateways/web/public/css/bootstrap.css +3793 -4340
- data/lib/flapjack/gateways/web/public/css/bootstrap.css.map +1 -0
- data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.svg +273 -214
- data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/lib/flapjack/gateways/web/public/js/bootstrap.js +1637 -1607
- data/lib/flapjack/gateways/web/public/js/self_stats.js +1 -2
- data/lib/flapjack/gateways/web/views/_pagination.html.erb +19 -0
- data/lib/flapjack/gateways/web/views/check.html.erb +159 -121
- data/lib/flapjack/gateways/web/views/checks.html.erb +82 -41
- data/lib/flapjack/gateways/web/views/contact.html.erb +59 -71
- data/lib/flapjack/gateways/web/views/contacts.html.erb +32 -8
- data/lib/flapjack/gateways/web/views/index.html.erb +2 -2
- data/lib/flapjack/gateways/web/views/{layout.erb → layout.html.erb} +7 -23
- data/lib/flapjack/gateways/web/views/self_stats.html.erb +32 -33
- data/lib/flapjack/gateways/web/views/tag.html.erb +32 -0
- data/lib/flapjack/gateways/web/views/tags.html.erb +51 -0
- data/lib/flapjack/logger.rb +34 -3
- data/lib/flapjack/notifier.rb +180 -112
- data/lib/flapjack/patches.rb +8 -63
- data/lib/flapjack/pikelet.rb +185 -143
- data/lib/flapjack/processor.rb +323 -191
- data/lib/flapjack/record_queue.rb +33 -0
- data/lib/flapjack/redis_proxy.rb +66 -0
- data/lib/flapjack/utility.rb +21 -15
- data/lib/flapjack/version.rb +2 -1
- data/libexec/httpbroker.go +218 -14
- data/libexec/oneoff.go +13 -10
- data/spec/lib/flapjack/configuration_spec.rb +286 -0
- data/spec/lib/flapjack/coordinator_spec.rb +103 -157
- data/spec/lib/flapjack/data/check_spec.rb +175 -0
- data/spec/lib/flapjack/data/contact_spec.rb +26 -349
- data/spec/lib/flapjack/data/event_spec.rb +76 -291
- data/spec/lib/flapjack/data/medium_spec.rb +19 -0
- data/spec/lib/flapjack/data/rule_spec.rb +43 -0
- data/spec/lib/flapjack/data/scheduled_maintenance_spec.rb +976 -0
- data/spec/lib/flapjack/data/unscheduled_maintenance_spec.rb +34 -0
- data/spec/lib/flapjack/gateways/aws_sns_spec.rb +111 -60
- data/spec/lib/flapjack/gateways/email_spec.rb +194 -161
- data/spec/lib/flapjack/gateways/jabber_spec.rb +961 -162
- data/spec/lib/flapjack/gateways/jsonapi/methods/check_links_spec.rb +155 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/checks_spec.rb +426 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/contact_links_spec.rb +217 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/contacts_spec.rb +425 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/events_spec.rb +271 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/media_spec.rb +257 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/medium_links_spec.rb +163 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/metrics_spec.rb +8 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/rule_links_spec.rb +212 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/rules_spec.rb +289 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/scheduled_maintenance_links_spec.rb +49 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/scheduled_maintenances_spec.rb +242 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/tag_links_spec.rb +274 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/tags_spec.rb +302 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/unscheduled_maintenance_links_spec.rb +49 -0
- data/spec/lib/flapjack/gateways/jsonapi/methods/unscheduled_maintenances_spec.rb +339 -0
- data/spec/lib/flapjack/gateways/jsonapi_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/oobetet_spec.rb +151 -79
- data/spec/lib/flapjack/gateways/pager_duty_spec.rb +353 -0
- data/spec/lib/flapjack/gateways/slack_spec.rb +53 -53
- data/spec/lib/flapjack/gateways/sms_aspsms_spec.rb +106 -0
- data/spec/lib/flapjack/gateways/sms_messagenet_spec.rb +111 -54
- data/spec/lib/flapjack/gateways/sms_nexmo_spec.rb +50 -51
- data/spec/lib/flapjack/gateways/sms_twilio_spec.rb +108 -48
- data/spec/lib/flapjack/gateways/web_spec.rb +144 -216
- data/spec/lib/flapjack/notifier_spec.rb +132 -1
- data/spec/lib/flapjack/pikelet_spec.rb +111 -50
- data/spec/lib/flapjack/processor_spec.rb +210 -40
- data/spec/lib/flapjack/redis_proxy_spec.rb +45 -0
- data/spec/lib/flapjack/utility_spec.rb +11 -15
- data/spec/service_consumers/fixture_data.rb +547 -0
- data/spec/service_consumers/pact_helper.rb +21 -32
- data/spec/service_consumers/pacts/flapjack-diner_v2.0.json +4652 -0
- data/spec/service_consumers/provider_states_for_flapjack-diner.rb +279 -322
- data/spec/service_consumers/provider_support.rb +8 -0
- data/spec/spec_helper.rb +34 -44
- data/spec/support/erb_view_helper.rb +1 -1
- data/spec/support/factories.rb +58 -0
- data/spec/support/jsonapi_helper.rb +15 -26
- data/spec/support/mock_logger.rb +43 -0
- data/spec/support/xmpp_comparable.rb +24 -0
- data/src/flapjack/transport_test.go +30 -1
- data/tasks/dump_keys.rake +82 -0
- data/tasks/events.rake +7 -7
- data/tasks/support/flapjack_config_benchmark.toml +28 -0
- data/tasks/support/flapjack_config_benchmark.yaml +0 -2
- metadata +175 -222
- data/Guardfile +0 -14
- data/etc/flapjack_config.yaml.example +0 -477
- data/features/cli_flapjack-populator.feature +0 -90
- data/features/support/silent_system.rb +0 -4
- data/lib/flapjack/cli/import.rb +0 -108
- data/lib/flapjack/data/entity.rb +0 -652
- data/lib/flapjack/data/entity_check.rb +0 -1044
- data/lib/flapjack/data/message.rb +0 -56
- data/lib/flapjack/data/migration.rb +0 -234
- data/lib/flapjack/data/notification_rule.rb +0 -425
- data/lib/flapjack/data/semaphore.rb +0 -44
- data/lib/flapjack/data/tagged.rb +0 -48
- data/lib/flapjack/gateways/jsonapi/check_methods.rb +0 -206
- data/lib/flapjack/gateways/jsonapi/check_presenter.rb +0 -221
- data/lib/flapjack/gateways/jsonapi/contact_methods.rb +0 -186
- data/lib/flapjack/gateways/jsonapi/entity_methods.rb +0 -223
- data/lib/flapjack/gateways/jsonapi/medium_methods.rb +0 -185
- data/lib/flapjack/gateways/jsonapi/metrics_methods.rb +0 -132
- data/lib/flapjack/gateways/jsonapi/notification_rule_methods.rb +0 -141
- data/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods.rb +0 -139
- data/lib/flapjack/gateways/jsonapi/report_methods.rb +0 -146
- data/lib/flapjack/gateways/pagerduty.rb +0 -318
- data/lib/flapjack/gateways/pagerduty/alert.text.erb +0 -10
- data/lib/flapjack/gateways/web/public/css/select2-bootstrap.css +0 -87
- data/lib/flapjack/gateways/web/public/css/select2.css +0 -615
- data/lib/flapjack/gateways/web/public/css/tablesort.css +0 -67
- data/lib/flapjack/gateways/web/public/img/select2-spinner.gif +0 -0
- data/lib/flapjack/gateways/web/public/img/select2.png +0 -0
- data/lib/flapjack/gateways/web/public/img/select2x2.png +0 -0
- data/lib/flapjack/gateways/web/public/js/backbone.js +0 -1581
- data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +0 -322
- data/lib/flapjack/gateways/web/public/js/flapjack.js +0 -82
- data/lib/flapjack/gateways/web/public/js/jquery.tablesorter.js +0 -1640
- data/lib/flapjack/gateways/web/public/js/jquery.tablesorter.widgets.js +0 -1390
- data/lib/flapjack/gateways/web/public/js/modules/contact.js +0 -520
- data/lib/flapjack/gateways/web/public/js/modules/entity.js +0 -28
- data/lib/flapjack/gateways/web/public/js/modules/medium.js +0 -40
- data/lib/flapjack/gateways/web/public/js/select2.js +0 -3397
- data/lib/flapjack/gateways/web/public/js/tablesort.js +0 -44
- data/lib/flapjack/gateways/web/public/js/underscore.js +0 -1276
- data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +0 -173
- data/lib/flapjack/gateways/web/views/entities.html.erb +0 -30
- data/lib/flapjack/gateways/web/views/entity.html.erb +0 -51
- data/lib/flapjack/rack_logger.rb +0 -47
- data/lib/flapjack/redis_pool.rb +0 -42
- data/spec/lib/flapjack/data/entity_check_spec.rb +0 -1418
- data/spec/lib/flapjack/data/entity_spec.rb +0 -872
- data/spec/lib/flapjack/data/message_spec.rb +0 -30
- data/spec/lib/flapjack/data/migration_spec.rb +0 -104
- data/spec/lib/flapjack/data/notification_rule_spec.rb +0 -232
- data/spec/lib/flapjack/data/notification_spec.rb +0 -53
- data/spec/lib/flapjack/data/semaphore_spec.rb +0 -24
- data/spec/lib/flapjack/filters/acknowledgement_spec.rb +0 -6
- data/spec/lib/flapjack/filters/delays_spec.rb +0 -6
- data/spec/lib/flapjack/filters/ok_spec.rb +0 -6
- data/spec/lib/flapjack/filters/scheduled_maintenance_spec.rb +0 -6
- data/spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb +0 -6
- data/spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb +0 -315
- data/spec/lib/flapjack/gateways/jsonapi/check_presenter_spec.rb +0 -223
- data/spec/lib/flapjack/gateways/jsonapi/contact_methods_spec.rb +0 -131
- data/spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb +0 -389
- data/spec/lib/flapjack/gateways/jsonapi/medium_methods_spec.rb +0 -231
- data/spec/lib/flapjack/gateways/jsonapi/notification_rule_methods_spec.rb +0 -169
- data/spec/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods_spec.rb +0 -114
- data/spec/lib/flapjack/gateways/jsonapi/report_methods_spec.rb +0 -590
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +0 -249
- data/spec/lib/flapjack/gateways/web/views/check.html.erb_spec.rb +0 -21
- data/spec/lib/flapjack/gateways/web/views/contact.html.erb_spec.rb +0 -24
- data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +0 -16
- data/spec/lib/flapjack/redis_pool_spec.rb +0 -29
- data/spec/service_consumers/pacts/flapjack-diner_v1.0.json +0 -4702
- data/tasks/entities.rake +0 -151
- data/tasks/profile.rake +0 -282
- data/tmp/acknowledge.rb +0 -13
- data/tmp/create_config_yaml.rb +0 -16
- data/tmp/create_event_ok.rb +0 -30
- data/tmp/create_event_unknown.rb +0 -30
- data/tmp/create_events_failure.rb +0 -34
- data/tmp/create_events_ok.rb +0 -32
- data/tmp/create_events_ok_fail_ack_ok.rb +0 -53
- data/tmp/create_events_ok_failure.rb +0 -41
- data/tmp/create_events_ok_failure_ack.rb +0 -53
- data/tmp/dummy_contacts.json +0 -43
- data/tmp/dummy_entities.json +0 -37
- data/tmp/generate_nagios_test_hosts.rb +0 -16
- data/tmp/notification_rules.rb +0 -73
- data/tmp/parse_config_yaml.rb +0 -7
- data/tmp/redis_find_spurious_unknown_states.rb +0 -52
- data/tmp/test_json_post.rb +0 -19
- data/tmp/test_notification_rules_api.rb +0 -171
@@ -1,872 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack/data/entity'
|
3
|
-
|
4
|
-
describe Flapjack::Data::Entity, :redis => true do
|
5
|
-
|
6
|
-
let(:name) { 'abc-123' }
|
7
|
-
let(:check) { 'ping' }
|
8
|
-
|
9
|
-
it "creates an entity if allowed when it can't find it" do
|
10
|
-
entity = Flapjack::Data::Entity.find_by_name(name, :redis => @redis, :create => true)
|
11
|
-
|
12
|
-
expect(entity).not_to be_nil
|
13
|
-
expect(entity.name).to eq(name)
|
14
|
-
expect(@redis.hget('all_entity_ids_by_name', name)).to match(/^\S+$/)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'creates tags if passed when added' do
|
18
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
19
|
-
'name' => name,
|
20
|
-
'tags' => ['database', 'virtual']},
|
21
|
-
:redis => @redis)
|
22
|
-
|
23
|
-
entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
|
24
|
-
expect(entity).not_to be_nil
|
25
|
-
expect(entity.tags).to eq(Set.new(['database', 'virtual']))
|
26
|
-
end
|
27
|
-
|
28
|
-
it "adds a registered contact with an entity" do
|
29
|
-
Flapjack::Data::Contact.add({'id' => '362',
|
30
|
-
'first_name' => 'John',
|
31
|
-
'last_name' => 'Johnson',
|
32
|
-
'email' => 'johnj@example.com' },
|
33
|
-
:redis => @redis)
|
34
|
-
|
35
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
36
|
-
'name' => name,
|
37
|
-
'contacts' => ['362']},
|
38
|
-
:redis => @redis)
|
39
|
-
|
40
|
-
entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
|
41
|
-
expect(entity).not_to be_nil
|
42
|
-
contacts = entity.contacts
|
43
|
-
expect(contacts).not_to be_nil
|
44
|
-
expect(contacts).to be_an(Array)
|
45
|
-
expect(contacts.size).to eq(1)
|
46
|
-
expect(contacts.first.name).to eq('John Johnson')
|
47
|
-
end
|
48
|
-
|
49
|
-
it "does not add a registered contact with an entity if the contact is unknown" do
|
50
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
51
|
-
'name' => name,
|
52
|
-
'contacts' => ['362']},
|
53
|
-
:redis => @redis)
|
54
|
-
|
55
|
-
entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
|
56
|
-
expect(entity).not_to be_nil
|
57
|
-
contacts = entity.contacts
|
58
|
-
expect(contacts).not_to be_nil
|
59
|
-
expect(contacts).to be_an(Array)
|
60
|
-
expect(contacts).to be_empty
|
61
|
-
end
|
62
|
-
|
63
|
-
it "finds an entity by id" do
|
64
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
65
|
-
'name' => name},
|
66
|
-
:redis => @redis)
|
67
|
-
|
68
|
-
entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
|
69
|
-
expect(entity).not_to be_nil
|
70
|
-
expect(entity.name).to eq(name)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "finds an entity by name" do
|
74
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
75
|
-
'name' => name},
|
76
|
-
:redis => @redis)
|
77
|
-
|
78
|
-
entity = Flapjack::Data::Entity.find_by_name(name, :redis => @redis)
|
79
|
-
expect(entity).not_to be_nil
|
80
|
-
expect(entity.id).to eq('5000')
|
81
|
-
end
|
82
|
-
|
83
|
-
it "returns an empty list when asked for all entities, if there are no entities" do
|
84
|
-
entities = Flapjack::Data::Entity.all(:redis => @redis)
|
85
|
-
expect(entities).not_to be_nil
|
86
|
-
expect(entities).to be_an(Array)
|
87
|
-
expect(entities.size).to eq(0)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "returns a list of all entities" do
|
91
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
92
|
-
'name' => name},
|
93
|
-
:redis => @redis)
|
94
|
-
Flapjack::Data::Entity.add({'id' => '5001',
|
95
|
-
'name' => "z_" + name},
|
96
|
-
:redis => @redis)
|
97
|
-
|
98
|
-
entities = Flapjack::Data::Entity.all(:redis => @redis)
|
99
|
-
expect(entities).not_to be_nil
|
100
|
-
expect(entities).to be_an(Array)
|
101
|
-
expect(entities.size).to eq(2)
|
102
|
-
expect(entities[0].id).to eq('5000')
|
103
|
-
expect(entities[1].id).to eq('5001')
|
104
|
-
end
|
105
|
-
|
106
|
-
it "returns a list of checks for an entity" do
|
107
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
108
|
-
'name' => name},
|
109
|
-
:redis => @redis)
|
110
|
-
|
111
|
-
@redis.zadd("current_checks:#{name}", Time.now.to_i, "ping")
|
112
|
-
@redis.zadd("current_checks:#{name}", Time.now.to_i, "ssh")
|
113
|
-
|
114
|
-
entity = Flapjack::Data::Entity.find_by_name(name, :redis => @redis)
|
115
|
-
check_list = entity.check_list
|
116
|
-
expect(check_list).not_to be_nil
|
117
|
-
expect(check_list.size).to eq(2)
|
118
|
-
sorted_list = check_list.sort
|
119
|
-
expect(sorted_list[0]).to eq('ping')
|
120
|
-
expect(sorted_list[1]).to eq('ssh')
|
121
|
-
end
|
122
|
-
|
123
|
-
it "returns a count of checks for an entity" do
|
124
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
125
|
-
'name' => name,
|
126
|
-
'contacts' => []},
|
127
|
-
:redis => @redis)
|
128
|
-
|
129
|
-
@redis.zadd("current_checks:#{name}", Time.now.to_i, "ping")
|
130
|
-
@redis.zadd("current_checks:#{name}", Time.now.to_i, "ssh")
|
131
|
-
|
132
|
-
entity = Flapjack::Data::Entity.find_by_id(5000, :redis => @redis)
|
133
|
-
check_count = entity.check_count
|
134
|
-
expect(check_count).not_to be_nil
|
135
|
-
expect(check_count).to eq(2)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "finds entity names matching a pattern" do
|
139
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
140
|
-
'name' => 'abc-123',
|
141
|
-
'contacts' => []},
|
142
|
-
:redis => @redis)
|
143
|
-
|
144
|
-
Flapjack::Data::Entity.add({'id' => '5001',
|
145
|
-
'name' => 'def-456',
|
146
|
-
'contacts' => []},
|
147
|
-
:redis => @redis)
|
148
|
-
|
149
|
-
entities = Flapjack::Data::Entity.find_all_name_matching('abc', :redis => @redis)
|
150
|
-
expect(entities).not_to be_nil
|
151
|
-
expect(entities).to be_an(Array)
|
152
|
-
expect(entities.size).to eq(1)
|
153
|
-
expect(entities.first).to eq('abc-123')
|
154
|
-
end
|
155
|
-
|
156
|
-
it "adds tags to entities" do
|
157
|
-
entity = Flapjack::Data::Entity.add({'id' => '5000',
|
158
|
-
'name' => 'abc-123',
|
159
|
-
'contacts' => []},
|
160
|
-
:redis => @redis)
|
161
|
-
|
162
|
-
entity.add_tags('source:foobar', 'foo')
|
163
|
-
|
164
|
-
expect(entity).not_to be_nil
|
165
|
-
expect(entity).to be_an(Flapjack::Data::Entity)
|
166
|
-
expect(entity.name).to eq('abc-123')
|
167
|
-
expect(entity.tags).to include("source:foobar")
|
168
|
-
expect(entity.tags).to include("foo")
|
169
|
-
|
170
|
-
# and test the tags as read back from redis
|
171
|
-
entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
|
172
|
-
expect(entity.tags).to include("source:foobar")
|
173
|
-
expect(entity.tags).to include("foo")
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
it "deletes tags from entities" do
|
178
|
-
entity = Flapjack::Data::Entity.add({'id' => '5000',
|
179
|
-
'name' => 'abc-123',
|
180
|
-
'contacts' => []},
|
181
|
-
:redis => @redis)
|
182
|
-
|
183
|
-
entity.add_tags('source:foobar', 'foo')
|
184
|
-
|
185
|
-
expect(entity).not_to be_nil
|
186
|
-
expect(entity.tags).to include("source:foobar")
|
187
|
-
expect(entity.tags).to include("foo")
|
188
|
-
|
189
|
-
entity.delete_tags('source:foobar')
|
190
|
-
|
191
|
-
expect(entity.tags).not_to include("source:foobar")
|
192
|
-
expect(entity.tags).to include("foo")
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
context 'renaming and merging' do
|
197
|
-
|
198
|
-
let(:time_i) { Time.now.to_i }
|
199
|
-
|
200
|
-
let(:sha1) { Digest::SHA1.new }
|
201
|
-
let(:hash_name1) { Digest.hexencode(sha1.digest('name1:PING'))[0..7].downcase }
|
202
|
-
let(:hash_name2) { Digest.hexencode(sha1.digest('name2:PING'))[0..7].downcase }
|
203
|
-
|
204
|
-
def add_name1
|
205
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
206
|
-
'name' => 'name1',
|
207
|
-
'contacts' => ['362']},
|
208
|
-
:redis => @redis)
|
209
|
-
end
|
210
|
-
|
211
|
-
def add_name2
|
212
|
-
Flapjack::Data::Entity.add({'id' => '5000',
|
213
|
-
'name' => 'name2',
|
214
|
-
'contacts' => ['362']},
|
215
|
-
:redis => @redis)
|
216
|
-
end
|
217
|
-
|
218
|
-
before(:each) do
|
219
|
-
Flapjack::Data::Contact.add({'id' => '362',
|
220
|
-
'first_name' => 'John',
|
221
|
-
'last_name' => 'Johnson',
|
222
|
-
'email' => 'johnj@example.com' },
|
223
|
-
:redis => @redis)
|
224
|
-
end
|
225
|
-
|
226
|
-
context 'check that rename and merge are called by add'
|
227
|
-
|
228
|
-
context 'entity renaming on #add' do
|
229
|
-
|
230
|
-
let(:time_i) { Time.now.to_i }
|
231
|
-
|
232
|
-
let(:sha1) { Digest::SHA1.new }
|
233
|
-
let(:hash_name1) { Digest.hexencode(sha1.digest('name1:PING'))[0..7].downcase }
|
234
|
-
let(:hash_name2) { Digest.hexencode(sha1.digest('name2:PING'))[0..7].downcase }
|
235
|
-
|
236
|
-
before(:each) do
|
237
|
-
add_name1
|
238
|
-
end
|
239
|
-
|
240
|
-
it 'renames the "entity name to id lookup" and the name in the "entity hash by id"' do
|
241
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name1')).to eq('5000')
|
242
|
-
expect(@redis.hget('all_entity_names_by_id', '5000')).to eq('name1')
|
243
|
-
|
244
|
-
add_name2
|
245
|
-
|
246
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name1')).to be_nil
|
247
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name2')).to eq('5000')
|
248
|
-
expect(@redis.hget('all_entity_names_by_id', '5000')).to eq('name2')
|
249
|
-
end
|
250
|
-
|
251
|
-
it 'does not rename an entity if an entity with the new name already exists' do
|
252
|
-
Flapjack::Data::Entity.add({'id' => '5001',
|
253
|
-
'name' => 'name2',
|
254
|
-
'contacts' => []},
|
255
|
-
:redis => @redis)
|
256
|
-
|
257
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name1')).to eq('5000')
|
258
|
-
expect(@redis.hget('all_entity_names_by_id', '5000')).to eq('name1')
|
259
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name2')).to eq('5001')
|
260
|
-
expect(@redis.hget('all_entity_names_by_id', '5001')).to eq('name2')
|
261
|
-
|
262
|
-
add_name2
|
263
|
-
|
264
|
-
# no change
|
265
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name1')).to eq('5000')
|
266
|
-
expect(@redis.hget('all_entity_names_by_id', '5000')).to eq('name1')
|
267
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name2')).to eq('5001')
|
268
|
-
expect(@redis.hget('all_entity_names_by_id', '5001')).to eq('name2')
|
269
|
-
end
|
270
|
-
|
271
|
-
it 'renames current check state' do
|
272
|
-
data = {'state' => 'critical', 'last_change' => time_i.to_s, 'last_update' => time_i.to_s}
|
273
|
-
@redis.mapped_hmset('check:name1:PING', data)
|
274
|
-
|
275
|
-
add_name2
|
276
|
-
|
277
|
-
expect(@redis.hgetall('check:name1:PING')).to eq({})
|
278
|
-
expect(@redis.hgetall('check:name2:PING')).to eq(data)
|
279
|
-
end
|
280
|
-
|
281
|
-
it 'renames stored check state changes' do
|
282
|
-
@redis.rpush('name1:PING:states', time_i)
|
283
|
-
@redis.set("name1:PING:#{time_i}:state", 'critical')
|
284
|
-
@redis.set("name1:PING:#{time_i}:summary", 'bad')
|
285
|
-
@redis.zadd('name1:PING:sorted_state_timestamps', time_i, time_i)
|
286
|
-
|
287
|
-
add_name2
|
288
|
-
|
289
|
-
expect(@redis.type('name1:PING:states')).to eq('none')
|
290
|
-
expect(@redis.type('name2:PING:states')).to eq('list')
|
291
|
-
expect(@redis.lindex('name2:PING:states', 0)).to eq(time_i.to_s)
|
292
|
-
expect(@redis.get("name1:PING:#{time_i}:state")).to be_nil
|
293
|
-
expect(@redis.get("name2:PING:#{time_i}:state")).to eq('critical')
|
294
|
-
expect(@redis.get("name1:PING:#{time_i}:summary")).to be_nil
|
295
|
-
expect(@redis.get("name2:PING:#{time_i}:summary")).to eq('bad')
|
296
|
-
expect(@redis.zrange("name1:PING:sorted_state_timestamps", 0, -1, :with_scores => true)).to eq([])
|
297
|
-
expect(@redis.zrange("name2:PING:sorted_state_timestamps", 0, -1, :with_scores => true)).to eq([[time_i.to_s, time_i.to_f]])
|
298
|
-
end
|
299
|
-
|
300
|
-
it 'renames stored action events' do
|
301
|
-
@redis.hset('name1:PING:actions', time_i.to_s, 'acknowledgement')
|
302
|
-
|
303
|
-
add_name2
|
304
|
-
|
305
|
-
expect(@redis.hget('name1:PING:actions', time_i.to_s)).to be_nil
|
306
|
-
expect(@redis.hget('name2:PING:actions', time_i.to_s)).to eq('acknowledgement')
|
307
|
-
end
|
308
|
-
|
309
|
-
it 'renames entries in the sorted set of failing checks' do
|
310
|
-
data = {'state' => 'critical', 'last_change' => time_i.to_s, 'last_update' => time_i.to_s}
|
311
|
-
@redis.mapped_hmset('check:name1:PING', data)
|
312
|
-
|
313
|
-
@redis.zadd('failed_checks', time_i, 'name1:PING')
|
314
|
-
|
315
|
-
add_name2
|
316
|
-
|
317
|
-
expect(@redis.zrange('failed_checks', 0, -1, :with_scores => true)).to eq([['name2:PING', time_i.to_f]])
|
318
|
-
end
|
319
|
-
|
320
|
-
it 'renames the list of current checks, and its entries' do
|
321
|
-
@redis.zadd('current_checks:name1', time_i, 'PING')
|
322
|
-
|
323
|
-
add_name2
|
324
|
-
|
325
|
-
expect(@redis.zrange('current_checks:name1', 0, -1, :with_scores => true)).to eq([])
|
326
|
-
expect(@redis.zrange('current_checks:name2', 0, -1, :with_scores => true)).to eq([['PING', time_i.to_f]])
|
327
|
-
end
|
328
|
-
|
329
|
-
it 'renames an entry in the list of current entities' do
|
330
|
-
@redis.zadd('current_entities', time_i, 'name1')
|
331
|
-
|
332
|
-
add_name2
|
333
|
-
|
334
|
-
expect(@redis.zrange('current_entities', 0, -1, :with_scores => true)).to eq([['name2', time_i.to_f]])
|
335
|
-
end
|
336
|
-
|
337
|
-
it 'renames a current unscheduled maintenance key' do
|
338
|
-
@redis.setex('name1:PING:unscheduled_maintenance', 30, time_i)
|
339
|
-
|
340
|
-
add_name2
|
341
|
-
|
342
|
-
expect(@redis.get('name1:PING:unscheduled_maintenance')).to be_nil
|
343
|
-
expect(@redis.get('name2:PING:unscheduled_maintenance')).to eq(time_i.to_s)
|
344
|
-
expect(@redis.ttl('name2:PING:unscheduled_maintenance')).to be <= 30
|
345
|
-
end
|
346
|
-
|
347
|
-
it 'renames stored unscheduled maintenance periods and sorted timestamps' do
|
348
|
-
@redis.zadd('name1:PING:unscheduled_maintenances', 30, time_i)
|
349
|
-
@redis.set("name1:PING:#{time_i}:unscheduled_maintenance:summary", 'really bad')
|
350
|
-
@redis.zadd('name1:PING:sorted_unscheduled_maintenance_timestamps', time_i, time_i)
|
351
|
-
|
352
|
-
add_name2
|
353
|
-
|
354
|
-
expect(@redis.zrange('name1:PING:unscheduled_maintenances', 0, -1, :with_scores => true)).to eq([])
|
355
|
-
expect(@redis.zrange('name2:PING:unscheduled_maintenances', 0, -1, :with_scores => true)).to eq([[time_i.to_s, 30.0]])
|
356
|
-
expect(@redis.get("name1:PING:#{time_i}:unscheduled_maintenance:summary")).to be_nil
|
357
|
-
expect(@redis.get("name2:PING:#{time_i}:unscheduled_maintenance:summary")).to eq('really bad')
|
358
|
-
expect(@redis.zrange('name1:PING:sorted_unscheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq([])
|
359
|
-
expect(@redis.zrange('name2:PING:sorted_unscheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq([[time_i.to_s, time_i.to_f]])
|
360
|
-
end
|
361
|
-
|
362
|
-
it 'renames a current scheduled maintenance key' do
|
363
|
-
@redis.setex('name1:PING:scheduled_maintenance', 30, time_i)
|
364
|
-
|
365
|
-
add_name2
|
366
|
-
|
367
|
-
expect(@redis.get('name1:PING:scheduled_maintenance')).to be_nil
|
368
|
-
expect(@redis.get('name2:PING:scheduled_maintenance')).to eq(time_i.to_s)
|
369
|
-
expect(@redis.ttl('name2:PING:scheduled_maintenance')).to be <= 30
|
370
|
-
end
|
371
|
-
|
372
|
-
it 'renames stored scheduled maintenance periods and sorted timestamps' do
|
373
|
-
@redis.zadd('name1:PING:scheduled_maintenances', 30, time_i)
|
374
|
-
@redis.set("name1:PING:#{time_i}:scheduled_maintenance:summary", 'really bad')
|
375
|
-
@redis.zadd('name1:PING:sorted_scheduled_maintenance_timestamps', time_i, time_i)
|
376
|
-
|
377
|
-
add_name2
|
378
|
-
|
379
|
-
expect(@redis.zrange('name1:PING:scheduled_maintenances', 0, -1, :with_scores => true)).to eq([])
|
380
|
-
expect(@redis.zrange('name2:PING:scheduled_maintenances', 0, -1, :with_scores => true)).to eq([[time_i.to_s, 30.0]])
|
381
|
-
expect(@redis.get("name1:PING:#{time_i}:scheduled_maintenance:summary")).to be_nil
|
382
|
-
expect(@redis.get("name2:PING:#{time_i}:scheduled_maintenance:summary")).to eq('really bad')
|
383
|
-
expect(@redis.zrange('name1:PING:sorted_scheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq([])
|
384
|
-
expect(@redis.zrange('name2:PING:sorted_scheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq([[time_i.to_s, time_i.to_f]])
|
385
|
-
end
|
386
|
-
|
387
|
-
it 'renames current notifications' do
|
388
|
-
@redis.set('name1:PING:last_problem_notification', time_i)
|
389
|
-
@redis.set('name1:PING:last_unknown_notification', time_i - 100)
|
390
|
-
@redis.set('name1:PING:last_warning_notification', time_i - 50)
|
391
|
-
@redis.set('name1:PING:last_critical_notification', time_i)
|
392
|
-
@redis.set('name1:PING:last_recovery_notification', time_i - 200)
|
393
|
-
@redis.set('name1:PING:last_acknowledgement_notification', time_i - 250)
|
394
|
-
|
395
|
-
add_name2
|
396
|
-
|
397
|
-
expect(@redis.get('name1:PING:last_problem_notification')).to be_nil
|
398
|
-
expect(@redis.get('name1:PING:last_unknown_notification')).to be_nil
|
399
|
-
expect(@redis.get('name1:PING:last_warning_notification')).to be_nil
|
400
|
-
expect(@redis.get('name1:PING:last_critical_notification')).to be_nil
|
401
|
-
expect(@redis.get('name1:PING:last_recovery_notification')).to be_nil
|
402
|
-
expect(@redis.get('name1:PING:last_acknowledgement_notification')).to be_nil
|
403
|
-
expect(@redis.get('name2:PING:last_problem_notification')).to eq(time_i.to_s)
|
404
|
-
expect(@redis.get('name2:PING:last_unknown_notification')).to eq((time_i - 100).to_s)
|
405
|
-
expect(@redis.get('name2:PING:last_warning_notification')).to eq((time_i - 50).to_s)
|
406
|
-
expect(@redis.get('name2:PING:last_critical_notification')).to eq(time_i.to_s)
|
407
|
-
expect(@redis.get('name2:PING:last_recovery_notification')).to eq((time_i - 200).to_s)
|
408
|
-
expect(@redis.get('name2:PING:last_acknowledgement_notification')).to eq((time_i - 250).to_s)
|
409
|
-
end
|
410
|
-
|
411
|
-
it 'renames stored notifications' do
|
412
|
-
@redis.lpush('name1:PING:problem_notifications', time_i)
|
413
|
-
@redis.lpush('name1:PING:unknown_notifications', time_i - 100)
|
414
|
-
@redis.lpush('name1:PING:warning_notifications', time_i - 50)
|
415
|
-
@redis.lpush('name1:PING:critical_notifications', time_i)
|
416
|
-
@redis.lpush('name1:PING:recovery_notifications', time_i - 200)
|
417
|
-
@redis.lpush('name1:PING:acknowledgement_notifications', time_i - 250)
|
418
|
-
|
419
|
-
add_name2
|
420
|
-
|
421
|
-
expect(@redis.llen('name1:PING:problem_notifications')).to eq(0)
|
422
|
-
expect(@redis.llen('name1:PING:unknown_notifications')).to eq(0)
|
423
|
-
expect(@redis.llen('name1:PING:warning_notifications')).to eq(0)
|
424
|
-
expect(@redis.llen('name1:PING:critical_notifications')).to eq(0)
|
425
|
-
expect(@redis.llen('name1:PING:recovery_notifications')).to eq(0)
|
426
|
-
expect(@redis.llen('name1:PING:acknowledgement_notifications')).to eq(0)
|
427
|
-
expect(@redis.lindex('name2:PING:problem_notifications', 0)).to eq(time_i.to_s)
|
428
|
-
expect(@redis.lindex('name2:PING:unknown_notifications', 0)).to eq((time_i - 100).to_s)
|
429
|
-
expect(@redis.lindex('name2:PING:warning_notifications', 0)).to eq((time_i - 50).to_s)
|
430
|
-
expect(@redis.lindex('name2:PING:critical_notifications', 0)).to eq(time_i.to_s)
|
431
|
-
expect(@redis.lindex('name2:PING:recovery_notifications', 0)).to eq((time_i - 200).to_s)
|
432
|
-
expect(@redis.lindex('name2:PING:acknowledgement_notifications', 0)).to eq((time_i - 250).to_s)
|
433
|
-
end
|
434
|
-
|
435
|
-
it 'renames alert blocks' do
|
436
|
-
@redis.setex('drop_alerts_for_contact:362:email:name1:PING:critical', 30, 30)
|
437
|
-
|
438
|
-
add_name2
|
439
|
-
|
440
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name1:PING:critical')).to be_nil
|
441
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name2:PING:critical')).to eq(30.to_s)
|
442
|
-
expect(@redis.ttl('drop_alerts_for_contact:362:email:name2:PING:critical')).to be <= 30
|
443
|
-
end
|
444
|
-
|
445
|
-
it "updates the check hash set" do
|
446
|
-
data = {'state' => 'critical', 'last_change' => time_i.to_s, 'last_update' => time_i.to_s}
|
447
|
-
@redis.mapped_hmset('check:name1:PING', data)
|
448
|
-
|
449
|
-
@redis.hset('checks_by_hash', hash_name1, 'name1:PING')
|
450
|
-
|
451
|
-
add_name2
|
452
|
-
|
453
|
-
expect(@redis.hget('checks_by_hash', hash_name1)).to be_nil
|
454
|
-
expect(@redis.hget('checks_by_hash', hash_name2)).to eq('name2:PING')
|
455
|
-
end
|
456
|
-
|
457
|
-
it 'renames entries within alerting checks' do
|
458
|
-
data = {'state' => 'critical', 'last_change' => time_i.to_s, 'last_update' => time_i.to_s}
|
459
|
-
@redis.mapped_hmset('check:name1:PING', data)
|
460
|
-
|
461
|
-
@redis.zadd('contact_alerting_checks:362:media:email', time_i, 'name1:PING')
|
462
|
-
|
463
|
-
add_name2
|
464
|
-
|
465
|
-
expect(@redis.zrange('contact_alerting_checks:362:media:email', 0, -1, :with_scores => true)).to eq(
|
466
|
-
[['name2:PING', time_i.to_f]]
|
467
|
-
)
|
468
|
-
end
|
469
|
-
|
470
|
-
end
|
471
|
-
|
472
|
-
context 'entity merging' do
|
473
|
-
|
474
|
-
let(:time_2_i) { time_i + 30 }
|
475
|
-
|
476
|
-
def do_merge
|
477
|
-
Flapjack::Data::Entity.merge('name1', 'name2', :redis => @redis)
|
478
|
-
end
|
479
|
-
|
480
|
-
# used as basic existence check for state on check on original entity
|
481
|
-
def add_state1
|
482
|
-
data = {'state' => 'critical', 'last_change' => time_i.to_s, 'last_update' => time_i.to_s}
|
483
|
-
@redis.mapped_hmset('check:name1:PING', data)
|
484
|
-
end
|
485
|
-
|
486
|
-
def add_state2
|
487
|
-
data = {'state' => 'critical', 'last_change' => time_2_i.to_s, 'last_update' => time_2_i.to_s}
|
488
|
-
@redis.mapped_hmset('check:name2:PING', data)
|
489
|
-
end
|
490
|
-
|
491
|
-
before(:each) do
|
492
|
-
add_name2
|
493
|
-
end
|
494
|
-
|
495
|
-
it 'clears the old id when a name exists' do
|
496
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name2')).to eq('5000')
|
497
|
-
expect(@redis.hget('all_entity_names_by_id', '5000')).to eq('name2')
|
498
|
-
|
499
|
-
Flapjack::Data::Entity.add({'id' => '5001',
|
500
|
-
'name' => 'name2'},
|
501
|
-
:redis => @redis)
|
502
|
-
|
503
|
-
expect(@redis.hget('all_entity_ids_by_name', 'name2')).to eq('5001')
|
504
|
-
expect(@redis.hget('all_entity_names_by_id', '5000')).to be_nil
|
505
|
-
expect(@redis.hget('all_entity_names_by_id', '5001')).to eq('name2')
|
506
|
-
end
|
507
|
-
|
508
|
-
it 'does not overwrite current state for a check' do
|
509
|
-
add_state1
|
510
|
-
data_2 = {'state' => 'critical', 'last_change' => time_2_i.to_s, 'last_update' => time_2_i.to_s}
|
511
|
-
@redis.mapped_hmset('check:name2:PING', data_2)
|
512
|
-
|
513
|
-
do_merge
|
514
|
-
|
515
|
-
expect(@redis.hgetall('check:name1:PING')).to eq({})
|
516
|
-
expect(@redis.hgetall('check:name2:PING')).to eq(data_2)
|
517
|
-
end
|
518
|
-
|
519
|
-
it 'sets current state for a check if no new state is set' do
|
520
|
-
data = {'state' => 'critical', 'last_change' => time_i.to_s, 'last_update' => time_i.to_s}
|
521
|
-
@redis.mapped_hmset('check:name1:PING', data)
|
522
|
-
|
523
|
-
do_merge
|
524
|
-
|
525
|
-
expect(@redis.hgetall('check:name1:PING')).to eq({})
|
526
|
-
expect(@redis.hgetall('check:name2:PING')).to eq(data)
|
527
|
-
end
|
528
|
-
|
529
|
-
it 'merges stored check state changes' do
|
530
|
-
add_state1
|
531
|
-
add_state2
|
532
|
-
|
533
|
-
@redis.rpush('name1:PING:states', time_i)
|
534
|
-
@redis.set("name1:PING:#{time_i}:state", 'critical')
|
535
|
-
@redis.set("name1:PING:#{time_i}:summary", 'bad')
|
536
|
-
@redis.zadd('name1:PING:sorted_state_timestamps', time_i, time_i)
|
537
|
-
|
538
|
-
@redis.rpush('name2:PING:states', time_2_i)
|
539
|
-
@redis.set("name2:PING:#{time_2_i}:state", 'ok')
|
540
|
-
@redis.set("name2:PING:#{time_2_i}:summary", 'good')
|
541
|
-
@redis.zadd('name2:PING:sorted_state_timestamps', time_2_i, time_2_i)
|
542
|
-
|
543
|
-
do_merge
|
544
|
-
|
545
|
-
expect(@redis.type('name1:PING:states')).to eq('none')
|
546
|
-
expect(@redis.type('name2:PING:states')).to eq('list')
|
547
|
-
|
548
|
-
expect(@redis.llen('name2:PING:states')).to eq(2)
|
549
|
-
expect(@redis.lindex('name2:PING:states', 0)).to eq(time_i.to_s)
|
550
|
-
expect(@redis.lindex('name2:PING:states', 1)).to eq(time_2_i.to_s)
|
551
|
-
|
552
|
-
expect(@redis.get("name1:PING:#{time_i}:state")).to be_nil
|
553
|
-
expect(@redis.get("name2:PING:#{time_i}:state")).to eq('critical')
|
554
|
-
expect(@redis.get("name2:PING:#{time_2_i}:state")).to eq('ok')
|
555
|
-
|
556
|
-
expect(@redis.get("name1:PING:#{time_i}:summary")).to be_nil
|
557
|
-
expect(@redis.get("name2:PING:#{time_i}:summary")).to eq('bad')
|
558
|
-
expect(@redis.get("name2:PING:#{time_2_i}:summary")).to eq('good')
|
559
|
-
|
560
|
-
expect(@redis.zrange("name1:PING:sorted_state_timestamps", 0, -1, :with_scores => true)).to eq(
|
561
|
-
[])
|
562
|
-
expect(@redis.zrange("name2:PING:sorted_state_timestamps", 0, -1, :with_scores => true)).to eq(
|
563
|
-
[[time_i.to_s, time_i.to_f], [time_2_i.to_s, time_2_i.to_f]])
|
564
|
-
end
|
565
|
-
|
566
|
-
it 'merges stored action events' do
|
567
|
-
@redis.hset('name1:PING:actions', time_i, 'acknowledgement')
|
568
|
-
@redis.hset('name2:PING:actions', time_2_i, 'test_notifications')
|
569
|
-
|
570
|
-
do_merge
|
571
|
-
|
572
|
-
expect(@redis.hget('name1:PING:actions', time_i.to_s)).to be_nil
|
573
|
-
expect(@redis.hget('name2:PING:actions', time_i.to_s)).to eq('acknowledgement')
|
574
|
-
expect(@redis.hget('name2:PING:actions', time_2_i.to_s)).to eq('test_notifications')
|
575
|
-
end
|
576
|
-
|
577
|
-
it 'does not overwrite an entry in the sorted set of failing checks' do
|
578
|
-
add_state1
|
579
|
-
add_state2
|
580
|
-
|
581
|
-
@redis.zadd('failed_checks', time_i, 'name1:PING')
|
582
|
-
@redis.zadd('failed_checks', time_2_i, 'name2:PING')
|
583
|
-
|
584
|
-
do_merge
|
585
|
-
|
586
|
-
expect(@redis.zrange('failed_checks', 0, -1, :with_scores => true)).to eq([['name2:PING', time_2_i.to_f]])
|
587
|
-
end
|
588
|
-
|
589
|
-
it 'merges an entry in the sorted set of failing checks (if no new state data)' do
|
590
|
-
add_state1
|
591
|
-
|
592
|
-
@redis.zadd('failed_checks', time_i, 'name1:PING')
|
593
|
-
|
594
|
-
do_merge
|
595
|
-
|
596
|
-
expect(@redis.zrange('failed_checks', 0, -1, :with_scores => true)).to eq([['name2:PING', time_i.to_f]])
|
597
|
-
end
|
598
|
-
|
599
|
-
it 'merges the list of current checks, and its entries' do
|
600
|
-
@redis.zadd('current_checks:name1', time_i, 'PING')
|
601
|
-
@redis.zadd('current_checks:name2', time_2_i, 'SSH')
|
602
|
-
|
603
|
-
do_merge
|
604
|
-
|
605
|
-
expect(@redis.zrange('current_checks:name1', 0, -1, :with_scores => true)).to eq(
|
606
|
-
[])
|
607
|
-
expect(@redis.zrange('current_checks:name2', 0, -1, :with_scores => true)).to eq(
|
608
|
-
[['PING', time_i.to_f], ['SSH', time_2_i.to_f]])
|
609
|
-
end
|
610
|
-
|
611
|
-
it 'removes an entry from the list of current entities' do
|
612
|
-
@redis.zadd('current_entities', time_i, 'name1')
|
613
|
-
@redis.zadd('current_entities', time_2_i, 'name2')
|
614
|
-
|
615
|
-
do_merge
|
616
|
-
|
617
|
-
expect(@redis.zrange('current_entities', 0, -1, :with_scores => true)).to eq([['name2', time_2_i.to_f]])
|
618
|
-
end
|
619
|
-
|
620
|
-
it 'moves an entry within the list of current entities' do
|
621
|
-
@redis.zadd('current_entities', time_i, 'name1')
|
622
|
-
|
623
|
-
do_merge
|
624
|
-
|
625
|
-
expect(@redis.zrange('current_entities', 0, -1, :with_scores => true)).to eq([['name2', time_i.to_f]])
|
626
|
-
end
|
627
|
-
|
628
|
-
it "renames an unscheduled maintenance key" do
|
629
|
-
@redis.setex('name1:PING:unscheduled_maintenance', 30, time_i)
|
630
|
-
@redis.zadd('name1:PING:unscheduled_maintenances', 30, time_i)
|
631
|
-
|
632
|
-
do_merge
|
633
|
-
|
634
|
-
expect(@redis.get('name1:PING:unscheduled_maintenance')).to be_nil
|
635
|
-
expect(@redis.get('name2:PING:unscheduled_maintenance')).to eq(time_i.to_s)
|
636
|
-
expect(@redis.ttl('name2:PING:unscheduled_maintenance')).to be <= 30
|
637
|
-
end
|
638
|
-
|
639
|
-
it 'merges an unscheduled maintenance key (older has longest to live)' do
|
640
|
-
@redis.setex('name1:PING:unscheduled_maintenance', 60, time_i)
|
641
|
-
@redis.zadd('name1:PING:unscheduled_maintenances', 60, time_i)
|
642
|
-
@redis.setex('name2:PING:unscheduled_maintenance', 20, time_2_i)
|
643
|
-
@redis.zadd('name2:PING:unscheduled_maintenances', 20, time_2_i)
|
644
|
-
|
645
|
-
do_merge
|
646
|
-
|
647
|
-
expect(@redis.get('name1:PING:unscheduled_maintenance')).to be_nil
|
648
|
-
expect(@redis.get('name2:PING:unscheduled_maintenance')).to eq(time_i.to_s)
|
649
|
-
expect(@redis.ttl('name2:PING:unscheduled_maintenance')).to be <= 60
|
650
|
-
end
|
651
|
-
|
652
|
-
it 'merges an unscheduled maintenance key (newer has longest to live)' do
|
653
|
-
@redis.setex('name1:PING:unscheduled_maintenance', 40, time_i)
|
654
|
-
@redis.zadd('name1:PING:unscheduled_maintenances', 40, time_i)
|
655
|
-
@redis.setex('name2:PING:unscheduled_maintenance', 20, time_2_i)
|
656
|
-
@redis.zadd('name2:PING:unscheduled_maintenances', 20, time_i)
|
657
|
-
|
658
|
-
do_merge
|
659
|
-
|
660
|
-
expect(@redis.get('name1:PING:unscheduled_maintenance')).to be_nil
|
661
|
-
expect(@redis.get('name2:PING:unscheduled_maintenance')).to eq(time_2_i.to_s)
|
662
|
-
expect(@redis.ttl('name2:PING:unscheduled_maintenance')).to be <= 20
|
663
|
-
end
|
664
|
-
|
665
|
-
it 'merges stored unscheduled maintenance periods and sorted timestamps' do
|
666
|
-
@redis.zadd('name1:PING:unscheduled_maintenances', 30, time_i)
|
667
|
-
@redis.set("name1:PING:#{time_i}:unscheduled_maintenance:summary", 'really bad')
|
668
|
-
@redis.zadd('name1:PING:sorted_unscheduled_maintenance_timestamps', time_i, time_i)
|
669
|
-
|
670
|
-
@redis.zadd('name2:PING:unscheduled_maintenances', 20, time_2_i)
|
671
|
-
@redis.set("name2:PING:#{time_2_i}:unscheduled_maintenance:summary", 'not too bad')
|
672
|
-
@redis.zadd('name2:PING:sorted_unscheduled_maintenance_timestamps', time_2_i, time_2_i)
|
673
|
-
|
674
|
-
do_merge
|
675
|
-
|
676
|
-
expect(@redis.zrange('name1:PING:unscheduled_maintenances', 0, -1, :with_scores => true)).to eq(
|
677
|
-
[])
|
678
|
-
expect(@redis.zrange('name2:PING:unscheduled_maintenances', 0, -1, :with_scores => true)).to eq(
|
679
|
-
[[time_2_i.to_s, 20.0], [time_i.to_s, 30.0]])
|
680
|
-
expect(@redis.get("name1:PING:#{time_i}:unscheduled_maintenance:summary")).to be_nil
|
681
|
-
expect(@redis.get("name2:PING:#{time_i}:unscheduled_maintenance:summary")).to eq('really bad')
|
682
|
-
expect(@redis.get("name2:PING:#{time_2_i}:unscheduled_maintenance:summary")).to eq('not too bad')
|
683
|
-
expect(@redis.zrange('name1:PING:sorted_unscheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq(
|
684
|
-
[])
|
685
|
-
expect(@redis.zrange('name2:PING:sorted_unscheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq(
|
686
|
-
[[time_i.to_s, time_i.to_f], [time_2_i.to_s, time_2_i.to_f]])
|
687
|
-
end
|
688
|
-
|
689
|
-
it "renames a scheduled maintenance key" do
|
690
|
-
@redis.setex('name1:PING:scheduled_maintenance', 30, time_i)
|
691
|
-
|
692
|
-
do_merge
|
693
|
-
|
694
|
-
expect(@redis.get('name1:PING:scheduled_maintenance')).to be_nil
|
695
|
-
expect(@redis.get('name2:PING:scheduled_maintenance')).to eq(time_i.to_s)
|
696
|
-
expect(@redis.ttl('name2:PING:scheduled_maintenance')).to be <= 30
|
697
|
-
end
|
698
|
-
|
699
|
-
it 'merges a scheduled maintenance key (older has longer to live)' do
|
700
|
-
@redis.setex('name1:PING:scheduled_maintenance', 60, time_i)
|
701
|
-
@redis.setex('name2:PING:scheduled_maintenance', 20, time_2_i)
|
702
|
-
|
703
|
-
do_merge
|
704
|
-
|
705
|
-
expect(@redis.get('name1:PING:scheduled_maintenance')).to be_nil
|
706
|
-
expect(@redis.get('name2:PING:scheduled_maintenance')).to eq(time_i.to_s)
|
707
|
-
expect(@redis.ttl('name2:PING:scheduled_maintenance')).to be <= 60
|
708
|
-
end
|
709
|
-
|
710
|
-
it 'merges a scheduled maintenance key (newer has longer to live)' do
|
711
|
-
@redis.setex('name1:PING:scheduled_maintenance', 40, time_i)
|
712
|
-
@redis.setex('name2:PING:scheduled_maintenance', 20, time_2_i)
|
713
|
-
|
714
|
-
do_merge
|
715
|
-
|
716
|
-
expect(@redis.get('name1:PING:scheduled_maintenance')).to be_nil
|
717
|
-
expect(@redis.get('name2:PING:scheduled_maintenance')).to eq(time_2_i.to_s)
|
718
|
-
expect(@redis.ttl('name2:PING:scheduled_maintenance')).to be <= 20
|
719
|
-
end
|
720
|
-
|
721
|
-
it 'merges stored scheduled maintenance periods and sorted timestamps' do
|
722
|
-
@redis.zadd('name1:PING:scheduled_maintenances', 30, time_i)
|
723
|
-
@redis.set("name1:PING:#{time_i}:scheduled_maintenance:summary", 'really bad')
|
724
|
-
@redis.zadd('name1:PING:sorted_scheduled_maintenance_timestamps', time_i, time_i)
|
725
|
-
|
726
|
-
@redis.zadd('name2:PING:scheduled_maintenances', 20, time_2_i)
|
727
|
-
@redis.set("name2:PING:#{time_2_i}:scheduled_maintenance:summary", 'not too bad')
|
728
|
-
@redis.zadd('name2:PING:sorted_scheduled_maintenance_timestamps', time_2_i, time_2_i)
|
729
|
-
|
730
|
-
do_merge
|
731
|
-
|
732
|
-
expect(@redis.zrange('name1:PING:scheduled_maintenances', 0, -1, :with_scores => true)).to eq(
|
733
|
-
[])
|
734
|
-
expect(@redis.zrange('name2:PING:scheduled_maintenances', 0, -1, :with_scores => true)).to eq(
|
735
|
-
[[time_2_i.to_s, 20.0], [time_i.to_s, 30.0]])
|
736
|
-
expect(@redis.get("name1:PING:#{time_i}:scheduled_maintenance:summary")).to be_nil
|
737
|
-
expect(@redis.get("name2:PING:#{time_i}:scheduled_maintenance:summary")).to eq('really bad')
|
738
|
-
expect(@redis.get("name2:PING:#{time_2_i}:scheduled_maintenance:summary")).to eq('not too bad')
|
739
|
-
expect(@redis.zrange('name1:PING:sorted_scheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq(
|
740
|
-
[])
|
741
|
-
expect(@redis.zrange('name2:PING:sorted_scheduled_maintenance_timestamps', 0, -1, :with_scores => true)).to eq(
|
742
|
-
[[time_i.to_s, time_i.to_f], [time_2_i.to_s, time_2_i.to_f]])
|
743
|
-
end
|
744
|
-
|
745
|
-
it 'merges current notifications, using old timestamp if no new one' do
|
746
|
-
@redis.set('name1:PING:last_problem_notification', time_i)
|
747
|
-
@redis.set('name1:PING:last_unknown_notification', time_i - 100)
|
748
|
-
@redis.set('name1:PING:last_warning_notification', time_i - 50)
|
749
|
-
@redis.set('name1:PING:last_critical_notification', time_i)
|
750
|
-
@redis.set('name1:PING:last_recovery_notification', time_i - 200)
|
751
|
-
@redis.set('name1:PING:last_acknowledgement_notification', time_i - 250)
|
752
|
-
|
753
|
-
@redis.set('name2:PING:last_problem_notification', time_i + 800)
|
754
|
-
@redis.set('name2:PING:last_critical_notification', time_i + 800)
|
755
|
-
|
756
|
-
do_merge
|
757
|
-
|
758
|
-
expect(@redis.get('name1:PING:last_problem_notification')).to be_nil
|
759
|
-
expect(@redis.get('name1:PING:last_unknown_notification')).to be_nil
|
760
|
-
expect(@redis.get('name1:PING:last_warning_notification')).to be_nil
|
761
|
-
expect(@redis.get('name1:PING:last_critical_notification')).to be_nil
|
762
|
-
expect(@redis.get('name1:PING:last_recovery_notification')).to be_nil
|
763
|
-
expect(@redis.get('name1:PING:last_acknowledgement_notification')).to be_nil
|
764
|
-
|
765
|
-
expect(@redis.get('name2:PING:last_problem_notification')).to eq((time_i + 800).to_s)
|
766
|
-
expect(@redis.get('name2:PING:last_unknown_notification')).to eq((time_i - 100).to_s)
|
767
|
-
expect(@redis.get('name2:PING:last_warning_notification')).to eq((time_i - 50).to_s)
|
768
|
-
expect(@redis.get('name2:PING:last_critical_notification')).to eq((time_i + 800).to_s)
|
769
|
-
expect(@redis.get('name2:PING:last_recovery_notification')).to eq((time_i - 200).to_s)
|
770
|
-
expect(@redis.get('name2:PING:last_acknowledgement_notification')).to eq((time_i - 250).to_s)
|
771
|
-
end
|
772
|
-
|
773
|
-
it 'merges stored notifications' do
|
774
|
-
add_state1
|
775
|
-
|
776
|
-
@redis.lpush('name1:PING:problem_notifications', time_i)
|
777
|
-
@redis.lpush('name1:PING:unknown_notifications', time_i - 100)
|
778
|
-
@redis.lpush('name1:PING:warning_notifications', time_i - 50)
|
779
|
-
@redis.lpush('name1:PING:critical_notifications', time_i)
|
780
|
-
@redis.lpush('name1:PING:recovery_notifications', time_i - 200)
|
781
|
-
@redis.lpush('name1:PING:acknowledgement_notifications', time_i - 250)
|
782
|
-
|
783
|
-
@redis.lpush('name2:PING:problem_notifications', time_i + 800)
|
784
|
-
@redis.lpush('name2:PING:unknown_notifications', time_i + 800)
|
785
|
-
|
786
|
-
do_merge
|
787
|
-
|
788
|
-
expect(@redis.llen('name1:PING:problem_notifications')).to eq(0)
|
789
|
-
expect(@redis.llen('name1:PING:unknown_notifications')).to eq(0)
|
790
|
-
expect(@redis.llen('name1:PING:warning_notifications')).to eq(0)
|
791
|
-
expect(@redis.llen('name1:PING:critical_notifications')).to eq(0)
|
792
|
-
expect(@redis.llen('name1:PING:recovery_notifications')).to eq(0)
|
793
|
-
expect(@redis.llen('name1:PING:acknowledgement_notifications')).to eq(0)
|
794
|
-
expect(@redis.lindex('name2:PING:problem_notifications', 0)).to eq(time_i.to_s)
|
795
|
-
expect(@redis.lindex('name2:PING:problem_notifications', 1)).to eq((time_i + 800).to_s)
|
796
|
-
expect(@redis.lindex('name2:PING:unknown_notifications', 0)).to eq((time_i - 100).to_s)
|
797
|
-
expect(@redis.lindex('name2:PING:unknown_notifications', 1)).to eq((time_i + 800).to_s)
|
798
|
-
expect(@redis.lindex('name2:PING:warning_notifications', 0)).to eq((time_i - 50).to_s)
|
799
|
-
expect(@redis.lindex('name2:PING:critical_notifications', 0)).to eq(time_i.to_s)
|
800
|
-
expect(@redis.lindex('name2:PING:recovery_notifications', 0)).to eq((time_i - 200).to_s)
|
801
|
-
expect(@redis.lindex('name2:PING:acknowledgement_notifications', 0)).to eq((time_i - 250).to_s)
|
802
|
-
end
|
803
|
-
|
804
|
-
it 'merges alerting checks (no notification state for new)' do
|
805
|
-
add_state1
|
806
|
-
|
807
|
-
@redis.zadd('contact_alerting_checks:362:media:email', time_i, 'name1:PING')
|
808
|
-
|
809
|
-
@redis.lpush('name1:PING:problem_notifications', time_i)
|
810
|
-
@redis.lpush('name1:PING:critical_notifications', time_i)
|
811
|
-
|
812
|
-
do_merge
|
813
|
-
|
814
|
-
expect(@redis.zrange('contact_alerting_checks:362:media:email', 0, -1, :with_scores => true)).to eq(
|
815
|
-
[['name2:PING', time_i.to_f]])
|
816
|
-
end
|
817
|
-
|
818
|
-
it 'merges alerting checks (existing notification state for new)' do
|
819
|
-
add_state1
|
820
|
-
|
821
|
-
@redis.zadd('contact_alerting_checks:362:media:email', time_i, 'name1:PING')
|
822
|
-
|
823
|
-
@redis.lpush('name1:PING:problem_notifications', time_i)
|
824
|
-
@redis.lpush('name1:PING:critical_notifications', time_i)
|
825
|
-
|
826
|
-
@redis.lpush('name2:PING:problem_notifications', time_i + 100)
|
827
|
-
@redis.lpush('name2:PING:critical_notifications', time_i + 100)
|
828
|
-
@redis.lpush('name2:PING:recovery_notifications', time_i + 150)
|
829
|
-
|
830
|
-
do_merge
|
831
|
-
|
832
|
-
expect(@redis.zrange('contact_alerting_checks:362:media:email', 0, -1, :with_scores => true)).to eq(
|
833
|
-
[])
|
834
|
-
end
|
835
|
-
|
836
|
-
it 'merges alert blocks (no notification state for new)' do
|
837
|
-
@redis.setex('drop_alerts_for_contact:362:email:name1:PING:critical', 30, 30)
|
838
|
-
|
839
|
-
do_merge
|
840
|
-
|
841
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name1:PING:critical')).to be_nil
|
842
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name2:PING:critical')).to eq(30.to_s)
|
843
|
-
expect(@redis.ttl('drop_alerts_for_contact:362:email:name2:PING:critical')).to be <= 30
|
844
|
-
end
|
845
|
-
|
846
|
-
it 'merges alert blocks (older has longer to run)' do
|
847
|
-
@redis.setex('drop_alerts_for_contact:362:email:name1:PING:critical', 30, 30)
|
848
|
-
@redis.setex('drop_alerts_for_contact:362:email:name2:PING:critical', 10, 10)
|
849
|
-
|
850
|
-
do_merge
|
851
|
-
|
852
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name1:PING:critical')).to be_nil
|
853
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name2:PING:critical')).to eq(30.to_s)
|
854
|
-
expect(@redis.ttl('drop_alerts_for_contact:362:email:name2:PING:critical')).to be <= 30
|
855
|
-
end
|
856
|
-
|
857
|
-
it 'merges alert blocks (newer has longer to run)' do
|
858
|
-
@redis.setex('drop_alerts_for_contact:362:email:name1:PING:critical', 30, 30)
|
859
|
-
@redis.setex('drop_alerts_for_contact:362:email:name2:PING:critical', 60, 60)
|
860
|
-
|
861
|
-
do_merge
|
862
|
-
|
863
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name1:PING:critical')).to be_nil
|
864
|
-
expect(@redis.get('drop_alerts_for_contact:362:email:name2:PING:critical')).to eq(60.to_s)
|
865
|
-
expect(@redis.ttl('drop_alerts_for_contact:362:email:name2:PING:critical')).to be <= 60
|
866
|
-
end
|
867
|
-
|
868
|
-
end
|
869
|
-
|
870
|
-
end
|
871
|
-
|
872
|
-
end
|