flapjack 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +11 -12
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -7
- data/Rakefile +0 -1
- data/bin/flapjack +2 -0
- data/etc/flapjack_config.yaml.example +20 -0
- data/features/ack_after_sched_maint.feature +1 -1
- data/features/cli.feature +1 -1
- data/features/notification_rules.feature +1 -1
- data/features/notifications.feature +0 -9
- data/features/rollup.feature +1 -1
- data/features/steps/events_steps.rb +20 -8
- data/features/steps/notifications_steps.rb +62 -75
- data/features/support/env.rb +17 -8
- data/flapjack.gemspec +4 -4
- data/lib/flapjack.rb +3 -0
- data/lib/flapjack/cli/import.rb +1 -0
- data/lib/flapjack/cli/maintenance.rb +1 -0
- data/lib/flapjack/cli/purge.rb +2 -0
- data/lib/flapjack/cli/receiver.rb +1 -0
- data/lib/flapjack/cli/simulate.rb +1 -0
- data/lib/flapjack/data/alert.rb +28 -1
- data/lib/flapjack/data/contact.rb +1 -1
- data/lib/flapjack/data/entity.rb +18 -8
- data/lib/flapjack/data/entity_check.rb +17 -0
- data/lib/flapjack/data/event.rb +33 -15
- data/lib/flapjack/data/migration.rb +46 -23
- data/lib/flapjack/filters/delays.rb +13 -6
- data/lib/flapjack/gateways/aws_sns.rb +115 -88
- data/lib/flapjack/gateways/aws_sns/alert.text.erb +2 -1
- data/lib/flapjack/gateways/email.rb +145 -135
- data/lib/flapjack/gateways/email/alert.html.erb +6 -4
- data/lib/flapjack/gateways/email/alert.text.erb +2 -0
- data/lib/flapjack/gateways/jabber.rb +61 -1
- data/lib/flapjack/gateways/jabber/alert.text.erb +1 -1
- data/lib/flapjack/gateways/pagerduty/alert.text.erb +1 -1
- data/lib/flapjack/gateways/sms_gammu.rb +119 -0
- data/lib/flapjack/gateways/sms_messagenet.rb +95 -67
- data/lib/flapjack/gateways/sms_messagenet/alert.text.erb +2 -1
- data/lib/flapjack/gateways/sms_twilio.rb +102 -74
- data/lib/flapjack/gateways/sms_twilio/alert.text.erb +2 -1
- data/lib/flapjack/logger.rb +1 -1
- data/lib/flapjack/notifier.rb +5 -14
- data/lib/flapjack/patches.rb +0 -58
- data/lib/flapjack/pikelet.rb +8 -78
- data/lib/flapjack/processor.rb +3 -1
- data/lib/flapjack/redis_pool.rb +2 -0
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/data/contact_spec.rb +2 -2
- data/spec/lib/flapjack/data/entity_spec.rb +15 -0
- data/spec/lib/flapjack/data/event_spec.rb +2 -2
- data/spec/lib/flapjack/data/migration_spec.rb +11 -0
- data/spec/lib/flapjack/gateways/aws_sns_spec.rb +12 -8
- data/spec/lib/flapjack/gateways/email_spec.rb +56 -51
- data/spec/lib/flapjack/gateways/sms_messagenet_spec.rb +17 -12
- data/spec/lib/flapjack/gateways/sms_twilio_spec.rb +17 -12
- data/spec/lib/flapjack/pikelet_spec.rb +9 -23
- data/spec/lib/flapjack/redis_pool_spec.rb +1 -0
- data/tasks/profile.rake +25 -109
- metadata +37 -39
- data/Gemfile-ruby1.9 +0 -30
- data/Gemfile-ruby1.9.lock +0 -250
- data/tasks/benchmarks.rake +0 -237
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08eb6e473cdb410cd9628953cee45bd15105e730
|
4
|
+
data.tar.gz: e70c64ec5ee5fbaebcd0a57ea28279637baa9ae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba9fe3aab9ae6f58038f663737a478991bfc378a263f1e83919ff608f6bcc5b44883a71f36f9568ec38a53f8273df044802034d2ca6540be70d5930aabb3ba07
|
7
|
+
data.tar.gz: e95391893e56e8b8fe95c46db61777b861e6b470889d61e578ffd3a856a6da39c95626c6f58519145768346795f57c859d17bbc6bb234cdc91a5766b6a80470c
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/.travis.yml
CHANGED
@@ -1,16 +1,8 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
script: "bundle exec rspec spec && bundle exec rake pact:verify && bundle exec cucumber features"
|
7
|
-
env: BUNDLE_GEMFILE=Gemfile-ruby1.9
|
8
|
-
- rvm: '2.0'
|
9
|
-
gemfile: Gemfile
|
10
|
-
script: "bundle exec rspec spec && bundle exec rake pact:verify && bundle exec cucumber features"
|
11
|
-
- rvm: '2.1'
|
12
|
-
gemfile: Gemfile
|
13
|
-
script: "bundle exec rspec spec && bundle exec rake pact:verify && bundle exec cucumber features"
|
2
|
+
rvm:
|
3
|
+
- '2.0'
|
4
|
+
- '2.1'
|
5
|
+
- '2.2'
|
14
6
|
services:
|
15
7
|
- redis-server
|
16
8
|
before_script:
|
@@ -18,6 +10,13 @@ before_script:
|
|
18
10
|
before_install:
|
19
11
|
- git submodule update --init --recursive
|
20
12
|
- gem install bundler
|
13
|
+
install:
|
14
|
+
- go get github.com/garyburd/redigo/redis
|
15
|
+
- go get github.com/go-martini/martini
|
16
|
+
- go get gopkg.in/alecthomas/kingpin.v1
|
17
|
+
- go get github.com/oguzbilgic/pandik
|
18
|
+
- bundle install
|
19
|
+
script: "bundle exec rspec spec && bundle exec rake pact:verify && bundle exec cucumber features && cd src/flapjack && go test -v"
|
21
20
|
notifications:
|
22
21
|
irc:
|
23
22
|
channels:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## Flapjack Changelog
|
2
2
|
|
3
|
+
# 1.2.2 - 2015-02-10
|
4
|
+
- Feature: Add the maint subcommand to the chat bot to fix #664 (@someword)
|
5
|
+
- Feature: support for Ruby 2.2, drop support for 1.9, removes Resque due to gem dependencies #760 (@ali-graham)
|
6
|
+
- Feature: Gammu SMS gateway #759 (@paologlim)
|
7
|
+
- Feature: Use microsecond resolution for logs (maint/1.x) #762 (@jgoldschrafe)
|
8
|
+
- Feature: Backport notification delays from master #748 (@jgoldschrafe)
|
9
|
+
- Feature: make event summary optional, fixes #513 #779 (@ali-graham)
|
10
|
+
- Bug: fix purge script #758 (@pulecp)
|
11
|
+
- Bug: Fix for orphaned entity data #784 (@ali-graham)
|
12
|
+
|
3
13
|
# 1.2.1 - 2014-12-10
|
4
14
|
- Bug: Fix PagerDuty log failure on POST (maint/1.x) #744 (@jgoldschrafe)
|
5
15
|
|
data/Gemfile
CHANGED
@@ -13,7 +13,6 @@ group :test do
|
|
13
13
|
gem 'rack-test'
|
14
14
|
gem 'pact'
|
15
15
|
gem 'async_rack_test', '>= 0.0.5'
|
16
|
-
gem 'resque_spec'
|
17
16
|
gem 'webmock'
|
18
17
|
gem 'guard'
|
19
18
|
gem 'rb-fsevent'
|
@@ -21,10 +20,4 @@ group :test do
|
|
21
20
|
gem 'guard-cucumber'
|
22
21
|
gem 'fuubar'
|
23
22
|
gem 'simplecov', :require => false
|
24
|
-
|
25
|
-
# # Not compiling under 1.9.3-p550 anyway
|
26
|
-
# if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
|
27
|
-
# gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools.rb
|
28
|
-
# gem 'perftools.rb'
|
29
|
-
# end
|
30
23
|
end
|
data/Rakefile
CHANGED
data/bin/flapjack
CHANGED
@@ -40,6 +40,7 @@ production:
|
|
40
40
|
email_queue: email_notifications
|
41
41
|
sms_queue: sms_notifications
|
42
42
|
sms_twilio_queue: sms_twilio_notifications
|
43
|
+
sms_gammu_queue: sms_gammu_notifications
|
43
44
|
sns_queue: sns_notifications
|
44
45
|
jabber_queue: jabber_notifications
|
45
46
|
pagerduty_queue: pagerduty_notifications
|
@@ -116,6 +117,22 @@ production:
|
|
116
117
|
#templates:
|
117
118
|
# rollup.text: '/etc/flapjack/templates/sms_twilio/rollup.text.erb'
|
118
119
|
# alert.text: '/etc/flapjack/templates/sms_twilio/alert.text.erb'
|
120
|
+
# Sends SMS notifications via Gammu
|
121
|
+
sms_gammu:
|
122
|
+
enabled: yes
|
123
|
+
queue: sms_gammu_notifications
|
124
|
+
from: "xxxxxxxxx"
|
125
|
+
mysql_host: "x.x.x.x"
|
126
|
+
mysql_database: "gammu"
|
127
|
+
mysql_username: "gammu"
|
128
|
+
mysql_password: "xxxxxxxx"
|
129
|
+
logger:
|
130
|
+
level: INFO
|
131
|
+
syslog_errors: yes
|
132
|
+
# location of custom alert templates
|
133
|
+
templates:
|
134
|
+
rollup.text: '/etc/flapjack/templates/sms_gammu/rollup.text.erb'
|
135
|
+
alert.text: '/etc/flapjack/templates/sms_gammu/alert.text.erb'
|
119
136
|
# Generates SNS notifications
|
120
137
|
sns:
|
121
138
|
enabled: no
|
@@ -169,6 +186,9 @@ production:
|
|
169
186
|
# Seconds between auto_refresh of entities/checks pages. Set to 0 to disable
|
170
187
|
auto_refresh: 120
|
171
188
|
access_log: "/var/log/flapjack/web_access.log"
|
189
|
+
# Main URL for this service eg: "http://flapjack.example/"
|
190
|
+
#base_url: "/"
|
191
|
+
# URL for accessing the JSONAPI service from the browser
|
172
192
|
api_url: "http://localhost:3081/"
|
173
193
|
# Full path to location of logo file, e.g. /etc/flapjack/custom_logo.png
|
174
194
|
#logo_image_path: "/etc/flapjack/web/custom_logo/flapjack-2013-notext-transparent-300-300.png"
|
data/features/cli.feature
CHANGED
@@ -5,28 +5,24 @@ Feature: notifications
|
|
5
5
|
|
6
6
|
# TODO test across multiple contacts
|
7
7
|
|
8
|
-
@resque
|
9
8
|
Scenario: Queue an SMS notification
|
10
9
|
Given the user wants to receive SMS notifications for entity 'example.com'
|
11
10
|
When an event notification is generated for entity 'example.com'
|
12
11
|
Then an SMS notification for entity 'example.com' should be queued for the user
|
13
12
|
And an email notification for entity 'example.com' should not be queued for the user
|
14
13
|
|
15
|
-
@resque
|
16
14
|
Scenario: Queue an SNS notification
|
17
15
|
Given the user wants to receive SNS notifications for entity 'example.com'
|
18
16
|
When an event notification is generated for entity 'example.com'
|
19
17
|
Then an SNS notification for entity 'example.com' should be queued for the user
|
20
18
|
And an email notification for entity 'example.com' should not be queued for the user
|
21
19
|
|
22
|
-
@resque
|
23
20
|
Scenario: Queue an email notification
|
24
21
|
Given the user wants to receive email notifications for entity 'example.com'
|
25
22
|
When an event notification is generated for entity 'example.com'
|
26
23
|
Then an email notification for entity 'example.com' should be queued for the user
|
27
24
|
And an SMS notification for entity 'example.com' should not be queued for the user
|
28
25
|
|
29
|
-
@resque
|
30
26
|
Scenario: Queue SMS and email notifications
|
31
27
|
Given the user wants to receive SMS notifications for entity 'example.com' and email notifications for entity 'example2.com'
|
32
28
|
When an event notification is generated for entity 'example.com'
|
@@ -36,11 +32,6 @@ Feature: notifications
|
|
36
32
|
Then an email notification for entity 'example.com' should not be queued for the user
|
37
33
|
And an email notification for entity 'example2.com' should be queued for the user
|
38
34
|
|
39
|
-
# NB: Scenarios below here are those that cover code run by the Resque workers
|
40
|
-
# We could maybe test resque integration as well, see
|
41
|
-
# http://corner.squareup.com/2010/08/cucumber-and-resque.html
|
42
|
-
# http://gist.github.com/532100
|
43
|
-
|
44
35
|
Scenario: Send a queued SMS notification
|
45
36
|
Given a user SMS notification has been queued for entity 'example.com'
|
46
37
|
When the SMS notification handler runs successfully
|
data/features/rollup.feature
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
def drain_events
|
4
4
|
loop do
|
5
|
-
event = Flapjack::Data::Event.next('events', :block => false,
|
5
|
+
event = Flapjack::Data::Event.next('events', :block => false,
|
6
|
+
:redis => @redis)
|
6
7
|
break unless event
|
7
8
|
@processor.send(:process_event, event)
|
8
9
|
end
|
@@ -12,12 +13,23 @@ end
|
|
12
13
|
def drain_notifications
|
13
14
|
return unless @notifier_redis
|
14
15
|
loop do
|
15
|
-
notification = Flapjack::Data::Notification.next('notifications',
|
16
|
+
notification = Flapjack::Data::Notification.next('notifications',
|
17
|
+
:block => false, :redis => @notifier_redis)
|
16
18
|
break unless notification
|
17
19
|
@notifier.send(:process_notification, notification)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
23
|
+
def drain_alerts(queue, gateway)
|
24
|
+
return unless @notifier_redis
|
25
|
+
loop do
|
26
|
+
alert = Flapjack::Data::Alert.next(queue, :block => false,
|
27
|
+
:redis => @notifier_redis, :logger => @logger)
|
28
|
+
break unless alert
|
29
|
+
gateway.send(:deliver, alert)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
21
33
|
def submit_event(event)
|
22
34
|
@redis.rpush('events', Flapjack.dump_json(event))
|
23
35
|
end
|
@@ -405,18 +417,18 @@ Then /^(\w+) (\w+) alert(?:s)?(?: of)?(?: type (\w+))?(?: and)?(?: rollup (\w+))
|
|
405
417
|
when 'no'
|
406
418
|
num_queued = 0
|
407
419
|
end
|
408
|
-
|
409
|
-
queued_length =
|
410
|
-
type_ok = notification_type ? ( n['
|
420
|
+
queued = redis_peek("#{media}_notifications", 0, 30)
|
421
|
+
queued_length = queued.find_all {|n|
|
422
|
+
type_ok = notification_type ? ( n['notification_type'] == notification_type ) : true
|
411
423
|
rollup_ok = case rollup
|
412
424
|
when 'none'
|
413
|
-
n['
|
414
|
-
when nil, n['
|
425
|
+
n['rollup'].nil?
|
426
|
+
when nil, n['rollup']
|
415
427
|
true
|
416
428
|
else
|
417
429
|
false
|
418
430
|
end
|
419
|
-
type_ok && rollup_ok && ( n['
|
431
|
+
type_ok && rollup_ok && ( n['address'] == address )
|
420
432
|
}.length
|
421
433
|
expect(queued_length).to eq(num_queued.to_i)
|
422
434
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# copied from flapjack-populator
|
3
3
|
# TODO use Flapjack::Data::Contact.add
|
4
4
|
def add_contact(contact = {})
|
5
|
-
@
|
5
|
+
@notifier_redis.multi do |multi|
|
6
6
|
multi.del("contact:#{contact['id']}")
|
7
7
|
multi.del("contact_media:#{contact['id']}")
|
8
8
|
multi.hset("contact:#{contact['id']}", 'first_name', contact['first_name'])
|
@@ -23,7 +23,7 @@ Given /^the user wants to receive SMS notifications for entity '([\w\.\-]+)'$/ d
|
|
23
23
|
Flapjack::Data::Entity.add({'id' => '5000',
|
24
24
|
'name' => entity,
|
25
25
|
'contacts' => ["0999"]},
|
26
|
-
:redis => @
|
26
|
+
:redis => @notifier_redis )
|
27
27
|
end
|
28
28
|
|
29
29
|
Given /^the user wants to receive SNS notifications for entity '([\w\.\-]+)'$/ do |entity|
|
@@ -35,7 +35,7 @@ Given /^the user wants to receive SNS notifications for entity '([\w\.\-]+)'$/ d
|
|
35
35
|
Flapjack::Data::Entity.add({'id' => '5000',
|
36
36
|
'name' => entity,
|
37
37
|
'contacts' => ["0999"]},
|
38
|
-
:redis => @
|
38
|
+
:redis => @notifier_redis )
|
39
39
|
end
|
40
40
|
|
41
41
|
Given /^the user wants to receive email notifications for entity '([\w\.\-]+)'$/ do |entity|
|
@@ -47,7 +47,7 @@ Given /^the user wants to receive email notifications for entity '([\w\.\-]+)'$/
|
|
47
47
|
Flapjack::Data::Entity.add({'id' => '5000',
|
48
48
|
'name' => entity,
|
49
49
|
'contacts' => ["0999"]},
|
50
|
-
:redis => @
|
50
|
+
:redis => @notifier_redis )
|
51
51
|
end
|
52
52
|
|
53
53
|
Given /^the user wants to receive SMS notifications for entity '([\w\.\-]+)' and email notifications for entity '([\w\.\-]+)'$/ do |entity1, entity2|
|
@@ -64,11 +64,11 @@ Given /^the user wants to receive SMS notifications for entity '([\w\.\-]+)' and
|
|
64
64
|
Flapjack::Data::Entity.add({'id' => '5000',
|
65
65
|
'name' => entity1,
|
66
66
|
'contacts' => ["0998"]},
|
67
|
-
:redis => @
|
67
|
+
:redis => @notifier_redis )
|
68
68
|
Flapjack::Data::Entity.add({'id' => '5001',
|
69
69
|
'name' => entity2,
|
70
70
|
'contacts' => ["0999"]},
|
71
|
-
:redis => @
|
71
|
+
:redis => @notifier_redis )
|
72
72
|
end
|
73
73
|
|
74
74
|
# TODO create the notification object in redis, flag the relevant operation as
|
@@ -90,33 +90,33 @@ When /^an event notification is generated for entity '([\w\.\-]+)'$/ do |entity|
|
|
90
90
|
|
91
91
|
Flapjack::Data::Notification.add('notifications', event,
|
92
92
|
:type => notification_type, :severity => severity, :last_state => last_state,
|
93
|
-
:redis => @
|
93
|
+
:redis => @notifier_redis)
|
94
94
|
drain_notifications
|
95
95
|
end
|
96
96
|
|
97
97
|
Then /^an SMS notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
|
98
|
-
queue =
|
99
|
-
expect(queue.select {|n| n[
|
98
|
+
queue = redis_peek('sms_notifications')
|
99
|
+
expect(queue.select {|n| n['event_id'] =~ /#{entity}:ping/ }).not_to be_empty
|
100
100
|
end
|
101
101
|
|
102
102
|
Then /^an SNS notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
|
103
|
-
queue =
|
104
|
-
expect(queue.select {|n| n[
|
103
|
+
queue = redis_peek('sns_notifications')
|
104
|
+
expect(queue.select {|n| n['event_id'] =~ /#{entity}:ping/ }).not_to be_empty
|
105
105
|
end
|
106
106
|
|
107
107
|
Then /^an email notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
|
108
|
-
queue =
|
109
|
-
expect(queue.select {|n| n[
|
108
|
+
queue = redis_peek('email_notifications')
|
109
|
+
expect(queue.select {|n| n['event_id'] =~ /#{entity}:ping/ }).not_to be_empty
|
110
110
|
end
|
111
111
|
|
112
112
|
Then /^an SMS notification for entity '([\w\.\-]+)' should not be queued for the user$/ do |entity|
|
113
|
-
queue =
|
114
|
-
expect(queue.select {|n| n[
|
113
|
+
queue = redis_peek('sms_notifications')
|
114
|
+
expect(queue.select {|n| n['event_id'] =~ /#{entity}:ping/ }).to be_empty
|
115
115
|
end
|
116
116
|
|
117
117
|
Then /^an email notification for entity '([\w\.\-]+)' should not be queued for the user$/ do |entity|
|
118
|
-
queue =
|
119
|
-
expect(queue.select {|n| n[
|
118
|
+
queue = redis_peek('email_notifications')
|
119
|
+
expect(queue.select {|n| n['event_id'] =~ /#{entity}:ping/ }).to be_empty
|
120
120
|
end
|
121
121
|
|
122
122
|
Given /^a user SMS notification has been queued for entity '([\w\.\-]+)'$/ do |entity|
|
@@ -134,13 +134,16 @@ Given /^a user SMS notification has been queued for entity '([\w\.\-]+)'$/ do |e
|
|
134
134
|
'id' => 1,
|
135
135
|
'state_duration' => 30,
|
136
136
|
'duration' => 45}
|
137
|
+
|
138
|
+
Flapjack::Data::Alert.add('sms_notifications', @sms_notification,
|
139
|
+
:redis => @notifier_redis)
|
137
140
|
end
|
138
141
|
|
139
142
|
Given /^a user SNS notification has been queued for entity '([\w\.\-]+)'$/ do |entity|
|
140
143
|
Flapjack::Data::Entity.add({'id' => '5000',
|
141
144
|
'name' => entity},
|
142
145
|
:redis => @redis )
|
143
|
-
@
|
146
|
+
@sns_notification = {'notification_type' => 'problem',
|
144
147
|
'contact_first_name' => 'John',
|
145
148
|
'contact_last_name' => 'Smith',
|
146
149
|
'state' => 'critical',
|
@@ -151,6 +154,9 @@ Given /^a user SNS notification has been queued for entity '([\w\.\-]+)'$/ do |e
|
|
151
154
|
'id' => 1,
|
152
155
|
'state_duration' => 30,
|
153
156
|
'duration' => 45}
|
157
|
+
|
158
|
+
Flapjack::Data::Alert.add('sns_notifications', @sns_notification,
|
159
|
+
:redis => @notifier_redis)
|
154
160
|
end
|
155
161
|
|
156
162
|
Given /^a user email notification has been queued for entity '([\w\.\-]+)'$/ do |entity|
|
@@ -168,66 +174,54 @@ Given /^a user email notification has been queued for entity '([\w\.\-]+)'$/ do
|
|
168
174
|
'id' => 2,
|
169
175
|
'state_duration' => 30,
|
170
176
|
'duration' => 3600}
|
171
|
-
end
|
172
177
|
|
173
|
-
|
178
|
+
Flapjack::Data::Alert.add('email_notifications', @email_notification,
|
179
|
+
:redis => @notifier_redis)
|
180
|
+
end
|
174
181
|
|
175
|
-
# TODO may need to get more complex, depending which SMS provider is used
|
176
182
|
When /^the SMS notification handler runs successfully$/ do
|
177
183
|
@request = stub_request(:get, /^#{Regexp.escape(Flapjack::Gateways::SmsMessagenet::MESSAGENET_DEFAULT_URL)}/)
|
178
184
|
|
179
|
-
Flapjack::Gateways::SmsMessagenet.
|
180
|
-
|
181
|
-
|
182
|
-
Flapjack::Gateways::SmsMessagenet.start
|
185
|
+
@sms_messagenet = Flapjack::Gateways::SmsMessagenet.new(:config => {
|
186
|
+
'username' => 'abcd', 'password' => 'efgh'
|
187
|
+
}, :redis_config => @redis_opts, :logger => @logger)
|
183
188
|
|
184
|
-
|
189
|
+
drain_alerts('sms_notifications', @sms_messagenet)
|
185
190
|
end
|
186
191
|
|
187
192
|
When /^the SNS notification handler runs successfully$/ do
|
188
193
|
@request = stub_request(:post, /amazonaws\.com/)
|
189
194
|
|
190
|
-
Flapjack::Gateways::AwsSns.
|
195
|
+
@aws_sns = Flapjack::Gateways::AwsSns.new(:config => {
|
191
196
|
'access_key' => "AKIAIOSFODNN7EXAMPLE",
|
192
197
|
'secret_key' => "secret"
|
193
|
-
})
|
194
|
-
Flapjack::Gateways::AwsSns.instance_variable_set('@redis', @redis)
|
195
|
-
Flapjack::Gateways::AwsSns.instance_variable_set('@logger', @logger)
|
196
|
-
Flapjack::Gateways::AwsSns.start
|
198
|
+
}, :redis_config => @redis_opts, :logger => @logger)
|
197
199
|
|
198
|
-
|
200
|
+
drain_alerts('sns_notifications', @aws_sns)
|
199
201
|
end
|
200
202
|
|
201
203
|
When /^the SMS notification handler fails to send an SMS$/ do
|
202
204
|
@request = stub_request(:get, /^#{Regexp.escape(Flapjack::Gateways::SmsMessagenet::MESSAGENET_DEFAULT_URL)}/).to_return(:status => [500, "Internal Server Error"])
|
203
|
-
Flapjack::Gateways::SmsMessagenet.instance_variable_set('@config', {'username' => 'abcd', 'password' => 'efgh'})
|
204
|
-
Flapjack::Gateways::SmsMessagenet.instance_variable_set('@redis', @redis)
|
205
|
-
Flapjack::Gateways::SmsMessagenet.instance_variable_set('@logger', @logger)
|
206
|
-
Flapjack::Gateways::SmsMessagenet.start
|
207
205
|
|
208
|
-
Flapjack::Gateways::SmsMessagenet.
|
206
|
+
@sms_messagenet = Flapjack::Gateways::SmsMessagenet.new(:config => {
|
207
|
+
'username' => 'abcd', 'password' => 'efgh'
|
208
|
+
}, :redis_config => @redis_opts, :logger => @logger)
|
209
|
+
|
210
|
+
drain_alerts('sms_notifications', @sms_messagenet)
|
209
211
|
end
|
210
212
|
|
211
213
|
When /^the SNS notification handler fails to send an SMS$/ do
|
212
214
|
@request = stub_request(:post, /amazonaws\.com/).to_return(:status => [500, "Internal Server Error"])
|
213
|
-
|
215
|
+
|
216
|
+
@aws_sns = Flapjack::Gateways::AwsSns.new(:config => {
|
214
217
|
'access_key' => "AKIAIOSFODNN7EXAMPLE",
|
215
218
|
'secret_key' => "secret"
|
216
|
-
})
|
217
|
-
Flapjack::Gateways::AwsSns.instance_variable_set('@redis', @redis)
|
218
|
-
Flapjack::Gateways::AwsSns.instance_variable_set('@logger', @logger)
|
219
|
-
Flapjack::Gateways::AwsSns.start
|
219
|
+
}, :redis_config => @redis_opts, :logger => @logger)
|
220
220
|
|
221
|
-
|
221
|
+
drain_alerts('sns_notifications', @aws_sns)
|
222
222
|
end
|
223
223
|
|
224
224
|
When /^the email notification handler runs successfully$/ do
|
225
|
-
Resque.redis = @redis
|
226
|
-
Flapjack::Gateways::Email.instance_variable_set('@config', {'smtp_config' => {'host' => '127.0.0.1', 'port' => 2525, 'from' => 'flapjack@example'}})
|
227
|
-
Flapjack::Gateways::Email.instance_variable_set('@redis', @redis)
|
228
|
-
Flapjack::Gateways::Email.instance_variable_set('@logger', @logger)
|
229
|
-
Flapjack::Gateways::Email.start
|
230
|
-
|
231
225
|
# poor man's stubbing
|
232
226
|
EM::P::SmtpClient.class_eval {
|
233
227
|
def self.send(args = {})
|
@@ -237,16 +231,16 @@ When /^the email notification handler runs successfully$/ do
|
|
237
231
|
end
|
238
232
|
}
|
239
233
|
|
240
|
-
Flapjack::Gateways::Email.
|
234
|
+
@email = Flapjack::Gateways::Email.new(:config => {
|
235
|
+
'smtp_config' => {'host' => '127.0.0.1',
|
236
|
+
'port' => 2525,
|
237
|
+
'from' => 'flapjack@example'}
|
238
|
+
}, :redis_config => @redis_opts, :logger => @logger)
|
239
|
+
|
240
|
+
drain_alerts('email_notifications', @email)
|
241
241
|
end
|
242
242
|
|
243
243
|
When /^the email notification handler fails to send an email$/ do
|
244
|
-
Resque.redis = @redis
|
245
|
-
Flapjack::Gateways::Email.instance_variable_set('@config', {'smtp_config' => {'host' => '127.0.0.1', 'port' => 2525, 'from' => 'flapjack@example'}})
|
246
|
-
Flapjack::Gateways::Email.instance_variable_set('@redis', @redis)
|
247
|
-
Flapjack::Gateways::Email.instance_variable_set('@logger', @logger)
|
248
|
-
Flapjack::Gateways::Email.start
|
249
|
-
|
250
244
|
# poor man's stubbing
|
251
245
|
EM::P::SmtpClient.class_eval {
|
252
246
|
def self.send(args = {})
|
@@ -256,33 +250,26 @@ When /^the email notification handler fails to send an email$/ do
|
|
256
250
|
end
|
257
251
|
}
|
258
252
|
|
259
|
-
Flapjack::Gateways::Email.
|
260
|
-
|
253
|
+
@email = Flapjack::Gateways::Email.new(:config => {
|
254
|
+
'smtp_config' => {'host' => '127.0.0.1',
|
255
|
+
'port' => 2525,
|
256
|
+
'from' => 'flapjack@example'}
|
257
|
+
}, :redis_config => @redis_opts, :logger => @logger)
|
261
258
|
|
262
|
-
|
263
|
-
expect(@request).to have_been_requested
|
264
|
-
expect(Flapjack::Gateways::SmsMessagenet.instance_variable_get('@sent')).to eq(1)
|
259
|
+
drain_alerts('email_notifications', @email)
|
265
260
|
end
|
266
261
|
|
267
|
-
Then /^the user should receive an
|
262
|
+
Then /^the user should( not)? receive an SMS notification$/ do |negativity|
|
268
263
|
expect(@request).to have_been_requested
|
269
|
-
expect(
|
270
|
-
end
|
271
|
-
|
272
|
-
Then /^the user should receive an email notification$/ do
|
273
|
-
expect(Flapjack::Gateways::Email.instance_variable_get('@sent')).to eq(1)
|
264
|
+
expect(@sms_messagenet.instance_variable_get('@sent')).to eq(negativity.nil? ? 1 : 0)
|
274
265
|
end
|
275
266
|
|
276
|
-
Then /^the user should not receive an
|
267
|
+
Then /^the user should( not)? receive an SNS notification$/ do |negativity|
|
277
268
|
expect(@request).to have_been_requested
|
278
|
-
expect(
|
269
|
+
expect(@aws_sns.instance_variable_get('@sent')).to eq(negativity.nil? ? 1 : 0)
|
279
270
|
end
|
280
271
|
|
281
|
-
Then /^the user should not receive an
|
282
|
-
expect(@
|
283
|
-
expect(Flapjack::Gateways::AwsSns.instance_variable_get('@sent')).to eq(0)
|
272
|
+
Then /^the user should( not)? receive an email notification$/ do |negativity|
|
273
|
+
expect(@email.instance_variable_get('@sent')).to eq(negativity.nil? ? 1 : 0)
|
284
274
|
end
|
285
275
|
|
286
|
-
Then /^the user should not receive an email notification$/ do
|
287
|
-
expect(Flapjack::Gateways::Email.instance_variable_get('@sent')).to eq(0)
|
288
|
-
end
|