flapjack 0.7.35 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -1
- data/Gemfile +3 -4
- data/Guardfile +1 -1
- data/README.md +38 -19
- data/Rakefile +1 -3
- data/etc/flapjack_config.yaml.example +11 -1
- data/features/steps/cli_steps.rb +3 -3
- data/features/steps/events_steps.rb +7 -6
- data/features/steps/flapjack-netsaint-parser_steps.rb +8 -8
- data/features/steps/notifications_steps.rb +10 -10
- data/features/steps/packaging-lintian_steps.rb +5 -9
- data/features/steps/time_travel_steps.rb +1 -1
- data/flapjack.gemspec +4 -3
- data/lib/flapjack/data/contact.rb +78 -6
- data/lib/flapjack/data/entity.rb +11 -2
- data/lib/flapjack/data/notification_rule.rb +67 -59
- data/lib/flapjack/data/semaphore.rb +44 -0
- data/lib/flapjack/gateways/api.rb +24 -28
- data/lib/flapjack/gateways/api/contact_methods.rb +1 -2
- data/lib/flapjack/gateways/api/entity_methods.rb +3 -3
- data/lib/flapjack/gateways/jsonapi.rb +249 -0
- data/lib/flapjack/gateways/jsonapi/contact_methods.rb +544 -0
- data/lib/flapjack/gateways/jsonapi/entity_check_presenter.rb +217 -0
- data/lib/flapjack/gateways/jsonapi/entity_methods.rb +350 -0
- data/lib/flapjack/gateways/jsonapi/entity_presenter.rb +75 -0
- data/lib/flapjack/gateways/jsonapi/rack/json_params_parser.rb +32 -0
- data/lib/flapjack/gateways/web.rb +78 -12
- data/lib/flapjack/gateways/web/public/css/bootstrap-theme.css +397 -0
- data/lib/flapjack/gateways/web/public/css/bootstrap-theme.min.css +7 -0
- data/lib/flapjack/gateways/web/public/css/bootstrap.css +7118 -0
- data/lib/flapjack/gateways/web/public/css/bootstrap.min.css +6 -8
- data/lib/flapjack/gateways/web/public/css/font-awesome.css +1338 -0
- data/lib/flapjack/gateways/web/public/css/font-awesome.min.css +4 -0
- data/lib/flapjack/gateways/web/public/css/screen.css +80 -0
- data/lib/flapjack/gateways/web/public/css/select2-bootstrap.css +87 -0
- data/lib/flapjack/gateways/web/public/css/select2.css +615 -0
- data/lib/flapjack/gateways/web/public/fonts/FontAwesome.otf +0 -0
- data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.eot +0 -0
- data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.svg +414 -0
- data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.woff +0 -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 +229 -0
- 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/img/flapjack-2013-notext-transparent-300-300.png +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-min.js +2 -0
- data/lib/flapjack/gateways/web/public/js/backbone.js +1581 -0
- data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +75 -0
- data/lib/flapjack/gateways/web/public/js/bootstrap.js +2276 -0
- data/lib/flapjack/gateways/web/public/js/contacts.js +225 -0
- data/lib/flapjack/gateways/web/public/js/jquery-1.10.2.js +9789 -0
- data/lib/flapjack/gateways/web/public/js/jquery-1.10.2.min.js +6 -0
- data/lib/flapjack/gateways/web/public/js/select2.js +3255 -0
- data/lib/flapjack/gateways/web/public/js/select2.min.js +22 -0
- data/lib/flapjack/gateways/web/public/js/underscore-min.js +6 -0
- data/lib/flapjack/gateways/web/public/js/underscore.js +1276 -0
- data/lib/flapjack/gateways/web/views/check.html.erb +423 -193
- data/lib/flapjack/gateways/web/views/checks.html.erb +51 -71
- data/lib/flapjack/gateways/web/views/contact.html.erb +142 -164
- data/lib/flapjack/gateways/web/views/contacts.html.erb +20 -40
- data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +83 -0
- data/lib/flapjack/gateways/web/views/entities.html.erb +18 -37
- data/lib/flapjack/gateways/web/views/entity.html.erb +46 -65
- data/lib/flapjack/gateways/web/views/index.html.erb +6 -27
- data/lib/flapjack/gateways/web/views/layout.erb +95 -0
- data/lib/flapjack/gateways/web/views/self_stats.html.erb +100 -114
- data/lib/flapjack/pikelet.rb +4 -2
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +120 -120
- data/spec/lib/flapjack/data/contact_spec.rb +66 -58
- data/spec/lib/flapjack/data/entity_check_spec.rb +179 -179
- data/spec/lib/flapjack/data/entity_spec.rb +71 -71
- data/spec/lib/flapjack/data/event_spec.rb +34 -30
- data/spec/lib/flapjack/data/message_spec.rb +6 -6
- data/spec/lib/flapjack/data/notification_rule_spec.rb +24 -24
- data/spec/lib/flapjack/data/notification_spec.rb +19 -19
- data/spec/lib/flapjack/data/semaphore_spec.rb +24 -0
- data/spec/lib/flapjack/data/tag_spec.rb +11 -10
- data/spec/lib/flapjack/gateways/api/contact_methods_spec.rb +201 -201
- data/spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb +55 -55
- data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +257 -257
- data/spec/lib/flapjack/gateways/api/entity_presenter_spec.rb +26 -26
- data/spec/lib/flapjack/gateways/api_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/email_spec.rb +4 -4
- data/spec/lib/flapjack/gateways/jabber_spec.rb +77 -77
- data/spec/lib/flapjack/gateways/jsonapi/contact_methods_spec.rb +830 -0
- data/spec/lib/flapjack/gateways/jsonapi/entity_check_presenter_spec.rb +211 -0
- data/spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb +863 -0
- data/spec/lib/flapjack/gateways/jsonapi/entity_presenter_spec.rb +108 -0
- data/spec/lib/flapjack/gateways/jsonapi_spec.rb +8 -0
- data/spec/lib/flapjack/gateways/oobetet_spec.rb +35 -35
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +40 -40
- data/spec/lib/flapjack/gateways/sms_messagenet_spec.rb +3 -3
- data/spec/lib/flapjack/gateways/web/views/check.html.erb_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/web/views/contact.html.erb_spec.rb +5 -5
- data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/web_spec.rb +73 -74
- data/spec/lib/flapjack/logger_spec.rb +13 -13
- data/spec/lib/flapjack/pikelet_spec.rb +33 -33
- data/spec/lib/flapjack/processor_spec.rb +22 -22
- data/spec/lib/flapjack/redis_pool_spec.rb +1 -1
- data/spec/lib/flapjack/utility_spec.rb +12 -12
- data/spec/spec_helper.rb +9 -9
- data/spec/support/erb_view_helper.rb +4 -0
- metadata +107 -96
- data/lib/flapjack/gateways/web/public/css/flapjack.css +0 -49
- data/lib/flapjack/gateways/web/views/_css.html.erb +0 -42
- data/lib/flapjack/gateways/web/views/_foot.html.erb +0 -3
- data/lib/flapjack/gateways/web/views/_head.html.erb +0 -5
- data/lib/flapjack/gateways/web/views/_nav.html.erb +0 -10
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 01e6182ada345384e280d5ed7a9ead80cc1c47c9
|
|
4
|
+
data.tar.gz: 2c93d9a269af81a435b8d24f17b96c5ffd69996a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ae3191374c88fae709ada04de6a27cdcd7203e99fb1bde425bf76819681f8c9bad2841f02207c2e41e37cc87b7cd15ede2bb7c61d48aba7af8e6cce6f3bce2ef
|
|
7
|
+
data.tar.gz: 43f07542553f64a3f886dc8f4dc7efb7f51dc23ddf3f4a802c7ee2fe9eedfb4ef768878655644fc5f8f4316377b21075f7e10d50b18d30f458fd5c3a8998053e
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
|
@@ -7,7 +7,7 @@ group :development do
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
group :test do
|
|
10
|
-
gem 'rspec'
|
|
10
|
+
gem 'rspec', '~> 3.0.0.beta1'
|
|
11
11
|
gem 'cucumber'
|
|
12
12
|
gem 'delorean'
|
|
13
13
|
gem 'rack-test'
|
|
@@ -15,12 +15,11 @@ group :test do
|
|
|
15
15
|
gem 'resque_spec'
|
|
16
16
|
gem 'webmock'
|
|
17
17
|
gem 'guard'
|
|
18
|
-
gem 'rb-fsevent'
|
|
18
|
+
gem 'rb-fsevent'
|
|
19
19
|
gem 'guard-rspec'
|
|
20
20
|
gem 'guard-cucumber'
|
|
21
21
|
gem 'fuubar'
|
|
22
|
-
gem 'fuubar-cucumber'
|
|
23
22
|
gem 'simplecov', :require => false
|
|
24
|
-
gem '
|
|
23
|
+
gem 'debugger-ruby_core_source', '>= 1.3.1' # required for perftools
|
|
25
24
|
gem 'perftools.rb'
|
|
26
25
|
end
|
data/Guardfile
CHANGED
|
@@ -7,7 +7,7 @@ end
|
|
|
7
7
|
|
|
8
8
|
# NB: seems to be buggy with the default --progress formatter, was
|
|
9
9
|
# causing failures to parse the features
|
|
10
|
-
guard 'cucumber', :cli => '--no-profile --color --
|
|
10
|
+
guard 'cucumber', :cli => '--no-profile --color --strict' do
|
|
11
11
|
watch(%r{^features/.+\.feature$})
|
|
12
12
|
watch(%r{^features/support/.+$}) { 'features' }
|
|
13
13
|
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
data/README.md
CHANGED
|
@@ -2,15 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/flpjck/flapjack)
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
[Flapjack](http://flapjack.io/) is a flexible monitoring notification routing system that handles:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
* **Alert routing** (determining who should receive alerts based on interest, time of day, scheduled maintenance, etc)
|
|
8
|
+
* **Alert summarisation** (with per-user, per media summary thresholds)
|
|
9
|
+
* **Your standard operational tasks** (setting scheduled maintenance, acknowledgements, etc)
|
|
10
|
+
|
|
11
|
+
Flapjack will be immediately useful to you if:
|
|
12
|
+
|
|
13
|
+
* You want to **identify failures faster** by rolling up your alerts across multiple monitoring systems.
|
|
14
|
+
* You monitor infrastructures that have **multiple teams responsible** for keeping them up.
|
|
15
|
+
* Your monitoring infrastructure is **multitenant**, and each customer has a **bespoke alerting strategy**.
|
|
16
|
+
* You want to dip your toe in the water and try alternative check execution engines like Sensu, Icinga, or cron in parallel to Nagios.
|
|
17
|
+
|
|
18
|
+
### The technical low-down
|
|
8
19
|
|
|
9
20
|
Flapjack provides a scalable method for dealing with events representing changes in system state (OK -> WARNING -> CRITICAL transitions) and alerting appropriate people as necessary.
|
|
10
21
|
|
|
11
22
|
At its core, Flapjack processes events received from external check execution engines, such as Nagios. Nagios provides a 'perfdata' event output channel, which writes to a named pipe. `flapjack-nagios-receiver` then reads from this named pipe, converts each line to JSON and adds them to the events queue.
|
|
12
23
|
|
|
13
|
-
Flapjack
|
|
24
|
+
Flapjack sits downstream of check execution engines (like Nagios, Sensu, Icinga, or cron), processing events to determine:
|
|
25
|
+
|
|
26
|
+
* if a problem has been detected
|
|
27
|
+
* who should know about the problem
|
|
28
|
+
* how they should be told
|
|
14
29
|
|
|
15
30
|
Additional check engines can be supported by adding additional receiver processes similar to the nagios receiver.
|
|
16
31
|
|
|
@@ -18,25 +33,25 @@ Additional check engines can be supported by adding additional receiver processe
|
|
|
18
33
|
|
|
19
34
|
**Ubuntu Precise 64 (12.04):**
|
|
20
35
|
|
|
21
|
-
Add the
|
|
36
|
+
Add the Flapjack Debian repository to your Apt sources:
|
|
22
37
|
|
|
23
|
-
```text
|
|
38
|
+
``` text
|
|
24
39
|
echo 'deb http://packages.flapjack.io/deb precise main' > /tmp/flapjack.list
|
|
25
40
|
sudo cp /tmp/flapjack.list /etc/apt/sources.list.d/flapjack.list
|
|
26
41
|
sudo apt-get update
|
|
27
42
|
```
|
|
28
43
|
|
|
29
|
-
Install the latest
|
|
44
|
+
Install the latest Flapjack package:
|
|
30
45
|
|
|
31
|
-
```text
|
|
46
|
+
``` text
|
|
32
47
|
sudo apt-get install flapjack
|
|
33
48
|
```
|
|
34
49
|
|
|
35
50
|
Alternatively, [download the deb](http://packages.flapjack.io/deb/pool/main/f/flapjack/) and install using `sudo dpkg -i <filename>`
|
|
36
51
|
|
|
37
|
-
The
|
|
52
|
+
The Flapjack package is an [Omnibus](https://github.com/opscode/omnibus-ruby) package and as such contains most dependencies under `/opt/flapjack`, including Redis.
|
|
38
53
|
|
|
39
|
-
Installing the package will start
|
|
54
|
+
Installing the package will start Redis and Flapjack. You should now be able to access the Flapjack Web UI at:
|
|
40
55
|
|
|
41
56
|
[http://localhost:3080/](http://localhost:3080)
|
|
42
57
|
|
|
@@ -44,23 +59,25 @@ And consume the REST API at:
|
|
|
44
59
|
|
|
45
60
|
[http://localhost:3081/](http://localhost:3081)
|
|
46
61
|
|
|
62
|
+
N.B. The Redis installed by Flapjack runs on a non-standard port, so it doesn't conflict with other Redis instances you may already have installed.
|
|
63
|
+
|
|
47
64
|
**Other OSes:**
|
|
48
65
|
|
|
49
|
-
Currently we only make a package for Ubuntu Precise (amd64). If you feel comfortable getting a ruby 1.9 or 2.0 environment going on your preferred OS, then you can also just install
|
|
66
|
+
Currently we only make a package for Ubuntu Precise (amd64). If you feel comfortable getting a ruby 1.9 or 2.0 environment going on your preferred OS, then you can also just install Flapjack from rubygems.org:
|
|
50
67
|
|
|
51
68
|
```text
|
|
52
69
|
gem install flapjack
|
|
53
70
|
```
|
|
54
71
|
|
|
55
|
-
Using a tool like [rbenv](https://github.com/sstephenson/rbenv) or [rvm](https://rvm.io/) is recommended to keep your
|
|
72
|
+
Using a tool like [rbenv](https://github.com/sstephenson/rbenv) or [rvm](https://rvm.io/) is recommended to keep your Ruby applications from intefering with one another.
|
|
56
73
|
|
|
57
|
-
Alternatively, you can add support for your OS of choice to [omnibus-flapjack](https://github.com/flpjck/omnibus-flapjack) and build a native package. Pull requests welcome!
|
|
74
|
+
Alternatively, you can add support for your OS of choice to [omnibus-flapjack](https://github.com/flpjck/omnibus-flapjack) and build a native package. Pull requests welcome, and we'll help you make this happen!
|
|
58
75
|
|
|
59
76
|
## Configuring
|
|
60
77
|
|
|
61
78
|
Have a look at the default config file and modify things as required. See the [Configuring Components](https://github.com/flpjck/flapjack/wiki/USING#wiki-configuring_components) section on the wiki for more details.
|
|
62
79
|
|
|
63
|
-
```bash
|
|
80
|
+
``` bash
|
|
64
81
|
# hack the config
|
|
65
82
|
sudo vi /etc/flapjack/flapjack_config.yaml
|
|
66
83
|
|
|
@@ -72,10 +89,11 @@ sudo /etc/init.d/flapjack reload
|
|
|
72
89
|
|
|
73
90
|
**Ubuntu Precise 64:**
|
|
74
91
|
|
|
75
|
-
After installing the
|
|
92
|
+
After installing the Flapjack package, Redis and Flapjack should be automatically started.
|
|
76
93
|
|
|
77
|
-
First up, start
|
|
78
|
-
|
|
94
|
+
First up, start Redis if it's not already started:
|
|
95
|
+
|
|
96
|
+
``` bash
|
|
79
97
|
# status:
|
|
80
98
|
sudo /etc/init.d/redis status
|
|
81
99
|
|
|
@@ -83,8 +101,9 @@ sudo /etc/init.d/redis status
|
|
|
83
101
|
sudo /etc/init.d/redis start
|
|
84
102
|
```
|
|
85
103
|
|
|
86
|
-
Operating
|
|
87
|
-
|
|
104
|
+
Operating Flapjack:
|
|
105
|
+
|
|
106
|
+
``` bash
|
|
88
107
|
# status:
|
|
89
108
|
sudo /etc/init.d/flapjack status
|
|
90
109
|
|
|
@@ -126,7 +145,7 @@ If you make changes to the documentation locally, here's how to publish them:
|
|
|
126
145
|
|
|
127
146
|
## More on the wiki
|
|
128
147
|
|
|
129
|
-
https://github.com/flpjck/flapjack/wiki has even more goodies:
|
|
148
|
+
[The Flapjack wiki](https://github.com/flpjck/flapjack/wiki) has even more goodies:
|
|
130
149
|
|
|
131
150
|
- [Using Flapjack](https://github.com/flpjck/flapjack/wiki/USING)
|
|
132
151
|
- [Developing Flapjack](https://github.com/flpjck/flapjack/wiki/DEVELOPING)
|
data/Rakefile
CHANGED
|
@@ -19,9 +19,7 @@ Bundler::GemHelper.install_tasks
|
|
|
19
19
|
|
|
20
20
|
Cucumber::Rake::Task.new(:features) do |t|
|
|
21
21
|
#t.cucumber_opts = 'features --format pretty'
|
|
22
|
-
|
|
23
|
-
#t.cucumber_opts = '--format fuubar'
|
|
24
|
-
t.cucumber_opts = '--format Cucumber::Formatter::Fuubar'
|
|
22
|
+
t.cucumber_opts = '--format progress'
|
|
25
23
|
end
|
|
26
24
|
|
|
27
25
|
require 'rspec/core/rake_task'
|
|
@@ -87,13 +87,23 @@ production:
|
|
|
87
87
|
port: 3080
|
|
88
88
|
timeout: 300
|
|
89
89
|
access_log: "/var/log/flapjack/web_access.log"
|
|
90
|
+
api_url: "http://localhost:3081/"
|
|
90
91
|
logger:
|
|
91
92
|
level: INFO
|
|
92
93
|
syslog_errors: yes
|
|
93
|
-
|
|
94
|
+
jsonapi:
|
|
94
95
|
enabled: yes
|
|
95
96
|
port: 3081
|
|
96
97
|
timeout: 300
|
|
98
|
+
access_log: "/var/log/flapjack/jsonapi_access.log"
|
|
99
|
+
base_url: "http://localhost:3081/"
|
|
100
|
+
logger:
|
|
101
|
+
level: INFO
|
|
102
|
+
syslog_errors: yes
|
|
103
|
+
api:
|
|
104
|
+
enabled: yes
|
|
105
|
+
port: 3071
|
|
106
|
+
timeout: 300
|
|
97
107
|
access_log: "/var/log/flapjack/api_access.log"
|
|
98
108
|
logger:
|
|
99
109
|
level: INFO
|
data/features/steps/cli_steps.rb
CHANGED
|
@@ -60,7 +60,7 @@ Then /^(\S+) should ((?:re)?start|stop) within (\d+) seconds$/ do |exe, start_st
|
|
|
60
60
|
attempts += 1; sleep 0.1; retry if attempts < max_attempts
|
|
61
61
|
running = false
|
|
62
62
|
end
|
|
63
|
-
running.
|
|
63
|
+
expect(running).to be true
|
|
64
64
|
when 'stop'
|
|
65
65
|
if process
|
|
66
66
|
# it's a child process, so we can use waitpid
|
|
@@ -84,7 +84,7 @@ Then /^(\S+) should ((?:re)?start|stop) within (\d+) seconds$/ do |exe, start_st
|
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
|
-
running.
|
|
87
|
+
expect(running).to be false
|
|
88
88
|
when 'restart'
|
|
89
89
|
read_pid = nil
|
|
90
90
|
while attempts < max_attempts
|
|
@@ -93,7 +93,7 @@ Then /^(\S+) should ((?:re)?start|stop) within (\d+) seconds$/ do |exe, start_st
|
|
|
93
93
|
break if read_pid != pid
|
|
94
94
|
attempts += 1; sleep 0.1
|
|
95
95
|
end
|
|
96
|
-
read_pid.
|
|
96
|
+
expect(read_pid).not_to eq(pid)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
end
|
|
@@ -279,7 +279,7 @@ Then /^a notification should not be generated(?: for check '([\w\.\-]+)' on enti
|
|
|
279
279
|
entity ||= @entity
|
|
280
280
|
message = @logger.messages.find_all {|m| m =~ /enerating notification for event #{entity}:#{check}/ }.last
|
|
281
281
|
found = message ? message.match(/Not generating notification/) : false
|
|
282
|
-
found.
|
|
282
|
+
expect(found).to be_truthy
|
|
283
283
|
end
|
|
284
284
|
|
|
285
285
|
Then /^a notification should be generated(?: for check '([\w\.\-]+)' on entity '([\w\.\-]+)')?$/ do |check, entity|
|
|
@@ -287,13 +287,13 @@ Then /^a notification should be generated(?: for check '([\w\.\-]+)' on entity '
|
|
|
287
287
|
entity ||= @entity
|
|
288
288
|
message = @logger.messages.find_all {|m| m =~ /enerating notification for event #{entity}:#{check}/ }.last
|
|
289
289
|
found = message ? message.match(/Generating notification/) : false
|
|
290
|
-
found.
|
|
290
|
+
expect(found).to be_truthy
|
|
291
291
|
end
|
|
292
292
|
|
|
293
293
|
Then /^(un)?scheduled maintenance should be generated(?: for check '([\w\.\-]+)' on entity '([\w\.\-]+)')?$/ do |unsched, check, entity|
|
|
294
294
|
check ||= @check
|
|
295
295
|
entity ||= @entity
|
|
296
|
-
@redis.get("#{entity}:#{check}:#{unsched || ''}scheduled_maintenance").
|
|
296
|
+
expect(@redis.get("#{entity}:#{check}:#{unsched || ''}scheduled_maintenance")).not_to be_nil
|
|
297
297
|
end
|
|
298
298
|
|
|
299
299
|
Then /^show me the (\w+ )*log$/ do |adjective|
|
|
@@ -401,7 +401,7 @@ Given /^user (\S+) has the following notification rules:$/ do |contact_id, rules
|
|
|
401
401
|
end
|
|
402
402
|
|
|
403
403
|
Then /^all alert dropping keys for user (\S+) should have expired$/ do |contact_id|
|
|
404
|
-
@redis.keys("drop_alerts_for_contact:#{contact_id}*").
|
|
404
|
+
expect(@redis.keys("drop_alerts_for_contact:#{contact_id}*")).to be_empty
|
|
405
405
|
end
|
|
406
406
|
|
|
407
407
|
Then /^(\w+) (\w+) alert(?:s)?(?: of)?(?: type (\w+))?(?: and)?(?: rollup (\w+))? should be queued for (.*)$/ do |num_queued, media, notification_type, rollup, address|
|
|
@@ -412,7 +412,7 @@ Then /^(\w+) (\w+) alert(?:s)?(?: of)?(?: type (\w+))?(?: and)?(?: rollup (\w+))
|
|
|
412
412
|
num_queued = 0
|
|
413
413
|
end
|
|
414
414
|
queue = Resque.peek("#{media}_notifications", 0, 30)
|
|
415
|
-
queue.find_all {|n|
|
|
415
|
+
queued_length = queue.find_all {|n|
|
|
416
416
|
type_ok = notification_type ? ( n['args'].first['notification_type'] == notification_type ) : true
|
|
417
417
|
rollup_ok = true
|
|
418
418
|
if rollup
|
|
@@ -423,7 +423,8 @@ Then /^(\w+) (\w+) alert(?:s)?(?: of)?(?: type (\w+))?(?: and)?(?: rollup (\w+))
|
|
|
423
423
|
end
|
|
424
424
|
end
|
|
425
425
|
type_ok && rollup_ok && ( n['args'].first['address'] == address )
|
|
426
|
-
}.length
|
|
426
|
+
}.length
|
|
427
|
+
expect(queued_length).to eq(num_queued.to_i)
|
|
427
428
|
end
|
|
428
429
|
|
|
429
430
|
When(/^user (\S+) ceases to be a contact of entity '(.*)'$/) do |contact_id, entity|
|
|
@@ -6,16 +6,16 @@ Given /^NetSaint configuration is at "([^"]*)"$/ do |path|
|
|
|
6
6
|
files << root.join('netsaint.cfg')
|
|
7
7
|
files << root.join('resource.cfg')
|
|
8
8
|
|
|
9
|
-
File.directory?(root).
|
|
9
|
+
expect(File.directory?(root)).to be true
|
|
10
10
|
files.each do |filename|
|
|
11
|
-
File.exists?(filename).
|
|
11
|
+
expect(File.exists?(filename)).to be true
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
Then /^I should see a valid JSON output$/ do
|
|
16
|
-
|
|
16
|
+
expect {
|
|
17
17
|
@data = Oj.load(@output)
|
|
18
|
-
}.
|
|
18
|
+
}.not_to raise_error
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
Then /^show me the output$/ do
|
|
@@ -23,8 +23,8 @@ Then /^show me the output$/ do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
Then /^I should see a list of (\w+)$/ do |type|
|
|
26
|
-
@data[type].
|
|
27
|
-
@data[type].size.
|
|
26
|
+
expect(@data[type]).not_to be_nil
|
|
27
|
+
expect(@data[type].size).to be > 0
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
Then /^I should see the following attributes for every (\w+):$/ do |type, table|
|
|
@@ -33,7 +33,7 @@ Then /^I should see the following attributes for every (\w+):$/ do |type, table|
|
|
|
33
33
|
@data[type].each_pair do |name, items|
|
|
34
34
|
items.each do |item|
|
|
35
35
|
values.each do |attr|
|
|
36
|
-
item[attr].
|
|
36
|
+
expect(item[attr]).not_to be_nil
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -42,7 +42,7 @@ Then /^I should see the following attributes for every (\w+):$/ do |type, table|
|
|
|
42
42
|
@data[type].each_pair do |name, items|
|
|
43
43
|
items.each do |item|
|
|
44
44
|
nils.each do |attr|
|
|
45
|
-
item.member?(attr).
|
|
45
|
+
expect(item.member?(attr)).to be true
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -84,22 +84,22 @@ end
|
|
|
84
84
|
|
|
85
85
|
Then /^an SMS notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
|
|
86
86
|
queue = ResqueSpec.peek('sms_notifications')
|
|
87
|
-
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.
|
|
87
|
+
expect(queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }).not_to be_empty
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
Then /^an email notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
|
|
91
91
|
queue = ResqueSpec.peek('email_notifications')
|
|
92
|
-
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.
|
|
92
|
+
expect(queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }).not_to be_empty
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
Then /^an SMS notification for entity '([\w\.\-]+)' should not be queued for the user$/ do |entity|
|
|
96
96
|
queue = ResqueSpec.peek('sms_notifications')
|
|
97
|
-
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.
|
|
97
|
+
expect(queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }).to be_empty
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
Then /^an email notification for entity '([\w\.\-]+)' should not be queued for the user$/ do |entity|
|
|
101
101
|
queue = ResqueSpec.peek('email_notifications')
|
|
102
|
-
queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }.
|
|
102
|
+
expect(queue.select {|n| n[:args].first['event_id'] =~ /#{entity}:ping/ }).to be_empty
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
Given /^a user SMS notification has been queued for entity '([\w\.\-]+)'$/ do |entity|
|
|
@@ -199,19 +199,19 @@ When /^the email notification handler fails to send an email$/ do
|
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
Then /^the user should receive an SMS notification$/ do
|
|
202
|
-
@request.
|
|
203
|
-
Flapjack::Gateways::SmsMessagenet.instance_variable_get('@sent').
|
|
202
|
+
expect(@request).to have_been_requested
|
|
203
|
+
expect(Flapjack::Gateways::SmsMessagenet.instance_variable_get('@sent')).to eq(1)
|
|
204
204
|
end
|
|
205
205
|
|
|
206
206
|
Then /^the user should receive an email notification$/ do
|
|
207
|
-
Flapjack::Gateways::Email.instance_variable_get('@sent').
|
|
207
|
+
expect(Flapjack::Gateways::Email.instance_variable_get('@sent')).to eq(1)
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
Then /^the user should not receive an SMS notification$/ do
|
|
211
|
-
@request.
|
|
212
|
-
Flapjack::Gateways::SmsMessagenet.instance_variable_get('@sent').
|
|
211
|
+
expect(@request).to have_been_requested
|
|
212
|
+
expect(Flapjack::Gateways::SmsMessagenet.instance_variable_get('@sent')).to eq(0)
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
Then /^the user should not receive an email notification$/ do
|
|
216
|
-
Flapjack::Gateways::Email.instance_variable_get('@sent').
|
|
216
|
+
expect(Flapjack::Gateways::Email.instance_variable_get('@sent')).to eq(0)
|
|
217
217
|
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Given /^I am at the project root$/ do
|
|
2
|
-
Dir.pwd.split('/').last.
|
|
2
|
+
expect(Dir.pwd.split('/').last).to eq("flapjack")
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
Then /^I should see (\d+) lines of output$/ do |number|
|
|
6
|
-
@output.split.size.
|
|
6
|
+
expect(@output.split.size).to eq(number.to_i)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
Then /^every file in the output should start with "([^\"]*)"$/ do |string|
|
|
10
10
|
@output.split.each do |file|
|
|
11
|
-
`head -n 1 #{file}
|
|
11
|
+
expect(`head -n 1 #{file}`).to match(/^#{string}\s*$/)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -21,13 +21,9 @@ When /^I run `([^"]*)`$/ do |cmd|
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
Then /^the exit status should( not)? be (\d+)$/ do |negativity, number|
|
|
24
|
-
|
|
25
|
-
@exit_status.should_not == number.to_i
|
|
26
|
-
else
|
|
27
|
-
@exit_status.should == number.to_i
|
|
28
|
-
end
|
|
24
|
+
expect(@exit_status).send(negativity ? :not_to : :to, eq(number.to_i))
|
|
29
25
|
end
|
|
30
26
|
|
|
31
27
|
Then /^the output should contain "([^"]*)"$/ do |matcher|
|
|
32
|
-
@output.
|
|
28
|
+
expect(@output).to include(matcher)
|
|
33
29
|
end
|
|
@@ -40,6 +40,6 @@ end
|
|
|
40
40
|
# Then /^the time in UTC should be about (.+)$/ do |timestamp|
|
|
41
41
|
# actual = Time.now.in_time_zone('UTC')
|
|
42
42
|
# expected = Time.parse("#{timestamp} UTC")
|
|
43
|
-
# (expected..expected+5).cover?(actual).should
|
|
43
|
+
# (expected..expected+5).cover?(actual).should be true
|
|
44
44
|
# end
|
|
45
45
|
|