god 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Announce.txt +6 -6
- data/Gemfile +2 -0
- data/History.txt +19 -2
- data/{README.txt → LICENSE} +0 -37
- data/README.md +31 -0
- data/Rakefile +80 -38
- data/bin/god +21 -21
- data/doc/god.asciidoc +1487 -0
- data/doc/intro.asciidoc +20 -0
- data/ext/god/extconf.rb +3 -3
- data/ext/god/kqueue_handler.c +18 -18
- data/ext/god/netlink_handler.c +31 -31
- data/god.gemspec +24 -16
- data/lib/god.rb +261 -204
- data/lib/god/behavior.rb +14 -14
- data/lib/god/behaviors/clean_pid_file.rb +5 -5
- data/lib/god/behaviors/clean_unix_socket.rb +10 -10
- data/lib/god/behaviors/notify_when_flapping.rb +12 -12
- data/lib/god/cli/command.rb +59 -46
- data/lib/god/cli/run.rb +33 -37
- data/lib/god/cli/version.rb +6 -6
- data/lib/god/compat19.rb +1 -4
- data/lib/god/condition.rb +21 -21
- data/lib/god/conditions/always.rb +19 -6
- data/lib/god/conditions/complex.rb +18 -18
- data/lib/god/conditions/cpu_usage.rb +14 -14
- data/lib/god/conditions/degrading_lambda.rb +8 -8
- data/lib/god/conditions/disk_usage.rb +5 -5
- data/lib/god/conditions/flapping.rb +23 -23
- data/lib/god/conditions/http_response_code.rb +35 -19
- data/lib/god/conditions/lambda.rb +2 -2
- data/lib/god/conditions/memory_usage.rb +13 -13
- data/lib/god/conditions/process_exits.rb +14 -20
- data/lib/god/conditions/process_running.rb +16 -25
- data/lib/god/conditions/socket_responding.rb +132 -0
- data/lib/god/conditions/tries.rb +10 -10
- data/lib/god/configurable.rb +10 -10
- data/lib/god/contact.rb +20 -20
- data/lib/god/contacts/email.rb +7 -4
- data/lib/god/contacts/jabber.rb +1 -1
- data/lib/god/driver.rb +96 -64
- data/lib/god/errors.rb +9 -9
- data/lib/god/event_handler.rb +19 -19
- data/lib/god/event_handlers/dummy_handler.rb +4 -4
- data/lib/god/event_handlers/kqueue_handler.rb +3 -3
- data/lib/god/event_handlers/netlink_handler.rb +2 -2
- data/lib/god/logger.rb +13 -13
- data/lib/god/metric.rb +50 -22
- data/lib/god/process.rb +53 -52
- data/lib/god/registry.rb +7 -7
- data/lib/god/simple_logger.rb +14 -14
- data/lib/god/socket.rb +11 -11
- data/lib/god/sugar.rb +30 -15
- data/lib/god/sys_logger.rb +2 -2
- data/lib/god/system/portable_poller.rb +8 -8
- data/lib/god/system/process.rb +8 -8
- data/lib/god/system/slash_proc_poller.rb +13 -13
- data/lib/god/task.rb +237 -188
- data/lib/god/timeline.rb +5 -5
- data/lib/god/trigger.rb +11 -11
- data/lib/god/watch.rb +205 -53
- data/test/configs/child_events/child_events.god +5 -5
- data/test/configs/child_events/simple_server.rb +1 -1
- data/test/configs/child_polls/child_polls.god +4 -4
- data/test/configs/child_polls/simple_server.rb +4 -4
- data/test/configs/complex/complex.god +7 -7
- data/test/configs/complex/simple_server.rb +1 -1
- data/test/configs/contact/contact.god +1 -1
- data/test/configs/contact/simple_server.rb +1 -1
- data/test/configs/daemon_events/daemon_events.god +5 -5
- data/test/configs/daemon_events/simple_server.rb +1 -1
- data/test/configs/daemon_events/simple_server_stop.rb +1 -1
- data/test/configs/daemon_polls/daemon_polls.god +3 -3
- data/test/configs/daemon_polls/simple_server.rb +1 -1
- data/test/configs/degrading_lambda/degrading_lambda.god +3 -3
- data/test/configs/keepalive/keepalive.god +9 -0
- data/test/configs/keepalive/keepalive.rb +12 -0
- data/test/configs/lifecycle/lifecycle.god +2 -2
- data/test/configs/matias/matias.god +6 -6
- data/test/configs/real.rb +7 -7
- data/test/configs/running_load/running_load.god +2 -2
- data/test/configs/stop_options/simple_server.rb +1 -1
- data/test/configs/stress/simple_server.rb +1 -1
- data/test/configs/stress/stress.god +2 -2
- data/test/configs/task/task.god +5 -5
- data/test/configs/test.rb +7 -7
- data/test/helper.rb +8 -8
- data/test/test_behavior.rb +3 -3
- data/test/test_campfire.rb +1 -2
- data/test/test_condition.rb +10 -10
- data/test/test_conditions_disk_usage.rb +12 -12
- data/test/test_conditions_http_response_code.rb +24 -24
- data/test/test_conditions_process_running.rb +7 -7
- data/test/test_conditions_socket_responding.rb +122 -0
- data/test/test_conditions_tries.rb +12 -12
- data/test/test_contact.rb +19 -19
- data/test/test_driver.rb +17 -3
- data/test/test_event_handler.rb +12 -12
- data/test/test_god.rb +195 -117
- data/test/test_handlers_kqueue_handler.rb +4 -4
- data/test/test_jabber.rb +1 -1
- data/test/test_logger.rb +17 -17
- data/test/test_metric.rb +16 -16
- data/test/test_process.rb +47 -41
- data/test/test_prowl.rb +1 -1
- data/test/test_registry.rb +2 -2
- data/test/test_socket.rb +3 -3
- data/test/test_sugar.rb +7 -7
- data/test/test_system_portable_poller.rb +1 -1
- data/test/test_system_process.rb +5 -5
- data/test/test_task.rb +57 -57
- data/test/test_timeline.rb +8 -8
- data/test/test_trigger.rb +16 -16
- data/test/test_watch.rb +69 -62
- metadata +182 -69
- data/lib/god/dependency_graph.rb +0 -41
- data/lib/god/diagnostics.rb +0 -37
- data/test/test_dependency_graph.rb +0 -62
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: god
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 47
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 12
|
9
|
+
- 0
|
10
|
+
version: 0.12.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Tom Preston-Werner
|
@@ -11,95 +17,191 @@ autorequire:
|
|
11
17
|
bindir: bin
|
12
18
|
cert_chain: []
|
13
19
|
|
14
|
-
date:
|
15
|
-
default_executable:
|
20
|
+
date: 2012-01-13 00:00:00 -08:00
|
21
|
+
default_executable:
|
16
22
|
dependencies:
|
17
23
|
- !ruby/object:Gem::Dependency
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
22
27
|
requirements:
|
23
|
-
- -
|
28
|
+
- - ~>
|
24
29
|
- !ruby/object:Gem::Version
|
25
|
-
|
26
|
-
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 6
|
34
|
+
version: "1.6"
|
35
|
+
type: :development
|
36
|
+
name: json
|
37
|
+
version_requirements: *id001
|
27
38
|
- !ruby/object:Gem::Dependency
|
28
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 25
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 9
|
49
|
+
version: "0.9"
|
29
50
|
type: :development
|
30
|
-
|
31
|
-
version_requirements:
|
51
|
+
name: rake
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
32
57
|
requirements:
|
33
|
-
- -
|
58
|
+
- - ~>
|
34
59
|
- !ruby/object:Gem::Version
|
35
|
-
|
36
|
-
|
60
|
+
hash: 19
|
61
|
+
segments:
|
62
|
+
- 3
|
63
|
+
- 10
|
64
|
+
version: "3.10"
|
65
|
+
type: :development
|
66
|
+
name: rdoc
|
67
|
+
version_requirements: *id003
|
37
68
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 2
|
78
|
+
- 0
|
79
|
+
version: "2.0"
|
39
80
|
type: :development
|
40
|
-
|
41
|
-
version_requirements:
|
81
|
+
name: twitter
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
42
87
|
requirements:
|
43
|
-
- -
|
88
|
+
- - ~>
|
44
89
|
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
90
|
+
hash: 13
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
- 3
|
94
|
+
version: "0.3"
|
95
|
+
type: :development
|
96
|
+
name: prowly
|
97
|
+
version_requirements: *id005
|
47
98
|
- !ruby/object:Gem::Dependency
|
48
|
-
|
99
|
+
prerelease: false
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ~>
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 1
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
- 5
|
109
|
+
version: "0.5"
|
49
110
|
type: :development
|
50
|
-
|
51
|
-
version_requirements:
|
111
|
+
name: xmpp4r
|
112
|
+
version_requirements: *id006
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
prerelease: false
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
52
117
|
requirements:
|
53
|
-
- -
|
118
|
+
- - ~>
|
54
119
|
- !ruby/object:Gem::Version
|
120
|
+
hash: 25
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
- 0
|
124
|
+
- 3
|
55
125
|
version: 0.0.3
|
56
|
-
version:
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: snapshot
|
59
126
|
type: :development
|
60
|
-
|
61
|
-
version_requirements:
|
127
|
+
name: dike
|
128
|
+
version_requirements: *id007
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
prerelease: false
|
131
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
62
133
|
requirements:
|
63
|
-
- -
|
134
|
+
- - ~>
|
64
135
|
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rcov
|
136
|
+
hash: 15
|
137
|
+
segments:
|
138
|
+
- 1
|
139
|
+
- 0
|
140
|
+
version: "1.0"
|
72
141
|
type: :development
|
73
|
-
|
74
|
-
version_requirements:
|
142
|
+
name: snapshot
|
143
|
+
version_requirements: *id008
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
prerelease: false
|
146
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
75
148
|
requirements:
|
76
|
-
- -
|
149
|
+
- - ~>
|
77
150
|
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
|
80
|
-
-
|
81
|
-
|
151
|
+
hash: 25
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
- 9
|
155
|
+
version: "0.9"
|
82
156
|
type: :development
|
83
|
-
|
84
|
-
version_requirements:
|
157
|
+
name: rcov
|
158
|
+
version_requirements: *id009
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
prerelease: false
|
161
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
85
163
|
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 1.0.10
|
89
|
-
- - <
|
164
|
+
- - ~>
|
90
165
|
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
|
166
|
+
hash: 13
|
167
|
+
segments:
|
168
|
+
- 1
|
169
|
+
- 1
|
170
|
+
version: "1.1"
|
171
|
+
type: :development
|
172
|
+
name: daemons
|
173
|
+
version_requirements: *id010
|
93
174
|
- !ruby/object:Gem::Dependency
|
94
|
-
|
175
|
+
prerelease: false
|
176
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ~>
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
hash: 31
|
182
|
+
segments:
|
183
|
+
- 0
|
184
|
+
- 10
|
185
|
+
version: "0.10"
|
95
186
|
type: :development
|
96
|
-
|
97
|
-
version_requirements:
|
187
|
+
name: mocha
|
188
|
+
version_requirements: *id011
|
189
|
+
- !ruby/object:Gem::Dependency
|
190
|
+
prerelease: false
|
191
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
192
|
+
none: false
|
98
193
|
requirements:
|
99
|
-
- -
|
194
|
+
- - ~>
|
100
195
|
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
196
|
+
hash: 25
|
197
|
+
segments:
|
198
|
+
- 1
|
199
|
+
- 3
|
200
|
+
- 1
|
201
|
+
version: 1.3.1
|
202
|
+
type: :development
|
203
|
+
name: gollum
|
204
|
+
version_requirements: *id012
|
103
205
|
description: An easy to configure, easy to extend monitoring framework written in Ruby.
|
104
206
|
email: god-rb@googlegroups.com
|
105
207
|
executables:
|
@@ -107,13 +209,17 @@ executables:
|
|
107
209
|
extensions:
|
108
210
|
- ext/god/extconf.rb
|
109
211
|
extra_rdoc_files:
|
110
|
-
- README.
|
212
|
+
- README.md
|
111
213
|
files:
|
112
214
|
- Announce.txt
|
215
|
+
- Gemfile
|
113
216
|
- History.txt
|
114
|
-
-
|
217
|
+
- LICENSE
|
218
|
+
- README.md
|
115
219
|
- Rakefile
|
116
220
|
- bin/god
|
221
|
+
- doc/god.asciidoc
|
222
|
+
- doc/intro.asciidoc
|
117
223
|
- ext/god/.gitignore
|
118
224
|
- ext/god/extconf.rb
|
119
225
|
- ext/god/kqueue_handler.c
|
@@ -141,6 +247,7 @@ files:
|
|
141
247
|
- lib/god/conditions/memory_usage.rb
|
142
248
|
- lib/god/conditions/process_exits.rb
|
143
249
|
- lib/god/conditions/process_running.rb
|
250
|
+
- lib/god/conditions/socket_responding.rb
|
144
251
|
- lib/god/conditions/tries.rb
|
145
252
|
- lib/god/configurable.rb
|
146
253
|
- lib/god/contact.rb
|
@@ -151,8 +258,6 @@ files:
|
|
151
258
|
- lib/god/contacts/scout.rb
|
152
259
|
- lib/god/contacts/twitter.rb
|
153
260
|
- lib/god/contacts/webhook.rb
|
154
|
-
- lib/god/dependency_graph.rb
|
155
|
-
- lib/god/diagnostics.rb
|
156
261
|
- lib/god/driver.rb
|
157
262
|
- lib/god/errors.rb
|
158
263
|
- lib/god/event_handler.rb
|
@@ -189,6 +294,8 @@ files:
|
|
189
294
|
- test/configs/daemon_polls/simple_server.rb
|
190
295
|
- test/configs/degrading_lambda/degrading_lambda.god
|
191
296
|
- test/configs/degrading_lambda/tcp_server.rb
|
297
|
+
- test/configs/keepalive/keepalive.god
|
298
|
+
- test/configs/keepalive/keepalive.rb
|
192
299
|
- test/configs/lifecycle/lifecycle.god
|
193
300
|
- test/configs/matias/matias.god
|
194
301
|
- test/configs/real.rb
|
@@ -208,9 +315,9 @@ files:
|
|
208
315
|
- test/test_conditions_disk_usage.rb
|
209
316
|
- test/test_conditions_http_response_code.rb
|
210
317
|
- test/test_conditions_process_running.rb
|
318
|
+
- test/test_conditions_socket_responding.rb
|
211
319
|
- test/test_conditions_tries.rb
|
212
320
|
- test/test_contact.rb
|
213
|
-
- test/test_dependency_graph.rb
|
214
321
|
- test/test_driver.rb
|
215
322
|
- test/test_email.rb
|
216
323
|
- test/test_event_handler.rb
|
@@ -242,21 +349,27 @@ require_paths:
|
|
242
349
|
- lib
|
243
350
|
- ext
|
244
351
|
required_ruby_version: !ruby/object:Gem::Requirement
|
352
|
+
none: false
|
245
353
|
requirements:
|
246
354
|
- - ">="
|
247
355
|
- !ruby/object:Gem::Version
|
356
|
+
hash: 3
|
357
|
+
segments:
|
358
|
+
- 0
|
248
359
|
version: "0"
|
249
|
-
version:
|
250
360
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
361
|
+
none: false
|
251
362
|
requirements:
|
252
363
|
- - ">="
|
253
364
|
- !ruby/object:Gem::Version
|
365
|
+
hash: 3
|
366
|
+
segments:
|
367
|
+
- 0
|
254
368
|
version: "0"
|
255
|
-
version:
|
256
369
|
requirements: []
|
257
370
|
|
258
371
|
rubyforge_project: god
|
259
|
-
rubygems_version: 1.
|
372
|
+
rubygems_version: 1.6.2
|
260
373
|
signing_key:
|
261
374
|
specification_version: 2
|
262
375
|
summary: Process monitoring framework.
|
@@ -267,9 +380,9 @@ test_files:
|
|
267
380
|
- test/test_conditions_disk_usage.rb
|
268
381
|
- test/test_conditions_http_response_code.rb
|
269
382
|
- test/test_conditions_process_running.rb
|
383
|
+
- test/test_conditions_socket_responding.rb
|
270
384
|
- test/test_conditions_tries.rb
|
271
385
|
- test/test_contact.rb
|
272
|
-
- test/test_dependency_graph.rb
|
273
386
|
- test/test_driver.rb
|
274
387
|
- test/test_email.rb
|
275
388
|
- test/test_event_handler.rb
|
data/lib/god/dependency_graph.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module God
|
2
|
-
class DependencyGraph
|
3
|
-
attr_accessor :nodes
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
self.nodes = {}
|
7
|
-
end
|
8
|
-
|
9
|
-
def add(a, b)
|
10
|
-
node_a = self.nodes[a] || Node.new(a)
|
11
|
-
node_b = self.nodes[b] || Node.new(b)
|
12
|
-
|
13
|
-
node_a.add(node_b)
|
14
|
-
|
15
|
-
self.nodes[a] ||= node_a
|
16
|
-
self.nodes[b] ||= node_b
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
module God
|
22
|
-
class DependencyGraph
|
23
|
-
class Node
|
24
|
-
attr_accessor :name
|
25
|
-
attr_accessor :dependencies
|
26
|
-
|
27
|
-
def initialize(name)
|
28
|
-
self.name = name
|
29
|
-
self.dependencies = []
|
30
|
-
end
|
31
|
-
|
32
|
-
def add(node)
|
33
|
-
self.dependencies << node unless self.dependencies.include?(node)
|
34
|
-
end
|
35
|
-
|
36
|
-
def has_node?(node)
|
37
|
-
(self == node) || self.dependencies.any { |x| x.has_node?(node) }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/god/diagnostics.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
def start_dike
|
2
|
-
require 'dike'
|
3
|
-
Thread.new do
|
4
|
-
Dike.logfactory File.join(File.dirname(__FILE__), *%w[.. .. logs])
|
5
|
-
loop do
|
6
|
-
Dike.finger
|
7
|
-
sleep(1)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class BleakHouseDiagnostic
|
13
|
-
LOG_FILE = File.join(File.dirname(__FILE__), *%w[.. .. logs bleak.log])
|
14
|
-
|
15
|
-
def self.install
|
16
|
-
require 'snapshot'
|
17
|
-
self.spin
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.snapshot
|
21
|
-
@count ||= 0
|
22
|
-
filename = "/tmp/god-bleak-%s-%03i.dump" % [Process.pid,@count]
|
23
|
-
STDERR.puts "** BleakHouse: working..."
|
24
|
-
BleakHouse.ext_snapshot(filename, 3)
|
25
|
-
STDERR.puts "** BleakHouse: complete\n** Bleakhouse: Run 'bleak #{filename}' to analyze."
|
26
|
-
@count += 1
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.spin(delay = 60)
|
30
|
-
Thread.new do
|
31
|
-
loop do
|
32
|
-
sleep(delay)
|
33
|
-
self.snapshot
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class TestDependencyGraph < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@dg = DependencyGraph.new
|
6
|
-
end
|
7
|
-
|
8
|
-
# new
|
9
|
-
|
10
|
-
def test_new_should_accept_zero_arguments
|
11
|
-
assert @dg.instance_of?(DependencyGraph)
|
12
|
-
end
|
13
|
-
|
14
|
-
# add
|
15
|
-
|
16
|
-
def test_add_should_create_and_store_two_new_nodes
|
17
|
-
@dg.add('foo', 'bar')
|
18
|
-
assert_equal 2, @dg.nodes.size
|
19
|
-
assert @dg.nodes['foo'].instance_of?(DependencyGraph::Node)
|
20
|
-
assert @dg.nodes['bar'].instance_of?(DependencyGraph::Node)
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_add_should_record_dependency
|
24
|
-
@dg.add('foo', 'bar')
|
25
|
-
assert_equal 1, @dg.nodes['foo'].dependencies.size
|
26
|
-
assert_equal @dg.nodes['bar'], @dg.nodes['foo'].dependencies.first
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_add_should_ignore_dups
|
30
|
-
@dg.add('foo', 'bar')
|
31
|
-
@dg.add('foo', 'bar')
|
32
|
-
assert_equal 2, @dg.nodes.size
|
33
|
-
assert_equal 1, @dg.nodes['foo'].dependencies.size
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
class TestDependencyGraphNode < Test::Unit::TestCase
|
39
|
-
def setup
|
40
|
-
@foo = DependencyGraph::Node.new('foo')
|
41
|
-
@bar = DependencyGraph::Node.new('bar')
|
42
|
-
end
|
43
|
-
|
44
|
-
# new
|
45
|
-
|
46
|
-
def test_new_should_accept_zero_arguments
|
47
|
-
assert @foo.instance_of?(DependencyGraph::Node)
|
48
|
-
end
|
49
|
-
|
50
|
-
# add
|
51
|
-
|
52
|
-
def test_add_should_store_node_as_dependency
|
53
|
-
@foo.add(@bar)
|
54
|
-
assert_equal 1, @foo.dependencies.size
|
55
|
-
end
|
56
|
-
|
57
|
-
# has_node?
|
58
|
-
|
59
|
-
def test_has_node
|
60
|
-
assert @foo.has_node?(@foo)
|
61
|
-
end
|
62
|
-
end
|