fluentd 1.16.11-x86-mingw32 → 1.17.0-x86-mingw32
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.
- checksums.yaml +4 -4
- data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +50 -0
- data/.github/DISCUSSION_TEMPLATE/q-a.yml +47 -0
- data/.github/workflows/test-ruby-head.yml +31 -0
- data/.github/workflows/test.yml +6 -38
- data/CHANGELOG.md +33 -122
- data/README.md +4 -1
- data/Rakefile +1 -1
- data/SECURITY.md +4 -6
- data/fluentd.gemspec +5 -11
- data/lib/fluent/command/binlog_reader.rb +1 -1
- data/lib/fluent/command/fluentd.rb +1 -1
- data/lib/fluent/compat/formatter.rb +0 -6
- data/lib/fluent/config/configure_proxy.rb +2 -2
- data/lib/fluent/config/parser.rb +3 -15
- data/lib/fluent/config/types.rb +1 -1
- data/lib/fluent/config/v1_parser.rb +1 -1
- data/lib/fluent/config/yaml_parser/parser.rb +0 -4
- data/lib/fluent/configurable.rb +2 -2
- data/lib/fluent/counter/mutex_hash.rb +1 -1
- data/lib/fluent/fluent_log_event_router.rb +0 -2
- data/lib/fluent/plugin/buf_file.rb +1 -1
- data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +2 -3
- data/lib/fluent/plugin/filter_parser.rb +26 -8
- data/lib/fluent/plugin/formatter_csv.rb +4 -18
- data/lib/fluent/plugin/in_http.rb +17 -52
- data/lib/fluent/plugin/in_tail.rb +35 -3
- data/lib/fluent/plugin/out_file.rb +0 -8
- data/lib/fluent/plugin/out_forward.rb +0 -10
- data/lib/fluent/plugin/out_http.rb +125 -13
- data/lib/fluent/plugin/owned_by_mixin.rb +0 -1
- data/lib/fluent/plugin/parser_json.rb +34 -9
- data/lib/fluent/plugin/parser_msgpack.rb +24 -3
- data/lib/fluent/plugin_helper/metrics.rb +2 -2
- data/lib/fluent/plugin_helper/server.rb +1 -4
- data/lib/fluent/registry.rb +6 -6
- data/lib/fluent/supervisor.rb +3 -3
- data/lib/fluent/test/output_test.rb +1 -1
- data/lib/fluent/test.rb +2 -5
- data/lib/fluent/unique_id.rb +1 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +8 -38
- data/test/command/test_cat.rb +2 -2
- data/test/command/test_fluentd.rb +11 -58
- data/test/config/test_dsl.rb +1 -8
- data/test/config/test_element.rb +2 -2
- data/test/config/test_plugin_configuration.rb +6 -6
- data/test/helper.rb +7 -27
- data/test/log/test_console_adapter.rb +10 -3
- data/test/plugin/data/log_numeric/01.log +0 -0
- data/test/plugin/data/log_numeric/02.log +0 -0
- data/test/plugin/data/log_numeric/12.log +0 -0
- data/test/plugin/data/log_numeric/14.log +0 -0
- data/test/plugin/in_tail/test_io_handler.rb +14 -13
- data/test/plugin/in_tail/test_position_file.rb +7 -6
- data/test/plugin/out_forward/test_ack_handler.rb +3 -3
- data/test/plugin/out_forward/test_socket_cache.rb +3 -3
- data/test/plugin/test_buffer.rb +2 -2
- data/test/plugin/test_filter_grep.rb +1 -1
- data/test/plugin/test_filter_stdout.rb +4 -4
- data/test/plugin/test_formatter_hash.rb +2 -2
- data/test/plugin/test_in_forward.rb +1 -2
- data/test/plugin/test_in_http.rb +23 -1
- data/test/plugin/test_in_monitor_agent.rb +6 -6
- data/test/plugin/test_in_object_space.rb +0 -4
- data/test/plugin/test_in_syslog.rb +18 -25
- data/test/plugin/test_in_tail.rb +153 -5
- data/test/plugin/test_in_tcp.rb +1 -1
- data/test/plugin/test_in_udp.rb +10 -16
- data/test/plugin/test_out_exec_filter.rb +7 -12
- data/test/plugin/test_out_file.rb +2 -22
- data/test/plugin/test_out_forward.rb +37 -61
- data/test/plugin/test_out_http.rb +128 -0
- data/test/plugin/test_out_stdout.rb +3 -3
- data/test/plugin/test_out_stream.rb +1 -1
- data/test/plugin/test_output.rb +1 -1
- data/test/plugin/test_output_as_buffered.rb +2 -2
- data/test/plugin/test_output_as_buffered_retries.rb +2 -2
- data/test/plugin/test_owned_by.rb +0 -1
- data/test/plugin/test_parser_csv.rb +1 -1
- data/test/plugin/test_parser_json.rb +106 -31
- data/test/plugin/test_parser_msgpack.rb +127 -0
- data/test/plugin/test_storage.rb +0 -1
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_server.rb +41 -83
- data/test/plugin_helper/test_socket.rb +1 -1
- data/test/test_config.rb +0 -6
- data/test/test_configdsl.rb +1 -8
- data/test/test_event_router.rb +2 -2
- data/test/test_plugin_helper.rb +1 -1
- data/test/test_supervisor.rb +21 -32
- data/test/test_tls.rb +1 -1
- metadata +66 -52
- data/test/scripts/windows_service_test.ps1 +0 -73
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require_relative '../helper'
|
|
2
|
+
require 'fluent/test/driver/parser'
|
|
3
|
+
require 'fluent/plugin/parser_msgpack'
|
|
4
|
+
|
|
5
|
+
class MessagePackParserTest < ::Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
Fluent::Test.setup
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create_driver(conf)
|
|
11
|
+
Fluent::Test::Driver::Parser.new(Fluent::Plugin::MessagePackParser).configure(conf)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
sub_test_case "simple setting" do
|
|
15
|
+
data(
|
|
16
|
+
"Normal Hash",
|
|
17
|
+
{
|
|
18
|
+
input: "\x82\xA7message\xADHello msgpack\xA3numd",
|
|
19
|
+
expected: [{"message" => "Hello msgpack", "num" => 100}]
|
|
20
|
+
},
|
|
21
|
+
keep: true
|
|
22
|
+
)
|
|
23
|
+
data(
|
|
24
|
+
"Array of multiple Hash",
|
|
25
|
+
{
|
|
26
|
+
input: "\x92\x81\xA7message\xA3foo\x81\xA7message\xA3bar",
|
|
27
|
+
expected: [{"message"=>"foo"}, {"message"=>"bar"}]
|
|
28
|
+
},
|
|
29
|
+
keep: true
|
|
30
|
+
)
|
|
31
|
+
data(
|
|
32
|
+
"String",
|
|
33
|
+
{
|
|
34
|
+
# "Hello msgpack".to_msgpack
|
|
35
|
+
input: "\xADHello msgpack",
|
|
36
|
+
expected: [nil]
|
|
37
|
+
},
|
|
38
|
+
keep: true
|
|
39
|
+
)
|
|
40
|
+
data(
|
|
41
|
+
"Array of String",
|
|
42
|
+
{
|
|
43
|
+
# ["foo", "bar"].to_msgpack
|
|
44
|
+
input: "\x92\xA3foo\xA3bar",
|
|
45
|
+
expected: [nil, nil]
|
|
46
|
+
},
|
|
47
|
+
keep: true
|
|
48
|
+
)
|
|
49
|
+
data(
|
|
50
|
+
"Array of String and Hash",
|
|
51
|
+
{
|
|
52
|
+
# ["foo", {message: "bar"}].to_msgpack
|
|
53
|
+
input: "\x92\xA3foo\x81\xA7message\xA3bar",
|
|
54
|
+
expected: [nil, {"message"=>"bar"}]
|
|
55
|
+
},
|
|
56
|
+
keep: true
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def test_parse(data)
|
|
60
|
+
parsed_records = []
|
|
61
|
+
create_driver("").instance.parse(data[:input]) do |time, record|
|
|
62
|
+
parsed_records.append(record)
|
|
63
|
+
end
|
|
64
|
+
assert_equal(data[:expected], parsed_records)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_parse_io(data)
|
|
68
|
+
parsed_records = []
|
|
69
|
+
StringIO.open(data[:input]) do |io|
|
|
70
|
+
create_driver("").instance.parse_io(io) do |time, record|
|
|
71
|
+
parsed_records.append(record)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
assert_equal(data[:expected], parsed_records)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# This becomes NoMethodError if a non-Hash object is passed to convert_values.
|
|
79
|
+
# https://github.com/fluent/fluentd/issues/4100
|
|
80
|
+
sub_test_case "execute_convert_values with null_empty_string" do
|
|
81
|
+
data(
|
|
82
|
+
"Normal hash",
|
|
83
|
+
{
|
|
84
|
+
# {message: "foo", empty: ""}.to_msgpack
|
|
85
|
+
input: "\x82\xA7message\xA3foo\xA5empty\xA0",
|
|
86
|
+
expected: [{"message" => "foo", "empty" => nil}]
|
|
87
|
+
},
|
|
88
|
+
keep: true
|
|
89
|
+
)
|
|
90
|
+
data(
|
|
91
|
+
"Array of multiple Hash",
|
|
92
|
+
{
|
|
93
|
+
# [{message: "foo", empty: ""}, {message: "bar", empty: ""}].to_msgpack
|
|
94
|
+
input: "\x92\x82\xA7message\xA3foo\xA5empty\xA0\x82\xA7message\xA3bar\xA5empty\xA0",
|
|
95
|
+
expected: [{"message"=>"foo", "empty" => nil}, {"message"=>"bar", "empty" => nil}]
|
|
96
|
+
},
|
|
97
|
+
keep: true
|
|
98
|
+
)
|
|
99
|
+
data(
|
|
100
|
+
"String",
|
|
101
|
+
{
|
|
102
|
+
# "Hello msgpack".to_msgpack
|
|
103
|
+
input: "\xADHello msgpack",
|
|
104
|
+
expected: [nil]
|
|
105
|
+
},
|
|
106
|
+
keep: true
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
def test_parse(data)
|
|
110
|
+
parsed_records = []
|
|
111
|
+
create_driver("null_empty_string").instance.parse(data[:input]) do |time, record|
|
|
112
|
+
parsed_records.append(record)
|
|
113
|
+
end
|
|
114
|
+
assert_equal(data[:expected], parsed_records)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_parse_io(data)
|
|
118
|
+
parsed_records = []
|
|
119
|
+
StringIO.open(data[:input]) do |io|
|
|
120
|
+
create_driver("null_empty_string").instance.parse_io(io) do |time, record|
|
|
121
|
+
parsed_records.append(record)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
assert_equal(data[:expected], parsed_records)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
data/test/plugin/test_storage.rb
CHANGED
|
@@ -68,7 +68,6 @@ class StorageTest < Test::Unit::TestCase
|
|
|
68
68
|
|
|
69
69
|
assert_equal 'mytest', s.owner.system_config.process_name
|
|
70
70
|
assert_equal '1', s.instance_eval{ @_plugin_id }
|
|
71
|
-
assert_equal true, s.instance_eval{ @_plugin_id_configured }
|
|
72
71
|
end
|
|
73
72
|
|
|
74
73
|
test 'does NOT have features for high-performance/high-consistent storages' do
|
|
@@ -15,7 +15,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
15
15
|
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/plugin_helper_server")
|
|
16
16
|
|
|
17
17
|
setup do
|
|
18
|
-
@port = unused_port
|
|
18
|
+
@port = unused_port
|
|
19
19
|
if Fluent.windows?
|
|
20
20
|
@socket_manager_server = ServerEngine::SocketManager::Server.open
|
|
21
21
|
@socket_manager_path = @socket_manager_server.path
|
|
@@ -233,12 +233,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
233
233
|
# 'server_create_connection tcp' => [:server_create_connection, :unix],
|
|
234
234
|
)
|
|
235
235
|
test 'raise error if udp options specified for tcp/tls/unix' do |(m, proto)|
|
|
236
|
-
port = unused_port(protocol: proto)
|
|
237
236
|
assert_raise ArgumentError do
|
|
238
|
-
@d.__send__(m, :myserver, port, proto: proto, max_bytes: 128){|x| x }
|
|
237
|
+
@d.__send__(m, :myserver, @port, proto: proto, max_bytes: 128){|x| x }
|
|
239
238
|
end
|
|
240
239
|
assert_raise ArgumentError do
|
|
241
|
-
@d.__send__(m, :myserver, port, proto: proto, flags: 1){|x| x }
|
|
240
|
+
@d.__send__(m, :myserver, @port, proto: proto, flags: 1){|x| x }
|
|
242
241
|
end
|
|
243
242
|
end
|
|
244
243
|
|
|
@@ -246,9 +245,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
246
245
|
'server_create udp' => [:server_create, :udp],
|
|
247
246
|
)
|
|
248
247
|
test 'raise error if tcp/tls options specified for udp' do |(m, proto)|
|
|
249
|
-
port = unused_port(protocol: proto)
|
|
250
248
|
assert_raise(ArgumentError.new("BUG: linger_timeout is available for tcp/tls")) do
|
|
251
|
-
@d.__send__(m, :myserver, port, proto: proto, linger_timeout: 1, max_bytes: 128){|x| x }
|
|
249
|
+
@d.__send__(m, :myserver, @port, proto: proto, linger_timeout: 1, max_bytes: 128){|x| x }
|
|
252
250
|
end
|
|
253
251
|
end
|
|
254
252
|
|
|
@@ -256,9 +254,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
256
254
|
'server_create udp' => [:server_create, :udp],
|
|
257
255
|
)
|
|
258
256
|
test 'raise error if tcp/tls/unix backlog options specified for udp' do |(m, proto)|
|
|
259
|
-
port = unused_port(protocol: proto)
|
|
260
257
|
assert_raise(ArgumentError.new("BUG: backlog is available for tcp/tls")) do
|
|
261
|
-
@d.__send__(m, :myserver, port, proto: proto, backlog: 500){|x| x }
|
|
258
|
+
@d.__send__(m, :myserver, @port, proto: proto, backlog: 500){|x| x }
|
|
262
259
|
end
|
|
263
260
|
end
|
|
264
261
|
|
|
@@ -266,9 +263,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
266
263
|
'server_create udp' => [:server_create, :udp],
|
|
267
264
|
)
|
|
268
265
|
test 'raise error if tcp/tls send_keepalive_packet option is specified for udp' do |(m, proto)|
|
|
269
|
-
port = unused_port(protocol: proto)
|
|
270
266
|
assert_raise(ArgumentError.new("BUG: send_keepalive_packet is available for tcp/tls")) do
|
|
271
|
-
@d.__send__(m, :myserver, port, proto: proto, send_keepalive_packet: true){|x| x }
|
|
267
|
+
@d.__send__(m, :myserver, @port, proto: proto, send_keepalive_packet: true){|x| x }
|
|
272
268
|
end
|
|
273
269
|
end
|
|
274
270
|
|
|
@@ -280,9 +276,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
280
276
|
# 'server_create_connection unix' => [:server_create_connection, :unix, {}],
|
|
281
277
|
)
|
|
282
278
|
test 'raise error if tls options specified for tcp/udp/unix' do |(m, proto, kwargs)|
|
|
283
|
-
port = unused_port(protocol: proto)
|
|
284
279
|
assert_raise(ArgumentError.new("BUG: tls_options is available only for tls")) do
|
|
285
|
-
@d.__send__(m, :myserver, port, proto: proto, tls_options: {}, **kwargs){|x| x }
|
|
280
|
+
@d.__send__(m, :myserver, @port, proto: proto, tls_options: {}, **kwargs){|x| x }
|
|
286
281
|
end
|
|
287
282
|
end
|
|
288
283
|
|
|
@@ -294,8 +289,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
294
289
|
'server_create_connection tls' => [:server_create_connection, :tls, {tls_options: {insecure: true}}],
|
|
295
290
|
)
|
|
296
291
|
test 'can bind specified IPv4 address' do |(m, proto, kwargs)|
|
|
297
|
-
port
|
|
298
|
-
@d.__send__(m, :myserver, port, proto: proto, bind: "127.0.0.1", **kwargs){|x| x }
|
|
292
|
+
@d.__send__(m, :myserver, @port, proto: proto, bind: "127.0.0.1", **kwargs){|x| x }
|
|
299
293
|
assert_equal "127.0.0.1", @d._servers.first.bind
|
|
300
294
|
assert_equal "127.0.0.1", @d._servers.first.server.instance_eval{ instance_variable_defined?(:@listen_socket) ? @listen_socket : @_io }.addr[3]
|
|
301
295
|
end
|
|
@@ -309,8 +303,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
309
303
|
)
|
|
310
304
|
test 'can bind specified IPv6 address' do |(m, proto, kwargs)| # if available
|
|
311
305
|
omit "IPv6 unavailable here" unless ipv6_enabled?
|
|
312
|
-
port
|
|
313
|
-
@d.__send__(m, :myserver, port, proto: proto, bind: "::1", **kwargs){|x| x }
|
|
306
|
+
@d.__send__(m, :myserver, @port, proto: proto, bind: "::1", **kwargs){|x| x }
|
|
314
307
|
assert_equal "::1", @d._servers.first.bind
|
|
315
308
|
assert_equal "::1", @d._servers.first.server.instance_eval{ instance_variable_defined?(:@listen_socket) ? @listen_socket : @_io }.addr[3]
|
|
316
309
|
end
|
|
@@ -327,11 +320,10 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
327
320
|
test 'can create 2 or more servers which share same bind address and port if shared option is true' do |(m, proto, kwargs)|
|
|
328
321
|
begin
|
|
329
322
|
d2 = Dummy.new; d2.start; d2.after_start
|
|
330
|
-
port = unused_port(protocol: proto)
|
|
331
323
|
|
|
332
324
|
assert_nothing_raised do
|
|
333
|
-
@d.__send__(m, :myserver, port, proto: proto, **kwargs){|x| x }
|
|
334
|
-
d2.__send__(m, :myserver, port, proto: proto, **kwargs){|x| x }
|
|
325
|
+
@d.__send__(m, :myserver, @port, proto: proto, **kwargs){|x| x }
|
|
326
|
+
d2.__send__(m, :myserver, @port, proto: proto, **kwargs){|x| x }
|
|
335
327
|
end
|
|
336
328
|
ensure
|
|
337
329
|
d2.stop; d2.before_shutdown; d2.shutdown; d2.after_shutdown; d2.close; d2.terminate
|
|
@@ -352,37 +344,17 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
352
344
|
test 'cannot create 2 or more servers using same bind address and port if shared option is false' do |(m, proto, kwargs)|
|
|
353
345
|
begin
|
|
354
346
|
d2 = Dummy.new; d2.start; d2.after_start
|
|
355
|
-
port = unused_port(protocol: proto)
|
|
356
347
|
|
|
357
348
|
assert_nothing_raised do
|
|
358
|
-
@d.__send__(m, :myserver, port, proto: proto, shared: false, **kwargs){|x| x }
|
|
349
|
+
@d.__send__(m, :myserver, @port, proto: proto, shared: false, **kwargs){|x| x }
|
|
359
350
|
end
|
|
360
351
|
assert_raise(Errno::EADDRINUSE, Errno::EACCES) do
|
|
361
|
-
d2.__send__(m, :myserver, port, proto: proto, **kwargs){|x| x }
|
|
352
|
+
d2.__send__(m, :myserver, @port, proto: proto, **kwargs){|x| x }
|
|
362
353
|
end
|
|
363
354
|
ensure
|
|
364
355
|
d2.stop; d2.before_shutdown; d2.shutdown; d2.after_shutdown; d2.close; d2.terminate
|
|
365
356
|
end
|
|
366
357
|
end
|
|
367
|
-
|
|
368
|
-
test 'close all connections by shutdown' do
|
|
369
|
-
@d.server_create_tcp(:s, @port) do |data, conn|
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
client_sockets = []
|
|
373
|
-
5.times do
|
|
374
|
-
client_sockets << TCPSocket.open("127.0.0.1", @port)
|
|
375
|
-
end
|
|
376
|
-
waiting(4){ sleep 0.1 until @d.instance_variable_get(:@_server_connections).size == 5 }
|
|
377
|
-
|
|
378
|
-
@d.stop
|
|
379
|
-
@d.before_shutdown
|
|
380
|
-
@d.shutdown
|
|
381
|
-
|
|
382
|
-
assert_true @d.instance_variable_get(:@_server_connections).empty?
|
|
383
|
-
ensure
|
|
384
|
-
client_sockets.each(&:close)
|
|
385
|
-
end
|
|
386
358
|
end
|
|
387
359
|
|
|
388
360
|
sub_test_case '#server_create' do
|
|
@@ -393,18 +365,16 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
393
365
|
# 'unix' => [:unix, {}],
|
|
394
366
|
)
|
|
395
367
|
test 'raise error if block argument is not specified or too many' do |(proto, kwargs)|
|
|
396
|
-
port = unused_port(protocol: proto)
|
|
397
368
|
assert_raise(ArgumentError.new("BUG: block must have 1 or 2 arguments")) do
|
|
398
|
-
@d.server_create(:myserver, port, proto: proto, **kwargs){ 1 }
|
|
369
|
+
@d.server_create(:myserver, @port, proto: proto, **kwargs){ 1 }
|
|
399
370
|
end
|
|
400
371
|
assert_raise(ArgumentError.new("BUG: block must have 1 or 2 arguments")) do
|
|
401
|
-
@d.server_create(:myserver, port, proto: proto, **kwargs){|sock, conn, what_is_this| 1 }
|
|
372
|
+
@d.server_create(:myserver, @port, proto: proto, **kwargs){|sock, conn, what_is_this| 1 }
|
|
402
373
|
end
|
|
403
374
|
end
|
|
404
375
|
|
|
405
376
|
test 'creates udp server if specified in proto' do
|
|
406
|
-
port
|
|
407
|
-
@d.server_create(:myserver, port, proto: :udp, max_bytes: 512){|x| x }
|
|
377
|
+
@d.server_create(:myserver, @port, proto: :udp, max_bytes: 512){|x| x }
|
|
408
378
|
|
|
409
379
|
created_server_info = @d._servers.first
|
|
410
380
|
assert_equal :udp, created_server_info.proto
|
|
@@ -617,8 +587,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
617
587
|
sub_test_case '#server_create_udp' do
|
|
618
588
|
test 'can accept all keyword arguments valid for udp server' do
|
|
619
589
|
assert_nothing_raised do
|
|
620
|
-
port
|
|
621
|
-
@d.server_create_udp(:s, port, bind: '127.0.0.1', shared: false, resolve_name: true, max_bytes: 100, flags: 1) do |data, conn|
|
|
590
|
+
@d.server_create_udp(:s, @port, bind: '127.0.0.1', shared: false, resolve_name: true, max_bytes: 100, flags: 1) do |data, conn|
|
|
622
591
|
# ...
|
|
623
592
|
end
|
|
624
593
|
end
|
|
@@ -626,15 +595,14 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
626
595
|
|
|
627
596
|
test 'creates a udp server just to read data' do
|
|
628
597
|
received = ""
|
|
629
|
-
port
|
|
630
|
-
@d.server_create_udp(:s, port, max_bytes: 128) do |data|
|
|
598
|
+
@d.server_create_udp(:s, @port, max_bytes: 128) do |data|
|
|
631
599
|
received << data
|
|
632
600
|
end
|
|
633
601
|
bind_port = unused_port(protocol: :udp, bind: "127.0.0.1")
|
|
634
602
|
3.times do
|
|
635
603
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
636
604
|
sock.bind("127.0.0.1", bind_port)
|
|
637
|
-
sock.connect("127.0.0.1", port)
|
|
605
|
+
sock.connect("127.0.0.1", @port)
|
|
638
606
|
sock.puts "yay"
|
|
639
607
|
sock.puts "foo"
|
|
640
608
|
sock.close
|
|
@@ -646,17 +614,16 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
646
614
|
test 'creates a udp server to read and write data' do
|
|
647
615
|
received = ""
|
|
648
616
|
responses = []
|
|
649
|
-
port
|
|
650
|
-
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
617
|
+
@d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock|
|
|
651
618
|
received << data
|
|
652
619
|
sock.write "ack\n"
|
|
653
620
|
end
|
|
654
|
-
bind_port = unused_port
|
|
621
|
+
bind_port = unused_port
|
|
655
622
|
3.times do
|
|
656
623
|
begin
|
|
657
624
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
658
625
|
sock.bind("127.0.0.1", bind_port)
|
|
659
|
-
sock.connect("127.0.0.1", port)
|
|
626
|
+
sock.connect("127.0.0.1", @port)
|
|
660
627
|
th = Thread.new do
|
|
661
628
|
while true
|
|
662
629
|
begin
|
|
@@ -687,12 +654,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
687
654
|
|
|
688
655
|
received = ""
|
|
689
656
|
responses = []
|
|
690
|
-
|
|
691
|
-
@d.server_create_udp(:s, port, bind: "::1", max_bytes: 128) do |data, sock|
|
|
657
|
+
@d.server_create_udp(:s, @port, bind: "::1", max_bytes: 128) do |data, sock|
|
|
692
658
|
received << data
|
|
693
659
|
sock.write "ack\n"
|
|
694
660
|
end
|
|
695
|
-
bind_port = unused_port
|
|
661
|
+
bind_port = unused_port
|
|
696
662
|
3.times do
|
|
697
663
|
begin
|
|
698
664
|
sock = UDPSocket.new(Socket::AF_INET6)
|
|
@@ -701,7 +667,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
701
667
|
responses << sock.recv(16)
|
|
702
668
|
true
|
|
703
669
|
end
|
|
704
|
-
sock.connect("::1", port)
|
|
670
|
+
sock.connect("::1", @port)
|
|
705
671
|
sock.write "yay\nfoo\n"
|
|
706
672
|
th.join(5)
|
|
707
673
|
ensure
|
|
@@ -716,14 +682,13 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
716
682
|
test 'does not resolve name of client address in default' do
|
|
717
683
|
received = ""
|
|
718
684
|
sources = []
|
|
719
|
-
port
|
|
720
|
-
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
685
|
+
@d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock|
|
|
721
686
|
received << data
|
|
722
687
|
sources << sock.remote_host
|
|
723
688
|
end
|
|
724
689
|
3.times do
|
|
725
690
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
726
|
-
sock.connect("127.0.0.1", port)
|
|
691
|
+
sock.connect("127.0.0.1", @port)
|
|
727
692
|
sock.puts "yay"
|
|
728
693
|
sock.close
|
|
729
694
|
end
|
|
@@ -737,14 +702,13 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
737
702
|
|
|
738
703
|
received = ""
|
|
739
704
|
sources = []
|
|
740
|
-
port
|
|
741
|
-
@d.server_create_udp(:s, port, resolve_name: true, max_bytes: 128) do |data, sock|
|
|
705
|
+
@d.server_create_udp(:s, @port, resolve_name: true, max_bytes: 128) do |data, sock|
|
|
742
706
|
received << data
|
|
743
707
|
sources << sock.remote_host
|
|
744
708
|
end
|
|
745
709
|
3.times do
|
|
746
710
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
747
|
-
sock.connect("127.0.0.1", port)
|
|
711
|
+
sock.connect("127.0.0.1", @port)
|
|
748
712
|
sock.puts "yay"
|
|
749
713
|
sock.close
|
|
750
714
|
end
|
|
@@ -756,8 +720,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
756
720
|
test 'raises error if plugin registers data callback for connection object from #server_create' do
|
|
757
721
|
received = ""
|
|
758
722
|
errors = []
|
|
759
|
-
port
|
|
760
|
-
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
723
|
+
@d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock|
|
|
761
724
|
received << data
|
|
762
725
|
begin
|
|
763
726
|
sock.data{|d| received << d.upcase }
|
|
@@ -766,7 +729,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
766
729
|
end
|
|
767
730
|
end
|
|
768
731
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
769
|
-
sock.connect("127.0.0.1", port)
|
|
732
|
+
sock.connect("127.0.0.1", @port)
|
|
770
733
|
sock.write "foo\n"
|
|
771
734
|
sock.close
|
|
772
735
|
|
|
@@ -779,8 +742,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
779
742
|
test 'raise error if plugin registers write_complete callback for udp' do
|
|
780
743
|
received = ""
|
|
781
744
|
errors = []
|
|
782
|
-
port
|
|
783
|
-
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
745
|
+
@d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock|
|
|
784
746
|
received << data
|
|
785
747
|
begin
|
|
786
748
|
sock.on(:write_complete){|conn| "" }
|
|
@@ -789,7 +751,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
789
751
|
end
|
|
790
752
|
end
|
|
791
753
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
792
|
-
sock.connect("127.0.0.1", port)
|
|
754
|
+
sock.connect("127.0.0.1", @port)
|
|
793
755
|
sock.write "foo\n"
|
|
794
756
|
sock.close
|
|
795
757
|
|
|
@@ -802,8 +764,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
802
764
|
test 'raises error if plugin registers close callback for udp' do
|
|
803
765
|
received = ""
|
|
804
766
|
errors = []
|
|
805
|
-
port
|
|
806
|
-
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
767
|
+
@d.server_create_udp(:s, @port, max_bytes: 128) do |data, sock|
|
|
807
768
|
received << data
|
|
808
769
|
begin
|
|
809
770
|
sock.on(:close){|d| "" }
|
|
@@ -812,7 +773,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
812
773
|
end
|
|
813
774
|
end
|
|
814
775
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
815
|
-
sock.connect("127.0.0.1", port)
|
|
776
|
+
sock.connect("127.0.0.1", @port)
|
|
816
777
|
sock.write "foo\n"
|
|
817
778
|
sock.close
|
|
818
779
|
|
|
@@ -825,12 +786,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
825
786
|
test 'can bind IPv4 / IPv6 together' do
|
|
826
787
|
omit "IPv6 unavailable here" unless ipv6_enabled?
|
|
827
788
|
|
|
828
|
-
port = unused_port(protocol: :udp)
|
|
829
789
|
assert_nothing_raised do
|
|
830
|
-
@d.server_create_udp(:s_ipv4_udp, port, bind: '0.0.0.0', shared: false, max_bytes: 128) do |data, sock|
|
|
790
|
+
@d.server_create_udp(:s_ipv4_udp, @port, bind: '0.0.0.0', shared: false, max_bytes: 128) do |data, sock|
|
|
831
791
|
# ...
|
|
832
792
|
end
|
|
833
|
-
@d.server_create_udp(:s_ipv6_udp, port, bind: '::', shared: false, max_bytes: 128) do |data, sock|
|
|
793
|
+
@d.server_create_udp(:s_ipv6_udp, @port, bind: '::', shared: false, max_bytes: 128) do |data, sock|
|
|
834
794
|
# ...
|
|
835
795
|
end
|
|
836
796
|
end
|
|
@@ -843,12 +803,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
843
803
|
max_bytes, records, expected = data.values
|
|
844
804
|
|
|
845
805
|
actual_records = []
|
|
846
|
-
port
|
|
847
|
-
@d.server_create_udp(:myserver, port, max_bytes: max_bytes) do |data, sock|
|
|
806
|
+
@d.server_create_udp(:myserver, @port, max_bytes: max_bytes) do |data, sock|
|
|
848
807
|
actual_records << data
|
|
849
808
|
end
|
|
850
809
|
|
|
851
|
-
open_client(:udp, "127.0.0.1", port) do |sock|
|
|
810
|
+
open_client(:udp, "127.0.0.1", @port) do |sock|
|
|
852
811
|
records.each do |record|
|
|
853
812
|
sock.send(record, 0)
|
|
854
813
|
end
|
|
@@ -864,12 +823,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
864
823
|
max_bytes, records, expected = data.values
|
|
865
824
|
|
|
866
825
|
actual_records = []
|
|
867
|
-
port
|
|
868
|
-
@d.server_create_udp(:myserver, port, max_bytes: max_bytes) do |data|
|
|
826
|
+
@d.server_create_udp(:myserver, @port, max_bytes: max_bytes) do |data|
|
|
869
827
|
actual_records << data
|
|
870
828
|
end
|
|
871
829
|
|
|
872
|
-
open_client(:udp, "127.0.0.1", port) do |sock|
|
|
830
|
+
open_client(:udp, "127.0.0.1", @port) do |sock|
|
|
873
831
|
records.each do |record|
|
|
874
832
|
sock.send(record, 0)
|
|
875
833
|
end
|
data/test/test_config.rb
CHANGED
|
@@ -167,7 +167,6 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
167
167
|
tag: tag.dummy
|
|
168
168
|
- source:
|
|
169
169
|
$type: tcp
|
|
170
|
-
$log_level: info
|
|
171
170
|
tag: tag.tcp
|
|
172
171
|
parse:
|
|
173
172
|
$arg:
|
|
@@ -177,7 +176,6 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
177
176
|
- match:
|
|
178
177
|
$tag: tag.*
|
|
179
178
|
$type: stdout
|
|
180
|
-
$log_level: debug
|
|
181
179
|
buffer:
|
|
182
180
|
$type: memory
|
|
183
181
|
flush_interval: 1s
|
|
@@ -210,12 +208,10 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
210
208
|
'tag.dummy',
|
|
211
209
|
'tcp',
|
|
212
210
|
'tag.tcp',
|
|
213
|
-
'info',
|
|
214
211
|
'none',
|
|
215
212
|
'why.parse.section.doesnot.have.arg,huh',
|
|
216
213
|
'stdout',
|
|
217
214
|
'tag.*',
|
|
218
|
-
'debug',
|
|
219
215
|
'null',
|
|
220
216
|
'**',
|
|
221
217
|
'@FLUENT_LOG',
|
|
@@ -228,12 +224,10 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
228
224
|
dummy_source_conf['tag'],
|
|
229
225
|
tcp_source_conf['@type'],
|
|
230
226
|
tcp_source_conf['tag'],
|
|
231
|
-
tcp_source_conf['@log_level'],
|
|
232
227
|
parse_tcp_conf['@type'],
|
|
233
228
|
parse_tcp_conf.arg,
|
|
234
229
|
match_conf['@type'],
|
|
235
230
|
match_conf.arg,
|
|
236
|
-
match_conf['@log_level'],
|
|
237
231
|
fluent_log_conf['@type'],
|
|
238
232
|
fluent_log_conf.arg,
|
|
239
233
|
label_conf.arg,
|
data/test/test_configdsl.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require_relative 'helper'
|
|
2
2
|
require 'fluent/config/dsl'
|
|
3
3
|
require 'fluent/test'
|
|
4
|
-
require 'tempfile'
|
|
5
4
|
|
|
6
5
|
class ConfigDSLTest < Test::Unit::TestCase
|
|
7
6
|
# TEST_CONFIG1 = %[
|
|
@@ -108,12 +107,8 @@ match('aa')
|
|
|
108
107
|
|
|
109
108
|
def test_with_ruby_keyword
|
|
110
109
|
uname_string = `uname -a`
|
|
111
|
-
tmpfile = Tempfile.create('fluentd-test')
|
|
112
|
-
tmpfile.write(uname_string)
|
|
113
|
-
tmpfile.close
|
|
114
|
-
|
|
115
110
|
root1 = Fluent::Config::DSL::Parser.parse(<<DSL)
|
|
116
|
-
uname_str = ruby.open(
|
|
111
|
+
uname_str = ruby.open('|uname -a'){|out| out.read}
|
|
117
112
|
source {
|
|
118
113
|
uname uname_str
|
|
119
114
|
}
|
|
@@ -149,7 +144,5 @@ source {
|
|
|
149
144
|
}
|
|
150
145
|
DSL
|
|
151
146
|
assert_raise (NoMethodError) { Fluent::Config::DSL::Parser.parse(conf3) }
|
|
152
|
-
ensure
|
|
153
|
-
File.delete(tmpfile.path)
|
|
154
147
|
end
|
|
155
148
|
end
|
data/test/test_event_router.rb
CHANGED
|
@@ -175,7 +175,7 @@ class EventRouterTest < ::Test::Unit::TestCase
|
|
|
175
175
|
test "don't call default collector when tag matched" do
|
|
176
176
|
event_router.add_rule('test', output)
|
|
177
177
|
assert_rr do
|
|
178
|
-
|
|
178
|
+
dont_allow(default_collector).emit_events('test', is_a(OneEventStream))
|
|
179
179
|
event_router.emit('test', Engine.now, 'k' => 'v')
|
|
180
180
|
end
|
|
181
181
|
# check emit handler doesn't catch rr error
|
|
@@ -201,7 +201,7 @@ class EventRouterTest < ::Test::Unit::TestCase
|
|
|
201
201
|
event_router.add_rule('test', filter)
|
|
202
202
|
|
|
203
203
|
assert_rr do
|
|
204
|
-
|
|
204
|
+
dont_allow(filter).filter_stream('test', is_a(OneEventStream)) { events }
|
|
205
205
|
event_router.emit('foo', Engine.now, 'k' => 'v')
|
|
206
206
|
end
|
|
207
207
|
end
|
data/test/test_plugin_helper.rb
CHANGED
|
@@ -2,7 +2,7 @@ require_relative 'helper'
|
|
|
2
2
|
require 'fluent/plugin_helper'
|
|
3
3
|
require 'fluent/plugin/base'
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class ConfigTest < Test::Unit::TestCase
|
|
6
6
|
module FluentTest; end
|
|
7
7
|
|
|
8
8
|
sub_test_case 'Fluent::Plugin::Base.helpers method works as shortcut to include helper modules' do
|