arborist 0.0.1.pre20160128152542 → 0.0.1.pre20160606141735

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -0
  4. data/ChangeLog +426 -1
  5. data/Manifest.txt +17 -2
  6. data/Nodes.md +70 -0
  7. data/Protocol.md +68 -9
  8. data/README.md +3 -5
  9. data/Rakefile +4 -1
  10. data/TODO.md +52 -20
  11. data/lib/arborist.rb +19 -6
  12. data/lib/arborist/cli.rb +39 -25
  13. data/lib/arborist/client.rb +97 -4
  14. data/lib/arborist/command/client.rb +2 -1
  15. data/lib/arborist/command/start.rb +51 -5
  16. data/lib/arborist/dependency.rb +286 -0
  17. data/lib/arborist/event.rb +7 -2
  18. data/lib/arborist/event/{node_matching.rb → node.rb} +11 -5
  19. data/lib/arborist/event/node_acked.rb +5 -7
  20. data/lib/arborist/event/node_delta.rb +30 -3
  21. data/lib/arborist/event/node_disabled.rb +16 -0
  22. data/lib/arborist/event/node_down.rb +10 -0
  23. data/lib/arborist/event/node_quieted.rb +11 -0
  24. data/lib/arborist/event/node_unknown.rb +10 -0
  25. data/lib/arborist/event/node_up.rb +10 -0
  26. data/lib/arborist/event/node_update.rb +2 -11
  27. data/lib/arborist/event/sys_node_added.rb +10 -0
  28. data/lib/arborist/event/sys_node_removed.rb +10 -0
  29. data/lib/arborist/exceptions.rb +4 -0
  30. data/lib/arborist/manager.rb +188 -18
  31. data/lib/arborist/manager/event_publisher.rb +1 -1
  32. data/lib/arborist/manager/tree_api.rb +92 -13
  33. data/lib/arborist/mixins.rb +17 -0
  34. data/lib/arborist/monitor.rb +10 -1
  35. data/lib/arborist/monitor/socket.rb +123 -2
  36. data/lib/arborist/monitor_runner.rb +6 -5
  37. data/lib/arborist/node.rb +420 -94
  38. data/lib/arborist/node/ack.rb +72 -0
  39. data/lib/arborist/node/host.rb +43 -8
  40. data/lib/arborist/node/resource.rb +73 -0
  41. data/lib/arborist/node/root.rb +6 -0
  42. data/lib/arborist/node/service.rb +89 -22
  43. data/lib/arborist/observer.rb +1 -1
  44. data/lib/arborist/subscription.rb +11 -6
  45. data/spec/arborist/client_spec.rb +93 -5
  46. data/spec/arborist/dependency_spec.rb +375 -0
  47. data/spec/arborist/event/node_delta_spec.rb +66 -0
  48. data/spec/arborist/event/node_down_spec.rb +84 -0
  49. data/spec/arborist/event/node_spec.rb +59 -0
  50. data/spec/arborist/event/node_update_spec.rb +14 -3
  51. data/spec/arborist/event_spec.rb +3 -3
  52. data/spec/arborist/manager/tree_api_spec.rb +295 -3
  53. data/spec/arborist/manager_spec.rb +240 -57
  54. data/spec/arborist/monitor_spec.rb +26 -3
  55. data/spec/arborist/node/ack_spec.rb +74 -0
  56. data/spec/arborist/node/host_spec.rb +79 -0
  57. data/spec/arborist/node/resource_spec.rb +56 -0
  58. data/spec/arborist/node/service_spec.rb +68 -2
  59. data/spec/arborist/node_spec.rb +288 -11
  60. data/spec/arborist/subscription_spec.rb +23 -14
  61. data/spec/arborist_spec.rb +0 -4
  62. data/spec/data/observers/webservices.rb +10 -2
  63. data/spec/spec_helper.rb +8 -0
  64. metadata +58 -15
  65. metadata.gz.sig +0 -0
  66. data/LICENSE +0 -29
