flapjack 0.7.14 → 0.7.15
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/etc/flapjack_config.yaml.example +1 -0
- data/features/events.feature +5 -0
- data/features/notification_rules.feature +1 -1
- data/features/steps/events_steps.rb +28 -13
- data/features/steps/notifications_steps.rb +1 -1
- data/lib/flapjack/coordinator.rb +3 -1
- data/lib/flapjack/data/contact.rb +8 -6
- data/lib/flapjack/data/entity_check.rb +78 -113
- data/lib/flapjack/data/event.rb +54 -65
- data/lib/flapjack/data/notification.rb +5 -1
- data/lib/flapjack/executive.rb +42 -38
- data/lib/flapjack/filters/acknowledgement.rb +5 -5
- data/lib/flapjack/filters/base.rb +2 -2
- data/lib/flapjack/filters/delays.rb +11 -11
- data/lib/flapjack/filters/detect_mass_client_failures.rb +8 -8
- data/lib/flapjack/filters/ok.rb +6 -6
- data/lib/flapjack/filters/scheduled_maintenance.rb +2 -2
- data/lib/flapjack/filters/unscheduled_maintenance.rb +3 -2
- data/lib/flapjack/gateways/api.rb +374 -277
- data/lib/flapjack/gateways/api/entity_check_presenter.rb +52 -21
- data/lib/flapjack/gateways/api/entity_presenter.rb +14 -9
- data/lib/flapjack/gateways/email.rb +7 -0
- data/lib/flapjack/gateways/email/alert.html.haml +13 -1
- data/lib/flapjack/gateways/email/alert.text.erb +5 -4
- data/lib/flapjack/gateways/jabber.rb +90 -34
- data/lib/flapjack/gateways/pagerduty.rb +6 -2
- data/lib/flapjack/gateways/web.rb +13 -8
- data/lib/flapjack/gateways/web/views/check.haml +70 -45
- data/lib/flapjack/gateways/web/views/checks.haml +1 -1
- data/lib/flapjack/gateways/web/views/entity.haml +1 -1
- data/lib/flapjack/patches.rb +9 -2
- data/lib/flapjack/pikelet.rb +14 -10
- data/lib/flapjack/utility.rb +10 -4
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +19 -5
- data/spec/lib/flapjack/data/entity_check_spec.rb +3 -30
- data/spec/lib/flapjack/data/event_spec.rb +96 -1
- data/spec/lib/flapjack/executive_spec.rb +5 -11
- data/spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb +22 -3
- data/spec/lib/flapjack/gateways/api/entity_presenter_spec.rb +30 -15
- data/spec/lib/flapjack/gateways/api_spec.rb +552 -186
- data/spec/lib/flapjack/gateways/email_spec.rb +2 -0
- data/spec/lib/flapjack/gateways/jabber_spec.rb +5 -4
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +3 -2
- data/spec/lib/flapjack/gateways/web_spec.rb +17 -12
- data/spec/lib/flapjack/pikelet_spec.rb +5 -2
- metadata +4 -5
- data/config.ru +0 -11
@@ -14,10 +14,10 @@
|
|
14
14
|
= nav
|
15
15
|
%h2 #{@check} on #{@entity}
|
16
16
|
%h3 State: #{@check_state ? @check_state.upcase : ''}
|
17
|
-
- if (['warning', 'critical', 'unknown'].include?(@check_state) and
|
17
|
+
- if (['warning', 'critical', 'unknown'].include?(@check_state) and !@current_scheduled_maintenance)
|
18
18
|
%form{:action => "/acknowledgements/#{check_path_escaped}", :method => "post", :class => "form-inline"}
|
19
19
|
%input{:type => 'hidden', :name => 'acknowledgement_id', :value => "#{@acknowledgement_id}"}
|
20
|
-
%input{:type => 'submit', :value => 'Acknowledge', :class => 'button'}
|
20
|
+
%input{:type => 'submit', :value => @current_unscheduled_maintenance ? 'Replace acknowledgment' : 'Acknowledge', :class => 'button'}
|
21
21
|
with
|
22
22
|
%label{:for => 'summary'}
|
23
23
|
summary:
|
@@ -25,14 +25,23 @@
|
|
25
25
|
%label{:for => 'duration'}
|
26
26
|
duration:
|
27
27
|
%input{:type => 'text', :name => 'duration', :value => ''}
|
28
|
-
|
28
|
+
e.g. "5 hours"
|
29
|
+
- current_time = (@current_unscheduled_maintenance || @current_scheduled_maintenance) ? Time.now : nil
|
29
30
|
- if @current_unscheduled_maintenance
|
30
31
|
%h3 (Acknowledged - #{@current_unscheduled_maintenance[:summary]})
|
32
|
+
- start = Time.at(@current_unscheduled_maintenance[:start_time])
|
33
|
+
- finish = Time.at(@current_unscheduled_maintenance[:start_time] + @current_unscheduled_maintenance[:duration])
|
34
|
+
- remain = time_period_in_words( (finish - current_time).ceil )
|
35
|
+
%p #{start} -> #{finish} (#{remain} remaining)
|
31
36
|
%form{:action => "/end_unscheduled_maintenance/#{check_path_escaped}", :method => "post"}
|
32
37
|
%p
|
33
38
|
%input{:type => 'submit', :value => 'End Unscheduled Maintenance (Unacknowledge)', :class => 'button'}
|
34
39
|
- if @current_scheduled_maintenance
|
35
40
|
%h4 (Scheduled Maintenance - #{@current_scheduled_maintenance[:summary]})
|
41
|
+
- start = Time.at(@current_scheduled_maintenance[:start_time])
|
42
|
+
- finish = Time.at(@current_scheduled_maintenance[:start_time] + @current_scheduled_maintenance[:duration])
|
43
|
+
- remain = time_period_in_words( (finish - current_time).ceil )
|
44
|
+
%p #{start} -> #{finish} (#{remain} remaining)
|
36
45
|
%h3 Output: #{@check_summary}
|
37
46
|
%p #{@check_details}
|
38
47
|
%table{:class => "table table-hover table-condensed"}
|
@@ -40,60 +49,62 @@
|
|
40
49
|
%td Last state change:
|
41
50
|
%td #{relative_time_ago(Time.at(@check_last_change.to_i))} ago
|
42
51
|
%td #{Time.at(@check_last_change.to_i)}
|
52
|
+
%td
|
43
53
|
%tr
|
44
54
|
%td Last update:
|
45
55
|
%td #{relative_time_ago(Time.at(@check_last_update.to_i))} ago
|
46
56
|
%td #{Time.at(@check_last_update.to_i)}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
-
|
52
|
-
- last_critical = ''
|
57
|
+
%td
|
58
|
+
- last_critical = nil
|
59
|
+
- if @last_notifications[:critical] && @last_notifications[:critical][:timestamp]
|
60
|
+
- t = Time.at(@last_notifications[:critical][:timestamp])
|
61
|
+
- last_critical = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:critical][:summary]}
|
53
62
|
%tr
|
54
63
|
%td Last critical notification:
|
55
|
-
%td=
|
56
|
-
%td= last_critical
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
- last_warning
|
64
|
+
%td= last_critical ? last_critical[:relative] : 'never'
|
65
|
+
%td= last_critical ? last_critical[:time] : ''
|
66
|
+
%td= last_critical ? last_critical[:summary] : ''
|
67
|
+
|
68
|
+
- last_warning = nil
|
69
|
+
- if @last_notifications[:warning] && @last_notifications[:warning][:timestamp]
|
70
|
+
- t = Time.at(@last_notifications[:warning][:timestamp])
|
71
|
+
- last_warning = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:warning][:summary]}
|
63
72
|
%tr
|
64
73
|
%td Last warning notification:
|
65
|
-
%td=
|
66
|
-
%td= last_warning
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
-
|
71
|
-
-
|
72
|
-
- last_unknown
|
74
|
+
%td= last_warning ? last_warning[:relative] : 'never'
|
75
|
+
%td= last_warning ? last_warning[:time] : ''
|
76
|
+
%td= last_warning ? last_warning[:summary] : ''
|
77
|
+
|
78
|
+
- last_unknown = nil
|
79
|
+
- if @last_notifications[:unknown] && @last_notifications[:unknown][:timestamp]
|
80
|
+
- t = Time.at(@last_notifications[:unknown][:timestamp])
|
81
|
+
- last_unknown = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:unknown][:summary]}
|
73
82
|
%tr
|
74
83
|
%td Last unknown notification:
|
75
|
-
%td=
|
76
|
-
%td= last_unknown
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
- last_recovery
|
84
|
+
%td= last_unknown ? last_unknown[:relative] : 'never'
|
85
|
+
%td= last_unknown ? last_unknown[:time] : ''
|
86
|
+
%td= last_unknown ? last_unknown[:summary] : ''
|
87
|
+
|
88
|
+
- last_recovery = nil
|
89
|
+
- if @last_notifications[:recovery] && @last_notifications[:recovery][:timestamp]
|
90
|
+
- t = Time.at(@last_notifications[:recovery][:timestamp])
|
91
|
+
- last_recovery = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:recovery][:summary]}
|
83
92
|
%tr
|
84
93
|
%td Last recovery notification:
|
85
|
-
%td=
|
86
|
-
%td= last_recovery
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
- last_ack
|
94
|
+
%td= last_recovery ? last_recovery[:relative] : 'never'
|
95
|
+
%td= last_recovery ? last_recovery[:time] : ''
|
96
|
+
%td= last_recovery ? last_recovery[:summary] : ''
|
97
|
+
|
98
|
+
- last_ack = nil
|
99
|
+
- if @last_notifications[:acknowledgement] && @last_notifications[:acknowledgement][:timestamp]
|
100
|
+
- t = Time.at(@last_notifications[:acknowledgement][:timestamp])
|
101
|
+
- last_ack = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:acknowledgement][:summary]}
|
93
102
|
%tr
|
94
103
|
%td Last acknowledgement notification:
|
95
|
-
%td=
|
96
|
-
%td= last_ack
|
104
|
+
%td= last_ack ? last_ack[:relative] : 'never'
|
105
|
+
%td= last_ack ? last_ack[:time] : ''
|
106
|
+
%td= last_ack ? last_ack[:summary] : ''
|
107
|
+
|
97
108
|
%h3 Scheduled Maintenance Periods
|
98
109
|
- if @scheduled_maintenances && !@scheduled_maintenances.empty?
|
99
110
|
%table{:class => "table table-bordered table-hover table-condensed"}
|
@@ -134,12 +145,12 @@
|
|
134
145
|
%label{:class => "control-label", :for => 'start_time'} Start time:
|
135
146
|
%div{:class => "controls"}
|
136
147
|
%input{:type => 'text', :name => 'start_time', :class => 'text', :size => '20', :maxlength => '80'}
|
137
|
-
|
148
|
+
e.g. "today 4pm", "two hours hence", "friday 2pm", "2012-01-28 13:00"
|
138
149
|
%div{:class => "control-group"}
|
139
150
|
%label{:class => "control-label", :for => 'duration'} Duration:
|
140
151
|
%div{:class => "controls"}
|
141
152
|
%input{:type => 'text', :name => 'duration', :class => 'text', :size => '20', :maxlength => '80'}
|
142
|
-
|
153
|
+
e.g. "1 hour", "2:30:00", "three days", etc
|
143
154
|
%div{:class => "control-group"}
|
144
155
|
%label{:class => "control-label", :for => 'summary'} Summary:
|
145
156
|
%div{:class => "controls"}
|
@@ -148,6 +159,20 @@
|
|
148
159
|
%div{:class => "controls"}
|
149
160
|
%input{:type => 'submit', :value => 'Save', :class => 'button'}
|
150
161
|
%p Times given will be interpreted in the local timezone of #{local_timezone}
|
162
|
+
|
163
|
+
- if @state_changes && !@state_changes.empty?
|
164
|
+
%h3 Recent state changes
|
165
|
+
%table{:class => "table table-bordered table-hover table-condensed"}
|
166
|
+
%tr
|
167
|
+
%th Timestamp
|
168
|
+
%th State
|
169
|
+
%th Summary
|
170
|
+
- @state_changes.each do |sc|
|
171
|
+
%tr
|
172
|
+
%td= Time.at(sc[:timestamp]).to_s
|
173
|
+
%td= sc[:state]
|
174
|
+
%td= sc[:summary]
|
175
|
+
|
151
176
|
%h3 Contacts
|
152
177
|
- if @contacts && !@contacts.empty?
|
153
178
|
%table{:class => "table table-bordered table-hover table-condensed"}
|
@@ -38,7 +38,7 @@
|
|
38
38
|
= " (Acknowledged)" if in_unscheduled_outage
|
39
39
|
= " (Scheduled Maintenance)" if in_scheduled_outage
|
40
40
|
%td= relative_time_ago(Time.at(changed.to_i)) + ' ago'
|
41
|
-
%td= (Time.
|
41
|
+
%td= relative_time_ago(Time.at(updated.to_i)) + ' ago'
|
42
42
|
- if notified && (notified > 0)
|
43
43
|
- last_notified = relative_time_ago(Time.at(notified.to_i)) + " ago, #{notified_kind}"
|
44
44
|
- else
|
@@ -36,7 +36,7 @@
|
|
36
36
|
= " (Acknowledged)" if in_unscheduled_outage
|
37
37
|
= " (Scheduled Maintenance)" if in_scheduled_outage
|
38
38
|
%td= relative_time_ago(Time.at(changed.to_i)) + ' ago'
|
39
|
-
%td= (Time.
|
39
|
+
%td= relative_time_ago(Time.at(updated.to_i)) + ' ago'
|
40
40
|
- if notified && (notified > 0)
|
41
41
|
- last_notified = relative_time_ago(Time.at(notified.to_i)) + " ago, #{notified_kind}"
|
42
42
|
- else
|
data/lib/flapjack/patches.rb
CHANGED
@@ -44,6 +44,8 @@ class Hash
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
# we don't want to stop the entire EM reactor when we stop a web server
|
48
|
+
# & @connections data type changed in thin 1.5.1
|
47
49
|
module Thin
|
48
50
|
|
49
51
|
# see https://github.com/flpjck/flapjack/issues/169
|
@@ -64,7 +66,6 @@ module Thin
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
# we don't want to stop the entire EM reactor when we stop a web server
|
68
69
|
module Backends
|
69
70
|
class Base
|
70
71
|
def stop!
|
@@ -72,7 +73,13 @@ module Thin
|
|
72
73
|
@stopping = false
|
73
74
|
|
74
75
|
# EventMachine.stop if EventMachine.reactor_running?
|
75
|
-
|
76
|
+
|
77
|
+
case @connections
|
78
|
+
when Array
|
79
|
+
@connections.each { |connection| connection.close_connection }
|
80
|
+
when Hash
|
81
|
+
@connections.each_value { |connection| connection.close_connection }
|
82
|
+
end
|
76
83
|
close
|
77
84
|
end
|
78
85
|
end
|
data/lib/flapjack/pikelet.rb
CHANGED
@@ -28,7 +28,6 @@ require 'flapjack/gateways/web'
|
|
28
28
|
require 'flapjack/logger'
|
29
29
|
require 'thin/version'
|
30
30
|
|
31
|
-
|
32
31
|
module Thin
|
33
32
|
# disable Thin's loading of daemons
|
34
33
|
# workaround for https://github.com/flpjck/flapjack/issues/133
|
@@ -52,12 +51,13 @@ module Flapjack
|
|
52
51
|
!type_klass.nil?
|
53
52
|
end
|
54
53
|
|
55
|
-
def self.create(type,
|
54
|
+
def self.create(type, opts = {})
|
56
55
|
pikelet = nil
|
57
56
|
[Flapjack::Pikelet::Generic,
|
58
57
|
Flapjack::Pikelet::Resque,
|
59
58
|
Flapjack::Pikelet::Thin].each do |kl|
|
60
|
-
|
59
|
+
next unless kl::PIKELET_TYPES[type]
|
60
|
+
break if pikelet = kl.create(type, opts)
|
61
61
|
end
|
62
62
|
pikelet
|
63
63
|
end
|
@@ -71,6 +71,7 @@ module Flapjack
|
|
71
71
|
|
72
72
|
@config = opts[:config] || {}
|
73
73
|
@redis_config = opts[:redis_config] || {}
|
74
|
+
@boot_time = opts[:boot_time]
|
74
75
|
|
75
76
|
@logger = Flapjack::Logger.new("flapjack-#{type}", @config['logger'])
|
76
77
|
|
@@ -98,9 +99,10 @@ module Flapjack
|
|
98
99
|
'pagerduty' => Flapjack::Gateways::Pagerduty,
|
99
100
|
'oobetet' => Flapjack::Gateways::Oobetet}
|
100
101
|
|
101
|
-
def self.create(type,
|
102
|
-
|
103
|
-
|
102
|
+
def self.create(type, opts = {})
|
103
|
+
self.new(type, PIKELET_TYPES[type], :config => opts[:config],
|
104
|
+
:redis_config => opts[:redis_config],
|
105
|
+
:boot_time => opts[:boot_time])
|
104
106
|
end
|
105
107
|
|
106
108
|
def initialize(type, pikelet_klass, opts = {})
|
@@ -140,8 +142,9 @@ module Flapjack
|
|
140
142
|
'sms' => Flapjack::Gateways::SmsMessagenet}
|
141
143
|
|
142
144
|
def self.create(type, opts = {})
|
143
|
-
|
144
|
-
|
145
|
+
self.new(type, PIKELET_TYPES[type], :config => opts[:config],
|
146
|
+
:redis_config => opts[:redis_config],
|
147
|
+
:boot_time => opts[:boot_time])
|
145
148
|
end
|
146
149
|
|
147
150
|
def initialize(type, pikelet_klass, opts = {})
|
@@ -198,9 +201,10 @@ module Flapjack
|
|
198
201
|
'api' => Flapjack::Gateways::API}
|
199
202
|
|
200
203
|
def self.create(type, opts = {})
|
201
|
-
return unless pikelet_klass = PIKELET_TYPES[type]
|
202
204
|
::Thin::Logging.silent = true
|
203
|
-
self.new(type,
|
205
|
+
self.new(type, PIKELET_TYPES[type], :config => opts[:config],
|
206
|
+
:redis_config => opts[:redis_config],
|
207
|
+
:boot_time => opts[:boot_time])
|
204
208
|
end
|
205
209
|
|
206
210
|
def initialize(type, pikelet_klass, opts = {})
|
data/lib/flapjack/utility.rb
CHANGED
@@ -7,10 +7,10 @@ module Flapjack
|
|
7
7
|
period_mm, period_ss = period.divmod(60)
|
8
8
|
period_hh, period_mm = period_mm.divmod(60)
|
9
9
|
period_dd, period_hh = period_hh.divmod(24)
|
10
|
-
["#{period_dd}
|
11
|
-
"#{period_hh}
|
12
|
-
"#{period_mm}
|
13
|
-
"#{period_ss}
|
10
|
+
["#{period_dd} day#{plural_s(period_dd)}",
|
11
|
+
"#{period_hh} hour#{plural_s(period_hh)}",
|
12
|
+
"#{period_mm} minute#{plural_s(period_mm)}",
|
13
|
+
"#{period_ss} second#{plural_s(period_ss)}"].reject {|s| s =~ /^0 /}.join(', ')
|
14
14
|
end
|
15
15
|
|
16
16
|
# Returns relative time in words referencing the given date
|
@@ -68,5 +68,11 @@ module Flapjack
|
|
68
68
|
Hash[ *( key_value_pairs.flatten(1) )]
|
69
69
|
end
|
70
70
|
|
71
|
+
private
|
72
|
+
|
73
|
+
def plural_s(value)
|
74
|
+
(value == 1) ? '' : 's'
|
75
|
+
end
|
76
|
+
|
71
77
|
end
|
72
78
|
end
|
data/lib/flapjack/version.rb
CHANGED
@@ -11,6 +11,8 @@ describe Flapjack::Coordinator do
|
|
11
11
|
let(:stdout_out) { mock('stdout_out') }
|
12
12
|
let(:syslog_out) { mock('syslog_out') }
|
13
13
|
|
14
|
+
let!(:time) { Time.now }
|
15
|
+
|
14
16
|
def setup_logger
|
15
17
|
formatter = mock('Formatter')
|
16
18
|
Log4r::PatternFormatter.should_receive(:new).with(
|
@@ -41,9 +43,12 @@ describe Flapjack::Coordinator do
|
|
41
43
|
executive.should_receive(:update_status)
|
42
44
|
executive.should_receive(:status).exactly(3).times.and_return('stopped')
|
43
45
|
|
46
|
+
Time.should_receive(:now).and_return(time)
|
47
|
+
|
44
48
|
fc = Flapjack::Coordinator.new(config)
|
45
49
|
Flapjack::Pikelet.should_receive(:create).with('executive',
|
46
|
-
:config => cfg['executive'], :redis_config => {}).
|
50
|
+
:config => cfg['executive'], :redis_config => {}, :boot_time => time).
|
51
|
+
and_return(executive)
|
47
52
|
|
48
53
|
fiber.should_receive(:resume)
|
49
54
|
Fiber.should_receive(:new).and_yield.and_return(fiber)
|
@@ -69,9 +74,12 @@ describe Flapjack::Coordinator do
|
|
69
74
|
executive.should_receive(:update_status)
|
70
75
|
executive.should_receive(:status).exactly(3).times.and_return('stopped')
|
71
76
|
|
77
|
+
Time.should_receive(:now).and_return(time)
|
78
|
+
|
72
79
|
fc = Flapjack::Coordinator.new(config)
|
73
80
|
Flapjack::Pikelet.should_receive(:create).with('executive',
|
74
|
-
:config => cfg['executive'], :redis_config => {})
|
81
|
+
:config => cfg['executive'], :redis_config => {}, :boot_time => time)
|
82
|
+
.and_return(executive)
|
75
83
|
|
76
84
|
fiber.should_receive(:resume)
|
77
85
|
Fiber.should_receive(:new).and_yield.and_return(fiber)
|
@@ -140,8 +148,10 @@ describe Flapjack::Coordinator do
|
|
140
148
|
executive.should_receive(:status).exactly(3).times.and_return('stopped')
|
141
149
|
|
142
150
|
jabber = mock('jabber')
|
143
|
-
Flapjack::Pikelet.should_receive(:create).
|
144
|
-
:config => {"enabled" => "yes"}, :redis_config => {}
|
151
|
+
Flapjack::Pikelet.should_receive(:create).
|
152
|
+
with('jabber', :config => {"enabled" => "yes"}, :redis_config => {},
|
153
|
+
:boot_time => time).
|
154
|
+
and_return(jabber)
|
145
155
|
jabber.should_receive(:start)
|
146
156
|
|
147
157
|
fiber.should_receive(:resume)
|
@@ -149,6 +159,7 @@ describe Flapjack::Coordinator do
|
|
149
159
|
|
150
160
|
config.should_receive(:for_redis).and_return({})
|
151
161
|
fc = Flapjack::Coordinator.new(config)
|
162
|
+
fc.instance_variable_set('@boot_time', time)
|
152
163
|
fc.instance_variable_set('@pikelets', [executive])
|
153
164
|
fc.reload
|
154
165
|
fc.instance_variable_get('@pikelets').should == [jabber]
|
@@ -178,6 +189,7 @@ describe Flapjack::Coordinator do
|
|
178
189
|
|
179
190
|
config.should_receive(:for_redis).and_return({})
|
180
191
|
fc = Flapjack::Coordinator.new(config)
|
192
|
+
fc.instance_variable_set('@boot_time', time)
|
181
193
|
fc.instance_variable_set('@pikelets', [executive])
|
182
194
|
fc.reload
|
183
195
|
fc.instance_variable_get('@pikelets').should == [executive]
|
@@ -213,11 +225,13 @@ describe Flapjack::Coordinator do
|
|
213
225
|
new_exec.should_receive(:start)
|
214
226
|
|
215
227
|
Flapjack::Pikelet.should_receive(:create).
|
216
|
-
with('executive', :config => new_cfg['executive'], :redis_config => {}
|
228
|
+
with('executive', :config => new_cfg['executive'], :redis_config => {},
|
229
|
+
:boot_time => time).
|
217
230
|
and_return(new_exec)
|
218
231
|
|
219
232
|
config.should_receive(:for_redis).and_return({})
|
220
233
|
fc = Flapjack::Coordinator.new(config)
|
234
|
+
fc.instance_variable_set('@boot_time', time)
|
221
235
|
fc.instance_variable_set('@pikelets', [executive])
|
222
236
|
fc.reload
|
223
237
|
fc.instance_variable_get('@pikelets').should == [new_exec]
|
@@ -354,33 +354,6 @@ describe Flapjack::Data::EntityCheck, :redis => true do
|
|
354
354
|
|
355
355
|
end
|
356
356
|
|
357
|
-
it "creates an acknowledgement" do
|
358
|
-
ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
|
359
|
-
t = Time.now.to_i
|
360
|
-
ec.create_acknowledgement('summary' => 'looking now',
|
361
|
-
'time' => t,
|
362
|
-
'acknowledgement_id' => '75',
|
363
|
-
'duration' => 40 * 60)
|
364
|
-
event_json = @redis.rpop('events')
|
365
|
-
event_json.should_not be_nil
|
366
|
-
event = nil
|
367
|
-
expect {
|
368
|
-
event = JSON.parse(event_json)
|
369
|
-
}.not_to raise_error
|
370
|
-
event.should_not be_nil
|
371
|
-
event.should be_a(Hash)
|
372
|
-
event.should == {
|
373
|
-
'entity' => name,
|
374
|
-
'check' => check,
|
375
|
-
'type' => 'action',
|
376
|
-
'state' => 'acknowledgement',
|
377
|
-
'summary' => 'looking now',
|
378
|
-
'time' => t,
|
379
|
-
'acknowledgement_id' => '75',
|
380
|
-
'duration' => 2400
|
381
|
-
}
|
382
|
-
end
|
383
|
-
|
384
357
|
it "returns its state" do
|
385
358
|
@redis.hset("check:#{name}:#{check}", 'state', 'ok')
|
386
359
|
|
@@ -520,9 +493,9 @@ describe Flapjack::Data::EntityCheck, :redis => true do
|
|
520
493
|
@redis.set("#{name}:#{check}:last_recovery_notification", t)
|
521
494
|
|
522
495
|
ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
|
523
|
-
ec.
|
524
|
-
ec.
|
525
|
-
ec.
|
496
|
+
ec.last_notification_for_state(:problem)[:timestamp].should == t - 30
|
497
|
+
ec.last_notification_for_state(:acknowledgement)[:timestamp].should == t - 15
|
498
|
+
ec.last_notification_for_state(:recovery)[:timestamp].should == t
|
526
499
|
end
|
527
500
|
|
528
501
|
it "finds all related contacts" do
|