god 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/History.txt +43 -7
  2. data/Manifest.txt +20 -4
  3. data/Rakefile +1 -1
  4. data/bin/god +263 -195
  5. data/examples/events.god +66 -34
  6. data/examples/gravatar.god +25 -12
  7. data/init/god +42 -0
  8. data/lib/god/behavior.rb +9 -29
  9. data/lib/god/behaviors/clean_pid_file.rb +6 -2
  10. data/lib/god/behaviors/notify_when_flapping.rb +4 -4
  11. data/lib/god/condition.rb +48 -6
  12. data/lib/god/conditions/always.rb +5 -1
  13. data/lib/god/conditions/cpu_usage.rb +13 -5
  14. data/lib/god/conditions/degrading_lambda.rb +8 -3
  15. data/lib/god/conditions/flapping.rb +97 -0
  16. data/lib/god/conditions/http_response_code.rb +97 -0
  17. data/lib/god/conditions/lambda.rb +8 -2
  18. data/lib/god/conditions/memory_usage.rb +13 -5
  19. data/lib/god/conditions/process_exits.rb +11 -3
  20. data/lib/god/conditions/process_running.rb +22 -4
  21. data/lib/god/conditions/tries.rb +16 -5
  22. data/lib/god/configurable.rb +54 -0
  23. data/lib/god/contact.rb +106 -0
  24. data/lib/god/contacts/email.rb +73 -0
  25. data/lib/god/errors.rb +3 -0
  26. data/lib/god/hub.rb +138 -33
  27. data/lib/god/logger.rb +21 -4
  28. data/lib/god/metric.rb +3 -4
  29. data/lib/god/process.rb +93 -49
  30. data/lib/god/socket.rb +60 -0
  31. data/lib/god/task.rb +233 -0
  32. data/lib/god/trigger.rb +43 -0
  33. data/lib/god/watch.rb +48 -114
  34. data/lib/god.rb +216 -63
  35. data/test/configs/child_events/child_events.god +20 -1
  36. data/test/configs/child_polls/child_polls.god +26 -6
  37. data/test/configs/child_polls/simple_server.rb +10 -1
  38. data/test/configs/contact/contact.god +74 -0
  39. data/test/configs/contact/simple_server.rb +3 -0
  40. data/test/configs/daemon_events/daemon_events.god +5 -2
  41. data/test/configs/daemon_events/simple_server.rb +2 -0
  42. data/test/configs/daemon_events/simple_server_stop.rb +9 -0
  43. data/test/configs/degrading_lambda/degrading_lambda.god +1 -3
  44. data/test/configs/task/logs/.placeholder +0 -0
  45. data/test/configs/task/task.god +26 -0
  46. data/test/helper.rb +19 -11
  47. data/test/test_conditions_http_response_code.rb +115 -0
  48. data/test/test_conditions_process_running.rb +2 -2
  49. data/test/test_conditions_tries.rb +21 -0
  50. data/test/test_contact.rb +109 -0
  51. data/test/test_god.rb +101 -17
  52. data/test/test_hub.rb +64 -1
  53. data/test/test_process.rb +43 -56
  54. data/test/{test_server.rb → test_socket.rb} +6 -20
  55. data/test/test_task.rb +86 -0
  56. data/test/test_trigger.rb +59 -0
  57. data/test/test_watch.rb +32 -7
  58. metadata +27 -8
  59. data/lib/god/reporter.rb +0 -25
  60. data/lib/god/server.rb +0 -37
  61. data/test/test_reporter.rb +0 -18
data/test/test_process.rb CHANGED
@@ -2,9 +2,9 @@ require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  module God
4
4
  class Process
5
- def fork
6
- raise "You forgot to stub fork"
7
- end
5
+ # def fork
6
+ # raise "You forgot to stub fork"
7
+ # end
8
8
 
9
9
  def exec(*args)
10
10
  raise "You forgot to stub exec"
@@ -19,6 +19,9 @@ class TestProcessChild < Test::Unit::TestCase
19
19
  @p.name = 'foo'
