flapjack 0.6.43 → 0.6.44
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/flapjack +4 -2
- data/bin/flapjack-nagios-receiver +4 -1
- data/bin/flapjack-populator +4 -1
- data/etc/flapjack_config.yaml.example +111 -106
- data/features/steps/notifications_steps.rb +6 -6
- data/lib/flapjack/configuration.rb +76 -24
- data/lib/flapjack/coordinator.rb +27 -44
- data/lib/flapjack/data/entity.rb +28 -7
- data/lib/flapjack/data/entity_check.rb +18 -20
- data/lib/flapjack/executive.rb +5 -4
- data/lib/flapjack/gateways/api.rb +391 -0
- data/lib/flapjack/gateways/api/entity_check_presenter.rb +185 -0
- data/lib/flapjack/gateways/api/entity_presenter.rb +70 -0
- data/lib/flapjack/gateways/base.rb +38 -0
- data/lib/flapjack/{notification → gateways}/email.rb +4 -5
- data/lib/flapjack/{notification → gateways}/email/alert.html.haml +0 -0
- data/lib/flapjack/{notification → gateways}/email/alert.text.erb +0 -0
- data/lib/flapjack/gateways/jabber.rb +387 -0
- data/lib/flapjack/gateways/oobetet.rb +241 -0
- data/lib/flapjack/gateways/pagerduty.rb +247 -0
- data/lib/flapjack/{notification → gateways}/sms.rb +5 -6
- data/lib/flapjack/{notification → gateways}/sms/messagenet.rb +1 -1
- data/lib/flapjack/gateways/web.rb +293 -0
- data/lib/flapjack/{web → gateways/web}/views/_css.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/_nav.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/check.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/contact.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/contacts.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/index.haml +0 -0
- data/lib/flapjack/{web → gateways/web}/views/self_stats.haml +0 -0
- data/lib/flapjack/pikelet.rb +0 -23
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +56 -36
- data/spec/lib/flapjack/data/entity_spec.rb +53 -4
- data/spec/lib/flapjack/{api → gateways/api}/entity_check_presenter_spec.rb +10 -13
- data/spec/lib/flapjack/{api → gateways/api}/entity_presenter_spec.rb +10 -10
- data/spec/lib/flapjack/{api_spec.rb → gateways/api_spec.rb} +14 -14
- data/spec/lib/flapjack/gateways/email_spec.rb +6 -0
- data/spec/lib/flapjack/{jabber_spec.rb → gateways/jabber_spec.rb} +9 -9
- data/spec/lib/flapjack/{oobetet_spec.rb → gateways/oobetet_spec.rb} +10 -10
- data/spec/lib/flapjack/{pagerduty_spec.rb → gateways/pagerduty_spec.rb} +11 -11
- data/spec/lib/flapjack/gateways/sms_spec.rb +6 -0
- data/spec/lib/flapjack/{web_spec.rb → gateways/web_spec.rb} +4 -4
- metadata +46 -79
- data/bin/install-flapjack-systemwide +0 -58
- data/features/steps/flapjack-importer_steps.rb +0 -109
- data/features/steps/flapjack-worker_steps.rb +0 -68
- data/lib/flapjack/api.rb +0 -388
- data/lib/flapjack/api/entity_check_presenter.rb +0 -181
- data/lib/flapjack/api/entity_presenter.rb +0 -66
- data/lib/flapjack/cli/worker_manager.rb +0 -46
- data/lib/flapjack/inifile.rb +0 -44
- data/lib/flapjack/jabber.rb +0 -383
- data/lib/flapjack/notifier_engine.rb +0 -40
- data/lib/flapjack/notifiers/mailer/init.rb +0 -3
- data/lib/flapjack/notifiers/mailer/mailer.rb +0 -51
- data/lib/flapjack/notifiers/xmpp/init.rb +0 -3
- data/lib/flapjack/notifiers/xmpp/xmpp.rb +0 -46
- data/lib/flapjack/oobetet.rb +0 -240
- data/lib/flapjack/pagerduty.rb +0 -242
- data/lib/flapjack/web.rb +0 -286
- data/spec.old/check_sandbox/echo +0 -3
- data/spec.old/check_sandbox/sandboxed_check +0 -5
- data/spec.old/configs/flapjack-notifier-couchdb.ini +0 -25
- data/spec.old/configs/flapjack-notifier.ini +0 -39
- data/spec.old/configs/recipients.ini +0 -14
- data/spec.old/helpers.rb +0 -15
- data/spec.old/inifile_spec.rb +0 -66
- data/spec.old/mock-notifiers/mock/init.rb +0 -3
- data/spec.old/mock-notifiers/mock/mock.rb +0 -19
- data/spec.old/notifier-directories/spoons/testmailer/init.rb +0 -20
- data/spec.old/notifier_application_spec.rb +0 -222
- data/spec.old/notifier_filters_spec.rb +0 -52
- data/spec.old/notifier_options_multiplexer_spec.rb +0 -71
- data/spec.old/notifier_options_spec.rb +0 -115
- data/spec.old/notifier_spec.rb +0 -57
- data/spec.old/notifiers/mailer_spec.rb +0 -36
- data/spec.old/notifiers/xmpp_spec.rb +0 -36
- data/spec.old/persistence/datamapper_spec.rb +0 -74
- data/spec.old/persistence/mock_persistence_backend.rb +0 -26
- data/spec.old/simple.ini +0 -6
- data/spec.old/spec.opts +0 -4
- data/spec.old/test-filters/blocker.rb +0 -13
- data/spec.old/test-filters/mock.rb +0 -13
- data/spec.old/transports/beanstalkd_spec.rb +0 -44
- data/spec.old/transports/mock_transport.rb +0 -58
- data/spec.old/worker_application_spec.rb +0 -62
- data/spec.old/worker_options_spec.rb +0 -83
- data/spec/lib/flapjack/notification/email_spec.rb +0 -6
- data/spec/lib/flapjack/notification/sms_spec.rb +0 -6
data/spec.old/notifier_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'notifier_engine')
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'transports', 'result')
|
3
|
-
require File.join(File.dirname(__FILE__), 'helpers')
|
4
|
-
|
5
|
-
describe "running the notifier" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should complain if no logger has been specified" do
|
11
|
-
lambda {
|
12
|
-
n = Flapjack::NotifierEngine.new
|
13
|
-
}.should raise_error(RuntimeError)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should warn if no notifiers have been specified" do
|
17
|
-
n = Flapjack::NotifierEngine.new(:log => MockLogger.new)
|
18
|
-
n.log.messages.last.should =~ /no notifiers/
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should log when adding a new notifier" do
|
22
|
-
mock_notifier = mock("MockFlapjack::NotifierEngine")
|
23
|
-
n = Flapjack::NotifierEngine.new(:log => MockLogger.new,
|
24
|
-
:notifiers => [mock_notifier])
|
25
|
-
n.log.messages.last.should =~ /using the (.+) notifier/
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should call notify on each notifier when notifying" do
|
29
|
-
mock_notifier = mock("MockFlapjack::NotifierEngine")
|
30
|
-
mock_notifier.should_receive(:notify)
|
31
|
-
|
32
|
-
result = Flapjack::Transport::Result.new(:result => {:check_id => 12345})
|
33
|
-
|
34
|
-
n = Flapjack::NotifierEngine.new(:log => MockLogger.new,
|
35
|
-
:notifiers => [mock_notifier])
|
36
|
-
n.notify!(:result => result,
|
37
|
-
:event => true,
|
38
|
-
:recipients => [OpenStruct.new({:name => "John Doe"})])
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should log notification on each notifier" do
|
42
|
-
mock_notifier = mock("MockFlapjack::NotifierEngine")
|
43
|
-
mock_notifier.stub!(:notify)
|
44
|
-
|
45
|
-
result = Flapjack::Transport::Result.new(:result => {:check_id => 12345})
|
46
|
-
|
47
|
-
n = Flapjack::NotifierEngine.new(:log => MockLogger.new,
|
48
|
-
:notifiers => [mock_notifier])
|
49
|
-
n.notify!(:result => result,
|
50
|
-
:event => true,
|
51
|
-
:recipients => [OpenStruct.new({:name => "John Doe"})])
|
52
|
-
n.log.messages.last.should =~ /12345/
|
53
|
-
n.log.messages.last.should =~ /John Doe/
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'flapjack', 'notifiers', 'mailer', 'init')
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'helpers')
|
3
|
-
|
4
|
-
describe "mailing notifier" do
|
5
|
-
|
6
|
-
it "should error if no from address is provided" do
|
7
|
-
lambda {
|
8
|
-
mailer = Flapjack::Notifiers::Mailer.new(:log => MockLogger.new)
|
9
|
-
}.should raise_error(ArgumentError, /from address/)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should error if no recipient is provided" do
|
13
|
-
mailer = Flapjack::Notifiers::Mailer.new(:from_address => "test@example.org")
|
14
|
-
lambda {
|
15
|
-
mailer.notify()
|
16
|
-
}.should raise_error(ArgumentError, /recipient/)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should error if no result is provided" do
|
20
|
-
mailer = Flapjack::Notifiers::Mailer.new(:from_address => "test@example.org")
|
21
|
-
lambda {
|
22
|
-
mailer.notify(:who => 'foo')
|
23
|
-
}.should raise_error(ArgumentError, /result/)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should deliver mail to a recipient" do
|
27
|
-
mailer = Flapjack::Notifiers::Mailer.new(:from_address => "test@example.org")
|
28
|
-
response = mailer.notify(:who => OpenStruct.new(:email => "nobody@example.org"),
|
29
|
-
:result => OpenStruct.new(:id => 11, :status => 2, :output => "foo"))
|
30
|
-
response.status.should == '250'
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should have a configurable server to send through"
|
34
|
-
end
|
35
|
-
|
36
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'flapjack', 'notifiers', 'xmpp', 'init')
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'helpers')
|
3
|
-
|
4
|
-
describe "xmpp notifier" do
|
5
|
-
|
6
|
-
it "should error if no login details provided" do
|
7
|
-
lambda {
|
8
|
-
xmpp = Flapjack::Notifiers::Xmpp.new
|
9
|
-
}.should raise_error(ArgumentError)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should error if no recipient is provided" do
|
13
|
-
xmpp = Flapjack::Notifiers::Xmpp.new(:jid => "5b73a016c5c644e9bf1601a241fc27f5@jabber.org", :password => "5b73a016c5c644e9bf1601a241fc27f5")
|
14
|
-
lambda {
|
15
|
-
xmpp.notify(:result => 'foo')
|
16
|
-
}.should raise_error(ArgumentError, /recipient/)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should error if no result is provided" do
|
20
|
-
xmpp = Flapjack::Notifiers::Xmpp.new(:jid => "5b73a016c5c644e9bf1601a241fc27f5@jabber.org", :password => "5b73a016c5c644e9bf1601a241fc27f5")
|
21
|
-
lambda {
|
22
|
-
xmpp.notify(:who => 'foo')
|
23
|
-
}.should raise_error(ArgumentError, /result/)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should deliver message to a recipient" do
|
27
|
-
xmpp = Flapjack::Notifiers::Xmpp.new(:jid => "5b73a016c5c644e9bf1601a241fc27f5@jabber.org", :password => "5b73a016c5c644e9bf1601a241fc27f5")
|
28
|
-
lambda {
|
29
|
-
response = xmpp.notify(:who => OpenStruct.new(:jid => "5b73a016c5c644e9bf1601a241fc27f5@jabber.org"),
|
30
|
-
:result => OpenStruct.new(:id => 11, :status => 2, :output => "foo"))
|
31
|
-
}.should_not raise_error
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
|
@@ -1,74 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'flapjack', 'applications', 'notifier')
|
4
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'flapjack', 'persistence', 'data_mapper')
|
5
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'flapjack', 'transports', 'result')
|
6
|
-
require File.join(File.dirname(__FILE__), '..', 'helpers')
|
7
|
-
require 'tmpdir'
|
8
|
-
|
9
|
-
describe "datamapper persistence backend" do
|
10
|
-
|
11
|
-
it "should query its parent's statuses" do
|
12
|
-
backend_options = { :uri => "sqlite3://#{Dir.mktmpdir}/flapjack.db", :log => MockLogger.new }
|
13
|
-
DataMapper.setup(:default, backend_options[:uri])
|
14
|
-
DataMapper.auto_migrate!
|
15
|
-
|
16
|
-
bad = Check.new(:command => "exit 1", :name => "bad")
|
17
|
-
bad.save.should be_true
|
18
|
-
|
19
|
-
good = Check.new(:command => "exit 0", :name => "good")
|
20
|
-
good.save.should be_true
|
21
|
-
|
22
|
-
relation = RelatedCheck.new(:parent_check => bad, :child_check => good)
|
23
|
-
relation.save.should be_true
|
24
|
-
|
25
|
-
# the bad check doesn't have failing parents
|
26
|
-
raw_result = {:check_id => bad.id, :retval => 2}
|
27
|
-
result = Flapjack::Transport::Result.new(:result => raw_result)
|
28
|
-
|
29
|
-
backend = Flapjack::Persistence::DataMapper.new(backend_options)
|
30
|
-
backend.any_parents_failed?(result).should be_false
|
31
|
-
|
32
|
-
bad.status = 2
|
33
|
-
bad.save
|
34
|
-
|
35
|
-
# the good check has a failing parent (bad)
|
36
|
-
raw_result = {:check_id => good.id, :retval => 0}
|
37
|
-
result = Flapjack::Transport::Result.new(:result => raw_result)
|
38
|
-
backend.any_parents_failed?(result).should be_true
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should persist a result" do
|
42
|
-
backend_options = { :uri => "sqlite3://#{Dir.mktmpdir}/flapjack.db", :log => MockLogger.new }
|
43
|
-
DataMapper.setup(:default, backend_options[:uri])
|
44
|
-
DataMapper.auto_migrate!
|
45
|
-
|
46
|
-
backend = Flapjack::Persistence::DataMapper.new(backend_options)
|
47
|
-
|
48
|
-
check = Check.new(:command => "exit 0", :name => "good")
|
49
|
-
check.save.should be_true
|
50
|
-
|
51
|
-
raw_result = {:check_id => check.id, :retval => 2}
|
52
|
-
result = Flapjack::Transport::Result.new(:result => raw_result)
|
53
|
-
|
54
|
-
backend.save(result).should be_true
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should create an event" do
|
58
|
-
backend_options = { :uri => "sqlite3://#{Dir.mktmpdir}/flapjack.db", :log => MockLogger.new }
|
59
|
-
DataMapper.setup(:default, backend_options[:uri])
|
60
|
-
DataMapper.auto_migrate!
|
61
|
-
|
62
|
-
backend = Flapjack::Persistence::DataMapper.new(backend_options)
|
63
|
-
|
64
|
-
check = Check.new(:command => "exit 0", :name => "good")
|
65
|
-
check.save.should be_true
|
66
|
-
|
67
|
-
raw_result = {:check_id => check.id, :retval => 2}
|
68
|
-
result = Flapjack::Transport::Result.new(:result => raw_result)
|
69
|
-
|
70
|
-
backend.create_event(result).should be_true
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
module Flapjack
|
5
|
-
module Persistence
|
6
|
-
class MockPersistenceBackend
|
7
|
-
def initialize(options={})
|
8
|
-
@options = options
|
9
|
-
@config = OpenStruct.new(@options)
|
10
|
-
@queue = []
|
11
|
-
@log = @config.log
|
12
|
-
end
|
13
|
-
|
14
|
-
# log if the method is called (essentially, these are dodgy mocks)
|
15
|
-
%w(any_parents_failed? save create_event).each do |method|
|
16
|
-
class_eval <<-HERE
|
17
|
-
def #{method}(*args)
|
18
|
-
@log.info("method #{method} was called on MockPersistenceBackend")
|
19
|
-
end
|
20
|
-
HERE
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
data/spec.old/simple.ini
DELETED
data/spec.old/spec.opts
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'flapjack', 'applications', 'notifier')
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'helpers')
|
3
|
-
require 'beanstalk-client'
|
4
|
-
|
5
|
-
describe "notifier application" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
lambda {
|
9
|
-
begin
|
10
|
-
@beanstalk = Beanstalk::Connection.new('localhost:11300', 'results')
|
11
|
-
rescue => e
|
12
|
-
# give helpful error messages to people unfamiliar with the test suite
|
13
|
-
puts
|
14
|
-
puts "You need to have an instance of beanstalkd running locally to run these tests!"
|
15
|
-
puts
|
16
|
-
raise
|
17
|
-
end
|
18
|
-
}.should_not raise_error
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should handle good, bad, and ugly test result" do
|
22
|
-
[ {:output => "", :id => 1, :retval => 0},
|
23
|
-
{:output => "", :id => 2, :retval => 1},
|
24
|
-
{:output => "", :id => 3, :retval => 2} ].each do |result|
|
25
|
-
@beanstalk.yput(result)
|
26
|
-
end
|
27
|
-
|
28
|
-
options = { :notifiers => {},
|
29
|
-
:filters => [],
|
30
|
-
:log => MockLogger.new,
|
31
|
-
:transport => {:backend => :beanstalkd},
|
32
|
-
:persistence => {:backend => :mock_persistence_backend,
|
33
|
-
:basedir => File.join(File.dirname(__FILE__), '..', 'persistence')}}
|
34
|
-
app = Flapjack::Notifier::Application.run(options)
|
35
|
-
|
36
|
-
3.times do |n|
|
37
|
-
lambda {
|
38
|
-
app.process_result
|
39
|
-
}.should_not raise_error
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
@@ -1,58 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
module Flapjack
|
5
|
-
module Transport
|
6
|
-
class MockTransport
|
7
|
-
def initialize(options={})
|
8
|
-
@options = options
|
9
|
-
@config = OpenStruct.new(@options)
|
10
|
-
@queue = []
|
11
|
-
@log = @config.log
|
12
|
-
end
|
13
|
-
|
14
|
-
%w(delete put).each do |method|
|
15
|
-
class_eval <<-HERE
|
16
|
-
def #{method}(*args)
|
17
|
-
@log.info("method #{method} was called on MockTransport")
|
18
|
-
end
|
19
|
-
HERE
|
20
|
-
end
|
21
|
-
|
22
|
-
# exactly the same as above, just returns a real object
|
23
|
-
def next
|
24
|
-
@log.info("method next was called on MockTransport")
|
25
|
-
MockResult.new(@options)
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
module Flapjack
|
34
|
-
module Transport
|
35
|
-
class MockResult
|
36
|
-
def initialize(options={})
|
37
|
-
@options = options
|
38
|
-
@config = OpenStruct.new(@options)
|
39
|
-
@log = @config.log
|
40
|
-
end
|
41
|
-
|
42
|
-
# log if the method is called (essentially, these are dodgy mocks)
|
43
|
-
%w(warning? critical? any_parents_failed? save check_id frequency).each do |method|
|
44
|
-
class_eval <<-HERE
|
45
|
-
def #{method}(*args)
|
46
|
-
@log.info("method #{method} was called on MockResult")
|
47
|
-
end
|
48
|
-
HERE
|
49
|
-
end
|
50
|
-
|
51
|
-
# exactly the same as above, just returns a real object
|
52
|
-
def command(*args)
|
53
|
-
@log.info("method command was called on MockResult")
|
54
|
-
"echo foo"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'applications', 'worker')
|
2
|
-
require File.join(File.dirname(__FILE__), 'helpers')
|
3
|
-
|
4
|
-
describe "worker application" do
|
5
|
-
|
6
|
-
it "should have a simple booting interface " do
|
7
|
-
options = {:log => MockLogger.new}
|
8
|
-
app = Flapjack::Worker::Application.run(options)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should load beanstalkd as the default transport" do
|
12
|
-
options = {:log => MockLogger.new}
|
13
|
-
app = Flapjack::Worker::Application.run(options)
|
14
|
-
|
15
|
-
app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport/i}.should_not be_nil
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should setup two transports (checks + results)" do
|
19
|
-
options = {:log => MockLogger.new}
|
20
|
-
app = Flapjack::Worker::Application.run(options)
|
21
|
-
|
22
|
-
app.log.messages.find_all {|msg| msg =~ /loading.+beanstalkd.+transport/i}.size.should == 2
|
23
|
-
app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport.+checks/i}.should be_true
|
24
|
-
app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport.+results/i}.should be_true
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should load a transport as specified in options" do
|
28
|
-
options = {:log => MockLogger.new, :transport => {:backend => :beanstalkd}}
|
29
|
-
app = Flapjack::Worker::Application.run(options)
|
30
|
-
|
31
|
-
app.log.messages.find {|msg| msg =~ /loading.+beanstalkd.+transport/i}.should_not be_nil
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should error if the specified transport dosen't exist" do
|
35
|
-
options = {:log => MockLogger.new, :transport => {:backend => :nonexistant}}
|
36
|
-
lambda {
|
37
|
-
app = Flapjack::Worker::Application.run(options)
|
38
|
-
}.should raise_error
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should execute checks in a sandbox"
|
42
|
-
|
43
|
-
it "should use a limited interface for dealing with transports" do
|
44
|
-
options = { :log => MockLogger.new,
|
45
|
-
:transport => {:backend => :mock_transport,
|
46
|
-
:basedir => File.join(File.dirname(__FILE__), 'transports')} }
|
47
|
-
app = Flapjack::Worker::Application.run(options)
|
48
|
-
app.process_check
|
49
|
-
|
50
|
-
# check allowed methods were called
|
51
|
-
allowed_methods = %w(next)
|
52
|
-
allowed_methods.each do |method|
|
53
|
-
app.log.messages.find {|msg| msg =~ /#{method} was called/}.should_not be_nil
|
54
|
-
end
|
55
|
-
|
56
|
-
# check no other methods were called
|
57
|
-
called_methods = app.log.messages.find_all {|msg| msg =~ /^method .+ was called on MockTransport$/i }.map {|msg| msg.split(' ')[1]}
|
58
|
-
(allowed_methods - called_methods).size.should == 0
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
end
|