em-langrove 0.0.4.5
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.
- data/.rspec +1 -0
- data/.rvmrc +62 -0
- data/.watchr +27 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +61 -0
- data/Rakefile +24 -0
- data/bin/langrove +3 -0
- data/functional/config/boot.rb +64 -0
- data/functional/config/daemons.yml +13 -0
- data/functional/config/environment.rb +28 -0
- data/functional/config/environments/development.rb +0 -0
- data/functional/config/environments/production.rb +0 -0
- data/functional/config/environments/test.rb +0 -0
- data/functional/lib/client/socket_to_file.rb +47 -0
- data/functional/lib/daemon/datagram.rb +21 -0
- data/functional/lib/protocol/socket_to_file.rb +55 -0
- data/functional/libexec/daemon.rb +68 -0
- data/functional/tmp/README +1 -0
- data/lib/langrove/_base.rb +28 -0
- data/lib/langrove/adaptor/base.rb +2 -0
- data/lib/langrove/adaptor_base.rb +116 -0
- data/lib/langrove/client/base.rb +2 -0
- data/lib/langrove/client/datagram.rb +25 -0
- data/lib/langrove/client_base.rb +92 -0
- data/lib/langrove/daemon/base.rb +2 -0
- data/lib/langrove/daemon_base.rb +281 -0
- data/lib/langrove/ext/class_loader.rb +148 -0
- data/lib/langrove/ext/config_item.rb +34 -0
- data/lib/langrove/ext/config_loader.rb +16 -0
- data/lib/langrove/ext/fake_logger.rb +8 -0
- data/lib/langrove/ext/find.rb +90 -0
- data/lib/langrove/ext/persistable.rb +103 -0
- data/lib/langrove/ext/string.rb +35 -0
- data/lib/langrove/ext.rb +7 -0
- data/lib/langrove/handler/base.rb +2 -0
- data/lib/langrove/handler_base.rb +148 -0
- data/lib/langrove/job/base.rb +1 -0
- data/lib/langrove/job_base.rb +24 -0
- data/lib/langrove/protocol/base.rb +2 -0
- data/lib/langrove/protocol/syslog.rb +32 -0
- data/lib/langrove/protocol_base.rb +32 -0
- data/lib/langrove/version.rb +3 -0
- data/lib/langrove.rb +1 -0
- data/spec/functional/daemon/datagram_spec.rb +121 -0
- data/spec/langrove/adaptor_base_spec.rb +63 -0
- data/spec/langrove/client/datagram_spec.rb +1 -0
- data/spec/langrove/client_base_spec.rb +5 -0
- data/spec/langrove/daemon_base_spec.rb +154 -0
- data/spec/langrove/ext/class_loader_spec.rb +83 -0
- data/spec/langrove/ext/config_item_spec.rb +81 -0
- data/spec/langrove/ext/config_loader_spec.rb +5 -0
- data/spec/langrove/ext/fake_logger_spec.rb +0 -0
- data/spec/langrove/ext/find_spec.rb +53 -0
- data/spec/langrove/ext/persistable_spec.rb +117 -0
- data/spec/langrove/ext/string_spec.rb +16 -0
- data/spec/langrove/handler_base_spec.rb +103 -0
- data/spec/langrove/job_base_spec.rb +28 -0
- data/spec/langrove/protocol/syslog_spec.rb +45 -0
- data/spec/langrove/protocol_base_spec.rb +6 -0
- data/spec/todo_spec.rb +12 -0
- data/tmp/README +2 -0
- metadata +203 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'langrove'
|
2
|
+
|
3
|
+
describe LanGrove::Daemon::Base do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
|
7
|
+
@logger = LanGrove::FakeLogger.new :silent
|
8
|
+
|
9
|
+
@daemon_name = 'pretend_daemon'
|
10
|
+
|
11
|
+
@adaptor_class = 'MyEventMachineServer'
|
12
|
+
@collection_class = 'Base'
|
13
|
+
@client_class = 'Base'
|
14
|
+
@protocol_class = 'Base'
|
15
|
+
|
16
|
+
@config = {
|
17
|
+
|
18
|
+
:daemons => {
|
19
|
+
|
20
|
+
@daemon_name => {
|
21
|
+
|
22
|
+
:server => false,
|
23
|
+
|
24
|
+
:adaptor => {
|
25
|
+
|
26
|
+
# Test default
|
27
|
+
|
28
|
+
},
|
29
|
+
|
30
|
+
:client => {
|
31
|
+
|
32
|
+
:class => @client_class
|
33
|
+
|
34
|
+
},
|
35
|
+
|
36
|
+
:protocol => {
|
37
|
+
|
38
|
+
:class => @protocol_class
|
39
|
+
|
40
|
+
},
|
41
|
+
|
42
|
+
:handler => {
|
43
|
+
|
44
|
+
:collection => @collection_class
|
45
|
+
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
subject do
|
54
|
+
|
55
|
+
LanGrove::Daemon::Base.new( @config, @daemon_name, @logger )
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'requires a logger' do
|
60
|
+
|
61
|
+
expect {
|
62
|
+
|
63
|
+
LanGrove::Daemon::Base.new( @config, @daemon_name, nil )
|
64
|
+
|
65
|
+
}.to raise_error( LanGrove::DaemonConfigException,
|
66
|
+
|
67
|
+
/Requires a logger/
|
68
|
+
|
69
|
+
)
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'requires a configuration' do
|
74
|
+
|
75
|
+
expect {
|
76
|
+
|
77
|
+
LanGrove::Daemon::Base.new( {}, @daemon_name, @logger )
|
78
|
+
|
79
|
+
}.to raise_error( LanGrove::DaemonConfigException,
|
80
|
+
|
81
|
+
/Missing config item/
|
82
|
+
|
83
|
+
)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'attempts to latebind an adaptor by config' do
|
88
|
+
|
89
|
+
@config[ :daemons ][ @daemon_name ][ :adaptor ][ :class ] = @adaptor_class
|
90
|
+
|
91
|
+
expect {
|
92
|
+
|
93
|
+
LanGrove::Daemon::Base.new( @config, @daemon_name, @logger )
|
94
|
+
|
95
|
+
}.to raise_error( LanGrove::ClassLoaderException,
|
96
|
+
|
97
|
+
|
98
|
+
"no such file to load -- adaptor/my_event_machine_server.rb"
|
99
|
+
|
100
|
+
)
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'defaults to Adaptor::Base' do
|
105
|
+
|
106
|
+
|
107
|
+
adaptor = subject.instance_variable_get( :@adaptor )
|
108
|
+
adaptor.should be_a( LanGrove::Adaptor::Base )
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'latebinds a handler by config' do
|
113
|
+
|
114
|
+
handler = subject.instance_variable_get( :@handler )
|
115
|
+
|
116
|
+
handler.should be_a( LanGrove::Handler.const_get( @collection_class ) )
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'loads the client defininition by config' do
|
121
|
+
|
122
|
+
client = subject.instance_variable_get( :@client )
|
123
|
+
|
124
|
+
client.should == LanGrove::Client::Base
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'does not instanciate the client' do
|
129
|
+
|
130
|
+
client = subject.instance_variable_get( :@client )
|
131
|
+
|
132
|
+
client.should_not be_a(LanGrove::Client::Base)
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'loads the protocol defininition by config' do
|
137
|
+
|
138
|
+
protocol = subject.instance_variable_get( :@protocol )
|
139
|
+
|
140
|
+
protocol.should == LanGrove::Protocol::Base
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'does not instanciate the protocol' do
|
145
|
+
|
146
|
+
protocol = subject.instance_variable_get( :@protocol )
|
147
|
+
|
148
|
+
protocol.should_not be_a(LanGrove::Protocol::Base)
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'it schedules periodics'
|
153
|
+
|
154
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'langrove/ext/class_loader'
|
2
|
+
require 'langrove/ext/fake_logger'
|
3
|
+
|
4
|
+
describe LanGrove::ClassLoader do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
|
8
|
+
@logger = LanGrove::FakeLogger.new :silent
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'raises on missing class definition file' do
|
13
|
+
|
14
|
+
expect {
|
15
|
+
|
16
|
+
LanGrove::ClassLoader.create( {
|
17
|
+
|
18
|
+
:module => 'Protocol',
|
19
|
+
:class => 'MedievalLanternMorse'
|
20
|
+
|
21
|
+
}, @logger )
|
22
|
+
|
23
|
+
}.to raise_error(
|
24
|
+
|
25
|
+
LanGrove::ClassLoaderException,
|
26
|
+
|
27
|
+
"no such file to load -- protocol/medieval_lantern_morse.rb"
|
28
|
+
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'raises on missing ModuleName' do
|
33
|
+
|
34
|
+
expect {
|
35
|
+
|
36
|
+
LanGrove::ClassLoader.create( {
|
37
|
+
|
38
|
+
:class => 'MedievalLanternMorse'
|
39
|
+
|
40
|
+
}, @logger )
|
41
|
+
|
42
|
+
}.to raise_error(
|
43
|
+
|
44
|
+
LanGrove::ClassLoaderException, /:module/
|
45
|
+
|
46
|
+
)
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'raises on missing ClassName' do
|
51
|
+
|
52
|
+
expect {
|
53
|
+
|
54
|
+
LanGrove::ClassLoader.create( {
|
55
|
+
|
56
|
+
:module => 'Protocol'
|
57
|
+
|
58
|
+
}, @logger )
|
59
|
+
|
60
|
+
}.to raise_error(
|
61
|
+
|
62
|
+
LanGrove::ClassLoaderException, /:class/
|
63
|
+
|
64
|
+
)
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns a constantized class definition' do
|
69
|
+
|
70
|
+
test = LanGrove::ClassLoader.create( {
|
71
|
+
|
72
|
+
:module => 'Protocol',
|
73
|
+
:class => 'Base'
|
74
|
+
|
75
|
+
}, @logger ).new( nil, @logger )
|
76
|
+
|
77
|
+
test.should be_a( LanGrove::Protocol::Base )
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'also works on local implementation'
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'langrove/ext'
|
2
|
+
|
3
|
+
describe LanGrove::ConfigItem do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@config_hash = {
|
7
|
+
'root' => "3",
|
8
|
+
'BLANK' => "",
|
9
|
+
:daemons => {
|
10
|
+
'puppet_log' => {
|
11
|
+
:handler => {
|
12
|
+
:collection => 'SyslogStateMachines'
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'accesses config items' do
|
20
|
+
LanGrove::ConfigItem.get(@config_hash, ['root']).should == '3'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'accesses nested config items' do
|
24
|
+
LanGrove::ConfigItem.get(@config_hash,
|
25
|
+
|
26
|
+
[:daemons , 'puppet_log', :handler, :collection]
|
27
|
+
|
28
|
+
).should == 'SyslogStateMachines'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'raises a config exception if the key isnt present' do
|
32
|
+
|
33
|
+
expect {
|
34
|
+
|
35
|
+
LanGrove::ConfigItem.get(@config_hash, ['NOT'])
|
36
|
+
|
37
|
+
}.to raise_error( LanGrove::ConfigException, /Missing config item 'NOT'/ )
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'raises a config exception if the key isnt present' do
|
42
|
+
|
43
|
+
expect {
|
44
|
+
|
45
|
+
LanGrove::ConfigItem.get(@config_hash, ['BLANK'])
|
46
|
+
|
47
|
+
}.to raise_error( LanGrove::ConfigException, /Missing config item 'BLANK'/ )
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'raises a config exception if the value isnt present' do
|
52
|
+
|
53
|
+
expect {
|
54
|
+
|
55
|
+
LanGrove::ConfigItem.get(@config_hash, ['BLANK'], false)
|
56
|
+
|
57
|
+
}.to_not raise_error( LanGrove::ConfigException, /Missing config item 'BLANK'/ )
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'raises a config exception if the nested item isnt present' do
|
62
|
+
|
63
|
+
expect {
|
64
|
+
|
65
|
+
LanGrove::ConfigItem.get(@config_hash, [ :daemons, 'NEITHER', 'this'])
|
66
|
+
|
67
|
+
}.to raise_error( LanGrove::ConfigException, /Missing config item 'NEITHER'/ )
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'does not raise on not mandatory fields' do
|
72
|
+
|
73
|
+
expect {
|
74
|
+
|
75
|
+
LanGrove::ConfigItem.get(@config_hash, [ :daemons, 'NEITHER' ], false)
|
76
|
+
|
77
|
+
}.to_not raise_error( LanGrove::ConfigException )
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'langrove/ext/find'
|
2
|
+
|
3
|
+
describe LanGrove::Find do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
|
7
|
+
|
8
|
+
@path = File.expand_path('../../../../bin', __FILE__ )
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'searches finds' do
|
13
|
+
|
14
|
+
test = []
|
15
|
+
|
16
|
+
LanGrove::Find.with(
|
17
|
+
|
18
|
+
:type => :file,
|
19
|
+
:path => @path,
|
20
|
+
:relative => true
|
21
|
+
|
22
|
+
) do |found|
|
23
|
+
|
24
|
+
test << found
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
test.length.should == 1
|
29
|
+
test[0].should == 'langrove'
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'searches filters' do
|
34
|
+
|
35
|
+
test = []
|
36
|
+
|
37
|
+
LanGrove::Find.with(
|
38
|
+
|
39
|
+
:type => :file,
|
40
|
+
:path => @path,
|
41
|
+
:include => 'scotch mist'
|
42
|
+
|
43
|
+
) do |found|
|
44
|
+
|
45
|
+
test << found
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
test.length.should == 0
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'langrove/ext'
|
2
|
+
|
3
|
+
#
|
4
|
+
# This will likely change.
|
5
|
+
#
|
6
|
+
|
7
|
+
describe LanGrove::Persistable do
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
|
11
|
+
class TestSerialization
|
12
|
+
attr_accessor :data
|
13
|
+
end
|
14
|
+
|
15
|
+
@class_instance = TestSerialization.new
|
16
|
+
@class_instance.data = 'VALUE'
|
17
|
+
|
18
|
+
@now = Time.now
|
19
|
+
@state_file = File.dirname( __FILE__ ) + "/../../../tmp/persistable.yml"
|
20
|
+
|
21
|
+
#
|
22
|
+
# delete the file
|
23
|
+
#
|
24
|
+
File.delete( @state_file ) if File.file?( @state_file )
|
25
|
+
|
26
|
+
@hash = {
|
27
|
+
'tree' => {
|
28
|
+
'type' => {
|
29
|
+
:thing1 => 1
|
30
|
+
}
|
31
|
+
},
|
32
|
+
:now => @now,
|
33
|
+
:class_instance => @class_instance
|
34
|
+
}
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
subject do
|
39
|
+
|
40
|
+
test = LanGrove::Persistable.new
|
41
|
+
test.instance_variable_set :@logger, (LanGrove::FakeLogger.new :silent)
|
42
|
+
test
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'can serialize a hash to file' do
|
47
|
+
|
48
|
+
#
|
49
|
+
# install the hash to be 'stored'
|
50
|
+
#
|
51
|
+
subject.instance_variable_set( :@hash, @hash )
|
52
|
+
subject.store_hash( '@hash', @state_file )
|
53
|
+
|
54
|
+
#
|
55
|
+
# is the file there?
|
56
|
+
#
|
57
|
+
File.file?( @state_file ).should == true
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'can de-serialize a hash' do
|
62
|
+
|
63
|
+
before :each do
|
64
|
+
|
65
|
+
#
|
66
|
+
# set up the file to read
|
67
|
+
#
|
68
|
+
subject.instance_variable_set( :@hash, @hash )
|
69
|
+
subject.store_hash( '@hash', @state_file )
|
70
|
+
|
71
|
+
#
|
72
|
+
# replace the hash with another containg other things
|
73
|
+
#
|
74
|
+
subject.instance_variable_set( :@hash, { 'thing2' => 2 } )
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'from file' do
|
79
|
+
|
80
|
+
subject.load_hash( '@hash', @state_file )
|
81
|
+
|
82
|
+
hash = subject.instance_variable_get( :@hash )
|
83
|
+
hash['tree']['type'][:thing1].should == 1
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'from file and re-instanciate as correct native ruby classes' do
|
88
|
+
|
89
|
+
subject.load_hash( '@hash', @state_file )
|
90
|
+
hash = subject.instance_variable_get( :@hash )
|
91
|
+
|
92
|
+
hash[:now].should be_a( Time )
|
93
|
+
hash[:now].should == @now
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'from file and re-instanciate as correct userland ruby classes' do
|
98
|
+
|
99
|
+
subject.load_hash( '@hash', @state_file )
|
100
|
+
hash = subject.instance_variable_get( :@hash )
|
101
|
+
|
102
|
+
hash[:class_instance].should be_a( TestSerialization )
|
103
|
+
hash[:class_instance].data.should == 'VALUE'
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'from file and not overrwrite other variables in the hash' do
|
108
|
+
|
109
|
+
subject.load_hash( '@hash', @state_file )
|
110
|
+
hash = subject.instance_variable_get( :@hash )
|
111
|
+
|
112
|
+
hash['tree']['type'][:thing1].should == 1
|
113
|
+
hash['thing2'].should == 2
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'langrove/ext'
|
2
|
+
describe String do
|
3
|
+
|
4
|
+
it 'has been extended to camelize' do
|
5
|
+
|
6
|
+
"this_is_a_class_file_name".camelize.should == "ThisIsAClassFileName"
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'has been extended to underscore' do
|
11
|
+
|
12
|
+
"ThisIsAClassName".underscore.should == "this_is_a_class_name"
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'langrove'
|
2
|
+
|
3
|
+
describe LanGrove::Handler::Base do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
|
7
|
+
@logger = LanGrove::FakeLogger.new :silent
|
8
|
+
|
9
|
+
@daemon_name = 'test_daemon'
|
10
|
+
|
11
|
+
@config = {
|
12
|
+
|
13
|
+
:daemons => {
|
14
|
+
|
15
|
+
@daemon_name => {
|
16
|
+
|
17
|
+
:handler => {
|
18
|
+
|
19
|
+
:collection => 'Base'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
subject do
|
28
|
+
|
29
|
+
LanGrove::Handler::Base.new( @config, @daemon_name, @logger )
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'maintains a connected client collection with' do
|
34
|
+
|
35
|
+
it 'in a hash' do
|
36
|
+
|
37
|
+
clients = subject.instance_variable_get( :@clients )
|
38
|
+
|
39
|
+
clients.should be_a( Hash )
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'connect()' do
|
44
|
+
|
45
|
+
it 'using a key defined by the client' do
|
46
|
+
|
47
|
+
client = double( 'Client' )
|
48
|
+
client.should_receive( :respond_to? ).with( :unique_key ).and_return( true )
|
49
|
+
client.should_receive( :unique_key ).and_return('KEY1')
|
50
|
+
|
51
|
+
subject.connect( client )
|
52
|
+
|
53
|
+
clients = subject.instance_variable_get( :@clients )
|
54
|
+
|
55
|
+
clients['KEY1'].should == client
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'using the client itself as the key if unique is not defined' do
|
60
|
+
|
61
|
+
client = double( 'Client' )
|
62
|
+
client.should_receive( :respond_to? ).with( :unique_key ).and_return( false )
|
63
|
+
|
64
|
+
subject.connect( client )
|
65
|
+
|
66
|
+
clients = subject.instance_variable_get( :@clients )
|
67
|
+
|
68
|
+
clients[ client ].should == 1
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'disconnect()' do
|
75
|
+
|
76
|
+
it 'to remove the client from the collection'
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'call the periodic ticker to all attached clients' do
|
81
|
+
|
82
|
+
client1 = Object.const_set( 'Client', Class.new() do
|
83
|
+
|
84
|
+
self.class_eval { attr_accessor :unique }
|
85
|
+
|
86
|
+
end).new
|
87
|
+
client1.unique = 'kEy'
|
88
|
+
|
89
|
+
client2 = Object.new
|
90
|
+
|
91
|
+
client1.should_receive( :periodic )
|
92
|
+
client2.should_receive( :periodic )
|
93
|
+
|
94
|
+
subject.connect( client1 )
|
95
|
+
subject.connect( client2 )
|
96
|
+
|
97
|
+
subject.periodic
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'langrove'
|
2
|
+
|
3
|
+
describe LanGrove::Job::Base do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
|
7
|
+
@logger = LanGrove::FakeLogger.new
|
8
|
+
|
9
|
+
@queue_name = :snooker_queue
|
10
|
+
|
11
|
+
@config = {}
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'initializes' do
|
16
|
+
|
17
|
+
test = LanGrove::Job::Base.new( @config, @queue_name, @logger )
|
18
|
+
test.should be_a( LanGrove::Job::Base )
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has methods' do
|
23
|
+
|
24
|
+
LanGrove::Job::Base.new( @config, @queue_name, @logger ).undefined_method( "TEST" )
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'langrove/protocol/syslog'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
describe LanGrove::Protocol::Syslog.new do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
|
8
|
+
@message1 = "<00>Apr 4 11:00:06 host program[321]: Message with: 1"
|
9
|
+
@message2 = "<00>Jun 25 16:15:15 host.name.co.za tag[3241]: Message with: 2"
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
pending 'it decodes the loglevel'
|
14
|
+
|
15
|
+
pending 'it supports tagless and pidless'
|
16
|
+
|
17
|
+
it 'decodes a timestamp' do
|
18
|
+
|
19
|
+
subject.decode( @message1 )[:timestamp].should == DateTime.parse( 'Apr 4 11:00:06' )
|
20
|
+
subject.decode( @message2 )[:timestamp].should == DateTime.parse( 'Jun 25 16:15:15' )
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'decodes a hostname corrected for prepended vlanN' do
|
25
|
+
|
26
|
+
subject.decode( @message1 )[:hostname].should == 'host'
|
27
|
+
subject.decode( @message2 )[:hostname].should == 'host.name.co.za'
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'decodes the log tag' do
|
32
|
+
|
33
|
+
subject.decode( @message1 )[:tag].should == 'program[321]'
|
34
|
+
subject.decode( @message2 )[:tag].should == 'tag[3241]'
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'decodes the log event' do
|
39
|
+
|
40
|
+
subject.decode( @message1 )[:event].should == 'Message with: 1'
|
41
|
+
subject.decode( @message2 )[:event].should == 'Message with: 2'
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/spec/todo_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
describe 'Outstanding:' do
|
2
|
+
|
3
|
+
pending 'Symbolize the config keys'
|
4
|
+
pending 'make a langrove --create for developers to recursively copy ./functional from the gem install dir as a base for getting the framework up and running'
|
5
|
+
pending 'cut and publish'
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
pending 'rdoc'
|
11
|
+
|
12
|
+
end
|
data/tmp/README
ADDED