20
20
  @p.stubs(:test).returns true # so we don't try to mkdir_p
21
21
  Process.stubs(:detach) # because we stub fork
22
+
23
+ ::Process::Sys.stubs(:setuid).returns(true)
24
+ ::Process::Sys.stubs(:setgid).returns(true)
22
25
  end
23
26
 
24
27
  # valid?
@@ -39,7 +42,7 @@ class TestProcessChild < Test::Unit::TestCase
39
42
 
40
43
  def test_valid_should_return_true_if_uid_exists
41
44
  @p.start = 'qux'
42
- @p.log = 'bar'
45
+ @p.log = '/tmp/foo.log'
43
46
  @p.uid = 'root'
44
47
 
45
48
  assert @p.valid?
@@ -47,17 +50,19 @@ class TestProcessChild < Test::Unit::TestCase
47
50
 
48
51
  def test_valid_should_return_true_if_uid_does_not_exists
49
52
  @p.start = 'qux'
50
- @p.log = 'bar'
53
+ @p.log = '/tmp/foo.log'
51
54
  @p.uid = 'foobarbaz'
52
55
 
53
56
  no_stdout do
54
- assert !@p.valid?
57
+ no_stderr do
58
+ assert !@p.valid?
59
+ end
55
60
  end
56
61
  end
57
62
 
58
63
  def test_valid_should_return_true_if_gid_exists
59
64
  @p.start = 'qux'
60
- @p.log = 'bar'
65
+ @p.log = '/tmp/foo.log'
61
66
  @p.gid = 'wheel'
62
67
 
63
68
  assert @p.valid?
@@ -65,15 +70,38 @@ class TestProcessChild < Test::Unit::TestCase
65
70
 
66
71
  def test_valid_should_return_true_if_gid_does_not_exists
67
72
  @p.start = 'qux'
68
- @p.log = 'bar'
73
+ @p.log = '/tmp/foo.log'
69
74
  @p.gid = 'foobarbaz'
70
75
 
71
76
  no_stdout do
72
- assert !@p.valid?
77
+ no_stderr do
78
+ assert !@p.valid?
79
+ end
80
+ end
81
+ end
82
+
83
+ # call_action
84
+
85
+ def test_call_action_should_write_pid
86
+ # Only for start, restart
87
+ [:start, :restart].each do |action|
88
+ @p.stubs(:test).returns true
89
+ IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new])
90
+ @p.expects(:fork)
91
+ Process.expects(:waitpid)
92
+ File.expects(:open).with(@p.default_pid_file, 'w')
93
+ @p.send("#{action}=", "run")
94
+ @p.call_action(action)
73
95
  end
74
96
  end
75
97
  end
76
98
 
99
+ ###############################################################################
100
+ #
101
+ # Daemon
102
+ #
103
+ ###############################################################################
104
+
77
105
  class TestProcessDaemon < Test::Unit::TestCase
78
106
  def setup
79
107
  God.internal_init
@@ -92,17 +120,13 @@ class TestProcessDaemon < Test::Unit::TestCase
92
120
  assert !@p.alive?
93
121
  end
94
122
 
95
- # valid?
96
-
97
- def test_valid_should_return_false_if_no_name
98
- @p.name = nil
99
- @p.start = 'bar'
100
- @p.stop = 'baz'
101
- no_stdout do
102
- assert !@p.valid?
103
- end
123
+ def test_alive_should_return_false_if_no_such_file
124
+ File.expects(:read).with('blah.pid').raises(Errno::ENOENT)
125
+ assert !@p.alive?
104
126
  end
105
127
 
128
+ # valid?
129
+
106
130
  def test_valid_should_return_false_if_no_start
107
131
  @p.name = 'foo'
108
132
  @p.stop = 'baz'
@@ -120,17 +144,6 @@ class TestProcessDaemon < Test::Unit::TestCase
120
144
  end
121
145
  end
122
146
 
