fluentd 1.16.0 → 1.16.7
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/ISSUE_TEMPLATE/{bug_report.yaml → bug_report.yml} +1 -0
- data/.github/ISSUE_TEMPLATE/{feature_request.yaml → feature_request.yml} +1 -0
- data/.github/workflows/stale-actions.yml +24 -0
- data/.github/workflows/test.yml +39 -0
- data/CHANGELOG.md +161 -0
- data/CONTRIBUTING.md +1 -1
- data/MAINTAINERS.md +3 -3
- data/README.md +0 -2
- data/SECURITY.md +5 -9
- data/fluentd.gemspec +10 -2
- data/lib/fluent/command/ctl.rb +2 -2
- data/lib/fluent/command/fluentd.rb +1 -1
- data/lib/fluent/command/plugin_config_formatter.rb +1 -1
- data/lib/fluent/config/dsl.rb +1 -1
- data/lib/fluent/config/v1_parser.rb +2 -2
- data/lib/fluent/config/yaml_parser/parser.rb +4 -0
- data/lib/fluent/counter/server.rb +1 -1
- data/lib/fluent/counter/validator.rb +3 -3
- data/lib/fluent/engine.rb +1 -1
- data/lib/fluent/event.rb +8 -4
- data/lib/fluent/log.rb +9 -0
- data/lib/fluent/match.rb +1 -1
- data/lib/fluent/msgpack_factory.rb +6 -1
- data/lib/fluent/plugin/base.rb +1 -1
- data/lib/fluent/plugin/buffer.rb +96 -87
- data/lib/fluent/plugin/filter_record_transformer.rb +1 -1
- data/lib/fluent/plugin/in_forward.rb +1 -1
- data/lib/fluent/plugin/in_http.rb +8 -8
- data/lib/fluent/plugin/in_sample.rb +1 -1
- data/lib/fluent/plugin/in_tail/position_file.rb +32 -18
- data/lib/fluent/plugin/in_tail.rb +99 -31
- data/lib/fluent/plugin/in_tcp.rb +43 -0
- data/lib/fluent/plugin/out_exec_filter.rb +2 -2
- data/lib/fluent/plugin/out_file.rb +8 -0
- data/lib/fluent/plugin/output.rb +2 -2
- data/lib/fluent/plugin/parser_json.rb +4 -12
- data/lib/fluent/plugin_helper/event_loop.rb +2 -2
- data/lib/fluent/plugin_helper/record_accessor.rb +1 -1
- data/lib/fluent/plugin_helper/server.rb +8 -0
- data/lib/fluent/plugin_helper/thread.rb +3 -3
- data/lib/fluent/plugin_id.rb +1 -1
- data/lib/fluent/supervisor.rb +2 -2
- data/lib/fluent/system_config.rb +1 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +28 -3
- data/templates/new_gem/test/helper.rb.erb +0 -1
- data/test/command/test_cat.rb +2 -2
- data/test/command/test_fluentd.rb +65 -12
- data/test/config/test_system_config.rb +2 -2
- data/test/helper.rb +27 -7
- data/test/plugin/in_tail/test_io_handler.rb +13 -14
- data/test/plugin/in_tail/test_position_file.rb +37 -8
- 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_base.rb +1 -1
- data/test/plugin/test_buffer.rb +110 -0
- data/test/plugin/test_buffer_chunk.rb +11 -0
- data/test/plugin/test_in_forward.rb +11 -10
- data/test/plugin/test_in_http.rb +1 -1
- data/test/plugin/test_in_monitor_agent.rb +6 -6
- data/test/plugin/test_in_syslog.rb +25 -18
- data/test/plugin/test_in_tail.rb +639 -0
- data/test/plugin/test_in_tcp.rb +75 -5
- data/test/plugin/test_in_udp.rb +35 -1
- data/test/plugin/test_in_unix.rb +2 -2
- data/test/plugin/test_multi_output.rb +1 -1
- data/test/plugin/test_out_exec_filter.rb +14 -9
- data/test/plugin/test_out_file.rb +24 -4
- data/test/plugin/test_out_forward.rb +36 -42
- data/test/plugin/test_out_stream.rb +1 -1
- data/test/plugin/test_output.rb +12 -12
- data/test/plugin/test_output_as_buffered.rb +44 -44
- data/test/plugin/test_output_as_buffered_compress.rb +32 -18
- data/test/plugin/test_output_as_buffered_retries.rb +1 -1
- data/test/plugin/test_output_as_buffered_secondary.rb +2 -2
- data/test/plugin/test_parser_json.rb +31 -0
- data/test/plugin_helper/test_child_process.rb +15 -5
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_server.rb +110 -38
- data/test/plugin_helper/test_socket.rb +1 -1
- data/test/test_config.rb +6 -0
- data/test/test_event_router.rb +2 -2
- data/test/test_log.rb +38 -1
- data/test/test_msgpack_factory.rb +32 -0
- data/test/test_supervisor.rb +13 -0
- metadata +44 -17
- data/.github/workflows/linux-test.yaml +0 -36
- data/.github/workflows/macos-test.yaml +0 -34
- data/.github/workflows/windows-test.yaml +0 -49
|
@@ -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(protocol: :tcp)
|
|
19
19
|
if Fluent.windows?
|
|
20
20
|
@socket_manager_server = ServerEngine::SocketManager::Server.open
|
|
21
21
|
@socket_manager_path = @socket_manager_server.path
|
|
@@ -29,6 +29,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
29
29
|
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @socket_manager_path.to_s
|
|
30
30
|
|
|
31
31
|
@d = Dummy.new
|
|
32
|
+
@d.under_plugin_development = true
|
|
32
33
|
@d.start
|
|
33
34
|
@d.after_start
|
|
34
35
|
end
|
|
@@ -232,11 +233,12 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
232
233
|
# 'server_create_connection tcp' => [:server_create_connection, :unix],
|
|
233
234
|
)
|
|
234
235
|
test 'raise error if udp options specified for tcp/tls/unix' do |(m, proto)|
|
|
236
|
+
port = unused_port(protocol: proto)
|
|
235
237
|
assert_raise ArgumentError do
|
|
236
|
-
@d.__send__(m, :myserver,
|
|
238
|
+
@d.__send__(m, :myserver, port, proto: proto, max_bytes: 128){|x| x }
|
|
237
239
|
end
|
|
238
240
|
assert_raise ArgumentError do
|
|
239
|
-
@d.__send__(m, :myserver,
|
|
241
|
+
@d.__send__(m, :myserver, port, proto: proto, flags: 1){|x| x }
|
|
240
242
|
end
|
|
241
243
|
end
|
|
242
244
|
|
|
@@ -244,8 +246,9 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
244
246
|
'server_create udp' => [:server_create, :udp],
|
|
245
247
|
)
|
|
246
248
|
test 'raise error if tcp/tls options specified for udp' do |(m, proto)|
|
|
249
|
+
port = unused_port(protocol: proto)
|
|
247
250
|
assert_raise(ArgumentError.new("BUG: linger_timeout is available for tcp/tls")) do
|
|
248
|
-
@d.__send__(m, :myserver,
|
|
251
|
+
@d.__send__(m, :myserver, port, proto: proto, linger_timeout: 1, max_bytes: 128){|x| x }
|
|
249
252
|
end
|
|
250
253
|
end
|
|
251
254
|
|
|
@@ -253,8 +256,9 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
253
256
|
'server_create udp' => [:server_create, :udp],
|
|
254
257
|
)
|
|
255
258
|
test 'raise error if tcp/tls/unix backlog options specified for udp' do |(m, proto)|
|
|
259
|
+
port = unused_port(protocol: proto)
|
|
256
260
|
assert_raise(ArgumentError.new("BUG: backlog is available for tcp/tls")) do
|
|
257
|
-
@d.__send__(m, :myserver,
|
|
261
|
+
@d.__send__(m, :myserver, port, proto: proto, backlog: 500){|x| x }
|
|
258
262
|
end
|
|
259
263
|
end
|
|
260
264
|
|
|
@@ -262,8 +266,9 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
262
266
|
'server_create udp' => [:server_create, :udp],
|
|
263
267
|
)
|
|
264
268
|
test 'raise error if tcp/tls send_keepalive_packet option is specified for udp' do |(m, proto)|
|
|
269
|
+
port = unused_port(protocol: proto)
|
|
265
270
|
assert_raise(ArgumentError.new("BUG: send_keepalive_packet is available for tcp/tls")) do
|
|
266
|
-
@d.__send__(m, :myserver,
|
|
271
|
+
@d.__send__(m, :myserver, port, proto: proto, send_keepalive_packet: true){|x| x }
|
|
267
272
|
end
|
|
268
273
|
end
|
|
269
274
|
|
|
@@ -275,8 +280,9 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
275
280
|
# 'server_create_connection unix' => [:server_create_connection, :unix, {}],
|
|
276
281
|
)
|
|
277
282
|
test 'raise error if tls options specified for tcp/udp/unix' do |(m, proto, kwargs)|
|
|
283
|
+
port = unused_port(protocol: proto)
|
|
278
284
|
assert_raise(ArgumentError.new("BUG: tls_options is available only for tls")) do
|
|
279
|
-
@d.__send__(m, :myserver,
|
|
285
|
+
@d.__send__(m, :myserver, port, proto: proto, tls_options: {}, **kwargs){|x| x }
|
|
280
286
|
end
|
|
281
287
|
end
|
|
282
288
|
|
|
@@ -288,7 +294,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
288
294
|
'server_create_connection tls' => [:server_create_connection, :tls, {tls_options: {insecure: true}}],
|
|
289
295
|
)
|
|
290
296
|
test 'can bind specified IPv4 address' do |(m, proto, kwargs)|
|
|
291
|
-
|
|
297
|
+
port = unused_port(protocol: proto)
|
|
298
|
+
@d.__send__(m, :myserver, port, proto: proto, bind: "127.0.0.1", **kwargs){|x| x }
|
|
292
299
|
assert_equal "127.0.0.1", @d._servers.first.bind
|
|
293
300
|
assert_equal "127.0.0.1", @d._servers.first.server.instance_eval{ instance_variable_defined?(:@listen_socket) ? @listen_socket : @_io }.addr[3]
|
|
294
301
|
end
|
|
@@ -302,7 +309,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
302
309
|
)
|
|
303
310
|
test 'can bind specified IPv6 address' do |(m, proto, kwargs)| # if available
|
|
304
311
|
omit "IPv6 unavailable here" unless ipv6_enabled?
|
|
305
|
-
|
|
312
|
+
port = unused_port(protocol: proto)
|
|
313
|
+
@d.__send__(m, :myserver, port, proto: proto, bind: "::1", **kwargs){|x| x }
|
|
306
314
|
assert_equal "::1", @d._servers.first.bind
|
|
307
315
|
assert_equal "::1", @d._servers.first.server.instance_eval{ instance_variable_defined?(:@listen_socket) ? @listen_socket : @_io }.addr[3]
|
|
308
316
|
end
|
|
@@ -319,10 +327,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
319
327
|
test 'can create 2 or more servers which share same bind address and port if shared option is true' do |(m, proto, kwargs)|
|
|
320
328
|
begin
|
|
321
329
|
d2 = Dummy.new; d2.start; d2.after_start
|
|
330
|
+
port = unused_port(protocol: proto)
|
|
322
331
|
|
|
323
332
|
assert_nothing_raised do
|
|
324
|
-
@d.__send__(m, :myserver,
|
|
325
|
-
d2.__send__(m, :myserver,
|
|
333
|
+
@d.__send__(m, :myserver, port, proto: proto, **kwargs){|x| x }
|
|
334
|
+
d2.__send__(m, :myserver, port, proto: proto, **kwargs){|x| x }
|
|
326
335
|
end
|
|
327
336
|
ensure
|
|
328
337
|
d2.stop; d2.before_shutdown; d2.shutdown; d2.after_shutdown; d2.close; d2.terminate
|
|
@@ -343,12 +352,13 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
343
352
|
test 'cannot create 2 or more servers using same bind address and port if shared option is false' do |(m, proto, kwargs)|
|
|
344
353
|
begin
|
|
345
354
|
d2 = Dummy.new; d2.start; d2.after_start
|
|
355
|
+
port = unused_port(protocol: proto)
|
|
346
356
|
|
|
347
357
|
assert_nothing_raised do
|
|
348
|
-
@d.__send__(m, :myserver,
|
|
358
|
+
@d.__send__(m, :myserver, port, proto: proto, shared: false, **kwargs){|x| x }
|
|
349
359
|
end
|
|
350
360
|
assert_raise(Errno::EADDRINUSE, Errno::EACCES) do
|
|
351
|
-
d2.__send__(m, :myserver,
|
|
361
|
+
d2.__send__(m, :myserver, port, proto: proto, **kwargs){|x| x }
|
|
352
362
|
end
|
|
353
363
|
ensure
|
|
354
364
|
d2.stop; d2.before_shutdown; d2.shutdown; d2.after_shutdown; d2.close; d2.terminate
|
|
@@ -364,16 +374,18 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
364
374
|
# 'unix' => [:unix, {}],
|
|
365
375
|
)
|
|
366
376
|
test 'raise error if block argument is not specified or too many' do |(proto, kwargs)|
|
|
377
|
+
port = unused_port(protocol: proto)
|
|
367
378
|
assert_raise(ArgumentError.new("BUG: block must have 1 or 2 arguments")) do
|
|
368
|
-
@d.server_create(:myserver,
|
|
379
|
+
@d.server_create(:myserver, port, proto: proto, **kwargs){ 1 }
|
|
369
380
|
end
|
|
370
381
|
assert_raise(ArgumentError.new("BUG: block must have 1 or 2 arguments")) do
|
|
371
|
-
@d.server_create(:myserver,
|
|
382
|
+
@d.server_create(:myserver, port, proto: proto, **kwargs){|sock, conn, what_is_this| 1 }
|
|
372
383
|
end
|
|
373
384
|
end
|
|
374
385
|
|
|
375
386
|
test 'creates udp server if specified in proto' do
|
|
376
|
-
|
|
387
|
+
port = unused_port(protocol: :udp)
|
|
388
|
+
@d.server_create(:myserver, port, proto: :udp, max_bytes: 512){|x| x }
|
|
377
389
|
|
|
378
390
|
created_server_info = @d._servers.first
|
|
379
391
|
assert_equal :udp, created_server_info.proto
|
|
@@ -586,7 +598,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
586
598
|
sub_test_case '#server_create_udp' do
|
|
587
599
|
test 'can accept all keyword arguments valid for udp server' do
|
|
588
600
|
assert_nothing_raised do
|
|
589
|
-
|
|
601
|
+
port = unused_port(protocol: :udp)
|
|
602
|
+
@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
603
|
# ...
|
|
591
604
|
end
|
|
592
605
|
end
|
|
@@ -594,14 +607,15 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
594
607
|
|
|
595
608
|
test 'creates a udp server just to read data' do
|
|
596
609
|
received = ""
|
|
597
|
-
|
|
610
|
+
port = unused_port(protocol: :udp)
|
|
611
|
+
@d.server_create_udp(:s, port, max_bytes: 128) do |data|
|
|
598
612
|
received << data
|
|
599
613
|
end
|
|
600
614
|
bind_port = unused_port(protocol: :udp, bind: "127.0.0.1")
|
|
601
615
|
3.times do
|
|
602
616
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
603
617
|
sock.bind("127.0.0.1", bind_port)
|
|
604
|
-
sock.connect("127.0.0.1",
|
|
618
|
+
sock.connect("127.0.0.1", port)
|
|
605
619
|
sock.puts "yay"
|
|
606
620
|
sock.puts "foo"
|
|
607
621
|
sock.close
|
|
@@ -613,16 +627,17 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
613
627
|
test 'creates a udp server to read and write data' do
|
|
614
628
|
received = ""
|
|
615
629
|
responses = []
|
|
616
|
-
|
|
630
|
+
port = unused_port(protocol: :udp)
|
|
631
|
+
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
617
632
|
received << data
|
|
618
633
|
sock.write "ack\n"
|
|
619
634
|
end
|
|
620
|
-
bind_port = unused_port
|
|
635
|
+
bind_port = unused_port(protocol: :udp)
|
|
621
636
|
3.times do
|
|
622
637
|
begin
|
|
623
638
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
624
639
|
sock.bind("127.0.0.1", bind_port)
|
|
625
|
-
sock.connect("127.0.0.1",
|
|
640
|
+
sock.connect("127.0.0.1", port)
|
|
626
641
|
th = Thread.new do
|
|
627
642
|
while true
|
|
628
643
|
begin
|
|
@@ -653,11 +668,12 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
653
668
|
|
|
654
669
|
received = ""
|
|
655
670
|
responses = []
|
|
656
|
-
|
|
671
|
+
port = unused_port(protocol: :udp)
|
|
672
|
+
@d.server_create_udp(:s, port, bind: "::1", max_bytes: 128) do |data, sock|
|
|
657
673
|
received << data
|
|
658
674
|
sock.write "ack\n"
|
|
659
675
|
end
|
|
660
|
-
bind_port = unused_port
|
|
676
|
+
bind_port = unused_port(protocol: :udp)
|
|
661
677
|
3.times do
|
|
662
678
|
begin
|
|
663
679
|
sock = UDPSocket.new(Socket::AF_INET6)
|
|
@@ -666,7 +682,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
666
682
|
responses << sock.recv(16)
|
|
667
683
|
true
|
|
668
684
|
end
|
|
669
|
-
sock.connect("::1",
|
|
685
|
+
sock.connect("::1", port)
|
|
670
686
|
sock.write "yay\nfoo\n"
|
|
671
687
|
th.join(5)
|
|
672
688
|
ensure
|
|
@@ -681,13 +697,14 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
681
697
|
test 'does not resolve name of client address in default' do
|
|
682
698
|
received = ""
|
|
683
699
|
sources = []
|
|
684
|
-
|
|
700
|
+
port = unused_port(protocol: :udp)
|
|
701
|
+
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
685
702
|
received << data
|
|
686
703
|
sources << sock.remote_host
|
|
687
704
|
end
|
|
688
705
|
3.times do
|
|
689
706
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
690
|
-
sock.connect("127.0.0.1",
|
|
707
|
+
sock.connect("127.0.0.1", port)
|
|
691
708
|
sock.puts "yay"
|
|
692
709
|
sock.close
|
|
693
710
|
end
|
|
@@ -701,13 +718,14 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
701
718
|
|
|
702
719
|
received = ""
|
|
703
720
|
sources = []
|
|
704
|
-
|
|
721
|
+
port = unused_port(protocol: :udp)
|
|
722
|
+
@d.server_create_udp(:s, port, resolve_name: true, max_bytes: 128) do |data, sock|
|
|
705
723
|
received << data
|
|
706
724
|
sources << sock.remote_host
|
|
707
725
|
end
|
|
708
726
|
3.times do
|
|
709
727
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
710
|
-
sock.connect("127.0.0.1",
|
|
728
|
+
sock.connect("127.0.0.1", port)
|
|
711
729
|
sock.puts "yay"
|
|
712
730
|
sock.close
|
|
713
731
|
end
|
|
@@ -719,7 +737,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
719
737
|
test 'raises error if plugin registers data callback for connection object from #server_create' do
|
|
720
738
|
received = ""
|
|
721
739
|
errors = []
|
|
722
|
-
|
|
740
|
+
port = unused_port(protocol: :udp)
|
|
741
|
+
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
723
742
|
received << data
|
|
724
743
|
begin
|
|
725
744
|
sock.data{|d| received << d.upcase }
|
|
@@ -728,7 +747,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
728
747
|
end
|
|
729
748
|
end
|
|
730
749
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
731
|
-
sock.connect("127.0.0.1",
|
|
750
|
+
sock.connect("127.0.0.1", port)
|
|
732
751
|
sock.write "foo\n"
|
|
733
752
|
sock.close
|
|
734
753
|
|
|
@@ -741,7 +760,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
741
760
|
test 'raise error if plugin registers write_complete callback for udp' do
|
|
742
761
|
received = ""
|
|
743
762
|
errors = []
|
|
744
|
-
|
|
763
|
+
port = unused_port(protocol: :udp)
|
|
764
|
+
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
745
765
|
received << data
|
|
746
766
|
begin
|
|
747
767
|
sock.on(:write_complete){|conn| "" }
|
|
@@ -750,7 +770,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
750
770
|
end
|
|
751
771
|
end
|
|
752
772
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
753
|
-
sock.connect("127.0.0.1",
|
|
773
|
+
sock.connect("127.0.0.1", port)
|
|
754
774
|
sock.write "foo\n"
|
|
755
775
|
sock.close
|
|
756
776
|
|
|
@@ -763,7 +783,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
763
783
|
test 'raises error if plugin registers close callback for udp' do
|
|
764
784
|
received = ""
|
|
765
785
|
errors = []
|
|
766
|
-
|
|
786
|
+
port = unused_port(protocol: :udp)
|
|
787
|
+
@d.server_create_udp(:s, port, max_bytes: 128) do |data, sock|
|
|
767
788
|
received << data
|
|
768
789
|
begin
|
|
769
790
|
sock.on(:close){|d| "" }
|
|
@@ -772,7 +793,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
772
793
|
end
|
|
773
794
|
end
|
|
774
795
|
sock = UDPSocket.new(Socket::AF_INET)
|
|
775
|
-
sock.connect("127.0.0.1",
|
|
796
|
+
sock.connect("127.0.0.1", port)
|
|
776
797
|
sock.write "foo\n"
|
|
777
798
|
sock.close
|
|
778
799
|
|
|
@@ -785,15 +806,62 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
785
806
|
test 'can bind IPv4 / IPv6 together' do
|
|
786
807
|
omit "IPv6 unavailable here" unless ipv6_enabled?
|
|
787
808
|
|
|
809
|
+
port = unused_port(protocol: :udp)
|
|
788
810
|
assert_nothing_raised do
|
|
789
|
-
@d.server_create_udp(:s_ipv4_udp,
|
|
811
|
+
@d.server_create_udp(:s_ipv4_udp, port, bind: '0.0.0.0', shared: false, max_bytes: 128) do |data, sock|
|
|
790
812
|
# ...
|
|
791
813
|
end
|
|
792
|
-
@d.server_create_udp(:s_ipv6_udp,
|
|
814
|
+
@d.server_create_udp(:s_ipv6_udp, port, bind: '::', shared: false, max_bytes: 128) do |data, sock|
|
|
793
815
|
# ...
|
|
794
816
|
end
|
|
795
817
|
end
|
|
796
818
|
end
|
|
819
|
+
|
|
820
|
+
sub_test_case 'over max_bytes' do
|
|
821
|
+
data("cut off on Non-Windows", { max_bytes: 32, records: ["a" * 40], expected: ["a" * 32] }, keep: true) unless Fluent.windows?
|
|
822
|
+
data("drop on Windows", { max_bytes: 32, records: ["a" * 40], expected: [] }, keep: true) if Fluent.windows?
|
|
823
|
+
test 'with sock' do |data|
|
|
824
|
+
max_bytes, records, expected = data.values
|
|
825
|
+
|
|
826
|
+
actual_records = []
|
|
827
|
+
port = unused_port(protocol: :udp)
|
|
828
|
+
@d.server_create_udp(:myserver, port, max_bytes: max_bytes) do |data, sock|
|
|
829
|
+
actual_records << data
|
|
830
|
+
end
|
|
831
|
+
|
|
832
|
+
open_client(:udp, "127.0.0.1", port) do |sock|
|
|
833
|
+
records.each do |record|
|
|
834
|
+
sock.send(record, 0)
|
|
835
|
+
end
|
|
836
|
+
end
|
|
837
|
+
|
|
838
|
+
waiting(10) { sleep 0.1 until actual_records.size >= expected.size }
|
|
839
|
+
sleep 1 if expected.size == 0 # To confirm no record recieved.
|
|
840
|
+
|
|
841
|
+
assert_equal expected, actual_records
|
|
842
|
+
end
|
|
843
|
+
|
|
844
|
+
test 'without sock' do |data|
|
|
845
|
+
max_bytes, records, expected = data.values
|
|
846
|
+
|
|
847
|
+
actual_records = []
|
|
848
|
+
port = unused_port(protocol: :udp)
|
|
849
|
+
@d.server_create_udp(:myserver, port, max_bytes: max_bytes) do |data|
|
|
850
|
+
actual_records << data
|
|
851
|
+
end
|
|
852
|
+
|
|
853
|
+
open_client(:udp, "127.0.0.1", port) do |sock|
|
|
854
|
+
records.each do |record|
|
|
855
|
+
sock.send(record, 0)
|
|
856
|
+
end
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
waiting(10) { sleep 0.1 until actual_records.size >= expected.size }
|
|
860
|
+
sleep 1 if expected.size == 0 # To confirm no record recieved.
|
|
861
|
+
|
|
862
|
+
assert_equal expected, actual_records
|
|
863
|
+
end
|
|
864
|
+
end
|
|
797
865
|
end
|
|
798
866
|
|
|
799
867
|
module CertUtil
|
|
@@ -1284,7 +1352,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
1284
1352
|
# OpenSSL 1.1.1: "TLSv1.2"
|
|
1285
1353
|
if tls_version == "TLSv1/SSLv3" || tls_version == "TLSv1.2"
|
|
1286
1354
|
matched = true
|
|
1287
|
-
unless cipher_name.match(/#{conf.ciphers}/)
|
|
1355
|
+
unless cipher_name.match?(/#{conf.ciphers}/)
|
|
1288
1356
|
matched = false
|
|
1289
1357
|
break
|
|
1290
1358
|
end
|
|
@@ -1575,6 +1643,10 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
|
1575
1643
|
|
|
1576
1644
|
def open_client(proto, addr, port)
|
|
1577
1645
|
client = case proto
|
|
1646
|
+
when :udp
|
|
1647
|
+
c = UDPSocket.open
|
|
1648
|
+
c.connect(addr, port)
|
|
1649
|
+
c
|
|
1578
1650
|
when :tcp
|
|
1579
1651
|
TCPSocket.open(addr, port)
|
|
1580
1652
|
when :tls
|
data/test/test_config.rb
CHANGED
|
@@ -167,6 +167,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
167
167
|
tag: tag.dummy
|
|
168
168
|
- source:
|
|
169
169
|
$type: tcp
|
|
170
|
+
$log_level: info
|
|
170
171
|
tag: tag.tcp
|
|
171
172
|
parse:
|
|
172
173
|
$arg:
|
|
@@ -176,6 +177,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
176
177
|
- match:
|
|
177
178
|
$tag: tag.*
|
|
178
179
|
$type: stdout
|
|
180
|
+
$log_level: debug
|
|
179
181
|
buffer:
|
|
180
182
|
$type: memory
|
|
181
183
|
flush_interval: 1s
|
|
@@ -208,10 +210,12 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
208
210
|
'tag.dummy',
|
|
209
211
|
'tcp',
|
|
210
212
|
'tag.tcp',
|
|
213
|
+
'info',
|
|
211
214
|
'none',
|
|
212
215
|
'why.parse.section.doesnot.have.arg,huh',
|
|
213
216
|
'stdout',
|
|
214
217
|
'tag.*',
|
|
218
|
+
'debug',
|
|
215
219
|
'null',
|
|
216
220
|
'**',
|
|
217
221
|
'@FLUENT_LOG',
|
|
@@ -224,10 +228,12 @@ class ConfigTest < Test::Unit::TestCase
|
|
|
224
228
|
dummy_source_conf['tag'],
|
|
225
229
|
tcp_source_conf['@type'],
|
|
226
230
|
tcp_source_conf['tag'],
|
|
231
|
+
tcp_source_conf['@log_level'],
|
|
227
232
|
parse_tcp_conf['@type'],
|
|
228
233
|
parse_tcp_conf.arg,
|
|
229
234
|
match_conf['@type'],
|
|
230
235
|
match_conf.arg,
|
|
236
|
+
match_conf['@log_level'],
|
|
231
237
|
fluent_log_conf['@type'],
|
|
232
238
|
fluent_log_conf.arg,
|
|
233
239
|
label_conf.arg,
|
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
|
+
mock(default_collector).emit_events('test', is_a(OneEventStream)).never
|
|
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
|
+
mock(filter).filter_stream('test', is_a(OneEventStream)).never
|
|
205
205
|
event_router.emit('foo', Engine.now, 'k' => 'v')
|
|
206
206
|
end
|
|
207
207
|
end
|
data/test/test_log.rb
CHANGED
|
@@ -472,6 +472,43 @@ class LogTest < Test::Unit::TestCase
|
|
|
472
472
|
]
|
|
473
473
|
assert_equal(expected, log.out.logs)
|
|
474
474
|
end
|
|
475
|
+
|
|
476
|
+
def test_reject_on_max_size
|
|
477
|
+
ignore_same_log_interval = 10
|
|
478
|
+
|
|
479
|
+
logger = Fluent::Log.new(
|
|
480
|
+
ServerEngine::DaemonLogger.new(@log_device, log_level: ServerEngine::DaemonLogger::INFO),
|
|
481
|
+
ignore_same_log_interval: ignore_same_log_interval,
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
# Output unique log every second.
|
|
485
|
+
Fluent::Log::IGNORE_SAME_LOG_MAX_CACHE_SIZE.times do |i|
|
|
486
|
+
logger.info "Test #{i}"
|
|
487
|
+
Timecop.freeze(@timestamp + i)
|
|
488
|
+
end
|
|
489
|
+
logger.info "Over max size!"
|
|
490
|
+
|
|
491
|
+
# The newest cache and the latest caches in `ignore_same_log_interval` should exist.
|
|
492
|
+
assert { Thread.current[:last_same_log].size == ignore_same_log_interval + 1 }
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def test_clear_on_max_size
|
|
496
|
+
ignore_same_log_interval = 10
|
|
497
|
+
|
|
498
|
+
logger = Fluent::Log.new(
|
|
499
|
+
ServerEngine::DaemonLogger.new(@log_device, log_level: ServerEngine::DaemonLogger::INFO),
|
|
500
|
+
ignore_same_log_interval: ignore_same_log_interval,
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
# Output unique log at the same time.
|
|
504
|
+
Fluent::Log::IGNORE_SAME_LOG_MAX_CACHE_SIZE.times do |i|
|
|
505
|
+
logger.info "Test #{i}"
|
|
506
|
+
end
|
|
507
|
+
logger.info "Over max size!"
|
|
508
|
+
|
|
509
|
+
# Can't reject old logs, so all cache should be cleared and only the newest should exist.
|
|
510
|
+
assert { Thread.current[:last_same_log].size == 1 }
|
|
511
|
+
end
|
|
475
512
|
end
|
|
476
513
|
|
|
477
514
|
def test_dup
|
|
@@ -660,7 +697,7 @@ class LogTest < Test::Unit::TestCase
|
|
|
660
697
|
log.reopen!
|
|
661
698
|
log.info message
|
|
662
699
|
|
|
663
|
-
assert { path.read.lines.
|
|
700
|
+
assert { path.read.lines.count{ |line| line.include?(message) } == 2 }
|
|
664
701
|
# Assert reopening the same file.
|
|
665
702
|
# Especially, on Windows, the filepath is fixed for each process with rotate,
|
|
666
703
|
# so we need to care about this.
|
|
@@ -15,4 +15,36 @@ class MessagePackFactoryTest < Test::Unit::TestCase
|
|
|
15
15
|
assert mp.msgpack_factory
|
|
16
16
|
assert mp.msgpack_factory
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
sub_test_case 'thread_local_msgpack_packer' do
|
|
20
|
+
test 'packer is cached' do
|
|
21
|
+
packer1 = Fluent::MessagePackFactory.thread_local_msgpack_packer
|
|
22
|
+
packer2 = Fluent::MessagePackFactory.thread_local_msgpack_packer
|
|
23
|
+
assert_equal packer1, packer2
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
sub_test_case 'thread_local_msgpack_unpacker' do
|
|
28
|
+
test 'unpacker is cached' do
|
|
29
|
+
unpacker1 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
30
|
+
unpacker2 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
31
|
+
assert_equal unpacker1, unpacker2
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# We need to reset the buffer every time so that received incomplete data
|
|
35
|
+
# must not affect data from other senders.
|
|
36
|
+
test 'reset the internal buffer of unpacker every time' do
|
|
37
|
+
unpacker1 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
38
|
+
unpacker1.feed_each("\xA6foo") do |result|
|
|
39
|
+
flunk("This callback must not be called since the data is uncomplete.")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
records = []
|
|
43
|
+
unpacker2 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
44
|
+
unpacker2.feed_each("\xA3foo") do |result|
|
|
45
|
+
records.append(result)
|
|
46
|
+
end
|
|
47
|
+
assert_equal ["foo"], records
|
|
48
|
+
end
|
|
49
|
+
end
|
|
18
50
|
end
|
data/test/test_supervisor.rb
CHANGED
|
@@ -621,6 +621,19 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
|
621
621
|
assert_equal 10, $log.out.instance_variable_get(:@shift_size)
|
|
622
622
|
end
|
|
623
623
|
|
|
624
|
+
def test_can_start_with_rotate_but_no_log_path
|
|
625
|
+
config_path = "#{@tmp_dir}/empty.conf"
|
|
626
|
+
write_config config_path, ""
|
|
627
|
+
|
|
628
|
+
sv = Fluent::Supervisor.new(
|
|
629
|
+
config_path: config_path,
|
|
630
|
+
log_rotate_age: 5,
|
|
631
|
+
)
|
|
632
|
+
sv.__send__(:setup_global_logger)
|
|
633
|
+
|
|
634
|
+
assert_true $log.stdout?
|
|
635
|
+
end
|
|
636
|
+
|
|
624
637
|
sub_test_case "system log rotation" do
|
|
625
638
|
def parse_text(text)
|
|
626
639
|
basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
|