arborist 0.0.1.pre20160606141735 → 0.0.1.pre20160829140603

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +81 -2
  3. data/Events.md +11 -11
  4. data/Manifest.txt +2 -4
  5. data/TODO.md +9 -29
  6. data/lib/arborist.rb +6 -2
  7. data/lib/arborist/command/watch.rb +59 -8
  8. data/lib/arborist/loader/file.rb +1 -1
  9. data/lib/arborist/manager.rb +139 -50
  10. data/lib/arborist/manager/event_publisher.rb +29 -0
  11. data/lib/arborist/manager/tree_api.rb +16 -1
  12. data/lib/arborist/mixins.rb +36 -1
  13. data/lib/arborist/monitor.rb +12 -0
  14. data/lib/arborist/monitor/socket.rb +8 -9
  15. data/lib/arborist/monitor_runner.rb +2 -2
  16. data/lib/arborist/node.rb +16 -3
  17. data/lib/arborist/node/host.rb +25 -22
  18. data/lib/arborist/node/resource.rb +28 -14
  19. data/lib/arborist/node/service.rb +21 -2
  20. data/lib/arborist/observer_runner.rb +68 -7
  21. data/spec/arborist/client_spec.rb +3 -3
  22. data/spec/arborist/manager/event_publisher_spec.rb +0 -1
  23. data/spec/arborist/manager/tree_api_spec.rb +6 -5
  24. data/spec/arborist/manager_spec.rb +53 -24
  25. data/spec/arborist/node/resource_spec.rb +9 -0
  26. data/spec/arborist/node/service_spec.rb +16 -1
  27. data/spec/arborist/node_spec.rb +22 -12
  28. data/spec/arborist/observer_runner_spec.rb +58 -0
  29. data/spec/arborist/observer_spec.rb +15 -15
  30. data/spec/arborist/subscription_spec.rb +1 -1
  31. data/spec/data/nodes/{duir.rb → sub/duir.rb} +0 -0
  32. data/spec/data/observers/auditor.rb +2 -2
  33. data/spec/spec_helper.rb +1 -0
  34. metadata +30 -27
  35. checksums.yaml.gz.sig +0 -0
  36. data.tar.gz.sig +0 -2
  37. data/lib/arborist/event/sys_node_added.rb +0 -10
  38. data/lib/arborist/event/sys_node_removed.rb +0 -10
  39. data/lib/arborist/event/sys_reloaded.rb +0 -15
  40. metadata.gz.sig +0 -0
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env rspec -cfd
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ require 'arborist/observer_runner'
6
+
7
+
8
+ describe Arborist::ObserverRunner do
9
+
10
+
11
+ let( :zmq_loop ) { instance_double(ZMQ::Loop) }
12
+ let( :req_socket ) { instance_double(ZMQ::Socket::Req) }
13
+ let( :sub_socket ) { instance_double(ZMQ::Socket::Sub) }
14
+ let( :pollitem ) { instance_double(ZMQ::Pollitem) }
15
+
16
+ let( :runner ) do
17
+ obj = described_class.new
18
+ obj.reactor = zmq_loop
19
+ obj
20
+ end
21
+
22
+ let( :observer_class ) { Class.new(Arborist::Observer) }
23
+
24
+ let( :observer1 ) { observer_class.new("testing observer1") }
25
+ let( :observer2 ) { observer_class.new("testing observer2") }
26
+ let( :observer3 ) { observer_class.new("testing observer3") }
27
+ let( :observers ) {[ observer1, observer2, observer3 ]}
28
+
29
+
30
+ it "can load observers from an enumerator that yields Arborist::Observers" do
31
+ runner.load_observers([ observer1, observer2, observer3 ])
32
+ expect( runner.observers ).to include( observer1, observer2, observer3 )
33
+ end
34
+
35
+
36
+ describe "a runner with loaded observers" do
37
+
38
+ before( :each ) do
39
+ allow( zmq_loop ).to receive( :register ).with( an_instance_of(ZMQ::Pollitem) )
40
+ end
41
+
42
+
43
+ xit "subscribes to events for each of its observers and starts the ZMQ loop when run" do
44
+ expect( Arborist.zmq_context ).to receive( :socket ).
45
+ with( :REQ ).and_return( req_socket )
46
+ expect( Arborist.zmq_context ).to receive( :socket ).
47
+ with( :SUB ).and_return( sub_socket )
48
+
49
+ expect( req_socket ).to receive( :subscribe ).with( )
50
+ end
51
+
52
+ end
53
+
54
+
55
+ describe Arborist::ObserverRunner::Handler
56
+
57
+ end
58
+
@@ -45,8 +45,8 @@ describe Arborist::Observer do
45
45
 
46
46
  it "can specify an action to run when a subscribed event is received" do
47
47
  observer = described_class.new( "testing observer" ) do
48
- action do |uuid, event|
49
- puts( uuid )
48
+ action do |event|
49
+ # no-op
50
50
  end