123
- def test_valid_should_return_false_if_self_daemonized_and_log
124
- @p.pid_file = 'foo'
125
- @p.start = 'baz'
126
- @p.stop = 'qux'
127
- @p.log = 'bar'
128
-
129
- no_stdout do
130
- assert !@p.valid?
131
- end
132
- end
133
-
134
147
  # defaul_pid_file
135
148
 
136
149
  def test_default_pid_file
@@ -140,9 +153,8 @@ class TestProcessDaemon < Test::Unit::TestCase
140
153
  # call_action
141
154
  # These actually excercise call_action in the back at this point - Kev
142
155
 
143
- def test_call_action_with_string_should_fork_exec
156
+ def test_call_action_with_string_should_call_system
144
157
  @p.start = "do something"
145
- IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new])
146
158
  @p.expects(:fork)
147
159
  Process.expects(:waitpid)
148
160
  @p.call_action(:start)
@@ -155,31 +167,6 @@ class TestProcessDaemon < Test::Unit::TestCase
155
167
  @p.call_action(:start)
156
168
  end
157
169
 
158
- def test_call_action_without_pid_should_write_pid
159
- # Only for start, restart
160
- [:start, :restart].each do |action|
161
- @p = God::Process.new
162
- @p.name = 'foo'
163
- @p.stubs(:test).returns true
164
- IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new])
165
- @p.expects(:fork)
166
- Process.expects(:waitpid)
167
- File.expects(:open).with(@p.default_pid_file, 'w')
168
- @p.send("#{action}=", "run")
169
- @p.call_action(action)
170
- end
171
- end
172
-
173
- def test_call_action_should_not_write_pid_for_stop
174
- @p.pid_file = nil
175
- IO.expects(:pipe).returns([StringIO.new('1234'), StringIO.new])
176
- @p.expects(:fork)
177
- Process.expects(:waitpid)
178
- File.expects(:open).times(0)
179
- @p.stop = "stopping"
180
- @p.call_action(:stop)
181
- end
182
-
183
170
  def test_call_action_with_invalid_command_class_should_raise
184
171
  @p.start = 5
185
172
  @p.stop = 'baz'
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
- class TestServer < Test::Unit::TestCase
3
+ class TestSocket < Test::Unit::TestCase
4
4
  def setup
5
5
  silence_warnings do
6
6
  Object.const_set(:DRb, stub_everything)
@@ -10,46 +10,32 @@ class TestServer < Test::Unit::TestCase
10
10
  def test_should_start_a_drb_server
11
11
  DRb.expects(:start_service)
12
12
  no_stdout do
13
- Server.new
13
+ God::Socket.new
14
14
  end
15
15
  end
16
16
 
17
17
  def test_should_use_supplied_port_and_host
18
- DRb.expects(:start_service).with { |uri, object| uri == "druby://host:port" && object.is_a?(Server) }
18
+ DRb.expects(:start_service).with { |uri, object| uri == "drbunix:///tmp/god.9999.sock" && object.is_a?(God::Socket) }
19
19
  no_stdout do
20
- server = Server.new('host', 'port')
20
+ server = God::Socket.new(9999)
21
21
  end
22
22
  end
23
23
 
24
24
  def test_should_forward_foreign_method_calls_to_god
25
25
  server = nil
26
26
  no_stdout do
27
- server = Server.new
27
+ server = God::Socket.new
28
28
  end
29
29
  God.expects(:send).with(:something_random)
30
30
  server.something_random
31
31
  end
32
32
 
33
- def test_should_install_deny_all_by_default
34
- ACL.expects(:new).with(%w{deny all})
35
- no_stdout do
36
- Server.new
37
- end
38
- end
39
-
40
- def test_should_install_pass_through_acl
41
- ACL.expects(:new).with(%w{deny all allow 127.0.0.1 allow 0.0.0.0})
42
- no_stdout do
43
- Server.new(nil, 17165, %w{127.0.0.1 0.0.0.0})
44
- end
45
- end
46
-
47
33
  # ping
48
34
 
49
35
  def test_ping_should_return_true
50
36
  server = nil
51
37
  no_stdout do
52
- server = Server.new
38
+ server = God::Socket.new
53
39
  end
