nfagent 0.9.30 → 0.9.31
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/{sandbox/dumps/debug → .gemtest} +0 -0
- data/History.txt +1 -1
- data/Manifest.txt +14 -32
- data/PostInstall.txt +0 -6
- data/{README.rdoc → README.txt} +15 -7
- data/Rakefile +21 -18
- data/bin/squid_log_writer +0 -2
- data/lib/nfagent.rb +1 -6
- data/lib/nfagent/chunk.rb +16 -30
- data/lib/nfagent/chunk_handler.rb +23 -55
- data/lib/nfagent/cli.rb +2 -2
- data/lib/nfagent/client.rb +2 -5
- data/lib/nfagent/config.rb +0 -33
- data/lib/nfagent/event.rb +1 -1
- data/lib/nfagent/payload.rb +7 -11
- data/lib/nfagent/server.rb +0 -5
- data/lib/nfagent/submitter.rb +0 -1
- data/nfagent.conf +4 -4
- metadata +102 -131
- data/lib/nfagent/mapper_proxy.rb +0 -18
- data/lib/nfagent/object_extra.rb +0 -5
- data/lib/nfagent/plugin.rb +0 -14
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/test/config +0 -5
- data/test/plugins/my_mapper.rb +0 -18
- data/test/test_chunk.rb +0 -79
- data/test/test_chunk_handler.rb +0 -131
- data/test/test_client.rb +0 -20
- data/test/test_config.rb +0 -49
- data/test/test_helper.rb +0 -6
- data/test/test_mapper_proxy.rb +0 -20
- data/test/test_nfagent.rb +0 -8
- data/test/test_payload.rb +0 -77
- data/test/test_plugin.rb +0 -13
data/test/config
DELETED
data/test/plugins/my_mapper.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
class MyMapper
|
|
2
|
-
def initialize
|
|
3
|
-
@hash = {
|
|
4
|
-
'dan' => 'acme',
|
|
5
|
-
'paul' => 'jetson',
|
|
6
|
-
'mike' => 'acme'
|
|
7
|
-
}
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def before_shutdown
|
|
11
|
-
# Put any cleanup code in here
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def find_account_id(username, client_ip)
|
|
15
|
-
raise NFAgent::IgnoreLine if username == 'andrew'
|
|
16
|
-
@hash[username]
|
|
17
|
-
end
|
|
18
|
-
end
|
data/test/test_chunk.rb
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require 'test/test_helper'
|
|
3
|
-
|
|
4
|
-
class TestChunk < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
NFAgent::Config.config_file = "test/config"
|
|
7
|
-
NFAgent::Config.init
|
|
8
|
-
@logline = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico - NONE/- text/html"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
test "initialize" do
|
|
12
|
-
chunk = NFAgent::Chunk.new
|
|
13
|
-
assert_equal 500, chunk.max_size
|
|
14
|
-
chunk = NFAgent::Chunk.new(600)
|
|
15
|
-
assert_equal 600, chunk.max_size
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
test "full" do
|
|
19
|
-
chunk = NFAgent::Chunk.new(20)
|
|
20
|
-
19.times do
|
|
21
|
-
chunk << @logline
|
|
22
|
-
end
|
|
23
|
-
assert !chunk.full?
|
|
24
|
-
chunk << @logline
|
|
25
|
-
assert chunk.full?
|
|
26
|
-
assert_raises(NFAgent::ChunkFull) { chunk << @logline }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
test "won't expire if empty" do
|
|
30
|
-
NFAgent::Config.chunk_time_out = 1
|
|
31
|
-
chunk = NFAgent::Chunk.new
|
|
32
|
-
assert !chunk.expired?
|
|
33
|
-
Timecop.freeze(Time.now + 61) do
|
|
34
|
-
assert !chunk.expired?
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
test "expired" do
|
|
39
|
-
chunk = NFAgent::Chunk.new
|
|
40
|
-
chunk << @logline
|
|
41
|
-
assert !chunk.expired?
|
|
42
|
-
Timecop.freeze(Time.now + 61) do
|
|
43
|
-
assert chunk.expired?
|
|
44
|
-
assert_raises(NFAgent::ChunkExpired) { chunk << @logline }
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
test "day boundary" do
|
|
49
|
-
d = Date.today
|
|
50
|
-
Timecop.travel(Time.local(2011, 1, 10, 23, 59, 58)) do
|
|
51
|
-
chunk = NFAgent::Chunk.new
|
|
52
|
-
Timecop.travel(Time.local(2011, 1, 11, 0, 0, 10)) do
|
|
53
|
-
assert_raises(NFAgent::DayBoundary) { chunk << @logline }
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
test "submit" do
|
|
59
|
-
EM.expects(:defer)
|
|
60
|
-
chunk = NFAgent::Chunk.new
|
|
61
|
-
chunk.submit
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
test "dump" do
|
|
65
|
-
Zlib::Deflate.expects(:deflate).returns("x\234\313\316*/\314HO-\312N\317(J\005\000&~\005u").times(2)
|
|
66
|
-
chunk = NFAgent::Chunk.new
|
|
67
|
-
chunk << @logline
|
|
68
|
-
payload = chunk.dump
|
|
69
|
-
assert_equal 1, payload.line_count
|
|
70
|
-
assert_instance_of String, payload.data
|
|
71
|
-
# Dump with key
|
|
72
|
-
payload = chunk.dump('acme')
|
|
73
|
-
assert_equal 'acme', payload.key
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
test "dump from LogLine" do
|
|
77
|
-
flunk
|
|
78
|
-
end
|
|
79
|
-
end
|
data/test/test_chunk_handler.rb
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require 'test/test_helper'
|
|
3
|
-
|
|
4
|
-
class TestChunkHandler < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
NFAgent::Config.config_file = "test/config"
|
|
7
|
-
NFAgent::Config.init
|
|
8
|
-
NFAgent::Config.plugin_directory = File.dirname(__FILE__) + '/../test/plugins/'
|
|
9
|
-
NFAgent::Plugin.load_plugins
|
|
10
|
-
@logline = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico dan NONE/- text/html"
|
|
11
|
-
@logline2 = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico paul NONE/- text/html"
|
|
12
|
-
@ignored_logline = "1253604221 19 127.0.0.1 TCP_MISS/200 562 GET http://www.gravatar.com/blavatar/e81cfb9068d04d1cfd598533bb380e1f?s=16&d=http://s.wordpress.com/favicon.ico andrew NONE/- text/html"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
test "append line" do
|
|
16
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
17
|
-
chunk_handler.append(@logline)
|
|
18
|
-
assert_equal 1, chunk_handler.chunk_group['all'].size
|
|
19
|
-
assert_instance_of String, chunk_handler.chunk_group['all'][-1]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
test "append with local parsing" do
|
|
23
|
-
NFAgent::Config.parse = 'locally'
|
|
24
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
25
|
-
chunk_handler.append(@logline)
|
|
26
|
-
assert_equal 1, chunk_handler.chunk_group['all'].size
|
|
27
|
-
assert_instance_of Squiggle::LogLine, chunk_handler.chunk_group['all'][-1]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
test "append with multi" do
|
|
31
|
-
NFAgent::Config.parse = 'locally'
|
|
32
|
-
NFAgent::Config.mode = 'multi'
|
|
33
|
-
NFAgent::Config.mapper = 'MyMapper'
|
|
34
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
35
|
-
chunk_handler.append(@logline)
|
|
36
|
-
assert chunk_handler.chunk_group.has_key?('acme')
|
|
37
|
-
assert_equal 1, chunk_handler.chunk_group['acme'].size
|
|
38
|
-
chunk_handler.append(@logline2)
|
|
39
|
-
assert chunk_handler.chunk_group.has_key?('acme')
|
|
40
|
-
assert chunk_handler.chunk_group.has_key?('jetson')
|
|
41
|
-
assert_equal 1, chunk_handler.chunk_group['acme'].size
|
|
42
|
-
assert_equal 1, chunk_handler.chunk_group['jetson'].size
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test "mapper raises ignore line in multi mode" do
|
|
46
|
-
NFAgent::Config.parse = 'locally'
|
|
47
|
-
NFAgent::Config.mode = 'multi'
|
|
48
|
-
NFAgent::Config.mapper = 'MyMapper'
|
|
49
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
50
|
-
chunk_handler.append(@ignored_logline)
|
|
51
|
-
assert !chunk_handler.chunk_group.has_key?('acme')
|
|
52
|
-
assert !chunk_handler.chunk_group.has_key?('jetson')
|
|
53
|
-
assert chunk_handler.chunk_group['acme'].blank?
|
|
54
|
-
assert chunk_handler.chunk_group['jetson'].blank?
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
test "reset chunk after expiry in multi mode" do
|
|
58
|
-
NFAgent::Config.parse = 'locally'
|
|
59
|
-
NFAgent::Config.mode = 'multi'
|
|
60
|
-
NFAgent::Config.mapper = 'MyMapper'
|
|
61
|
-
NFAgent::Chunk.any_instance.expects(:submit).at_least_once
|
|
62
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
63
|
-
chunk_handler.append(@logline)
|
|
64
|
-
Timecop.travel(30) do
|
|
65
|
-
chunk_handler.append(@logline2)
|
|
66
|
-
assert_equal 1, chunk_handler.chunk_group['acme'].size
|
|
67
|
-
assert_equal 1, chunk_handler.chunk_group['jetson'].size
|
|
68
|
-
|
|
69
|
-
Timecop.travel(31) do
|
|
70
|
-
chunk_handler.check_full_or_expired
|
|
71
|
-
assert !chunk_handler.chunk_group.has_key?('acme')
|
|
72
|
-
assert_equal 1, chunk_handler.chunk_group['jetson'].size
|
|
73
|
-
|
|
74
|
-
Timecop.travel(31) do
|
|
75
|
-
chunk_handler.check_full_or_expired
|
|
76
|
-
assert !chunk_handler.chunk_group.has_key?('acme')
|
|
77
|
-
assert !chunk_handler.chunk_group.has_key?('jestson')
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
test "reset chunk after full with check_full_or_expired in multi mode" do
|
|
84
|
-
NFAgent::Config.parse = 'locally'
|
|
85
|
-
NFAgent::Config.mode = 'multi'
|
|
86
|
-
NFAgent::Config.mapper = 'MyMapper'
|
|
87
|
-
EM.expects(:defer).times(2)
|
|
88
|
-
chunk_handler = NFAgent::ChunkHandler.new(:chunk_size => 10)
|
|
89
|
-
9.times { chunk_handler.append(@logline) }
|
|
90
|
-
9.times { chunk_handler.append(@logline2) }
|
|
91
|
-
assert_equal 9, chunk_handler.chunk_group['acme'].size
|
|
92
|
-
assert_equal 9, chunk_handler.chunk_group['jetson'].size
|
|
93
|
-
chunk_handler.append(@logline)
|
|
94
|
-
chunk_handler.check_full_or_expired
|
|
95
|
-
assert !chunk_handler.chunk_group.has_key?('acme')
|
|
96
|
-
chunk_handler.append(@logline2)
|
|
97
|
-
chunk_handler.check_full_or_expired
|
|
98
|
-
assert !chunk_handler.chunk_group.has_key?('jetson')
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
test "fail an invalid logline in local parse mode" do
|
|
102
|
-
NFAgent::Config.parse = 'locally'
|
|
103
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
104
|
-
chunk_handler.append("") # Invalid logline
|
|
105
|
-
assert chunk_handler.chunk_group['all'].nil?
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
test "reset chunk is passed appropriate key in multi mode" do
|
|
109
|
-
NFAgent::Config.parse = 'locally'
|
|
110
|
-
NFAgent::Config.mode = 'multi'
|
|
111
|
-
NFAgent::Config.mapper = 'MyMapper'
|
|
112
|
-
NFAgent::Chunk.any_instance.expects(:submit).with('acme')
|
|
113
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
114
|
-
chunk_handler.append(@logline)
|
|
115
|
-
Timecop.travel(61) do
|
|
116
|
-
chunk_handler.check_full_or_expired
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
test "reset chunk is passed nil key in normal mode" do
|
|
121
|
-
NFAgent::Config.parse = 'remotely'
|
|
122
|
-
NFAgent::Config.mode = 'normal'
|
|
123
|
-
NFAgent::Chunk.any_instance.expects(:submit).with(nil)
|
|
124
|
-
chunk_handler = NFAgent::ChunkHandler.new
|
|
125
|
-
chunk_handler.append(@logline)
|
|
126
|
-
Timecop.travel(61) do
|
|
127
|
-
chunk_handler.check_full_or_expired
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
end
|
data/test/test_client.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require 'test/test_helper'
|
|
3
|
-
|
|
4
|
-
class TestClient < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
test "post data with configured client key" do
|
|
9
|
-
Net::HTTP::Post.any_instance.expects(:set_form_data).with({ 'payload' => 'data', 'checksum' => 'checksum', 'line_count' => 10, 'chunk_expired' => false, 'key' => '1234' })
|
|
10
|
-
hash = { 'payload' => 'data', 'checksum' => 'checksum', 'line_count' => 10, 'chunk_expired' => false }
|
|
11
|
-
NFAgent::Client.post(:collector, hash)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
test "post data with key passed in data hash" do
|
|
15
|
-
Net::HTTP::Post.any_instance.expects(:set_form_data).with({ 'payload' => 'data', 'checksum' => 'checksum', 'line_count' => 10, 'chunk_expired' => false, 'key' => 'abcd' })
|
|
16
|
-
hash = { 'payload' => 'data', 'checksum' => 'checksum', 'line_count' => 10, 'chunk_expired' => false, 'key' => 'abcd' }
|
|
17
|
-
NFAgent::Client.post(:collector, hash)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
data/test/test_config.rb
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require 'test/test_helper'
|
|
3
|
-
|
|
4
|
-
class TestConfig < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
NFAgent::Config.attrs.clear
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
test "defaults" do
|
|
10
|
-
puts "HHHHHH"
|
|
11
|
-
p NFAgent::Config.attrs
|
|
12
|
-
assert_equal "normal", NFAgent::Config.mode
|
|
13
|
-
assert_equal "remotely", NFAgent::Config.parse
|
|
14
|
-
assert_equal 60, NFAgent::Config.chunk_timeout
|
|
15
|
-
assert_equal 'UTC', NFAgent::Config.time_zone
|
|
16
|
-
assert_equal '/etc/nfagent/plugins/', NFAgent::Config.plugin_directory
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
test "validates valid mode" do
|
|
20
|
-
NFAgent::Config.mode = 'some stupid thing'
|
|
21
|
-
assert_raises(RuntimeError) { NFAgent::Config.validate }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
test "validates mapping with multi" do
|
|
25
|
-
NFAgent::Config.attrs.clear
|
|
26
|
-
NFAgent::Config.config_file = "test/config"
|
|
27
|
-
NFAgent::Config.init
|
|
28
|
-
|
|
29
|
-
NFAgent::Config.mode = 'multi'
|
|
30
|
-
assert_raises(RuntimeError) { NFAgent::Config.validate }
|
|
31
|
-
NFAgent::Config.mapper = 'AccountMapper'
|
|
32
|
-
assert_raises(RuntimeError) { NFAgent::Config.validate }
|
|
33
|
-
NFAgent::Config.parse = 'locally'
|
|
34
|
-
assert NFAgent::Config.validate
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
test "validates valid parse option" do
|
|
38
|
-
NFAgent::Config.attrs.clear
|
|
39
|
-
NFAgent::Config.config_file = "test/config"
|
|
40
|
-
NFAgent::Config.init
|
|
41
|
-
|
|
42
|
-
NFAgent::Config.parse = 'some stupid thing'
|
|
43
|
-
assert_raises(RuntimeError) { NFAgent::Config.validate }
|
|
44
|
-
NFAgent::Config.parse = 'locally'
|
|
45
|
-
assert NFAgent::Config.validate
|
|
46
|
-
NFAgent::Config.parse = 'remotely'
|
|
47
|
-
assert NFAgent::Config.validate
|
|
48
|
-
end
|
|
49
|
-
end
|
data/test/test_helper.rb
DELETED
data/test/test_mapper_proxy.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require 'test/test_helper'
|
|
3
|
-
|
|
4
|
-
class TestMapperProxy < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
NFAgent::Config.plugin_directory = File.dirname(__FILE__) + '/../test/plugins/'
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
test "instantiate just once" do
|
|
10
|
-
MyMapper.expects(:new).at_most_once
|
|
11
|
-
NFAgent::Config.mapper = nil
|
|
12
|
-
NFAgent::MapperProxy.instance
|
|
13
|
-
NFAgent::MapperProxy.instance
|
|
14
|
-
NFAgent::MapperProxy.instance
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
test "mapper method" do
|
|
18
|
-
assert_equal 'acme', NFAgent::MapperProxy.find_account_id('dan', '192.168.0.10')
|
|
19
|
-
end
|
|
20
|
-
end
|
data/test/test_nfagent.rb
DELETED
data/test/test_payload.rb
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require 'test/test_helper'
|
|
3
|
-
|
|
4
|
-
class TestPayload < ActiveSupport::TestCase
|
|
5
|
-
setup do
|
|
6
|
-
FileUtils.rm_f(Dir.glob("test/sandbox/dumps/*"))
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
test "to_hash" do
|
|
10
|
-
payload = NFAgent::Payload.new do |p|
|
|
11
|
-
p.data = "data"
|
|
12
|
-
p.checksum = "checksum"
|
|
13
|
-
p.line_count = 10
|
|
14
|
-
p.chunk_expired = false
|
|
15
|
-
end
|
|
16
|
-
assert_equal({ 'payload' => 'data', 'checksum' => 'checksum', 'line_count' => 10, 'chunk_expired' => false }, payload.to_hash)
|
|
17
|
-
# Check key
|
|
18
|
-
payload = NFAgent::Payload.new do |p|
|
|
19
|
-
p.data = "data"
|
|
20
|
-
p.checksum = "checksum"
|
|
21
|
-
p.line_count = 10
|
|
22
|
-
p.chunk_expired = false
|
|
23
|
-
p.key = '1234'
|
|
24
|
-
end
|
|
25
|
-
assert_equal({ 'payload' => 'data', 'checksum' => 'checksum', 'line_count' => 10, 'chunk_expired' => false, 'key' => '1234' }, payload.to_hash)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
test "write-to-disk" do
|
|
29
|
-
payload = NFAgent::Payload.new do |p|
|
|
30
|
-
p.data = "data"
|
|
31
|
-
p.checksum = "checksum"
|
|
32
|
-
p.line_count = 10
|
|
33
|
-
p.chunk_expired = false
|
|
34
|
-
end
|
|
35
|
-
payload.write_to_disk("test/sandbox/dumps")
|
|
36
|
-
assert File.exists?("test/sandbox/dumps/checksum-0")
|
|
37
|
-
# And read back in
|
|
38
|
-
payload = NFAgent::Payload.read_from_file("checksum-0", "test/sandbox/dumps/")
|
|
39
|
-
assert_equal "data", payload.data
|
|
40
|
-
assert_equal 0, payload.attempt
|
|
41
|
-
assert !payload.key
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
test "write-to-disk with non-zero attempt number" do
|
|
45
|
-
payload = NFAgent::Payload.new do |p|
|
|
46
|
-
p.data = "data"
|
|
47
|
-
p.checksum = "checksum"
|
|
48
|
-
p.line_count = 10
|
|
49
|
-
p.chunk_expired = false
|
|
50
|
-
p.attempt = 10
|
|
51
|
-
end
|
|
52
|
-
payload.write_to_disk("test/sandbox/dumps")
|
|
53
|
-
assert File.exists?("test/sandbox/dumps/checksum-10")
|
|
54
|
-
# And read back in
|
|
55
|
-
payload = NFAgent::Payload.read_from_file("checksum-10", "test/sandbox/dumps/")
|
|
56
|
-
assert_equal "data", payload.data
|
|
57
|
-
assert_equal 10, payload.attempt
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
test "write-to-disk with key" do
|
|
61
|
-
payload = NFAgent::Payload.new do |p|
|
|
62
|
-
p.data = "data"
|
|
63
|
-
p.checksum = "checksum"
|
|
64
|
-
p.line_count = 10
|
|
65
|
-
p.chunk_expired = false
|
|
66
|
-
p.key = '1234'
|
|
67
|
-
end
|
|
68
|
-
payload.write_to_disk("test/sandbox/dumps")
|
|
69
|
-
assert File.exists?("test/sandbox/dumps/checksum-0-1234")
|
|
70
|
-
# And read back in
|
|
71
|
-
payload = NFAgent::Payload.read_from_file("checksum-0-1234", "test/sandbox/dumps/")
|
|
72
|
-
assert_equal "data", payload.data
|
|
73
|
-
assert_equal 0, payload.attempt
|
|
74
|
-
assert_equal '1234', payload.key
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
end
|
data/test/test_plugin.rb
DELETED