51
51
  end
52
52
 
@@ -57,11 +57,11 @@ describe Arborist::Observer do
57
57
 
58
58
  it "can specify more than one action to run when a subscribed event is received" do
59
59
  observer = described_class.new( "testing observer" ) do
60
- action do |uuid, event|
61
- puts( uuid )
60
+ action do |event|
61
+ # no-op
62
62
  end
63
- action do |uuid, event|
64
- $stderr.puts( uuid )
63
+ action do |event|
64
+ # no-op
65
65
  end
66
66
  end
67
67
 
@@ -74,7 +74,7 @@ describe Arborist::Observer do
74
74
  it "can specify a summary action" do
75
75
  observer = described_class.new( "testing observer" ) do
76
76
  summarize( every: 5 ) do |events|
77
- puts( events.size )
77
+ # no-op
78
78
  end
79
79
  end
80
80
 
@@ -87,10 +87,10 @@ describe Arborist::Observer do
87
87
  it "can specify a mix of regular and summary actions" do
88
88
  observer = described_class.new( "testing observer" ) do
89
89
  summarize( every: 5 ) do |events|
90
- puts( events.size )
90
+ # no-op
91
91
  end
92
- action do |uuid, event|
93
- $stderr.puts( uuid )
92
+ action do |event|
93
+ # no-op
94
94
  end
95
95
  end
96
96
 
@@ -104,10 +104,10 @@ describe Arborist::Observer do
104
104
  it "passes events it is given to handle to its actions" do
105
105
  observer = described_class.new( "testing observer" ) do
106
106
  summarize( every: 5 ) do |events|
107
- puts( events.size )
107
+ # no-op
108
108
  end
109
- action do |uuid, event|
110
- $stderr.puts( uuid )
109
+ action do |event|
110
+ # no-op
111
111
  end
112
112
  end
113
113
 
@@ -126,8 +126,8 @@ describe Arborist::Observer do
126
126
  summarize( every: 5 ) do |events|
127
127
  summarize_called = true
128
128
  end
129
- action do |uuid, event|
130
- $stderr.puts( uuid )
129
+ action do |event|
130
+ # no-op
131
131
  end
132
132
  end
133
133
 
@@ -48,7 +48,7 @@ describe Arborist::Subscription do
48
48
  it "publishes events which are of any type if the specified type is `nil`" do
49
49
  subscription = described_class.new( &published_events.method(:push) )
50
50
  event1 = Arborist::Event.create( 'node_delta', host_node, status: ['up', 'down'] )
51
- event2 = Arborist::Event.create( 'sys_reloaded' )
51
+ event2 = Arborist::Event.create( 'node_update', host_node )
52
52
 
53
53
  subscription.on_events( event1, event2 )
54
54
 
File without changes
@@ -6,8 +6,8 @@ require 'arborist'
6
6
 
7
7
  Arborist::Observer "Audit Logger" do
8
8
  subscribe to: 'node.update', on: 'localhost'
9
- action do |uuid, event|
10
- $stderr.puts "%s: %p" % [ uuid, event ]
9
+ action do |event|
10
+ $stderr.puts "%p" % [ event ]
11
11
  end
12
12
  summarize( every: 8 ) do |events|
13
13
  $stderr.puts "Audit summary:"
@@ -67,6 +67,7 @@ module Arborist::TestHelpers
67
67
 
68
68
 
69
69
  def make_testing_manager
70
+ Arborist::Manager.linger = 0
70
71
  loader = Arborist::Loader.create( :file, SPEC_DATA_DIR + 'nodes' )
71
72
  return Arborist.manager_for( loader )
72
73
  end
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.pre20160606141735
4
+ version: 0.0.1.pre20160829140603
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -11,26 +11,32 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDMDCCAhigAwIBAgIBAjANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
14
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MQwwCgYDVQQDDANnZWQx
15
15
  GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
16
- HhcNMTYwNjAyMDE1NTQ2WhcNMTcwNjAyMDE1NTQ2WjA+MQwwCgYDVQQDDANnZWQx
16
+ HhcNMTYwODIwMTgxNzQyWhcNMTcwODIwMTgxNzQyWjA+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fSjJrn0sPBlYyOXgCoByfZnZyrIMH/UY+lgQqS
35
+ 6Von1VDsfQm0eJh5zYZD64ZF86phSR7mUX3mXItwH04HrZwkWpvgd871DZVR3i1n
36
+ w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
37
+ p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
32
38
  -----END CERTIFICATE-----
33
- date: 2016-06-06 00:00:00.000000000 Z
39
+ date: 2016-08-29 00:00:00.000000000 Z
34
40
  dependencies:
35
41
  - !ruby/object:Gem::Dependency
36
42
  name: schedulability
@@ -178,14 +184,14 @@ dependencies:
178
184
  requirements:
179
185
  - - "~>"