54
40
  assert server.ping
55
41
  end
data/test/test_task.rb ADDED
@@ -0,0 +1,86 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestTask < Test::Unit::TestCase
4
+ def setup
5
+ God.internal_init
6
+ @task = Task.new
7
+ @task.name = 'foo'
8
+ @task.valid_states = [:foo, :bar]
9
+ @task.initial_state = :foo
10
+ @task.interval = 5
11
+ @task.prepare
12
+ end
13
+
14
+ # valid?
15
+
16
+ def test_valid_should_return_false_if_no_name
17
+ @task.name = nil
18
+ no_stdout do
19
+ assert !@task.valid?
20
+ end
21
+ end
22
+
23
+ def test_valid_should_return_false_if_no_valid_states
24
+ @task.valid_states = nil
25
+ no_stdout do
26
+ assert !@task.valid?
27
+ end
28
+ end
29
+
30
+ def test_valid_should_return_false_if_no_initial_state
31
+ @task.initial_state = nil
32
+ no_stdout do
33
+ assert !@task.valid?
34
+ end
35
+ end
36
+
37
+ # transition
38
+
39
+ def test_transition_should_be_always_if_no_block_was_given
40
+ @task.transition(:foo, :bar)
41
+
42
+ assert 1, @task.metrics.size
43
+ assert Conditions::Always, @task.metrics.keys.first.class
44
+ end
45
+
46
+ # method_missing
47
+
48
+ def test_method_missing_should_create_accessor_for_states
49
+ assert_nothing_raised do
50
+ @task.foo = 'testing'
51
+ end
52
+ end
53
+
54
+ def test_method_missing_should_raise_for_non_states
55
+ assert_raise NoMethodError do
56
+ @task.baz = 5
57
+ end
58
+ end
59
+
60
+ def test_method_missing_should_raise_for_non_setters
61
+ assert_raise NoMethodError do
62
+ @task.baz
63
+ end
64
+ end
65
+
66
+ # action
67
+
68
+ def test_action_should_send_string_commands_to_system
69
+ @task.foo = 'foo'
70
+ @task.expects(:system).with('foo')
71
+ no_stdout { @task.action(:foo, nil) }
72
+ end
73
+
74
+ def test_action_should_cal_lambda_commands
75
+ @task.foo = lambda { }
76
+ @task.foo.expects(:call)
77
+ no_stdout { @task.action(:foo, nil) }
78
+ end
79
+
80
+ def test_action_should_raise_not_implemented_on_non_string_or_lambda_action
81
+ assert_raise NotImplementedError do
82
+ @task.foo = 7
83
+ @task.action(:foo, nil)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,59 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestTrigger < Test::Unit::TestCase
4
+ def setup
5
+ Trigger.reset
6
+ end
7
+
8
+ # base case
9
+
10
+ def test_should_have_empty_triggers
11
+ assert_equal({}, Trigger.triggers)
12
+ end
13
+
14
+ # register
15
+
16
+ def test_register_should_add_condition_to_triggers
17
+ c = Condition.new
18
+ c.watch = stub(:name => 'foo')
19
+ Trigger.register(c)
20
+
21
+ assert_equal({'foo' => [c]}, Trigger.triggers)
22
+ end
23
+
24
+ def test_register_should_add_condition_to_triggers_twice
25
+ watch = stub(:name => 'foo')
26
+ c = Condition.new
27
+ c.watch = watch
28
+ Trigger.register(c)
29
+
30
+ c2 = Condition.new
31
+ c2.watch = watch
32
+ Trigger.register(c2)
33
+
34
+ assert_equal({'foo' => [c, c2]}, Trigger.triggers)
35
+ end
36
+
37
+ # deregister
38
+
39
+ def test_deregister_should_remove_condition_from_triggers
40
+ c = Condition.new
41
+ c.watch = stub(:name => 'foo')
42
+ Trigger.register(c)
43
+ Trigger.deregister(c)
44
+
45
+ assert_equal({}, Trigger.triggers)
46
+ end
47
+
48
+ # broadcast
49
+
50
+ def test_broadcast_should_call_process_on_each_condition
51
+ c = Condition.new
52
+ c.watch = stub(:name => 'foo')
53
+ Trigger.register(c)
54
+
55
+ c.expects(:process).with(:state_change, [:up, :start])
56
+
57
+ Trigger.broadcast(c.watch, :state_change, [:up, :start])
58
+ end
59
+ end
data/test/test_watch.rb CHANGED
@@ -2,10 +2,12 @@ require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class TestWatch < Test::Unit::TestCase
4
4
  def setup
