fluentd 1.15.3-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 +77 -0
- data/MAINTAINERS.md +2 -0
- data/README.md +0 -1
- data/fluentd.gemspec +2 -2
- data/lib/fluent/command/fluentd.rb +55 -53
- data/lib/fluent/daemon.rb +2 -4
- data/lib/fluent/log/console_adapter.rb +66 -0
- data/lib/fluent/log.rb +35 -5
- 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_tcp.rb +4 -2
- 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 -251
- 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 +137 -6
- 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_tcp.rb +15 -0
- 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 +0 -21
- data/test/test_formatter.rb +23 -20
- data/test/test_log.rb +71 -36
- data/test/test_supervisor.rb +277 -282
- metadata +12 -19
- data/.drone.yml +0 -35
- data/.gitlab-ci.yml +0 -103
- data/test/test_logger_initializer.rb +0 -46
data/test/test_config.rb
CHANGED
@@ -344,27 +344,6 @@ class ConfigTest < Test::Unit::TestCase
|
|
344
344
|
File.open(path, "w:#{encoding}:utf-8") {|f| f.write data }
|
345
345
|
end
|
346
346
|
|
347
|
-
def test_inline
|
348
|
-
prepare_config
|
349
|
-
opts = {
|
350
|
-
:config_path => "#{TMP_DIR}/config_test_1.conf",
|
351
|
-
:inline_config => "<source>\n type http\n port 2222\n </source>",
|
352
|
-
:use_v1_config => false
|
353
|
-
}
|
354
|
-
assert_nothing_raised do
|
355
|
-
Fluent::Supervisor.new(opts)
|
356
|
-
end
|
357
|
-
create_warn_dummy_logger
|
358
|
-
end
|
359
|
-
|
360
|
-
def create_warn_dummy_logger
|
361
|
-
dl_opts = {}
|
362
|
-
dl_opts[:log_level] = ServerEngine::DaemonLogger::WARN
|
363
|
-
logdev = Fluent::Test::DummyLogDevice.new
|
364
|
-
logger = ServerEngine::DaemonLogger.new(logdev, dl_opts)
|
365
|
-
$log = Fluent::Log.new(logger)
|
366
|
-
end
|
367
|
-
|
368
347
|
sub_test_case '.build' do
|
369
348
|
test 'read config' do
|
370
349
|
write_config("#{TMP_DIR}/build/config_build.conf", 'key value')
|
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
@@ -5,6 +5,7 @@ require 'fluent/log'
|
|
5
5
|
require 'timecop'
|
6
6
|
require 'logger'
|
7
7
|
require 'securerandom'
|
8
|
+
require 'pathname'
|
8
9
|
|
9
10
|
class LogTest < Test::Unit::TestCase
|
10
11
|
def tmp_dir
|
@@ -33,6 +34,14 @@ class LogTest < Test::Unit::TestCase
|
|
33
34
|
end
|
34
35
|
end
|
35
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")
|
43
|
+
end
|
44
|
+
|
36
45
|
sub_test_case "log level" do
|
37
46
|
data(
|
38
47
|
trace: [Fluent::Log::LEVEL_TRACE, 0],
|
@@ -593,45 +602,71 @@ class LogTest < Test::Unit::TestCase
|
|
593
602
|
|
594
603
|
def test_log_rotates_specified_size_with_logdevio
|
595
604
|
with_timezone('utc') do
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
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
|
601
649
|
|
602
|
-
|
603
|
-
|
604
|
-
log = Fluent::Log.new(logger)
|
650
|
+
def test_reopen
|
651
|
+
path = Pathname(@tmp_dir) + "fluent.log"
|
605
652
|
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
assert_true File.exist?(path)
|
610
|
-
assert_true !File.exist?(path0)
|
611
|
-
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)
|
612
656
|
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
log.info msg3
|
627
|
-
c = File.read(path)
|
628
|
-
c0 = File.read(path0)
|
629
|
-
assert_match msg3, c
|
630
|
-
assert_match msg2, c0
|
631
|
-
assert_true File.exist?(path)
|
632
|
-
assert_true File.exist?(path0)
|
633
|
-
assert_true !File.exist?(path1)
|
634
|
-
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
|
635
670
|
end
|
636
671
|
end
|
637
672
|
|