@@ -3,6 +3,8 @@
3
3
  require_relative '../spec_helper'
4
4
 
5
5
  require 'arborist/subscription'
6
+ require 'arborist/node/host'
7
+ require 'arborist/node/service'
6
8
 
7
9
 
8
10
  describe Arborist::Subscription do
@@ -16,11 +18,16 @@ describe Arborist::Subscription do
16
18
  let( :service_node ) do
17
19
  host_node.service( 'ssh' )
18
20
  end
19
- let( :publisher ) do
20
- instance_double( Arborist::Manager::EventPublisher )
21
- end
21
+ let( :published_events ) {[]}
22
22
  let( :subscription ) do
23
- described_class.new( publisher, 'node.delta', type: 'host' )
23
+ described_class.new( 'node.delta', type: 'host', &published_events.method(:push) )
24
+ end
25
+
26
+
27
+ it "raises an error if created without a callback block" do
28
+ expect {
29
+ described_class.new
30
+ }.to raise_error( LocalJumpError, /requires a callback block/i )
24
31
  end
25
32
 
26
33
 
@@ -32,39 +39,41 @@ describe Arborist::Subscription do
32
39
  it "publishes events which are of the desired type and have matching criteria" do
33
40
  event = Arborist::Event.create( 'node_delta', host_node, status: ['up', 'down'] )
34
41
 
35
- expect( publisher ).to receive( :publish ).with( subscription.id, event )
36
-
37
42
  subscription.on_events( event )
43
+
44
+ expect( published_events ).to eq([ subscription.id, event ])
38
45
  end
39
46
 
40
47
 
41
48
  it "publishes events which are of any type if the specified type is `nil`" do
42
- subscription = described_class.new( publisher )
49
+ subscription = described_class.new( &published_events.method(:push) )
43
50
  event1 = Arborist::Event.create( 'node_delta', host_node, status: ['up', 'down'] )
44
51
  event2 = Arborist::Event.create( 'sys_reloaded' )
45
52
 
46
- expect( publisher ).to receive( :publish ).with( subscription.id, event1 )
47
- expect( publisher ).to receive( :publish ).with( subscription.id, event2 )
48
-
49
53
  subscription.on_events( event1, event2 )
54
+
55
+ expect( published_events ).to eq([
56
+ subscription.id, event1,
57
+ subscription.id, event2
58
+ ])
50
59
  end
51
60
 
52
61
 
53
62
  it "doesn't publish events which are of the desired type but don't have matching criteria" do
54
63
  event = Arborist::Event.create( 'node_delta', service_node, status: ['up', 'down'] )
55
64
 
56
- expect( publisher ).to_not receive( :publish )
57
-
58
65
  subscription.on_events( event )
66
+
67
+ expect( published_events ).to be_empty
59
68
  end
60
69
 
61
70
 
62
71
  it "doesn't publish events which have matching criteria but aren't of the desired type" do
63
72
  event = Arborist::Event.create( 'node_update', host_node )
64
73
 
65
- expect( publisher ).to_not receive( :publish )
66
-
67
74
  subscription.on_events( event )
75
+
76
+ expect( published_events ).to be_empty
68
77
  end
69
78
 
70
79
  end
@@ -16,10 +16,6 @@ describe Arborist do
16
16
  ENV.delete(Arborist::CONFIG_ENV)
17
17
  end
18
18
 
19
- after( :each ) do
20
- Arborist::Node::Root.reset
21
- end
22
-
23
19
  after( :all ) do
24
20
  ENV[Arborist::CONFIG_ENV] = @original_config_env
25
21
  end
@@ -6,9 +6,17 @@ require 'arborist'
6
6
 
7
7
  Arborist::Observer "Webservers" do
8
8
  subscribe to: 'node.delta',
