fluentd 1.15.2-x64-mingw-ucrt → 1.16.0-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linux-test.yaml +2 -2
- data/.github/workflows/macos-test.yaml +2 -2
- data/.github/workflows/windows-test.yaml +2 -2
- data/CHANGELOG.md +96 -0
- data/MAINTAINERS.md +2 -0
- data/README.md +0 -1
- data/fluentd.gemspec +2 -2
- data/lib/fluent/command/fluentd.rb +55 -64
- data/lib/fluent/config/yaml_parser/loader.rb +18 -1
- data/lib/fluent/daemon.rb +2 -4
- data/lib/fluent/file_wrapper.rb +137 -0
- data/lib/fluent/log/console_adapter.rb +66 -0
- data/lib/fluent/log.rb +35 -5
- data/lib/fluent/oj_options.rb +1 -2
- data/lib/fluent/plugin/base.rb +5 -7
- data/lib/fluent/plugin/buf_file.rb +32 -3
- data/lib/fluent/plugin/buf_file_single.rb +32 -3
- data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
- data/lib/fluent/plugin/buffer.rb +21 -0
- data/lib/fluent/plugin/in_tail.rb +1 -6
- data/lib/fluent/plugin/in_tcp.rb +4 -2
- data/lib/fluent/plugin/out_file.rb +0 -4
- data/lib/fluent/plugin/out_forward/ack_handler.rb +19 -4
- data/lib/fluent/plugin/out_forward.rb +2 -2
- data/lib/fluent/plugin/out_secondary_file.rb +39 -22
- data/lib/fluent/plugin/output.rb +49 -12
- data/lib/fluent/plugin_helper/http_server/server.rb +2 -1
- data/lib/fluent/supervisor.rb +157 -232
- data/lib/fluent/test/driver/base.rb +11 -5
- data/lib/fluent/test/driver/filter.rb +4 -0
- data/lib/fluent/test/startup_shutdown.rb +6 -8
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_ctl.rb +1 -1
- data/test/command/test_fluentd.rb +168 -22
- data/test/command/test_plugin_config_formatter.rb +0 -1
- data/test/compat/test_parser.rb +5 -5
- data/test/config/test_system_config.rb +0 -8
- data/test/log/test_console_adapter.rb +110 -0
- data/test/plugin/out_forward/test_ack_handler.rb +39 -0
- data/test/plugin/test_base.rb +98 -0
- data/test/plugin/test_buf_file.rb +62 -23
- data/test/plugin/test_buf_file_single.rb +65 -0
- data/test/plugin/test_in_http.rb +2 -3
- data/test/plugin/test_in_monitor_agent.rb +2 -3
- data/test/plugin/test_in_tail.rb +105 -103
- data/test/plugin/test_in_tcp.rb +15 -0
- data/test/plugin/test_out_file.rb +3 -2
- data/test/plugin/test_out_forward.rb +14 -18
- data/test/plugin/test_out_http.rb +1 -0
- data/test/plugin/test_output.rb +269 -0
- data/test/plugin/test_parser_regexp.rb +1 -6
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_server.rb +10 -5
- data/test/test_config.rb +57 -21
- data/test/{plugin/test_file_wrapper.rb → test_file_wrapper.rb} +2 -2
- data/test/test_formatter.rb +23 -20
- data/test/test_log.rb +85 -40
- data/test/test_supervisor.rb +300 -283
- metadata +15 -24
- data/.drone.yml +0 -35
- data/.github/workflows/issue-auto-closer.yml +0 -12
- data/.github/workflows/stale-actions.yml +0 -22
- data/.gitlab-ci.yml +0 -103
- data/lib/fluent/plugin/file_wrapper.rb +0 -131
- data/test/test_logger_initializer.rb +0 -46
data/test/test_formatter.rb
CHANGED
@@ -18,7 +18,7 @@ module FormatterTest
|
|
18
18
|
|
19
19
|
def test_call
|
20
20
|
formatter = Formatter.new
|
21
|
-
formatter.configure(
|
21
|
+
formatter.configure(config_element())
|
22
22
|
assert_raise NotImplementedError do
|
23
23
|
formatter.format('tag', Engine.now, {})
|
24
24
|
end
|
@@ -130,7 +130,7 @@ module FormatterTest
|
|
130
130
|
include FormatterTest
|
131
131
|
|
132
132
|
def setup
|
133
|
-
@formatter = TextFormatter::MessagePackFormatter
|
133
|
+
@formatter = Fluent::Test::FormatterTestDriver.new(TextFormatter::MessagePackFormatter)
|
134
134
|
@time = Engine.now
|
135
135
|
end
|
136
136
|
|
@@ -146,7 +146,7 @@ module FormatterTest
|
|
146
146
|
include FormatterTest
|
147
147
|
|
148
148
|
def setup
|
149
|
-
@formatter = TextFormatter::LabeledTSVFormatter
|
149
|
+
@formatter = Fluent::Test::FormatterTestDriver.new(TextFormatter::LabeledTSVFormatter)
|
150
150
|
@time = Engine.now
|
151
151
|
@newline = if Fluent.windows?
|
152
152
|
"\r\n"
|
@@ -156,16 +156,16 @@ module FormatterTest
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def test_config_params
|
159
|
-
assert_equal "\t", @formatter.delimiter
|
160
|
-
assert_equal ":", @formatter.label_delimiter
|
159
|
+
assert_equal "\t", @formatter.instance.delimiter
|
160
|
+
assert_equal ":", @formatter.instance.label_delimiter
|
161
161
|
|
162
162
|
@formatter.configure(
|
163
163
|
'delimiter' => ',',
|
164
164
|
'label_delimiter' => '=',
|
165
165
|
)
|
166
166
|
|
167
|
-
assert_equal ",", @formatter.delimiter
|
168
|
-
assert_equal "=", @formatter.label_delimiter
|
167
|
+
assert_equal ",", @formatter.instance.delimiter
|
168
|
+
assert_equal "=", @formatter.instance.label_delimiter
|
169
169
|
end
|
170
170
|
|
171
171
|
def test_format
|
@@ -220,14 +220,14 @@ module FormatterTest
|
|
220
220
|
include FormatterTest
|
221
221
|
|
222
222
|
def setup
|
223
|
-
@formatter = TextFormatter::CsvFormatter
|
223
|
+
@formatter = Fluent::Test::FormatterTestDriver.new(TextFormatter::CsvFormatter)
|
224
224
|
@time = Engine.now
|
225
225
|
end
|
226
226
|
|
227
227
|
def test_config_params
|
228
|
-
assert_equal ',', @formatter.delimiter
|
229
|
-
assert_equal true, @formatter.force_quotes
|
230
|
-
assert_nil @formatter.fields
|
228
|
+
assert_equal ',', @formatter.instance.delimiter
|
229
|
+
assert_equal true, @formatter.instance.force_quotes
|
230
|
+
assert_nil @formatter.instance.fields
|
231
231
|
end
|
232
232
|
|
233
233
|
data(
|
@@ -237,8 +237,8 @@ module FormatterTest
|
|
237
237
|
def test_config_params_with_customized_delimiters(data)
|
238
238
|
expected, target = data
|
239
239
|
@formatter.configure('delimiter' => target, 'fields' => 'a,b,c')
|
240
|
-
assert_equal expected, @formatter.delimiter
|
241
|
-
assert_equal ['a', 'b', 'c'], @formatter.fields
|
240
|
+
assert_equal expected, @formatter.instance.delimiter
|
241
|
+
assert_equal ['a', 'b', 'c'], @formatter.instance.fields
|
242
242
|
end
|
243
243
|
|
244
244
|
def test_format
|
@@ -299,7 +299,7 @@ module FormatterTest
|
|
299
299
|
'blank' => 'one,,two,three')
|
300
300
|
def test_config_params_with_fields(data)
|
301
301
|
@formatter.configure('fields' => data)
|
302
|
-
assert_equal %w(one two three), @formatter.fields
|
302
|
+
assert_equal %w(one two three), @formatter.instance.fields
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
@@ -313,31 +313,34 @@ module FormatterTest
|
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
|
+
def create_driver(klass_or_str)
|
317
|
+
Fluent::Test::FormatterTestDriver.new(klass_or_str)
|
318
|
+
end
|
316
319
|
|
317
320
|
def test_config_params
|
318
|
-
formatter = TextFormatter::SingleValueFormatter
|
319
|
-
assert_equal "message", formatter.message_key
|
321
|
+
formatter = create_driver(TextFormatter::SingleValueFormatter)
|
322
|
+
assert_equal "message", formatter.instance.message_key
|
320
323
|
|
321
324
|
formatter.configure('message_key' => 'foobar')
|
322
|
-
assert_equal "foobar", formatter.message_key
|
325
|
+
assert_equal "foobar", formatter.instance.message_key
|
323
326
|
end
|
324
327
|
|
325
328
|
def test_format
|
326
|
-
formatter =
|
329
|
+
formatter = create_driver('single_value')
|
327
330
|
formatter.configure({})
|
328
331
|
formatted = formatter.format('tag', Engine.now, {'message' => 'awesome'})
|
329
332
|
assert_equal("awesome#{@newline}", formatted)
|
330
333
|
end
|
331
334
|
|
332
335
|
def test_format_without_newline
|
333
|
-
formatter =
|
336
|
+
formatter = create_driver('single_value')
|
334
337
|
formatter.configure('add_newline' => 'false')
|
335
338
|
formatted = formatter.format('tag', Engine.now, {'message' => 'awesome'})
|
336
339
|
assert_equal("awesome", formatted)
|
337
340
|
end
|
338
341
|
|
339
342
|
def test_format_with_message_key
|
340
|
-
formatter = TextFormatter::SingleValueFormatter
|
343
|
+
formatter = create_driver(TextFormatter::SingleValueFormatter)
|
341
344
|
formatter.configure('message_key' => 'foobar')
|
342
345
|
formatted = formatter.format('tag', Engine.now, {'foobar' => 'foo'})
|
343
346
|
|
data/test/test_log.rb
CHANGED
@@ -4,13 +4,17 @@ require 'fluent/engine'
|
|
4
4
|
require 'fluent/log'
|
5
5
|
require 'timecop'
|
6
6
|
require 'logger'
|
7
|
+
require 'securerandom'
|
8
|
+
require 'pathname'
|
7
9
|
|
8
10
|
class LogTest < Test::Unit::TestCase
|
9
|
-
|
11
|
+
def tmp_dir
|
12
|
+
File.join(File.dirname(__FILE__), "tmp", "log", "#{ENV['TEST_ENV_NUMBER']}", SecureRandom.hex(10))
|
13
|
+
end
|
10
14
|
|
11
15
|
def setup
|
12
|
-
|
13
|
-
FileUtils.mkdir_p(
|
16
|
+
@tmp_dir = tmp_dir
|
17
|
+
FileUtils.mkdir_p(@tmp_dir)
|
14
18
|
@log_device = Fluent::Test::DummyLogDevice.new
|
15
19
|
@timestamp = Time.parse("2016-04-21 02:58:41 +0000")
|
16
20
|
@timestamp_str = @timestamp.strftime("%Y-%m-%d %H:%M:%S %z")
|
@@ -21,6 +25,21 @@ class LogTest < Test::Unit::TestCase
|
|
21
25
|
@log_device.reset
|
22
26
|
Timecop.return
|
23
27
|
Thread.current[:last_repeated_stacktrace] = nil
|
28
|
+
begin
|
29
|
+
FileUtils.rm_rf(@tmp_dir)
|
30
|
+
rescue Errno::EACCES
|
31
|
+
# It may occur on Windows because of delete pending state due to delayed GC.
|
32
|
+
# Ruby 3.2 or later doesn't ignore Errno::EACCES:
|
33
|
+
# https://github.com/ruby/ruby/commit/983115cf3c8f75b1afbe3274f02c1529e1ce3a81
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_per_process_path
|
38
|
+
path = Fluent::Log.per_process_path("C:/tmp/test.log", :supervisor, 0)
|
39
|
+
assert_equal(path, "C:/tmp/test-supervisor-0.log")
|
40
|
+
|
41
|
+
path = Fluent::Log.per_process_path("C:/tmp/test.log", :worker, 1)
|
42
|
+
assert_equal(path, "C:/tmp/test-1.log")
|
24
43
|
end
|
25
44
|
|
26
45
|
sub_test_case "log level" do
|
@@ -560,7 +579,7 @@ class LogTest < Test::Unit::TestCase
|
|
560
579
|
Timecop.freeze(@timestamp)
|
561
580
|
|
562
581
|
rotate_age, rotate_size, travel_term = expected
|
563
|
-
path = "#{
|
582
|
+
path = "#{@tmp_dir}/log-dev-io-#{rotate_size}-#{rotate_age}"
|
564
583
|
|
565
584
|
logdev = Fluent::LogDeviceIO.new(path, shift_age: rotate_age, shift_size: rotate_size)
|
566
585
|
logger = ServerEngine::DaemonLogger.new(logdev)
|
@@ -583,45 +602,71 @@ class LogTest < Test::Unit::TestCase
|
|
583
602
|
|
584
603
|
def test_log_rotates_specified_size_with_logdevio
|
585
604
|
with_timezone('utc') do
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
605
|
+
begin
|
606
|
+
rotate_age = 2
|
607
|
+
rotate_size = 100
|
608
|
+
path = "#{@tmp_dir}/log-dev-io-#{rotate_size}-#{rotate_age}"
|
609
|
+
path0 = path + '.0'
|
610
|
+
path1 = path + '.1'
|
611
|
+
|
612
|
+
logdev = Fluent::LogDeviceIO.new(path, shift_age: rotate_age, shift_size: rotate_size)
|
613
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
614
|
+
log = Fluent::Log.new(logger)
|
615
|
+
|
616
|
+
msg = 'a' * 101
|
617
|
+
log.info msg
|
618
|
+
assert_match msg, File.read(path)
|
619
|
+
assert_true File.exist?(path)
|
620
|
+
assert_true !File.exist?(path0)
|
621
|
+
assert_true !File.exist?(path1)
|
622
|
+
|
623
|
+
# create log.0
|
624
|
+
msg2 = 'b' * 101
|
625
|
+
log.info msg2
|
626
|
+
c = File.read(path)
|
627
|
+
c0 = File.read(path0)
|
628
|
+
assert_match msg2, c
|
629
|
+
assert_match msg, c0
|
630
|
+
assert_true File.exist?(path)
|
631
|
+
assert_true File.exist?(path0)
|
632
|
+
assert_true !File.exist?(path1)
|
633
|
+
|
634
|
+
# rotate
|
635
|
+
msg3 = 'c' * 101
|
636
|
+
log.info msg3
|
637
|
+
c = File.read(path)
|
638
|
+
c0 = File.read(path0)
|
639
|
+
assert_match msg3, c
|
640
|
+
assert_match msg2, c0
|
641
|
+
assert_true File.exist?(path)
|
642
|
+
assert_true File.exist?(path0)
|
643
|
+
assert_true !File.exist?(path1)
|
644
|
+
ensure
|
645
|
+
logdev&.close
|
646
|
+
end
|
647
|
+
end
|
648
|
+
end
|
591
649
|
|
592
|
-
|
593
|
-
|
594
|
-
log = Fluent::Log.new(logger)
|
650
|
+
def test_reopen
|
651
|
+
path = Pathname(@tmp_dir) + "fluent.log"
|
595
652
|
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
assert_true File.exist?(path)
|
600
|
-
assert_true !File.exist?(path0)
|
601
|
-
assert_true !File.exist?(path1)
|
653
|
+
logdev = Fluent::LogDeviceIO.new(path.to_s)
|
654
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
655
|
+
log = Fluent::Log.new(logger, path: path)
|
602
656
|
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
log.info msg3
|
617
|
-
c = File.read(path)
|
618
|
-
c0 = File.read(path0)
|
619
|
-
assert_match msg3, c
|
620
|
-
assert_match msg2, c0
|
621
|
-
assert_true File.exist?(path)
|
622
|
-
assert_true File.exist?(path0)
|
623
|
-
assert_true !File.exist?(path1)
|
624
|
-
end
|
657
|
+
message = "This is test message."
|
658
|
+
|
659
|
+
log.info message
|
660
|
+
log.reopen!
|
661
|
+
log.info message
|
662
|
+
|
663
|
+
assert { path.read.lines.select{ |line| line.include?(message) }.size == 2 }
|
664
|
+
# Assert reopening the same file.
|
665
|
+
# Especially, on Windows, the filepath is fixed for each process with rotate,
|
666
|
+
# so we need to care about this.
|
667
|
+
assert { path.parent.entries.size == 3 } # [".", "..", "fluent.log"]
|
668
|
+
ensure
|
669
|
+
logdev&.close
|
625
670
|
end
|
626
671
|
end
|
627
672
|
|