5
+ God.internal_init
5
6
  @watch = Watch.new
6
7
  @watch.name = 'foo'
7
8
  @watch.start = lambda { }
8
9
  @watch.stop = lambda { }
10
+ @watch.prepare
9
11
  end
10
12
 
11
13
  # new
@@ -31,8 +33,8 @@ class TestWatch < Test::Unit::TestCase
31
33
  end
32
34
  end
33
35
 
34
- def test_new_should_have_nil_state
35
- assert_equal nil, @watch.state
36
+ def test_new_should_have_unmonitored_state
37
+ assert_equal :unmonitored, @watch.state
36
38
  end
37
39
 
38
40
  # mutex
@@ -84,6 +86,13 @@ class TestWatch < Test::Unit::TestCase
84
86
  assert_equal 1, @watch.metrics[:init].size
85
87
  end
86
88
 
89
+ # lifecycle
90
+
91
+ def test_lifecycle_should_create_and_record_a_metric_for_nil_start_state
92
+ @watch.lifecycle { }
93
+ assert_equal 1, @watch.metrics[nil].size
94
+ end
95
+
87
96
  # start_if
88
97
 
89
98
  def test_start_if_should_place_a_metric_on_up_state
@@ -116,7 +125,7 @@ class TestWatch < Test::Unit::TestCase
116
125
  # unmonitor
117
126
 
118
127
  def test_unmonitor_should_move_to_nil
119
- @watch.expects(:move).with(nil)
128
+ @watch.expects(:move).with(:unmonitored)
120
129
  @watch.unmonitor
121
130
  end
122
131
 
@@ -198,7 +207,7 @@ class TestWatch < Test::Unit::TestCase
198
207
  c = Conditions::FakePollCondition.new
199
208
  [:start, :stop].each do |cmd|
200
209
  @watch.expects(:call_action).with(c, cmd)
201
- no_stdout { @watch.action(cmd, c) }
210
+ @watch.action(cmd, c)
202
211
  end
203
212
  end
204
213
 
@@ -206,14 +215,14 @@ class TestWatch < Test::Unit::TestCase
206
215
  c = Conditions::FakePollCondition.new
207
216
  @watch.expects(:call_action).with(c, :stop)
208
217
  @watch.expects(:call_action).with(c, :start)
209
- no_stdout { @watch.action(:restart, c) }
218
+ @watch.action(:restart, c)
210
219
  end
211
220
 
212
221
  def test_action_should_restart_to_call_action_if_present
213
222
  @watch.restart = lambda { }
214
223
  c = Conditions::FakePollCondition.new
215
224
  @watch.expects(:call_action).with(c, :restart)
216
- no_stdout { @watch.action(:restart, c) }
225
+ @watch.action(:restart, c)
217
226
  end
218
227
 
219
228
  # call_action
@@ -221,7 +230,23 @@ class TestWatch < Test::Unit::TestCase
221
230
  def test_call_action
222
231
  c = Conditions::FakePollCondition.new
223
232
  God::Process.any_instance.expects(:call_action).with(:start)