9
- where: { type: 'service', port: 80, status: ['up', 'down'] }
9
+ where: {
10
+ type: 'service',
11
+ port: 80,
12
+ delta: { status: ['up', 'down'] }
13
+ }
10
14
  subscribe to: 'node.delta',
11
- where: { type: 'service', port: 443, status: ['up', 'down'] }
15
+ where: {
16
+ type: 'service',
17
+ port: 443,
18
+ delta: { status: ['up', 'down'] }
19
+ }
12
20
 
13
21
  action do |uuid, event|
14
22
  $stderr.puts "Webserver %s is DOWN (%p)" % [ event['data']['identifier'], event['data'] ]
@@ -15,6 +15,10 @@ require 'arborist/mixins'
15
15
 
16
16
  class TestNode < Arborist::Node; end
17
17
 
18
+ class TestSubNode < Arborist::Node
19
+ parent_type :test
20
+ end
21
+
18
22
  class TestEvent < Arborist::Event; end
19
23
 
20
24
 
@@ -111,6 +115,10 @@ RSpec.configure do |config|
111
115
  mock.syntax = :expect
112
116
  end
113
117
 
118
+ config.after( :each ) do
119
+ Arborist::Node::Root.reset
120
+ end
121
+
114
122
  config.filter_run_excluding( :no_ci ) if ENV['SEMAPHORE'] || ENV['CI']
115
123
 
116
124
  config.include( Loggability::SpecHelpers )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arborist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre20160128152542
4
+ version: 0.0.1.pre20160606141735
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -11,9 +11,9 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
14
+ MIIDMDCCAhigAwIBAgIBAjANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
15
15
  GTAXBgoJkiaJk/IsZAE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9XVuJMh20uWuw6pmv/Ub2RqAf82jQSbpz09G
31
- G8LHR7EjtPPmqCCunfyecJ6MmCNaiJCBxq2NYzyNmluPyHT8+0fuB5kccUVZm6CD
32
- xn3DzOkDE6NYbk8gC9rTsA==
24
+ AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSZ0hCV
25
+ qoHr122fGKelqffzEQBhszANBgkqhkiG9w0BAQUFAAOCAQEAF2XCzjfTFxkcVvuj
26
+ hhBezFkZnMDYtWezg4QCkR0RHg4sl1LdXjpvvI59SIgD/evD1hOteGKsXqD8t0E4
27
+ OPAWWv/z+JRma72zeYsBZLSDRPIUvBoul6qCpvY0MiWTh496mFwOxT5lvSAUoh+U
28
+ pQ/MQeH/yC6hbGp7IYska6J8T4z5XkYqafYZ3eKQ8H+xPd/z+gYx+jd0PfkWf1Wk
29
+ QQdziL01SKBHf33OAH/p/puCpwS+ZDfgnNx5oMijWbc671UXkrt7zjD0kGakq+9I
30
+ hnfm736z8j1wvWddqf45++gwPpDr1E4zoAq2PgRl/WBNyR0hfoZLpi3TnHu3eC0x
31
+ uALKNA==
33
32
  -----END CERTIFICATE-----
34
- date: 2016-01-28 00:00:00.000000000 Z
33
+ date: 2016-06-06 00:00:00.000000000 Z
35
34
  dependencies:
36
35
  - !ruby/object:Gem::Dependency
37
36
  name: schedulability
@@ -131,6 +130,34 @@ dependencies:
131
130
  - - "~>"
132
131
  - !ruby/object:Gem::Version
133
132
  version: '1.7'
133
+ - !ruby/object:Gem::Dependency
134
+ name: gli
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '2.3'
140
+ type: :runtime
141
+ prerelease: false
142
+ version_requirements: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '2.3'
147
+ - !ruby/object:Gem::Dependency
148
+ name: highline
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '1.7'
154
+ type: :runtime
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '1.7'
134
161
  - !ruby/object:Gem::Dependency
135
162
  name: hoe-mercurial
