flapjack 0.8.11 → 0.8.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/CONTRIBUTING.md +35 -0
- data/Gemfile +1 -1
- data/README.md +16 -14
- data/bin/flapjack-feed-events +124 -0
- data/bin/flapjack-nagios-receiver +1 -1
- data/bin/flapjack-nsca-receiver +1 -1
- data/etc/flapjack_config.yaml.example +1 -2
- data/features/cli_flapjack-feed-events.feature +104 -0
- data/features/steps/events_steps.rb +2 -2
- data/features/steps/packaging-lintian_steps.rb +2 -2
- data/features/support/env.rb +7 -1
- data/flapjack.gemspec +2 -3
- data/lib/flapjack/configuration.rb +1 -0
- data/lib/flapjack/data/contact.rb +1 -1
- data/lib/flapjack/data/event.rb +25 -21
- data/lib/flapjack/data/notification_rule.rb +43 -29
- data/lib/flapjack/gateways/api.rb +1 -1
- data/lib/flapjack/gateways/api/contact_methods.rb +13 -13
- data/lib/flapjack/gateways/jabber.rb +2 -2
- data/lib/flapjack/gateways/jsonapi.rb +16 -10
- data/lib/flapjack/gateways/jsonapi/contact_methods.rb +6 -6
- data/lib/flapjack/gateways/jsonapi/entity_methods.rb +2 -2
- data/lib/flapjack/gateways/jsonapi/medium_methods.rb +5 -4
- data/lib/flapjack/gateways/jsonapi/metrics_methods.rb +100 -0
- data/lib/flapjack/gateways/jsonapi/notification_rule_methods.rb +28 -11
- data/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods.rb +2 -1
- data/lib/flapjack/gateways/pagerduty.rb +7 -0
- data/lib/flapjack/gateways/web.rb +7 -2
- data/lib/flapjack/gateways/web/public/css/nv.d3.css +769 -0
- data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +150 -44
- data/lib/flapjack/gateways/web/public/js/d3.v3.min.js +5 -0
- data/lib/flapjack/gateways/web/public/js/flapjack.js +78 -0
- data/lib/flapjack/gateways/web/public/js/modules/contact.js +521 -0
- data/lib/flapjack/gateways/web/public/js/modules/entity.js +28 -0
- data/lib/flapjack/gateways/web/public/js/modules/medium.js +39 -0
- data/lib/flapjack/gateways/web/public/js/moment.js +2489 -0
- data/lib/flapjack/gateways/web/public/js/nv.d3.min.js +6 -0
- data/lib/flapjack/gateways/web/public/js/select2.js +12 -12
- data/lib/flapjack/gateways/web/public/js/self_stats.js +78 -0
- data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +108 -73
- data/lib/flapjack/gateways/web/views/layout.erb +11 -12
- data/lib/flapjack/gateways/web/views/self_stats.html.erb +32 -4
- data/lib/flapjack/patches.rb +1 -1
- data/lib/flapjack/pikelet.rb +1 -1
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/data/contact_spec.rb +0 -1
- data/spec/lib/flapjack/data/notification_rule_spec.rb +6 -4
- data/spec/lib/flapjack/gateways/jsonapi/contact_methods_spec.rb +15 -0
- data/spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb +19 -4
- data/spec/lib/flapjack/gateways/jsonapi/medium_methods_spec.rb +2 -3
- data/spec/lib/flapjack/gateways/jsonapi/notification_rule_methods_spec.rb +41 -3
- data/spec/lib/flapjack/gateways/jsonapi/pagerduty_credential_methods_spec.rb +2 -2
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +16 -0
- data/spec/spec_helper.rb +14 -2
- metadata +20 -17
- data/lib/flapjack/gateways/web/public/css/bootstrap-responsive.min.css +0 -9
- data/lib/flapjack/gateways/web/public/css/bootstrap-theme.css +0 -397
- data/lib/flapjack/gateways/web/public/css/bootstrap-theme.min.css +0 -7
- data/lib/flapjack/gateways/web/public/css/bootstrap.min.css +0 -7
- data/lib/flapjack/gateways/web/public/css/font-awesome.min.css +0 -4
- data/lib/flapjack/gateways/web/public/js/backbone-min.js +0 -2
- data/lib/flapjack/gateways/web/public/js/bootstrap.min.js +0 -6
- data/lib/flapjack/gateways/web/public/js/contacts.js +0 -490
- data/lib/flapjack/gateways/web/public/js/jquery-1.10.2.min.js +0 -6
- data/lib/flapjack/gateways/web/public/js/moment.min.js +0 -6
- data/lib/flapjack/gateways/web/public/js/select2.min.js +0 -22
- data/lib/flapjack/gateways/web/public/js/underscore-min.js +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c12d1908e4d17b6184593f91b1208c20cff78bcd
|
4
|
+
data.tar.gz: c3975b071f0b015ad7a2f0728430cdb4b5411751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71d0bcbb7e4317817dbadd673ebb719f8c07afd3b73d0daac58610f5774b1c653cbac43443020bc319abd98d40a1031d3273c6904557bc9cc8ad3f896042eccb
|
7
|
+
data.tar.gz: 756fb36155e507f440464f4e1841db59e43e5eff0c468579d208d19d4f2a45cf84494077f20ad685a82aa23807a364ddc26cfb655673cf2454e9e63721c1ffab
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
## Flapjack Changelog
|
2
2
|
|
3
|
+
# 0.8.12 - 2014-05-21
|
4
|
+
- Feature: highlight the section that I'm in #483 (@auxesis)
|
5
|
+
- Feature: Visualise the event queue length on self stats page #482 (@auxesis)
|
6
|
+
- Feature: Restructure backbone /edit_contacts UI (and backend file structure), fix remaining usage issues #515 (@ali-graham)
|
7
|
+
- Bug: pagerduty gateway exception when subdomain not set #486 (@jessereynolds)
|
8
|
+
- Bug: tests use default redis port #495 (@spazm)
|
9
|
+
- Bug: GET /notification_rules doesn't work #510 (@ali-graham)
|
10
|
+
- Bug: JSONAPI -- do not emit entities without ids #521 (@ali-graham)
|
11
|
+
- Bug: PATCHing blackhole properties for notification rule changes other blackholes #504 (@ali-graham)
|
12
|
+
- Chore: updated github urls to use new flapjack project name #491 (@spazm)
|
13
|
+
- Chore: Add a CONTRIBUTING.md doc for potential helpers #492 (@spazm)
|
14
|
+
|
15
|
+
|
3
16
|
# 0.8.11 - 2014-05-01
|
4
17
|
- Feature: simulate-failed-check - give -t a default of 45 seconds (@jessereynolds)
|
5
18
|
- Feature: allow email messages to have custom from address #468 (@mattdelves)
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#Contributing to ![Flapjack](https://raw.github.com/flapjack/flapjack/gh-pages/images/flapjack-2013-notext-transparent-50-50.png "Flapjack") Flapjack
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/flapjack/flapjack.png)](https://travis-ci.org/flapjack/flapjack)
|
4
|
+
|
5
|
+
Please see the [Contributing to Flapjack](https://github.com/flapjack/flapjack/wiki/DEVELOPING) section of the Flapjack wiki.
|
6
|
+
|
7
|
+
> Flapjack is, and will continue to be, well tested. Monitoring is like continuous integration for production apps, so why shouldn't your monitoring system have tests?
|
8
|
+
|
9
|
+
## Quick Start
|
10
|
+
|
11
|
+
1. clone the repo
|
12
|
+
|
13
|
+
git clone https://github.com/flapjack/flapjack.git
|
14
|
+
|
15
|
+
2. install development dependencies with bundler:
|
16
|
+
|
17
|
+
cd flapjack
|
18
|
+
gem install bundler
|
19
|
+
bundle install
|
20
|
+
|
21
|
+
3. install redis
|
22
|
+
4. run unit tests
|
23
|
+
|
24
|
+
rake spec
|
25
|
+
|
26
|
+
5. run integration tests
|
27
|
+
|
28
|
+
rake features
|
29
|
+
|
30
|
+
6. code coverage for tests
|
31
|
+
|
32
|
+
COVERAGE=x rake spec
|
33
|
+
COVERAGE=x rake features
|
34
|
+
|
35
|
+
7. make changes with tests, send a [pull request](https://help.github.com/articles/creating-a-pull-request), share love!
|
data/Gemfile
CHANGED
@@ -20,6 +20,6 @@ group :test do
|
|
20
20
|
gem 'guard-cucumber'
|
21
21
|
gem 'fuubar'
|
22
22
|
gem 'simplecov', :require => false
|
23
|
-
gem 'debugger-ruby_core_source', '>= 1.3.
|
23
|
+
gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools
|
24
24
|
gem 'perftools.rb'
|
25
25
|
end
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# ![Flapjack](https://raw.github.com/
|
1
|
+
# ![Flapjack](https://raw.github.com/flapjack/flapjack/gh-pages/images/flapjack-2013-notext-transparent-50-50.png "Flapjack") Flapjack
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
3
|
+
[![Build Status](https://travis-ci.org/flapjack/flapjack.png)](https://travis-ci.org/flapjack/flapjack)
|
4
4
|
|
5
5
|
[Flapjack](http://flapjack.io/) is a flexible monitoring notification routing system that handles:
|
6
6
|
|
@@ -71,11 +71,13 @@ gem install flapjack
|
|
71
71
|
|
72
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.
|
73
73
|
|
74
|
-
Alternatively, you can add support for your OS of choice to [omnibus-flapjack](https://github.com/
|
74
|
+
Alternatively, you can add support for your OS of choice to [omnibus-flapjack](https://github.com/flapjack/omnibus-flapjack) and build a native package. Pull requests welcome, and we'll help you make this happen!
|
75
|
+
|
76
|
+
You'll also need Redis >= 2.6.12.
|
75
77
|
|
76
78
|
## Configuring
|
77
79
|
|
78
|
-
Have a look at the default config file and modify things as required. See the [Configuring Components](https://github.com/
|
80
|
+
Have a look at the default config file and modify things as required. See the [Configuring Components](https://github.com/flapjack/flapjack/wiki/USING#wiki-configuring_components) section on the wiki for more details.
|
79
81
|
|
80
82
|
``` bash
|
81
83
|
# hack the config
|
@@ -122,11 +124,11 @@ sudo /etc/init.d/flapjack start
|
|
122
124
|
|
123
125
|
## Using - Details
|
124
126
|
|
125
|
-
For more information, including full specification of the configuration file and the data import formats, please refer to the [USING](https://github.com/
|
127
|
+
For more information, including full specification of the configuration file and the data import formats, please refer to the [USING](https://github.com/flapjack/flapjack/wiki/USING) section of the Flapjack wiki
|
126
128
|
|
127
129
|
## Developing Flapjack
|
128
130
|
|
129
|
-
Information on developing more Flapjack components or contributing to core Flapjack development can be found in the [DEVELOPING](https://github.com/
|
131
|
+
Information on developing more Flapjack components or contributing to core Flapjack development can be found in the [DEVELOPING](https://github.com/flapjack/flapjack/wiki/DEVELOPING) section of the Flapjack wiki
|
130
132
|
|
131
133
|
## Documentation Submodule
|
132
134
|
|
@@ -145,14 +147,14 @@ If you make changes to the documentation locally, here's how to publish them:
|
|
145
147
|
|
146
148
|
## More on the wiki
|
147
149
|
|
148
|
-
[The Flapjack wiki](https://github.com/
|
150
|
+
[The Flapjack wiki](https://github.com/flapjack/flapjack/wiki) has even more goodies:
|
149
151
|
|
150
|
-
- [Using Flapjack](https://github.com/
|
151
|
-
- [Developing Flapjack](https://github.com/
|
152
|
-
- [Redis Data Structure](https://github.com/
|
153
|
-
- [API](https://github.com/
|
154
|
-
- [Importing](https://github.com/
|
155
|
-
- [Debugging Flapjack](https://github.com/
|
156
|
-
- [Flapjack Glossary](https://github.com/
|
152
|
+
- [Using Flapjack](https://github.com/flapjack/flapjack/wiki/USING)
|
153
|
+
- [Developing Flapjack](https://github.com/flapjack/flapjack/wiki/DEVELOPING)
|
154
|
+
- [Redis Data Structure](https://github.com/flapjack/flapjack/wiki/DATA_STRUCTURES)
|
155
|
+
- [API](https://github.com/flapjack/flapjack/wiki/API)
|
156
|
+
- [Importing](https://github.com/flapjack/flapjack/wiki/IMPORTING)
|
157
|
+
- [Debugging Flapjack](https://github.com/flapjack/flapjack/wiki/DEBUGGING)
|
158
|
+
- [Flapjack Glossary](https://github.com/flapjack/flapjack/wiki/GLOSSARY)
|
157
159
|
|
158
160
|
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
unless $:.include?(File.dirname(__FILE__) + '/../lib/')
|
3
|
+
$: << File.dirname(__FILE__) + '/../lib'
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
require 'ostruct'
|
8
|
+
require 'redis'
|
9
|
+
require 'oj'
|
10
|
+
|
11
|
+
require 'flapjack/configuration'
|
12
|
+
require 'flapjack/data/event'
|
13
|
+
|
14
|
+
exe = File.basename(__FILE__)
|
15
|
+
|
16
|
+
options = OpenStruct.new
|
17
|
+
options.config = Flapjack::Configuration::DEFAULT_CONFIG_PATH
|
18
|
+
|
19
|
+
optparse = OptionParser.new do |opts|
|
20
|
+
opts.banner = "Usage: #{exe} [OPTIONS]"
|
21
|
+
|
22
|
+
opts.separator ""
|
23
|
+
opts.separator "Feed JSON blobs from file or STDIN into the Flapjack event queue."
|
24
|
+
opts.separator ""
|
25
|
+
opts.separator "Options"
|
26
|
+
|
27
|
+
opts.on("-c", "--config [PATH]", String, "PATH to the config file to use.") do |c|
|
28
|
+
options.config = c
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-f", "--from [FILE]", String, "path to the FILE to process; if not provided, defaults to STDIN.") do |f|
|
32
|
+
options.from = f
|
33
|
+
end
|
34
|
+
end
|
35
|
+
optparse.parse!(ARGV)
|
36
|
+
|
37
|
+
bail_with_usage = proc do |message|
|
38
|
+
puts message
|
39
|
+
puts "\n#{optparse}"
|
40
|
+
exit(false)
|
41
|
+
end
|
42
|
+
|
43
|
+
if options.help
|
44
|
+
puts optparse
|
45
|
+
exit
|
46
|
+
elsif options.version
|
47
|
+
puts Flapjack::VERSION
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
|
51
|
+
FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'production'
|
52
|
+
config = Flapjack::Configuration.new
|
53
|
+
config.load(options.config)
|
54
|
+
config_env = config.all
|
55
|
+
if config_env.nil? || config_env.empty?
|
56
|
+
puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{options.config}'"
|
57
|
+
exit(false)
|
58
|
+
end
|
59
|
+
redis = Redis.new(config.for_redis)
|
60
|
+
|
61
|
+
input = if options.from
|
62
|
+
File.open(options.from) # Explodes if file does not exist.
|
63
|
+
else
|
64
|
+
bail_with_usage.call("No file provided, and STDIN is from terminal! Exiting...") if $stdin.tty?
|
65
|
+
$stdin
|
66
|
+
end
|
67
|
+
|
68
|
+
# Sit and churn through the input stream until a valid JSON blob has been assembled.
|
69
|
+
# This handles both the case of a process sending a single JSON and then exiting
|
70
|
+
# (eg. cat foo.json | bin/flapjack-feed-event) *and* a longer-running process spitting
|
71
|
+
# out events (eg. /usr/bin/slow-event-feed | bin/flapjack-feed-event)
|
72
|
+
|
73
|
+
class EventFeedHandler < Oj::ScHandler
|
74
|
+
|
75
|
+
def initialize(&block)
|
76
|
+
@hash_depth = 0
|
77
|
+
@callback = block if block_given?
|
78
|
+
end
|
79
|
+
|
80
|
+
def hash_start
|
81
|
+
@hash_depth += 1
|
82
|
+
Hash.new
|
83
|
+
end
|
84
|
+
|
85
|
+
def hash_end
|
86
|
+
@hash_depth -= 1
|
87
|
+
end
|
88
|
+
|
89
|
+
def array_start
|
90
|
+
Array.new
|
91
|
+
end
|
92
|
+
|
93
|
+
def array_end
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_value(value)
|
97
|
+
@callback.call(value) if @callback
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
def hash_set(hash, key, value)
|
102
|
+
hash[key] = value
|
103
|
+
end
|
104
|
+
|
105
|
+
def array_append(array, value)
|
106
|
+
array << value
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
parser = EventFeedHandler.new do |parsed|
|
112
|
+
# Handle "parsed" (a hash)
|
113
|
+
errors = Flapjack::Data::Event.validation_errors_for_hash(parsed)
|
114
|
+
if errors.empty?
|
115
|
+
Flapjack::Data::Event.add(parsed, :redis => redis)
|
116
|
+
puts "Enqueued event data, #{parsed.inspect}"
|
117
|
+
else
|
118
|
+
puts "Invalid event data received, #{errors.join(', ')} #{parsed.inspect}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
Oj.sc_parse(parser, input)
|
123
|
+
|
124
|
+
puts "Done."
|
@@ -140,7 +140,7 @@ nagios.cfg changes:
|
|
140
140
|
host_perfdata_file_mode=p
|
141
141
|
service_perfdata_file_mode=p
|
142
142
|
|
143
|
-
Details on the wiki: https://github.com/
|
143
|
+
Details on the wiki: https://github.com/flapjack/flapjack/wiki/USING#configuring-nagios
|
144
144
|
'
|
145
145
|
|
146
146
|
exit
|
data/bin/flapjack-nsca-receiver
CHANGED
@@ -138,7 +138,7 @@ in the configfile:
|
|
138
138
|
The Nsca daemon is optionally writing to a tempfile if the named pipe does
|
139
139
|
not exist.
|
140
140
|
|
141
|
-
Details on the wiki: https://github.com/
|
141
|
+
Details on the wiki: https://github.com/flapjack/flapjack/wiki/USING#XXX
|
142
142
|
'
|
143
143
|
|
144
144
|
exit
|
@@ -0,0 +1,104 @@
|
|
1
|
+
@process
|
2
|
+
Feature: flapjack-feed-events command line
|
3
|
+
As a systems administrator
|
4
|
+
I should be able to use flapjack-feed-events
|
5
|
+
From the command line
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "flapjack-feed-events.yaml" with:
|
9
|
+
"""
|
10
|
+
test:
|
11
|
+
redis:
|
12
|
+
db: 14
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: Running with --help shows usage information
|
16
|
+
When I run `bin/flapjack-feed-events --help`
|
17
|
+
Then the exit status should be 0
|
18
|
+
And the output should contain "Usage: flapjack-feed-events"
|
19
|
+
And the output should contain "-c, --config"
|
20
|
+
And the output should contain "-f, --from"
|
21
|
+
|
22
|
+
Scenario: Running flapjack-feed-events with no arguments and no STDIN fails with a warning
|
23
|
+
When I run `bin/flapjack-feed-events -c tmp/cucumber_cli/flapjack-feed-events.yaml`
|
24
|
+
And the output should contain "No file provided, and STDIN is from terminal! Exiting..."
|
25
|
+
And the output should contain "Usage: flapjack-feed-events"
|
26
|
+
Then the exit status should be 1
|
27
|
+
|
28
|
+
|
29
|
+
Scenario: Feed a single event into the events queue
|
30
|
+
Given a file named "single-event.json" with:
|
31
|
+
"""
|
32
|
+
{
|
33
|
+
"entity": "client1-localhost-test-1",
|
34
|
+
"check": "foo",
|
35
|
+
"type": "service",
|
36
|
+
"state": "ok",
|
37
|
+
"summary": "testing"
|
38
|
+
}
|
39
|
+
"""
|
40
|
+
When I run `cat tmp/cucumber_cli/single-event.json | bin/flapjack-feed-events -c tmp/cucumber_cli/flapjack-feed-events.yaml`
|
41
|
+
Then the exit status should be 0
|
42
|
+
And the output should not contain "Invalid event data received"
|
43
|
+
And the output should contain "Enqueued event data, "
|
44
|
+
And the output should contain "client1-localhost-test-1"
|
45
|
+
And the output should contain "Done."
|
46
|
+
|
47
|
+
When I run `bin/flapjack-feed-events -c tmp/cucumber_cli/flapjack-feed-events.yaml -f tmp/cucumber_cli/single-event.json`
|
48
|
+
Then the exit status should be 0
|
49
|
+
And the output should not contain "Invalid event data received"
|
50
|
+
And the output should contain "Enqueued event data, "
|
51
|
+
And the output should contain "client1-localhost-test-1"
|
52
|
+
And the output should contain "Done."
|
53
|
+
|
54
|
+
|
55
|
+
Scenario: Feed multiple events into the events queue
|
56
|
+
Given a file named "multiple-events.json" with:
|
57
|
+
"""
|
58
|
+
{"entity": "client1-localhost-test-1", "check": "foo",
|
59
|
+
"type": "service", "state": "ok", "summary": "testing"}
|
60
|
+
{"entity": "client1-localhost-test-2",
|
61
|
+
"check": "bar", "type": "service", "state": "ok", "summary":
|
62
|
+
"testing"
|
63
|
+
}
|
64
|
+
"""
|
65
|
+
When I run `cat tmp/cucumber_cli/multiple-events.json | bin/flapjack-feed-events -c tmp/cucumber_cli/flapjack-feed-events.yaml`
|
66
|
+
Then the exit status should be 0
|
67
|
+
And the output should not contain "Invalid event data received"
|
68
|
+
And the output should contain "Enqueued event data, "
|
69
|
+
And the output should contain "client1-localhost-test-1"
|
70
|
+
And the output should contain "client1-localhost-test-2"
|
71
|
+
And the output should contain "Done."
|
72
|
+
|
73
|
+
When I run `bin/flapjack-feed-events -c tmp/cucumber_cli/flapjack-feed-events.yaml -f tmp/cucumber_cli/multiple-events.json`
|
74
|
+
Then the exit status should be 0
|
75
|
+
And the output should not contain "Invalid event data received"
|
76
|
+
And the output should contain "Enqueued event data, "
|
77
|
+
And the output should contain "client1-localhost-test-1"
|
78
|
+
And the output should contain "client1-localhost-test-2"
|
79
|
+
And the output should contain "Done."
|
80
|
+
|
81
|
+
Scenario: Feed invalid events into the events queue
|
82
|
+
Given a file named "invalid-events.json" with:
|
83
|
+
"""
|
84
|
+
{"entity": "client1-localhost-test-1"}
|
85
|
+
{"entity": "client1-localhost-test-2", "check": "bar"}
|
86
|
+
"""
|
87
|
+
When I run `cat tmp/cucumber_cli/invalid-events.json | bin/flapjack-feed-events -c tmp/cucumber_cli/flapjack-feed-events.yaml`
|
88
|
+
Then the exit status should be 0
|
89
|
+
And the output should not contain "Enqueued event data, "
|
90
|
+
And the output should contain "Invalid event data received"
|
91
|
+
And the output should contain "client1-localhost-test-1"
|
92
|
+
And the output should contain "client1-localhost-test-2"
|
93
|
+
And the output should contain "Done."
|
94
|
+
|
95
|
+
Scenario: Feed invalid JSON into the events queue
|
96
|
+
Given a file named "invalid-json.json" with:
|
97
|
+
"""
|
98
|
+
{"entity": "client1-localhost-test-1"
|
99
|
+
{"entity": "client1-localhost-test-2", "check": "bar"}
|
100
|
+
"""
|
101
|
+
When I run `cat tmp/cucumber_cli/invalid-json.json | bin/flapjack-feed-events -c tmp/cucumber_cli/flapjack-feed-events.yaml`
|
102
|
+
Then the exit status should be 1
|
103
|
+
And the output should not contain "Enqueued event data, "
|
104
|
+
And the output should contain "(Oj::ParseError)"
|
@@ -145,8 +145,8 @@ end
|
|
145
145
|
|
146
146
|
def icecube_schedule_to_time_restriction(sched, time_zone)
|
147
147
|
tr = sched.to_hash
|
148
|
-
tr[:start_time] = time_zone.utc_to_local(tr[:
|
149
|
-
tr[:end_time] = time_zone.utc_to_local(tr[:end_time][:time]).strftime
|
148
|
+
tr[:start_time] = {:time => time_zone.utc_to_local(tr[:start_time][:time]).strftime("%Y-%m-%d %H:%M:%S"), :zone => time_zone}
|
149
|
+
tr[:end_time] = {:time => time_zone.utc_to_local(tr[:end_time][:time]).strftime("%Y-%m-%d %H:%M:%S"), :zone => time_zone}
|
150
150
|
|
151
151
|
# rewrite IceCube::WeeklyRule to Weekly, etc
|
152
152
|
tr[:rrules].each {|rrule|
|
@@ -24,6 +24,6 @@ Then /^the exit status should( not)? be (\d+)$/ do |negativity, number|
|
|
24
24
|
expect(@exit_status).send(negativity ? :not_to : :to, eq(number.to_i))
|
25
25
|
end
|
26
26
|
|
27
|
-
Then /^the output should contain "([^"]*)"$/ do |matcher|
|
28
|
-
expect(@output).to include(matcher)
|
27
|
+
Then /^the output should( not)? contain "([^"]*)"$/ do |negativity, matcher|
|
28
|
+
expect(@output).send(negativity ? :not_to : :to, include(matcher))
|
29
29
|
end
|
data/features/support/env.rb
CHANGED
@@ -5,6 +5,7 @@ require 'delorean'
|
|
5
5
|
require 'chronic'
|
6
6
|
require 'active_support/time'
|
7
7
|
require 'ice_cube'
|
8
|
+
require 'flapjack/configuration'
|
8
9
|
require 'flapjack/data/entity_check'
|
9
10
|
require 'flapjack/data/event'
|
10
11
|
|
@@ -23,6 +24,8 @@ end
|
|
23
24
|
|
24
25
|
ENV["FLAPJACK_ENV"] = 'test'
|
25
26
|
FLAPJACK_ENV = 'test'
|
27
|
+
FLAPJACK_ROOT = File.join(File.dirname(__FILE__), '..', '..')
|
28
|
+
FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.yaml')
|
26
29
|
|
27
30
|
$: << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
28
31
|
|
@@ -119,7 +122,10 @@ EXPIRE_AS_IF_AT
|
|
119
122
|
|
120
123
|
end
|
121
124
|
|
122
|
-
|
125
|
+
config = Flapjack::Configuration.new
|
126
|
+
redis_opts = config.load(FLAPJACK_CONFIG) ?
|
127
|
+
config.for_redis :
|
128
|
+
{:db => 14, :driver => :ruby}
|
123
129
|
redis = ::Redis.new(redis_opts)
|
124
130
|
redis.flushdb
|
125
131
|
RedisDelorean.before_all(:redis => redis)
|