224
- @watch.call_action(c, :start)
233
+ no_stdout { @watch.call_action(c, :start) }
234
+ end
235
+
236
+ def test_call_action_should_call_before_start_when_behavior_has_that
237
+ @watch.behavior(:fake_behavior)
238
+ c = Conditions::FakePollCondition.new
239
+ God::Process.any_instance.expects(:call_action).with(:start)
240
+ Behaviors::FakeBehavior.any_instance.expects(:before_start)
241
+ no_stdout { @watch.call_action(c, :start) }
242
+ end
243
+
244
+ def test_call_action_should_call_after_start_when_behavior_has_that
245
+ @watch.behavior(:fake_behavior)
246
+ c = Conditions::FakePollCondition.new
247
+ God::Process.any_instance.expects(:call_action).with(:start)
248
+ Behaviors::FakeBehavior.any_instance.expects(:after_start)
249
+ no_stdout { @watch.call_action(c, :start) }
225
250
  end
226
251
 
227
252
  # canonical_hash_form
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: god
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.3
7
- date: 2007-09-10 00:00:00 -07:00
6
+ version: 0.5.0
7
+ date: 2007-10-05 00:00:00 -07:00
8
8
  summary: Like monit, only awesome
9
9
  require_paths:
10
10
  - lib
@@ -40,6 +40,7 @@ files:
40
40
  - ext/god/extconf.rb
41
41
  - ext/god/kqueue_handler.c
42
42
  - ext/god/netlink_handler.c
43
+ - init/god
43
44
  - lib/god.rb
44
45
  - lib/god/behavior.rb
45
46
  - lib/god/behaviors/clean_pid_file.rb
@@ -48,11 +49,16 @@ files:
48
49
  - lib/god/conditions/always.rb
49
50
  - lib/god/conditions/cpu_usage.rb
50
51
  - lib/god/conditions/degrading_lambda.rb
52
+ - lib/god/conditions/flapping.rb
53
+ - lib/god/conditions/http_response_code.rb
51
54
  - lib/god/conditions/lambda.rb
52
55
  - lib/god/conditions/memory_usage.rb
53
56
  - lib/god/conditions/process_exits.rb
54
57
  - lib/god/conditions/process_running.rb
55
58
  - lib/god/conditions/tries.rb
59
+ - lib/god/configurable.rb
60
+ - lib/god/contact.rb
61
+ - lib/god/contacts/email.rb
56
62
  - lib/god/dependency_graph.rb
57
63
  - lib/god/errors.rb
58
64
  - lib/god/event_handler.rb
@@ -64,19 +70,23 @@ files:
64
70
  - lib/god/metric.rb
65
71
  - lib/god/process.rb
66
72
  - lib/god/registry.rb
67
- - lib/god/reporter.rb
68
- - lib/god/server.rb
73
+ - lib/god/socket.rb
69
74
  - lib/god/sugar.rb
70
75
  - lib/god/system/process.rb
76
+ - lib/god/task.rb
71
77
  - lib/god/timeline.rb
72
78
  - lib/god/timer.rb
79
+ - lib/god/trigger.rb
73
80
  - lib/god/watch.rb
74
81
  - test/configs/child_events/child_events.god
75
82
  - test/configs/child_events/simple_server.rb
76
83
  - test/configs/child_polls/child_polls.god
77
84
  - test/configs/child_polls/simple_server.rb
85
+ - test/configs/contact/contact.god
86
+ - test/configs/contact/simple_server.rb
78
87
  - test/configs/daemon_events/daemon_events.god
79
88
  - test/configs/daemon_events/simple_server.rb
89
+ - test/configs/daemon_events/simple_server_stop.rb
80
90
  - test/configs/daemon_polls/daemon_polls.god
81
91
  - test/configs/daemon_polls/simple_server.rb
82
92
  - test/configs/degrading_lambda/degrading_lambda.god
@@ -85,12 +95,17 @@ files:
85
95
  - test/configs/running_load/running_load.god
86
96
  - test/configs/stress/simple_server.rb
87
97
  - test/configs/stress/stress.god
98
+ - test/configs/task/logs/.placeholder
99
+ - test/configs/task/task.god
88
100
  - test/configs/test.rb
89
101
  - test/helper.rb
90
102
  - test/suite.rb
91
103
  - test/test_behavior.rb
92
104
  - test/test_condition.rb
105
+ - test/test_conditions_http_response_code.rb
93
106
  - test/test_conditions_process_running.rb
