fluentd 1.12.1-x86-mingw32 → 1.13.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.deepsource.toml +13 -0
- data/.github/ISSUE_TEMPLATE/config.yml +2 -2
- data/.github/workflows/linux-test.yaml +36 -0
- data/.github/workflows/{build.yaml → macos-test.yaml} +8 -7
- data/.github/workflows/windows-test.yaml +46 -0
- data/.gitlab-ci.yml +19 -19
- data/CHANGELOG.md +163 -0
- data/CONTRIBUTING.md +2 -2
- data/MAINTAINERS.md +5 -2
- data/README.md +6 -3
- data/example/counter.conf +1 -1
- data/fluentd.gemspec +4 -2
- data/lib/fluent/command/bundler_injection.rb +1 -1
- data/lib/fluent/command/cat.rb +19 -4
- data/lib/fluent/command/fluentd.rb +1 -2
- data/lib/fluent/command/plugin_config_formatter.rb +2 -1
- data/lib/fluent/command/plugin_generator.rb +31 -1
- data/lib/fluent/compat/parser.rb +2 -2
- data/lib/fluent/config/section.rb +6 -1
- data/lib/fluent/config/types.rb +2 -2
- data/lib/fluent/event.rb +3 -13
- data/lib/fluent/load.rb +0 -1
- data/lib/fluent/log.rb +1 -0
- data/lib/fluent/plugin/file_wrapper.rb +49 -4
- data/lib/fluent/plugin/formatter_ltsv.rb +2 -2
- data/lib/fluent/plugin/in_http.rb +11 -1
- data/lib/fluent/plugin/in_monitor_agent.rb +1 -1
- data/lib/fluent/plugin/in_tail.rb +140 -41
- data/lib/fluent/plugin/in_tail/position_file.rb +15 -1
- data/lib/fluent/plugin/out_copy.rb +18 -5
- data/lib/fluent/plugin/out_exec_filter.rb +3 -3
- data/lib/fluent/plugin/out_forward.rb +75 -61
- data/lib/fluent/plugin/output.rb +11 -9
- data/lib/fluent/plugin/parser_csv.rb +2 -2
- data/lib/fluent/plugin/parser_syslog.rb +2 -2
- data/lib/fluent/plugin/service_discovery.rb +0 -15
- data/lib/fluent/plugin/storage_local.rb +4 -4
- data/lib/fluent/plugin_helper/http_server/router.rb +1 -1
- data/lib/fluent/plugin_helper/server.rb +4 -2
- data/lib/fluent/plugin_helper/service_discovery.rb +39 -1
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +11 -5
- data/lib/fluent/plugin_helper/socket_option.rb +2 -2
- data/lib/fluent/supervisor.rb +16 -1
- data/lib/fluent/system_config.rb +14 -0
- data/lib/fluent/time.rb +57 -1
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/fluent-plugin.gemspec.erb +3 -3
- data/test/command/test_cat.rb +99 -0
- data/test/command/test_fluentd.rb +8 -0
- data/test/config/test_configurable.rb +1 -1
- data/test/config/test_section.rb +9 -0
- data/test/config/test_system_config.rb +46 -0
- data/test/plugin/in_tail/test_io_handler.rb +4 -4
- data/test/plugin/in_tail/test_position_file.rb +58 -4
- data/test/plugin/test_file_wrapper.rb +115 -0
- data/test/plugin/test_in_exec.rb +1 -1
- data/test/plugin/test_in_forward.rb +59 -83
- data/test/plugin/test_in_http.rb +58 -40
- data/test/plugin/test_in_syslog.rb +66 -56
- data/test/plugin/test_in_tail.rb +298 -26
- data/test/plugin/test_in_tcp.rb +45 -32
- data/test/plugin/test_in_udp.rb +47 -33
- data/test/plugin/test_out_copy.rb +87 -0
- data/test/plugin/test_out_forward.rb +198 -91
- data/test/plugin/test_out_http.rb +1 -1
- data/test/plugin/test_out_stream.rb +18 -8
- data/test/plugin/test_output.rb +15 -3
- data/test/plugin/test_output_as_buffered_backup.rb +2 -0
- data/test/plugin/test_parser_csv.rb +14 -0
- data/test/plugin/test_parser_syslog.rb +14 -0
- data/test/plugin_helper/http_server/test_route.rb +1 -1
- data/test/plugin_helper/service_discovery/test_manager.rb +1 -1
- data/test/plugin_helper/test_child_process.rb +6 -3
- data/test/plugin_helper/test_http_server_helper.rb +34 -27
- data/test/plugin_helper/test_server.rb +144 -139
- data/test/plugin_helper/test_service_discovery.rb +74 -14
- data/test/plugin_helper/test_socket.rb +16 -9
- data/test/test_config.rb +2 -1
- data/test/test_event.rb +16 -0
- data/test/test_formatter.rb +30 -0
- data/test/test_output.rb +2 -2
- data/test/test_supervisor.rb +35 -0
- data/test/test_time_parser.rb +109 -0
- metadata +55 -11
- data/.travis.yml +0 -77
- data/appveyor.yml +0 -31
data/test/config/test_section.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative '../helper'
|
2
2
|
require 'fluent/config/section'
|
3
|
+
require 'pp'
|
3
4
|
|
4
5
|
module Fluent::Config
|
5
6
|
class TestSection < ::Test::Unit::TestCase
|
@@ -176,6 +177,14 @@ module Fluent::Config
|
|
176
177
|
s1 = Fluent::Config::Section.new(h1)
|
177
178
|
assert_equal(expected, s1.respond_to?(method))
|
178
179
|
end
|
180
|
+
|
181
|
+
test '#pretty_print' do
|
182
|
+
q = PP.new
|
183
|
+
h1 = {name: "s1", klass: "A"}
|
184
|
+
s1 = Fluent::Config::Section.new(h1)
|
185
|
+
s1.pretty_print(q)
|
186
|
+
assert_equal s1.inspect, q.output
|
187
|
+
end
|
179
188
|
end
|
180
189
|
end
|
181
190
|
end
|
@@ -143,5 +143,51 @@ module Fluent::Config
|
|
143
143
|
sc.overwrite_variables(**s.for_system_config)
|
144
144
|
assert_equal(level, sc.log_level)
|
145
145
|
end
|
146
|
+
|
147
|
+
sub_test_case "log rotation" do
|
148
|
+
data('daily' => "daily",
|
149
|
+
'weekly' => 'weekly',
|
150
|
+
'monthly' => 'monthly')
|
151
|
+
test "symbols for rotate_age" do |age|
|
152
|
+
conf = parse_text(<<-EOS)
|
153
|
+
<system>
|
154
|
+
<log>
|
155
|
+
rotate_age #{age}
|
156
|
+
</log>
|
157
|
+
</system>
|
158
|
+
EOS
|
159
|
+
sc = Fluent::SystemConfig.new(conf)
|
160
|
+
assert_equal(age.to_sym, sc.log.rotate_age)
|
161
|
+
end
|
162
|
+
|
163
|
+
test "numeric number for rotate age" do
|
164
|
+
conf = parse_text(<<-EOS)
|
165
|
+
<system>
|
166
|
+
<log>
|
167
|
+
rotate_age 3
|
168
|
+
</log>
|
169
|
+
</system>
|
170
|
+
EOS
|
171
|
+
s = FakeSupervisor.new
|
172
|
+
sc = Fluent::SystemConfig.new(conf)
|
173
|
+
assert_equal(3, sc.log.rotate_age)
|
174
|
+
end
|
175
|
+
|
176
|
+
data(h: ['100', 100],
|
177
|
+
k: ['1k', 1024],
|
178
|
+
m: ['1m', 1024 * 1024],
|
179
|
+
g: ['1g', 1024 * 1024 * 1024])
|
180
|
+
test "numeric and SI prefix for rotate_size" do |(label, size)|
|
181
|
+
conf = parse_text(<<-EOS)
|
182
|
+
<system>
|
183
|
+
<log>
|
184
|
+
rotate_size #{label}
|
185
|
+
</log>
|
186
|
+
</system>
|
187
|
+
EOS
|
188
|
+
sc = Fluent::SystemConfig.new(conf)
|
189
|
+
assert_equal(size, sc.log.rotate_size)
|
190
|
+
end
|
191
|
+
end
|
146
192
|
end
|
147
193
|
end
|
@@ -30,7 +30,7 @@ class IntailIOHandlerTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
returned_lines = ''
|
33
|
-
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 100, log: $log, open_on_every_update: false) do |lines, _watcher|
|
33
|
+
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 100, read_bytes_limit_per_second: -1, log: $log, open_on_every_update: false) do |lines, _watcher|
|
34
34
|
returned_lines << lines.join
|
35
35
|
true
|
36
36
|
end
|
@@ -62,7 +62,7 @@ class IntailIOHandlerTest < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
returned_lines = ''
|
65
|
-
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 100, log: $log, open_on_every_update: true) do |lines, _watcher|
|
65
|
+
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 100, read_bytes_limit_per_second: -1, log: $log, open_on_every_update: true) do |lines, _watcher|
|
66
66
|
returned_lines << lines.join
|
67
67
|
true
|
68
68
|
end
|
@@ -93,7 +93,7 @@ class IntailIOHandlerTest < Test::Unit::TestCase
|
|
93
93
|
end
|
94
94
|
|
95
95
|
returned_lines = []
|
96
|
-
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 5, log: $log, open_on_every_update: false) do |lines, _watcher|
|
96
|
+
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 5, read_bytes_limit_per_second: -1, log: $log, open_on_every_update: false) do |lines, _watcher|
|
97
97
|
returned_lines << lines.dup
|
98
98
|
true
|
99
99
|
end
|
@@ -119,7 +119,7 @@ class IntailIOHandlerTest < Test::Unit::TestCase
|
|
119
119
|
end
|
120
120
|
|
121
121
|
returned_lines = []
|
122
|
-
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 5, log: $log, open_on_every_update: false) do |lines, _watcher|
|
122
|
+
r = Fluent::Plugin::TailInput::TailWatcher::IOHandler.new(watcher, path: @file.path, read_lines_limit: 5, read_bytes_limit_per_second: -1, log: $log, open_on_every_update: false) do |lines, _watcher|
|
123
123
|
returned_lines << lines.dup
|
124
124
|
true
|
125
125
|
end
|
@@ -147,7 +147,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
147
147
|
write_data(@file, TEST_CONTENT)
|
148
148
|
pf = Fluent::Plugin::TailInput::PositionFile.load(@file, false, {}, **{logger: $log})
|
149
149
|
|
150
|
-
valid_target_info = Fluent::Plugin::TailInput::TargetInfo.new('valid_path',
|
150
|
+
valid_target_info = Fluent::Plugin::TailInput::TargetInfo.new('valid_path', File.stat(@file).ino)
|
151
151
|
f = pf[valid_target_info]
|
152
152
|
assert_equal Fluent::Plugin::TailInput::FilePositionEntry, f.class
|
153
153
|
assert_equal 2, f.read_pos
|
@@ -177,7 +177,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
177
177
|
assert_equal 0, f.read_inode
|
178
178
|
assert_equal 0, f.read_pos
|
179
179
|
|
180
|
-
pf[Fluent::Plugin::TailInput::TargetInfo.new('valid_path',
|
180
|
+
pf[Fluent::Plugin::TailInput::TargetInfo.new('valid_path', File.stat(@file).ino)].update(1, 2)
|
181
181
|
|
182
182
|
f = pf[Fluent::Plugin::TailInput::TargetInfo.new('nonexist_path', -1)]
|
183
183
|
assert_equal 0, f.read_inode
|
@@ -193,7 +193,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
193
193
|
test 'deletes entry by path' do
|
194
194
|
write_data(@file, TEST_CONTENT)
|
195
195
|
pf = Fluent::Plugin::TailInput::PositionFile.load(@file, false, {}, logger: $log)
|
196
|
-
inode1 =
|
196
|
+
inode1 = File.stat(@file).ino
|
197
197
|
target_info1 = Fluent::Plugin::TailInput::TargetInfo.new('valid_path', inode1)
|
198
198
|
p1 = pf[target_info1]
|
199
199
|
assert_equal Fluent::Plugin::TailInput::FilePositionEntry, p1.class
|
@@ -201,7 +201,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
201
201
|
pf.unwatch(target_info1)
|
202
202
|
assert_equal p1.read_pos, Fluent::Plugin::TailInput::PositionFile::UNWATCHED_POSITION
|
203
203
|
|
204
|
-
inode2 =
|
204
|
+
inode2 = File.stat(@file).ino
|
205
205
|
target_info2 = Fluent::Plugin::TailInput::TargetInfo.new('valid_path', inode2)
|
206
206
|
p2 = pf[target_info2]
|
207
207
|
assert_equal Fluent::Plugin::TailInput::FilePositionEntry, p2.class
|
@@ -282,4 +282,58 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
282
282
|
assert_equal 2, f.read_inode
|
283
283
|
end
|
284
284
|
end
|
285
|
+
|
286
|
+
sub_test_case "TargetInfo equality rules" do
|
287
|
+
sub_test_case "== operator" do
|
288
|
+
def test_equal
|
289
|
+
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234)
|
290
|
+
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1235)
|
291
|
+
|
292
|
+
assert_equal t1, t2
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_not_equal
|
296
|
+
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234)
|
297
|
+
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test2", 1234)
|
298
|
+
|
299
|
+
assert_not_equal t1, t2
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
sub_test_case "eql? method" do
|
304
|
+
def test_eql?
|
305
|
+
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234)
|
306
|
+
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 5321)
|
307
|
+
|
308
|
+
assert do
|
309
|
+
t1.eql? t2
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def test_not_eql?
|
314
|
+
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test2", 1234)
|
315
|
+
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test3", 1234)
|
316
|
+
|
317
|
+
assert do
|
318
|
+
!t1.eql? t2
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
sub_test_case "hash" do
|
324
|
+
def test_equal
|
325
|
+
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234)
|
326
|
+
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 7321)
|
327
|
+
|
328
|
+
assert_equal t1.hash, t2.hash
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_not_equal
|
332
|
+
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234)
|
333
|
+
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test2", 1234)
|
334
|
+
|
335
|
+
assert_not_equal t1.hash, t2.hash
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
285
339
|
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/plugin/file_wrapper'
|
3
|
+
|
4
|
+
class FileWrapperTest < Test::Unit::TestCase
|
5
|
+
require 'windows/file'
|
6
|
+
require 'windows/error'
|
7
|
+
include Windows::File
|
8
|
+
include Windows::Error
|
9
|
+
|
10
|
+
TMP_DIR = File.dirname(__FILE__) + "/../tmp/file_wrapper#{ENV['TEST_ENV_NUMBER']}"
|
11
|
+
|
12
|
+
def setup
|
13
|
+
FileUtils.mkdir_p(TMP_DIR)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
FileUtils.rm_rf(TMP_DIR)
|
18
|
+
end
|
19
|
+
|
20
|
+
sub_test_case 'Win32Error' do
|
21
|
+
test 'equal' do
|
22
|
+
assert_equal(Fluent::Win32Error.new(ERROR_SHARING_VIOLATION, "message"),
|
23
|
+
Fluent::Win32Error.new(ERROR_SHARING_VIOLATION, "message"))
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'different error code' do
|
27
|
+
assert_not_equal(Fluent::Win32Error.new(ERROR_FILE_NOT_FOUND),
|
28
|
+
Fluent::Win32Error.new(ERROR_SHARING_VIOLATION))
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'different error message' do
|
32
|
+
assert_not_equal(Fluent::Win32Error.new(ERROR_FILE_NOT_FOUND, "message1"),
|
33
|
+
Fluent::Win32Error.new(ERROR_FILE_NOT_FOUND, "message2"))
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'different class' do
|
37
|
+
assert_not_equal(Errno::EPIPE,
|
38
|
+
Fluent::Win32Error.new(ERROR_SHARING_VIOLATION))
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'ERROR_SHARING_VIOLATION message' do
|
42
|
+
assert_equal(Fluent::Win32Error.new(ERROR_SHARING_VIOLATION).message,
|
43
|
+
"Fluent::Win32Error: code: 32, The process cannot access the file because it is being used by another process.")
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'ERROR_SHARING_VIOLATION with a message' do
|
47
|
+
assert_equal(Fluent::Win32Error.new(ERROR_SHARING_VIOLATION, "cannot open the file").message,
|
48
|
+
"Fluent::Win32Error: code: 32, The process cannot access the file because it is being used by another process." +
|
49
|
+
" - cannot open the file")
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'to_s' do
|
53
|
+
assert_equal("Fluent::Win32Error: code: 32, The process cannot access the file because it is being used by another process. - C:\file.txt",
|
54
|
+
Fluent::Win32Error.new(ERROR_SHARING_VIOLATION, "C:\file.txt").to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'inspect' do
|
58
|
+
assert_equal("#<Fluent::Win32Error: code: 32, The process cannot access the file because it is being used by another process. - C:\file.txt>",
|
59
|
+
Fluent::Win32Error.new(ERROR_SHARING_VIOLATION, "C:\file.txt").inspect)
|
60
|
+
end
|
61
|
+
|
62
|
+
data('0' => [false, 0],
|
63
|
+
'9999' => [false, 9999],
|
64
|
+
'10000' => [true, 10000],
|
65
|
+
'10001' => [true, 10001])
|
66
|
+
test 'wsaerr?' do |data|
|
67
|
+
expected, code = data
|
68
|
+
assert_equal(expected, Fluent::Win32Error.new(code).wsaerr?)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
sub_test_case 'WindowsFile exceptions' do
|
73
|
+
test 'nothing raised' do
|
74
|
+
begin
|
75
|
+
path = "#{TMP_DIR}/test_windows_file.txt"
|
76
|
+
file1 = file2 = nil
|
77
|
+
file1 = File.open(path, "wb") do |f|
|
78
|
+
end
|
79
|
+
assert_nothing_raised do
|
80
|
+
file2 = Fluent::WindowsFile.new(path)
|
81
|
+
ensure
|
82
|
+
file2.close
|
83
|
+
end
|
84
|
+
ensure
|
85
|
+
file1.close if file1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
test 'Errno::ENOENT raised' do
|
90
|
+
path = "#{TMP_DIR}/nofile.txt"
|
91
|
+
file = nil
|
92
|
+
assert_raise(Errno::ENOENT) do
|
93
|
+
file = Fluent::WindowsFile.new(path)
|
94
|
+
ensure
|
95
|
+
file.close if file
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
test 'ERROR_SHARING_VIOLATION raised' do
|
100
|
+
begin
|
101
|
+
path = "#{TMP_DIR}/test_windows_file.txt"
|
102
|
+
file1 = file2 = nil
|
103
|
+
file1 = File.open(path, "wb")
|
104
|
+
win32err = Fluent::Win32Error.new(ERROR_SHARING_VIOLATION, path)
|
105
|
+
assert_raise(Errno::EACCES.new(win32err.message)) do
|
106
|
+
file2 = Fluent::WindowsFile.new(path, 'r', FILE_SHARE_READ)
|
107
|
+
ensure
|
108
|
+
file2.close if file2
|
109
|
+
end
|
110
|
+
ensure
|
111
|
+
file1.close if file1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end if Fluent.windows?
|
data/test/plugin/test_in_exec.rb
CHANGED
@@ -18,52 +18,55 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
18
18
|
Fluent::Test.setup
|
19
19
|
@responses = [] # for testing responses after sending data
|
20
20
|
@d = nil
|
21
|
+
@port = unused_port
|
21
22
|
end
|
22
23
|
|
23
24
|
def teardown
|
24
25
|
@d.instance_shutdown if @d
|
26
|
+
@port = nil
|
25
27
|
end
|
26
28
|
|
27
|
-
PORT = unused_port
|
28
|
-
|
29
29
|
SHARED_KEY = 'foobar1'
|
30
30
|
USER_NAME = 'tagomoris'
|
31
31
|
USER_PASSWORD = 'fluentd'
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def base_config
|
34
|
+
%[
|
35
|
+
port #{@port}
|
36
|
+
bind 127.0.0.1
|
37
|
+
]
|
38
|
+
end
|
37
39
|
LOCALHOST_HOSTNAME_GETTER = ->(){sock = UDPSocket.new(::Socket::AF_INET); sock.do_not_reverse_lookup = false; sock.connect("127.0.0.1", 2048); sock.peeraddr[2] }
|
38
40
|
LOCALHOST_HOSTNAME = LOCALHOST_HOSTNAME_GETTER.call
|
39
41
|
DUMMY_SOCK = Struct.new(:remote_host, :remote_addr, :remote_port).new(LOCALHOST_HOSTNAME, "127.0.0.1", 0)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
42
|
+
|
43
|
+
def config_auth
|
44
|
+
base_config + %[
|
45
|
+
<security>
|
46
|
+
self_hostname localhost
|
47
|
+
shared_key foobar1
|
48
|
+
user_auth true
|
49
|
+
<user>
|
50
|
+
username #{USER_NAME}
|
51
|
+
password #{USER_PASSWORD}
|
52
|
+
</user>
|
53
|
+
<client>
|
54
|
+
network 127.0.0.0/8
|
55
|
+
shared_key #{SHARED_KEY}
|
56
|
+
users ["#{USER_NAME}"]
|
57
|
+
</client>
|
58
|
+
</security>
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_driver(conf=base_config)
|
60
63
|
Fluent::Test::Driver::Input.new(Fluent::Plugin::ForwardInput).configure(conf)
|
61
64
|
end
|
62
65
|
|
63
66
|
sub_test_case '#configure' do
|
64
67
|
test 'simple' do
|
65
68
|
@d = d = create_driver
|
66
|
-
assert_equal
|
69
|
+
assert_equal @port, d.instance.port
|
67
70
|
assert_equal '127.0.0.1', d.instance.bind
|
68
71
|
assert_equal 0, d.instance.linger_timeout
|
69
72
|
assert_equal 0.5, d.instance.blocking_timeout
|
@@ -71,8 +74,8 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
71
74
|
end
|
72
75
|
|
73
76
|
test 'auth' do
|
74
|
-
@d = d = create_driver(
|
75
|
-
assert_equal
|
77
|
+
@d = d = create_driver(config_auth)
|
78
|
+
assert_equal @port, d.instance.port
|
76
79
|
assert_equal '127.0.0.1', d.instance.bind
|
77
80
|
assert_equal 0, d.instance.linger_timeout
|
78
81
|
assert !d.instance.backlog
|
@@ -86,17 +89,17 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
86
89
|
add_tag_prefix: "add_tag_prefix")
|
87
90
|
test 'tag parameters' do |data|
|
88
91
|
assert_raise(Fluent::ConfigError.new("'#{data}' parameter must not be empty")) {
|
89
|
-
create_driver(
|
92
|
+
create_driver(base_config + "#{data} ''")
|
90
93
|
}
|
91
94
|
end
|
92
95
|
|
93
96
|
test 'send_keepalive_packet is disabled by default' do
|
94
|
-
@d = d = create_driver(
|
97
|
+
@d = d = create_driver(config_auth)
|
95
98
|
assert_false d.instance.send_keepalive_packet
|
96
99
|
end
|
97
100
|
|
98
101
|
test 'send_keepalive_packet can be enabled' do
|
99
|
-
@d = d = create_driver(
|
102
|
+
@d = d = create_driver(config_auth + %[
|
100
103
|
send_keepalive_packet true
|
101
104
|
])
|
102
105
|
assert_true d.instance.send_keepalive_packet
|
@@ -104,7 +107,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
104
107
|
|
105
108
|
test 'both send_keepalive_packet and deny_keepalive cannot be enabled' do
|
106
109
|
assert_raise(Fluent::ConfigError.new("both 'send_keepalive_packet' and 'deny_keepalive' cannot be set to true")) do
|
107
|
-
create_driver(
|
110
|
+
create_driver(config_auth + %[
|
108
111
|
send_keepalive_packet true
|
109
112
|
deny_keepalive true
|
110
113
|
])
|
@@ -173,7 +176,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
173
176
|
end
|
174
177
|
|
175
178
|
test 'skip_invalid_event' do
|
176
|
-
@d = d = create_driver(
|
179
|
+
@d = d = create_driver(base_config + "skip_invalid_event true")
|
177
180
|
|
178
181
|
time = event_time("2011-01-02 13:14:15 UTC")
|
179
182
|
|
@@ -243,20 +246,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
243
246
|
|
244
247
|
sub_test_case 'forward' do
|
245
248
|
data(tcp: {
|
246
|
-
config: CONFIG,
|
247
249
|
options: {
|
248
250
|
auth: false
|
249
251
|
}
|
250
252
|
},
|
251
253
|
auth: {
|
252
|
-
config: CONFIG_AUTH,
|
253
254
|
options: {
|
254
255
|
auth: true
|
255
256
|
}
|
256
257
|
})
|
257
258
|
test 'plain' do |data|
|
258
|
-
config = data[:config]
|
259
259
|
options = data[:options]
|
260
|
+
config = options[:auth] ? config_auth : base_config
|
260
261
|
@d = d = create_driver(config)
|
261
262
|
|
262
263
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -285,7 +286,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
285
286
|
result: "new_prefix.tag1"
|
286
287
|
})
|
287
288
|
test 'tag parameters' do |data|
|
288
|
-
@d = create_driver(
|
289
|
+
@d = create_driver(base_config + data[:param])
|
289
290
|
time = event_time("2011-01-02 13:14:15 UTC")
|
290
291
|
options = {auth: false}
|
291
292
|
|
@@ -305,20 +306,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
305
306
|
end
|
306
307
|
|
307
308
|
data(tcp: {
|
308
|
-
config: CONFIG,
|
309
309
|
options: {
|
310
310
|
auth: false
|
311
311
|
}
|
312
312
|
},
|
313
313
|
auth: {
|
314
|
-
config: CONFIG_AUTH,
|
315
314
|
options: {
|
316
315
|
auth: true
|
317
316
|
}
|
318
317
|
})
|
319
318
|
test 'time_as_integer' do |data|
|
320
|
-
config = data[:config]
|
321
319
|
options = data[:options]
|
320
|
+
config = options[:auth] ? config_auth : base_config
|
322
321
|
@d = d = create_driver(config)
|
323
322
|
|
324
323
|
time_i = event_time("2011-01-02 13:14:15 UTC")
|
@@ -340,20 +339,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
340
339
|
end
|
341
340
|
|
342
341
|
data(tcp: {
|
343
|
-
config: CONFIG,
|
344
342
|
options: {
|
345
343
|
auth: false
|
346
344
|
}
|
347
345
|
},
|
348
346
|
auth: {
|
349
|
-
config: CONFIG_AUTH,
|
350
347
|
options: {
|
351
348
|
auth: true
|
352
349
|
}
|
353
350
|
})
|
354
351
|
test 'skip_invalid_event' do |data|
|
355
|
-
config = data[:config]
|
356
352
|
options = data[:options]
|
353
|
+
config = options[:auth] ? config_auth : base_config
|
357
354
|
@d = d = create_driver(config + "skip_invalid_event true")
|
358
355
|
|
359
356
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -380,20 +377,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
380
377
|
|
381
378
|
sub_test_case 'packed forward' do
|
382
379
|
data(tcp: {
|
383
|
-
config: CONFIG,
|
384
380
|
options: {
|
385
381
|
auth: false
|
386
382
|
}
|
387
383
|
},
|
388
384
|
auth: {
|
389
|
-
config: CONFIG_AUTH,
|
390
385
|
options: {
|
391
386
|
auth: true
|
392
387
|
}
|
393
388
|
})
|
394
389
|
test 'plain' do |data|
|
395
|
-
config = data[:config]
|
396
390
|
options = data[:options]
|
391
|
+
config = options[:auth] ? config_auth : base_config
|
397
392
|
@d = d = create_driver(config)
|
398
393
|
|
399
394
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -422,7 +417,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
422
417
|
result: "new_prefix.tag1"
|
423
418
|
})
|
424
419
|
test 'tag parameters' do |data|
|
425
|
-
@d = create_driver(
|
420
|
+
@d = create_driver(base_config + data[:param])
|
426
421
|
time = event_time("2011-01-02 13:14:15 UTC")
|
427
422
|
options = {auth: false}
|
428
423
|
|
@@ -442,20 +437,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
442
437
|
end
|
443
438
|
|
444
439
|
data(tcp: {
|
445
|
-
config: CONFIG,
|
446
440
|
options: {
|
447
441
|
auth: false
|
448
442
|
}
|
449
443
|
},
|
450
444
|
auth: {
|
451
|
-
config: CONFIG_AUTH,
|
452
445
|
options: {
|
453
446
|
auth: true
|
454
447
|
}
|
455
448
|
})
|
456
449
|
test 'time_as_integer' do |data|
|
457
|
-
config = data[:config]
|
458
450
|
options = data[:options]
|
451
|
+
config = options[:auth] ? config_auth : base_config
|
459
452
|
@d = d = create_driver(config)
|
460
453
|
|
461
454
|
time_i = event_time("2011-01-02 13:14:15 UTC").to_i
|
@@ -476,20 +469,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
476
469
|
end
|
477
470
|
|
478
471
|
data(tcp: {
|
479
|
-
config: CONFIG,
|
480
472
|
options: {
|
481
473
|
auth: false
|
482
474
|
}
|
483
475
|
},
|
484
476
|
auth: {
|
485
|
-
config: CONFIG_AUTH,
|
486
477
|
options: {
|
487
478
|
auth: true
|
488
479
|
}
|
489
480
|
})
|
490
481
|
test 'skip_invalid_event' do |data|
|
491
|
-
config = data[:config]
|
492
482
|
options = data[:options]
|
483
|
+
config = options[:auth] ? config_auth : base_config
|
493
484
|
@d = d = create_driver(config + "skip_invalid_event true")
|
494
485
|
|
495
486
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -577,7 +568,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
577
568
|
|
578
569
|
sub_test_case 'warning' do
|
579
570
|
test 'send_large_chunk_warning' do
|
580
|
-
@d = d = create_driver(
|
571
|
+
@d = d = create_driver(base_config + %[
|
581
572
|
chunk_size_warn_limit 16M
|
582
573
|
chunk_size_limit 32M
|
583
574
|
])
|
@@ -613,7 +604,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
613
604
|
end
|
614
605
|
|
615
606
|
test 'send_large_chunk_only_warning' do
|
616
|
-
@d = d = create_driver(
|
607
|
+
@d = d = create_driver(base_config + %[
|
617
608
|
chunk_size_warn_limit 16M
|
618
609
|
])
|
619
610
|
time = event_time("2014-04-25 13:14:15 UTC")
|
@@ -639,7 +630,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
639
630
|
end
|
640
631
|
|
641
632
|
test 'send_large_chunk_limit' do
|
642
|
-
@d = d = create_driver(
|
633
|
+
@d = d = create_driver(base_config + %[
|
643
634
|
chunk_size_warn_limit 16M
|
644
635
|
chunk_size_limit 32M
|
645
636
|
])
|
@@ -697,20 +688,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
697
688
|
|
698
689
|
sub_test_case 'respond to required ack' do
|
699
690
|
data(tcp: {
|
700
|
-
config: CONFIG,
|
701
691
|
options: {
|
702
692
|
auth: false
|
703
693
|
}
|
704
694
|
},
|
705
695
|
auth: {
|
706
|
-
config: CONFIG_AUTH,
|
707
696
|
options: {
|
708
697
|
auth: true
|
709
698
|
}
|
710
699
|
})
|
711
700
|
test 'message' do |data|
|
712
|
-
config = data[:config]
|
713
701
|
options = data[:options]
|
702
|
+
config = options[:auth] ? config_auth : base_config
|
714
703
|
@d = d = create_driver(config)
|
715
704
|
|
716
705
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -736,20 +725,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
736
725
|
|
737
726
|
# FIX: response is not pushed into @responses because IO.select has been blocked until InputForward shutdowns
|
738
727
|
data(tcp: {
|
739
|
-
config: CONFIG,
|
740
728
|
options: {
|
741
729
|
auth: false
|
742
730
|
}
|
743
731
|
},
|
744
732
|
auth: {
|
745
|
-
config: CONFIG_AUTH,
|
746
733
|
options: {
|
747
734
|
auth: true
|
748
735
|
}
|
749
736
|
})
|
750
737
|
test 'forward' do |data|
|
751
|
-
config = data[:config]
|
752
738
|
options = data[:options]
|
739
|
+
config = options[:auth] ? config_auth : base_config
|
753
740
|
@d = d = create_driver(config)
|
754
741
|
|
755
742
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -776,20 +763,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
776
763
|
end
|
777
764
|
|
778
765
|
data(tcp: {
|
779
|
-
config: CONFIG,
|
780
766
|
options: {
|
781
767
|
auth: false
|
782
768
|
}
|
783
769
|
},
|
784
770
|
auth: {
|
785
|
-
config: CONFIG_AUTH,
|
786
771
|
options: {
|
787
772
|
auth: true
|
788
773
|
}
|
789
774
|
})
|
790
775
|
test 'packed_forward' do |data|
|
791
|
-
config = data[:config]
|
792
776
|
options = data[:options]
|
777
|
+
config = options[:auth] ? config_auth : base_config
|
793
778
|
@d = d = create_driver(config)
|
794
779
|
|
795
780
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -817,22 +802,20 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
817
802
|
|
818
803
|
data(
|
819
804
|
tcp: {
|
820
|
-
config: CONFIG,
|
821
805
|
options: {
|
822
806
|
auth: false
|
823
807
|
}
|
824
808
|
},
|
825
809
|
### Auth is not supported with json
|
826
810
|
# auth: {
|
827
|
-
# config: CONFIG_AUTH,
|
828
811
|
# options: {
|
829
812
|
# auth: true
|
830
813
|
# }
|
831
814
|
# },
|
832
815
|
)
|
833
816
|
test 'message_json' do |data|
|
834
|
-
config = data[:config]
|
835
817
|
options = data[:options]
|
818
|
+
config = options[:auth] ? config_auth : base_config
|
836
819
|
@d = d = create_driver(config)
|
837
820
|
|
838
821
|
time_i = event_time("2011-01-02 13:14:15 UTC")
|
@@ -859,20 +842,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
859
842
|
|
860
843
|
sub_test_case 'not respond without required ack' do
|
861
844
|
data(tcp: {
|
862
|
-
config: CONFIG,
|
863
845
|
options: {
|
864
846
|
auth: false
|
865
847
|
}
|
866
848
|
},
|
867
849
|
auth: {
|
868
|
-
config: CONFIG_AUTH,
|
869
850
|
options: {
|
870
851
|
auth: true
|
871
852
|
}
|
872
853
|
})
|
873
854
|
test 'message' do |data|
|
874
|
-
config = data[:config]
|
875
855
|
options = data[:options]
|
856
|
+
config = options[:auth] ? config_auth : base_config
|
876
857
|
@d = d = create_driver(config)
|
877
858
|
|
878
859
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -893,20 +874,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
893
874
|
end
|
894
875
|
|
895
876
|
data(tcp: {
|
896
|
-
config: CONFIG,
|
897
877
|
options: {
|
898
878
|
auth: false
|
899
879
|
}
|
900
880
|
},
|
901
881
|
auth: {
|
902
|
-
config: CONFIG_AUTH,
|
903
882
|
options: {
|
904
883
|
auth: true
|
905
884
|
}
|
906
885
|
})
|
907
886
|
test 'forward' do |data|
|
908
|
-
config = data[:config]
|
909
887
|
options = data[:options]
|
888
|
+
config = options[:auth] ? config_auth : base_config
|
910
889
|
@d = d = create_driver(config)
|
911
890
|
|
912
891
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -929,20 +908,18 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
929
908
|
end
|
930
909
|
|
931
910
|
data(tcp: {
|
932
|
-
config: CONFIG,
|
933
911
|
options: {
|
934
912
|
auth: false
|
935
913
|
}
|
936
914
|
},
|
937
915
|
auth: {
|
938
|
-
config: CONFIG_AUTH,
|
939
916
|
options: {
|
940
917
|
auth: true
|
941
918
|
}
|
942
919
|
})
|
943
920
|
test 'packed_forward' do |data|
|
944
|
-
config = data[:config]
|
945
921
|
options = data[:options]
|
922
|
+
config = options[:auth] ? config_auth : base_config
|
946
923
|
@d = d = create_driver(config)
|
947
924
|
|
948
925
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -966,22 +943,21 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
966
943
|
|
967
944
|
data(
|
968
945
|
tcp: {
|
969
|
-
config: CONFIG,
|
970
946
|
options: {
|
971
947
|
auth: false
|
972
948
|
}
|
973
949
|
},
|
974
950
|
### Auth is not supported with json
|
975
951
|
# auth: {
|
976
|
-
# config:
|
952
|
+
# config: config_auth,
|
977
953
|
# options: {
|
978
954
|
# auth: true
|
979
955
|
# }
|
980
956
|
# },
|
981
957
|
)
|
982
958
|
test 'message_json' do |data|
|
983
|
-
config = data[:config]
|
984
959
|
options = data[:options]
|
960
|
+
config = options[:auth] ? config_auth : base_config
|
985
961
|
@d = d = create_driver(config)
|
986
962
|
|
987
963
|
time_i = event_time("2011-01-02 13:14:15 UTC").to_i
|
@@ -1096,7 +1072,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
1096
1072
|
end
|
1097
1073
|
|
1098
1074
|
def connect
|
1099
|
-
TCPSocket.new('127.0.0.1',
|
1075
|
+
TCPSocket.new('127.0.0.1', @port)
|
1100
1076
|
end
|
1101
1077
|
|
1102
1078
|
# Data ordering is not assured:
|
@@ -1165,7 +1141,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
1165
1141
|
end
|
1166
1142
|
|
1167
1143
|
def execute_test_with_source_hostname_key(*keys, &block)
|
1168
|
-
conf =
|
1144
|
+
conf = base_config.dup
|
1169
1145
|
if keys.include?(:hostname)
|
1170
1146
|
conf << <<EOL
|
1171
1147
|
source_hostname_key source_hostname
|