resurrected_god 0.14.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +559 -0
- data/README.md +9 -4
- data/bin/god +26 -28
- data/ext/god/extconf.rb +9 -9
- data/lib/god/behavior.rb +3 -5
- data/lib/god/behaviors/clean_pid_file.rb +4 -6
- data/lib/god/behaviors/clean_unix_socket.rb +4 -6
- data/lib/god/behaviors/notify_when_flapping.rb +13 -15
- data/lib/god/cli/command.rb +109 -89
- data/lib/god/cli/run.rb +51 -75
- data/lib/god/cli/version.rb +2 -4
- data/lib/god/condition.rb +12 -14
- data/lib/god/conditions/always.rb +3 -2
- data/lib/god/conditions/complex.rb +23 -24
- data/lib/god/conditions/cpu_usage.rb +12 -16
- data/lib/god/conditions/degrading_lambda.rb +15 -19
- data/lib/god/conditions/disk_usage.rb +7 -8
- data/lib/god/conditions/file_mtime.rb +3 -7
- data/lib/god/conditions/file_touched.rb +4 -5
- data/lib/god/conditions/flapping.rb +57 -62
- data/lib/god/conditions/http_response_code.rb +27 -32
- data/lib/god/conditions/lambda.rb +3 -5
- data/lib/god/conditions/memory_usage.rb +12 -16
- data/lib/god/conditions/process_exits.rb +12 -12
- data/lib/god/conditions/process_running.rb +8 -10
- data/lib/god/conditions/socket_responding.rb +23 -28
- data/lib/god/conditions/tries.rb +12 -14
- data/lib/god/configurable.rb +7 -10
- data/lib/god/contact.rb +41 -52
- data/lib/god/contacts/airbrake.rb +10 -12
- data/lib/god/contacts/campfire.rb +18 -20
- data/lib/god/contacts/email.rb +27 -28
- data/lib/god/contacts/prowl.rb +16 -17
- data/lib/god/contacts/scout.rb +2 -5
- data/lib/god/contacts/sensu.rb +15 -11
- data/lib/god/contacts/slack.rb +23 -33
- data/lib/god/contacts/statsd.rb +8 -8
- data/lib/god/contacts/twitter.rb +2 -2
- data/lib/god/contacts/webhook.rb +21 -24
- data/lib/god/driver.rb +12 -18
- data/lib/god/errors.rb +0 -2
- data/lib/god/event_handler.rb +40 -49
- data/lib/god/event_handlers/dummy_handler.rb +1 -1
- data/lib/god/event_handlers/kqueue_handler.rb +2 -2
- data/lib/god/event_handlers/netlink_handler.rb +1 -1
- data/lib/god/logger.rb +5 -13
- data/lib/god/metric.rb +13 -15
- data/lib/god/process.rb +93 -98
- data/lib/god/simple_logger.rb +13 -15
- data/lib/god/socket.rb +21 -23
- data/lib/god/sugar.rb +8 -8
- data/lib/god/sys_logger.rb +6 -8
- data/lib/god/system/portable_poller.rb +1 -9
- data/lib/god/system/process.rb +4 -6
- data/lib/god/system/slash_proc_poller.rb +17 -19
- data/lib/god/task.rb +110 -136
- data/lib/god/timeline.rb +2 -4
- data/lib/god/trigger.rb +7 -11
- data/lib/god/version.rb +1 -1
- data/lib/god/watch.rb +51 -57
- data/lib/god.rb +122 -148
- metadata +17 -370
- data/Announce.txt +0 -135
- data/Gemfile +0 -5
- data/Rakefile +0 -129
- data/doc/god.asciidoc +0 -1592
- data/doc/intro.asciidoc +0 -20
- data/ext/god/.gitignore +0 -5
- data/lib/god/compat19.rb +0 -33
- data/lib/god/contacts/hipchat.rb +0 -117
- data/lib/god/contacts/jabber.rb +0 -75
- data/test/configs/child_events/child_events.god +0 -44
- data/test/configs/child_events/simple_server.rb +0 -3
- data/test/configs/child_polls/child_polls.god +0 -37
- data/test/configs/child_polls/simple_server.rb +0 -12
- data/test/configs/complex/complex.god +0 -59
- data/test/configs/complex/simple_server.rb +0 -3
- data/test/configs/contact/contact.god +0 -118
- data/test/configs/contact/simple_server.rb +0 -3
- data/test/configs/daemon_events/daemon_events.god +0 -37
- data/test/configs/daemon_events/simple_server.rb +0 -8
- data/test/configs/daemon_events/simple_server_stop.rb +0 -11
- data/test/configs/daemon_polls/daemon_polls.god +0 -17
- data/test/configs/daemon_polls/simple_server.rb +0 -6
- data/test/configs/degrading_lambda/degrading_lambda.god +0 -31
- data/test/configs/degrading_lambda/tcp_server.rb +0 -15
- data/test/configs/keepalive/keepalive.god +0 -9
- data/test/configs/keepalive/keepalive.rb +0 -12
- data/test/configs/lifecycle/lifecycle.god +0 -25
- data/test/configs/matias/matias.god +0 -50
- data/test/configs/real.rb +0 -59
- data/test/configs/running_load/running_load.god +0 -16
- data/test/configs/stop_options/simple_server.rb +0 -12
- data/test/configs/stop_options/stop_options.god +0 -39
- data/test/configs/stress/simple_server.rb +0 -3
- data/test/configs/stress/stress.god +0 -15
- data/test/configs/task/logs/.placeholder +0 -0
- data/test/configs/task/task.god +0 -26
- data/test/configs/test.rb +0 -61
- data/test/configs/usr1_trapper.rb +0 -10
- data/test/helper.rb +0 -172
- data/test/suite.rb +0 -6
- data/test/test_airbrake.rb +0 -14
- data/test/test_behavior.rb +0 -18
- data/test/test_campfire.rb +0 -22
- data/test/test_condition.rb +0 -52
- data/test/test_conditions_disk_usage.rb +0 -50
- data/test/test_conditions_http_response_code.rb +0 -109
- data/test/test_conditions_process_running.rb +0 -40
- data/test/test_conditions_socket_responding.rb +0 -176
- data/test/test_conditions_tries.rb +0 -67
- data/test/test_contact.rb +0 -109
- data/test/test_driver.rb +0 -26
- data/test/test_email.rb +0 -34
- data/test/test_event_handler.rb +0 -82
- data/test/test_god.rb +0 -710
- data/test/test_god_system.rb +0 -201
- data/test/test_handlers_kqueue_handler.rb +0 -16
- data/test/test_hipchat.rb +0 -23
- data/test/test_jabber.rb +0 -29
- data/test/test_logger.rb +0 -55
- data/test/test_metric.rb +0 -74
- data/test/test_process.rb +0 -263
- data/test/test_prowl.rb +0 -15
- data/test/test_registry.rb +0 -15
- data/test/test_sensu.rb +0 -11
- data/test/test_slack.rb +0 -57
- data/test/test_socket.rb +0 -34
- data/test/test_statsd.rb +0 -22
- data/test/test_sugar.rb +0 -42
- data/test/test_system_portable_poller.rb +0 -17
- data/test/test_system_process.rb +0 -30
- data/test/test_task.rb +0 -246
- data/test/test_timeline.rb +0 -37
- data/test/test_trigger.rb +0 -63
- data/test/test_watch.rb +0 -286
- data/test/test_webhook.rb +0 -22
data/test/test_watch.rb
DELETED
@@ -1,286 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class TestWatch < Minitest::Test
|
4
|
-
def setup
|
5
|
-
God.internal_init
|
6
|
-
@watch = Watch.new
|
7
|
-
@watch.name = 'foo'
|
8
|
-
@watch.start = lambda { }
|
9
|
-
@watch.stop = lambda { }
|
10
|
-
@watch.prepare
|
11
|
-
end
|
12
|
-
|
13
|
-
# new
|
14
|
-
|
15
|
-
def test_new_should_have_no_behaviors
|
16
|
-
assert_equal [], @watch.behaviors
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_new_should_have_no_metrics
|
20
|
-
Watch::VALID_STATES.each do |state|
|
21
|
-
assert_equal [], @watch.metrics[state]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_new_should_have_standard_attributes
|
26
|
-
assert_nothing_raised do
|
27
|
-
@watch.name = 'foo'
|
28
|
-
@watch.start = 'start'
|
29
|
-
@watch.stop = 'stop'
|
30
|
-
@watch.restart = 'restart'
|
31
|
-
@watch.interval = 30
|
32
|
-
@watch.grace = 5
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_new_should_have_unmonitored_state
|
37
|
-
assert_equal :unmonitored, @watch.state
|
38
|
-
end
|
39
|
-
|
40
|
-
# valid?
|
41
|
-
|
42
|
-
def test_valid?
|
43
|
-
God::Process.any_instance.expects(:valid?)
|
44
|
-
@watch.valid?
|
45
|
-
end
|
46
|
-
|
47
|
-
# behavior
|
48
|
-
|
49
|
-
def test_behavior_should_record_behavior
|
50
|
-
beh = nil
|
51
|
-
@watch.behavior(:fake_behavior) { |b| beh = b }
|
52
|
-
assert_equal 1, @watch.behaviors.size
|
53
|
-
assert_equal beh, @watch.behaviors.first
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_invalid_behavior_should_abort
|
57
|
-
assert_abort do
|
58
|
-
@watch.behavior(:invalid)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# transition
|
63
|
-
|
64
|
-
def test_transition_should_abort_on_invalid_start_state
|
65
|
-
assert_abort do
|
66
|
-
@watch.transition(:foo, :bar)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_transition_should_accept_all_valid_start_states
|
71
|
-
assert_nothing_raised do
|
72
|
-
Watch::VALID_STATES.each do |state|
|
73
|
-
@watch.transition(state, :bar) { }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_transition_should_create_and_record_a_metric_for_the_given_start_state
|
79
|
-
@watch.transition(:init, :start) { }
|
80
|
-
assert_equal 1, @watch.metrics[:init].size
|
81
|
-
end
|
82
|
-
|
83
|
-
# lifecycle
|
84
|
-
|
85
|
-
def test_lifecycle_should_create_and_record_a_metric_for_nil_start_state
|
86
|
-
@watch.lifecycle { }
|
87
|
-
assert_equal 1, @watch.metrics[nil].size
|
88
|
-
end
|
89
|
-
|
90
|
-
# keepalive
|
91
|
-
|
92
|
-
def test_keepalive_should_place_metrics_on_up_state
|
93
|
-
@watch.keepalive(:memory_max => 5.megabytes, :cpu_max => 50.percent)
|
94
|
-
assert_equal 2, @watch.metrics[:up].size
|
95
|
-
end
|
96
|
-
|
97
|
-
# start_if
|
98
|
-
|
99
|
-
def test_start_if_should_place_a_metric_on_up_state
|
100
|
-
@watch.start_if { }
|
101
|
-
assert_equal 1, @watch.metrics[:up].size
|
102
|
-
end
|
103
|
-
|
104
|
-
# restart_if
|
105
|
-
|
106
|
-
def test_restart_if_should_place_a_metric_on_up_state
|
107
|
-
@watch.restart_if { }
|
108
|
-
assert_equal 1, @watch.metrics[:up].size
|
109
|
-
end
|
110
|
-
|
111
|
-
# monitor
|
112
|
-
|
113
|
-
def test_monitor_should_move_to_init_if_available
|
114
|
-
@watch.instance_eval do
|
115
|
-
transition(:init, :up) { }
|
116
|
-
end
|
117
|
-
@watch.expects(:move).with(:init)
|
118
|
-
@watch.monitor
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_monitor_should_move_to_up_if_no_init_available
|
122
|
-
@watch.expects(:move).with(:up)
|
123
|
-
@watch.monitor
|
124
|
-
end
|
125
|
-
|
126
|
-
# unmonitor
|
127
|
-
|
128
|
-
def test_unmonitor_should_move_to_nil
|
129
|
-
@watch.expects(:move).with(:unmonitored)
|
130
|
-
@watch.unmonitor
|
131
|
-
end
|
132
|
-
|
133
|
-
# move
|
134
|
-
|
135
|
-
def test_move_should_not_clean_up_if_from_state_is_nil
|
136
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
137
|
-
@watch.driver.expects(:message).never
|
138
|
-
|
139
|
-
metric = nil
|
140
|
-
|
141
|
-
@watch.instance_eval do
|
142
|
-
transition(:init, :up) do |on|
|
143
|
-
metric = on
|
144
|
-
on.condition(:process_running) do |c|
|
145
|
-
c.running = true
|
146
|
-
c.interval = 10
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
metric.expects(:disable).never
|
152
|
-
|
153
|
-
@watch.move(:init)
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_move_should_clean_up_from_state_if_not_nil
|
157
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
158
|
-
@watch.driver.expects(:message).never
|
159
|
-
|
160
|
-
metric = nil
|
161
|
-
|
162
|
-
@watch.instance_eval do
|
163
|
-
transition(:init, :up) do |on|
|
164
|
-
metric = on
|
165
|
-
on.condition(:process_running) do |c|
|
166
|
-
c.running = true
|
167
|
-
c.interval = 10
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
@watch.move(:init)
|
173
|
-
|
174
|
-
metric.expects(:disable)
|
175
|
-
|
176
|
-
@watch.move(:up)
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_move_should_call_action
|
180
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
181
|
-
@watch.driver.expects(:message).never
|
182
|
-
|
183
|
-
@watch.expects(:action).with(:start)
|
184
|
-
|
185
|
-
@watch.move(:start)
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_move_should_move_to_up_state_if_no_start_or_restart_metric
|
189
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
190
|
-
@watch.driver.expects(:message).never
|
191
|
-
|
192
|
-
[:start, :restart].each do |state|
|
193
|
-
@watch.expects(:action)
|
194
|
-
@watch.move(state)
|
195
|
-
assert_equal :up, @watch.state
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_move_should_enable_destination_metric
|
200
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
201
|
-
@watch.driver.expects(:message).never
|
202
|
-
|
203
|
-
metric = nil
|
204
|
-
|
205
|
-
@watch.instance_eval do
|
206
|
-
transition(:init, :up) do |on|
|
207
|
-
metric = on
|
208
|
-
on.condition(:process_running) do |c|
|
209
|
-
c.running = true
|
210
|
-
c.interval = 10
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
metric.expects(:enable)
|
216
|
-
|
217
|
-
@watch.move(:init)
|
218
|
-
end
|
219
|
-
|
220
|
-
# action
|
221
|
-
|
222
|
-
def test_action_should_pass_start_and_stop_actions_to_call_action
|
223
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
224
|
-
@watch.driver.expects(:message).never
|
225
|
-
|
226
|
-
c = Conditions::FakePollCondition.new
|
227
|
-
[:start, :stop].each do |cmd|
|
228
|
-
@watch.expects(:call_action).with(c, cmd)
|
229
|
-
@watch.action(cmd, c)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_action_should_do_stop_then_start_if_no_restart_command
|
234
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
235
|
-
@watch.driver.expects(:message).never
|
236
|
-
|
237
|
-
c = Conditions::FakePollCondition.new
|
238
|
-
@watch.expects(:call_action).with(c, :stop)
|
239
|
-
@watch.expects(:call_action).with(c, :start)
|
240
|
-
@watch.action(:restart, c)
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_action_should_restart_to_call_action_if_present
|
244
|
-
@watch.driver.stubs(:in_driver_context?).returns(true)
|
245
|
-
@watch.driver.expects(:message).never
|
246
|
-
|
247
|
-
@watch.restart = lambda { }
|
248
|
-
c = Conditions::FakePollCondition.new
|
249
|
-
@watch.expects(:call_action).with(c, :restart)
|
250
|
-
@watch.action(:restart, c)
|
251
|
-
end
|
252
|
-
|
253
|
-
# call_action
|
254
|
-
|
255
|
-
def test_call_action
|
256
|
-
c = Conditions::FakePollCondition.new
|
257
|
-
God::Process.any_instance.expects(:call_action).with(:start)
|
258
|
-
@watch.call_action(c, :start)
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_call_action_should_call_before_start_when_behavior_has_that
|
262
|
-
@watch.behavior(:fake_behavior)
|
263
|
-
c = Conditions::FakePollCondition.new
|
264
|
-
God::Process.any_instance.expects(:call_action).with(:start)
|
265
|
-
Behaviors::FakeBehavior.any_instance.expects(:before_start)
|
266
|
-
@watch.call_action(c, :start)
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_call_action_should_call_after_start_when_behavior_has_that
|
270
|
-
@watch.behavior(:fake_behavior)
|
271
|
-
c = Conditions::FakePollCondition.new
|
272
|
-
God::Process.any_instance.expects(:call_action).with(:start)
|
273
|
-
Behaviors::FakeBehavior.any_instance.expects(:after_start)
|
274
|
-
@watch.call_action(c, :start)
|
275
|
-
end
|
276
|
-
|
277
|
-
# canonical_hash_form
|
278
|
-
|
279
|
-
def test_canonical_hash_form_should_convert_symbol_to_hash
|
280
|
-
assert_equal({true => :foo}, @watch.canonical_hash_form(:foo))
|
281
|
-
end
|
282
|
-
|
283
|
-
def test_canonical_hash_form_should_convert_hash_to_hash
|
284
|
-
assert_equal({true => :foo}, @watch.canonical_hash_form(true => :foo))
|
285
|
-
end
|
286
|
-
end
|
data/test/test_webhook.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class TestWebhook < Minitest::Test
|
4
|
-
def setup
|
5
|
-
@webhook = God::Contacts::Webhook.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_notify
|
9
|
-
@webhook.url = 'http://example.com/switch'
|
10
|
-
Net::HTTP.any_instance.expects(:request).returns(Net::HTTPSuccess.new('a', 'b', 'c'))
|
11
|
-
|
12
|
-
@webhook.notify('msg', Time.now, 'prio', 'cat', 'host')
|
13
|
-
assert_equal "sent webhook to http://example.com/switch", @webhook.info
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_notify_with_url_containing_query_parameters
|
17
|
-
@webhook.url = 'http://example.com/switch?api_key=123'
|
18
|
-
Net::HTTP::Post.expects(:new).with('/switch?api_key=123')
|
19
|
-
|
20
|
-
@webhook.notify('msg', Time.now, 'prio', 'cat', 'host')
|
21
|
-
end
|
22
|
-
end
|