107
+ - test/test_conditions_tries.rb
108
+ - test/test_contact.rb
94
109
  - test/test_dependency_graph.rb
95
110
  - test/test_event_handler.rb
96
111
  - test/test_god.rb
@@ -100,18 +115,21 @@ files:
100
115
  - test/test_metric.rb
101
116
  - test/test_process.rb
102
117
  - test/test_registry.rb
103
- - test/test_reporter.rb
104
- - test/test_server.rb
118
+ - test/test_socket.rb
105
119
  - test/test_sugar.rb
106
120
  - test/test_system_process.rb
121
+ - test/test_task.rb
107
122
  - test/test_timeline.rb
108
123
  - test/test_timer.rb
124
+ - test/test_trigger.rb
109
125
  - test/test_watch.rb
110
126
  test_files:
111
127
  - test/test_behavior.rb
112
128
  - test/test_condition.rb
129
+ - test/test_conditions_http_response_code.rb
113
130
  - test/test_conditions_process_running.rb
114
131
  - test/test_conditions_tries.rb
132
+ - test/test_contact.rb
115
133
  - test/test_dependency_graph.rb
116
134
  - test/test_event_handler.rb
117
135
  - test/test_god.rb
@@ -121,12 +139,13 @@ test_files:
121
139
  - test/test_metric.rb
122
140
  - test/test_process.rb
123
141
  - test/test_registry.rb
124
- - test/test_reporter.rb
125
- - test/test_server.rb
142
+ - test/test_socket.rb
126
143
  - test/test_sugar.rb
127
144
  - test/test_system_process.rb
145
+ - test/test_task.rb
128
146
  - test/test_timeline.rb
129
147
  - test/test_timer.rb
148
+ - test/test_trigger.rb
130
149
  - test/test_watch.rb
131
150
  rdoc_options:
132
151
  - --main
data/lib/god/reporter.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'drb'
2
-
3
- module God
4
-
5
- class Reporter
6
- def initialize(host = nil, port = nil)
7
- @host = host
8
- @port = port || 7777
9
- @service = nil
10
- end
11
-
12
- def method_missing(*args, &block)
13
- service.send(*args, &block)
14
- end
15
-
16
- private
17
-
18
- def service
19
- return @service if @service
20
- DRb.start_service
21
- @service = DRbObject.new(nil, "druby://#{@host}:#{@port}")
22
- end
23
- end
24
-
25
- end
data/lib/god/server.rb DELETED
@@ -1,37 +0,0 @@
1
- require 'drb'
2
- require 'drb/acl'
3
-
4
- # The God::Server oversees the DRb server which dishes out info on this God daemon.
5
-
6
- module God
7
-
8
- class Server
9
- attr_reader :host, :port
10
-
11
- def initialize(host = nil, port = nil, allow = [])
12
- @host = host
13
- @port = port
14
- @acl = %w{deny all} + allow.inject([]) { |acc, a| acc + ['allow', a] }
15
- puts "Starting on #{@host}:#{@port}"
16
- start
17
- end
18
-
19
- def ping
20
- true
21
- end
22
-
23
- def method_missing(*args, &block)
24
- God.send(*args, &block)
25
- end
26
-
27
- private
28
-
29
- def start
30
- acl = ACL.new(@acl)
31
- DRb.install_acl(acl)
32
-
33
- @drb ||= DRb.start_service("druby://#{@host}:#{@port}", self)
34
- end
35
- end
36
-
37
- end
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- class TestReporter < Test::Unit::TestCase
4
-
5
- def test_should_create_a_drb_object
6
- DRb.expects(:start_service)
7
- DRbObject.expects(:new).with(nil, "druby://host:port").returns(stub(:anything => true))
8
-
9
- Reporter.new('host', 'port').anything
10
- end
11
-
12
- def test_should_forward_unknown_methods_to_drb_object
13
- Reporter.any_instance.expects(:service).returns(mock(:something_fake => true))
14
-
15
- reporter = Reporter.new('host', 'port')
16
- reporter.something_fake
17
- end
18
- end