180
186
  - !ruby/object:Gem::Version
181
- version: '0.7'
187
+ version: '0.8'
182
188
  type: :development
183
189
  prerelease: false
184
190
  version_requirements: !ruby/object:Gem::Requirement
185
191
  requirements:
186
192
  - - "~>"
187
193
  - !ruby/object:Gem::Version
188
- version: '0.7'
194
+ version: '0.8'
189
195
  - !ruby/object:Gem::Dependency
190
196
  name: hoe-highline
191
197
  requirement: !ruby/object:Gem::Requirement
@@ -262,14 +268,14 @@ dependencies:
262
268
  requirements:
263
269
  - - "~>"
264
270
  - !ruby/object:Gem::Version
265
- version: '3.14'
271
+ version: '3.15'
266
272
  type: :development
267
273
  prerelease: false
268
274
  version_requirements: !ruby/object:Gem::Requirement
269
275
  requirements:
270
276
  - - "~>"
271
277
  - !ruby/object:Gem::Version
272
- version: '3.14'
278
+ version: '3.15'
273
279
  description: |-
274
280
  Arborist is a monitoring toolkit that follows the UNIX philosophy
275
281
  of small parts and loose coupling for stability, reliability, and
@@ -327,9 +333,6 @@ files:
327
333
  - lib/arborist/event/node_unknown.rb
328
334
  - lib/arborist/event/node_up.rb
329
335
  - lib/arborist/event/node_update.rb
330
- - lib/arborist/event/sys_node_added.rb
331
- - lib/arborist/event/sys_node_removed.rb
332
- - lib/arborist/event/sys_reloaded.rb
333
336
  - lib/arborist/exceptions.rb
334
337
  - lib/arborist/loader.rb
335
338
  - lib/arborist/loader/file.rb
@@ -373,6 +376,7 @@ files:
373
376
  - spec/arborist/node_spec.rb
374
377
  - spec/arborist/observer/action_spec.rb
375
378
  - spec/arborist/observer/summarize_spec.rb
379
+ - spec/arborist/observer_runner_spec.rb
376
380
  - spec/arborist/observer_spec.rb
377
381
  - spec/arborist/subscription_spec.rb
378
382
  - spec/arborist_spec.rb
@@ -380,9 +384,9 @@ files:
380
384
  - spec/data/monitors/port_checks.rb
381
385
  - spec/data/monitors/system_resources.rb
382
386
  - spec/data/monitors/web_services.rb
383
- - spec/data/nodes/duir.rb
384
387
  - spec/data/nodes/localhost.rb
385
388
  - spec/data/nodes/sidonie.rb
389
+ - spec/data/nodes/sub/duir.rb
386
390
  - spec/data/nodes/yevaud.rb
387
391
  - spec/data/observers/auditor.rb
388
392
  - spec/data/observers/webservices.rb
@@ -415,4 +419,3 @@ specification_version: 4
415
419
  summary: Arborist is a monitoring toolkit that follows the UNIX philosophy of small
416
420
  parts and loose coupling for stability, reliability, and customizability
417
421
  test_files: []
418
- has_rdoc:
Binary file
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- uM�}�E�f���A�JtM%f��L��W?U`��(N՜r��u�����LQ��5Z���������2W4�6�j�o�`$n��]�^񥾥^�о]) <7�C�M ��t'>]�+*��e ��iZq������fO�l�]F�񇚫� Hn�rXe&��u�S�^�b���A �q֔��$���]�� �1�8�diIj4�����J�}J�
2
- C�.���������i��,�}����E�ݭ
@@ -1,10 +0,0 @@
1
- # -*- ruby -*-
2
- #encoding: utf-8
3
-
4
- require 'arborist/event' unless defined?( Arborist::Event )
5
- require 'arborist/event/node'
6
-
7
-
8
- # A system event generated when a node is added to the tree.
9
- class Arborist::Event::SysNodeAdded < Arborist::Event::Node
10
- end # class Arborist::Event::SysNodeAdded
@@ -1,10 +0,0 @@
1
- # -*- ruby -*-
2
- #encoding: utf-8
3
-
4
- require 'arborist/event' unless defined?( Arborist::Event )
5
- require 'arborist/event/node'
6
-
7
-
8
- # A system event generated when a node is removed from the tree.
9
- class Arborist::Event::SysNodeRemoved < Arborist::Event::Node
10
- end # class Arborist::Event::SysNodeRemoved
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'arborist/node' unless defined?( Arborist::Node )
4
-
5
-
6
- # An event sent when the manager reloads the node tree.
7
- class Arborist::Event::SysReloaded < Arborist::Event
8
-
9
-
10
- ### Create a NodeUpdate event for the specified +node+.
11
- def initialize( payload=Time.now )
12
- super
13
- end
14
-
15
- end # class Arborist::Event::NodeUpdate
metadata.gz.sig DELETED
Binary file