136
163
  requirement: !ruby/object:Gem::Requirement
@@ -272,7 +299,6 @@ files:
272
299
  - ChangeLog
273
300
  - Events.md
274
301
  - History.md
275
- - LICENSE
276
302
  - Manifest.txt
277
303
  - Monitors.md
278
304
  - Nodes.md
@@ -290,11 +316,19 @@ files:
290
316
  - lib/arborist/command/config.rb
291
317
  - lib/arborist/command/start.rb
292
318
  - lib/arborist/command/watch.rb
319
+ - lib/arborist/dependency.rb
293
320
  - lib/arborist/event.rb
321
+ - lib/arborist/event/node.rb
294
322
  - lib/arborist/event/node_acked.rb
295
323
  - lib/arborist/event/node_delta.rb
296
- - lib/arborist/event/node_matching.rb
324
+ - lib/arborist/event/node_disabled.rb
325
+ - lib/arborist/event/node_down.rb
326
+ - lib/arborist/event/node_quieted.rb
327
+ - lib/arborist/event/node_unknown.rb
328
+ - lib/arborist/event/node_up.rb
297
329
  - lib/arborist/event/node_update.rb
330
+ - lib/arborist/event/sys_node_added.rb
331
+ - lib/arborist/event/sys_node_removed.rb
298
332
  - lib/arborist/event/sys_reloaded.rb
299
333
  - lib/arborist/exceptions.rb
300
334
  - lib/arborist/loader.rb
@@ -307,7 +341,9 @@ files:
307
341
  - lib/arborist/monitor/socket.rb
308
342
  - lib/arborist/monitor_runner.rb
309
343
  - lib/arborist/node.rb
344
+ - lib/arborist/node/ack.rb
310
345
  - lib/arborist/node/host.rb
346
+ - lib/arborist/node/resource.rb
311
347
  - lib/arborist/node/root.rb
312
348
  - lib/arborist/node/service.rb
313
349
  - lib/arborist/observer.rb
@@ -316,6 +352,10 @@ files:
316
352
  - lib/arborist/observer_runner.rb
317
353
  - lib/arborist/subscription.rb
318
354
  - spec/arborist/client_spec.rb
355
+ - spec/arborist/dependency_spec.rb
356
+ - spec/arborist/event/node_delta_spec.rb
357
+ - spec/arborist/event/node_down_spec.rb
358
+ - spec/arborist/event/node_spec.rb
319
359
  - spec/arborist/event/node_update_spec.rb
320
360
  - spec/arborist/event_spec.rb
321
361
  - spec/arborist/manager/event_publisher_spec.rb
@@ -325,7 +365,9 @@ files:
325
365
  - spec/arborist/monitor/socket_spec.rb
326
366
  - spec/arborist/monitor_runner_spec.rb
327
367
  - spec/arborist/monitor_spec.rb
368
+ - spec/arborist/node/ack_spec.rb
328
369
  - spec/arborist/node/host_spec.rb
370
+ - spec/arborist/node/resource_spec.rb
329
371
  - spec/arborist/node/root_spec.rb
330
372
  - spec/arborist/node/service_spec.rb
331
373
  - spec/arborist/node_spec.rb
@@ -373,3 +415,4 @@ specification_version: 4
373
415
  summary: Arborist is a monitoring toolkit that follows the UNIX philosophy of small
374
416
  parts and loose coupling for stability, reliability, and customizability
375
417
  test_files: []
418
+ has_rdoc:
Binary file
data/LICENSE DELETED
@@ -1,29 +0,0 @@
1
- Copyright (c) 2015, Michael Granger and Mahlon E. Smith
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright notice,
8
- this list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright notice,
11
- this list of conditions and the following disclaimer in the documentation
12
- and/or other materials provided with the distribution.
13
-
14
- * Neither the name of the author/s, nor the names of the project's
15
- contributors may be used to endorse or promote products derived from this
16
- software without specific prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
-
29
-