fluentd 1.8.0.rc3 → 1.8.0
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/.travis.yml +4 -0
- data/CHANGELOG.md +24 -2
- data/MAINTAINERS.md +1 -0
- data/lib/fluent/command/fluentd.rb +4 -0
- data/lib/fluent/config/element.rb +28 -15
- data/lib/fluent/config/error.rb +6 -0
- data/lib/fluent/config/literal_parser.rb +24 -2
- data/lib/fluent/config/section.rb +43 -6
- data/lib/fluent/config/types.rb +98 -26
- data/lib/fluent/configurable.rb +2 -2
- data/lib/fluent/engine.rb +6 -6
- data/lib/fluent/plugin/base.rb +1 -1
- data/lib/fluent/plugin/formatter_stdout.rb +1 -1
- data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
- data/lib/fluent/plugin/out_forward.rb +3 -3
- data/lib/fluent/plugin/output.rb +11 -3
- data/lib/fluent/plugin_helper/compat_parameters.rb +11 -1
- data/lib/fluent/supervisor.rb +53 -65
- data/lib/fluent/system_config.rb +21 -7
- data/lib/fluent/time.rb +5 -3
- data/lib/fluent/version.rb +1 -1
- data/test/config/test_configurable.rb +154 -0
- data/test/config/test_element.rb +18 -0
- data/test/config/test_literal_parser.rb +4 -0
- data/test/config/test_system_config.rb +2 -1
- data/test/config/test_types.rb +293 -120
- data/test/plugin/out_forward/test_load_balancer.rb +1 -1
- data/test/plugin/test_in_monitor_agent.rb +2 -1
- data/test/plugin/test_out_stdout.rb +36 -1
- data/test/plugin/test_output.rb +25 -1
- data/test/test_logger_initializer.rb +26 -0
- data/test/test_supervisor.rb +26 -40
- metadata +6 -4
@@ -5,7 +5,7 @@ require 'fluent/plugin/out_forward/load_balancer'
|
|
5
5
|
|
6
6
|
class LoadBalancerTest < Test::Unit::TestCase
|
7
7
|
sub_test_case 'select_healthy_node' do
|
8
|
-
test 'select
|
8
|
+
test 'select healthy node' do
|
9
9
|
lb = Fluent::Plugin::ForwardOutput::LoadBalancer.new($log)
|
10
10
|
n1 = flexmock('node', :'standby?' => false, :'available?' => false, weight: 1)
|
11
11
|
n2 = flexmock('node', :'standby?' => false, :'available?' => true, weight: 1)
|
@@ -496,7 +496,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
496
496
|
tag monitor
|
497
497
|
")
|
498
498
|
d.instance.start
|
499
|
-
expected_response_regex = %r{pid:\d+\tppid:\d+\tconfig_path:#{@filepath}\tpid_file:\tplugin_dirs:/etc/fluent/plugin\tlog_path:}
|
499
|
+
expected_response_regex = %r{pid:\d+\tppid:\d+\tversion:#{Fluent::VERSION}\tconfig_path:#{@filepath}\tpid_file:\tplugin_dirs:/etc/fluent/plugin\tlog_path:}
|
500
500
|
assert_match(expected_response_regex,
|
501
501
|
get("http://127.0.0.1:#{@port}/api/config").body)
|
502
502
|
end
|
@@ -514,6 +514,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
514
514
|
assert_nil(res["pid_file"])
|
515
515
|
assert_equal(["/etc/fluent/plugin"], res["plugin_dirs"])
|
516
516
|
assert_nil(res["log_path"])
|
517
|
+
assert_equal(Fluent::VERSION, res["version"])
|
517
518
|
end
|
518
519
|
|
519
520
|
test "/api/config.json?debug=1" do
|
@@ -37,6 +37,25 @@ class StdoutOutputTest < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
test 'configure with time_format' do
|
41
|
+
d = create_driver(CONFIG + <<-CONF)
|
42
|
+
<format>
|
43
|
+
@type stdout
|
44
|
+
time_format %Y-%m-%dT%H:%M:%S.%L%z
|
45
|
+
</format>
|
46
|
+
CONF
|
47
|
+
|
48
|
+
time = event_time
|
49
|
+
out = capture_log do
|
50
|
+
d.run(default_tag: 'test') do
|
51
|
+
d.feed(time, {'test' => 'test'})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
t = Time.at(time).localtime.strftime("%Y-%m-%dT%H:%M:%S.%L%z")
|
56
|
+
assert_equal "#{t} test: {\"test\":\"test\"}\n", out
|
57
|
+
end
|
58
|
+
|
40
59
|
test 'emit with default configuration' do
|
41
60
|
d = create_driver
|
42
61
|
time = event_time()
|
@@ -157,6 +176,23 @@ class StdoutOutputTest < Test::Unit::TestCase
|
|
157
176
|
end
|
158
177
|
end
|
159
178
|
|
179
|
+
data(
|
180
|
+
'utc and !localtime' => "utc true\nlocaltime false",
|
181
|
+
'!utc and localtime' => "utc false\nlocaltime true")
|
182
|
+
test 'success when configure with localtime and utc' do |c|
|
183
|
+
assert_nothing_raised do
|
184
|
+
create_driver(CONFIG + c)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
data('utc and localtime' => "utc true\nlocaltime true",
|
189
|
+
'!utc and !localtime' => "utc false\nlocaltime false")
|
190
|
+
test 'raise an error when configure with localtime and utc' do |c|
|
191
|
+
assert_raise(Fluent::ConfigError.new('both of utc and localtime are specified, use only one of them')) do
|
192
|
+
create_driver(CONFIG + c)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
160
196
|
# Capture the log output of the block given
|
161
197
|
def capture_log(&block)
|
162
198
|
tmp = $log
|
@@ -167,4 +203,3 @@ class StdoutOutputTest < Test::Unit::TestCase
|
|
167
203
|
$log = tmp
|
168
204
|
end
|
169
205
|
end
|
170
|
-
|
data/test/plugin/test_output.rb
CHANGED
@@ -378,6 +378,30 @@ class OutputTest < Test::Unit::TestCase
|
|
378
378
|
assert { logs.any? { |log| log.include?("${chunk_id} is not allowed in this plugin") } }
|
379
379
|
end
|
380
380
|
|
381
|
+
test '#extract_placeholders logs warn message with not replaced key' do
|
382
|
+
@i.configure(config_element('ROOT', '', {}, [config_element('buffer', '')]))
|
383
|
+
tmpl = "/mypath/${key1}/test"
|
384
|
+
t = event_time('2016-04-11 20:30:00 +0900')
|
385
|
+
v = { key1: "value1" }
|
386
|
+
m = create_metadata(timekey: t, tag: 'fluentd.test.output', variables: v)
|
387
|
+
@i.extract_placeholders(tmpl, m)
|
388
|
+
logs = @i.log.out.logs
|
389
|
+
|
390
|
+
assert { logs.any? { |log| log.include?("chunk key placeholder 'key1' not replaced. template:#{tmpl}") } }
|
391
|
+
end
|
392
|
+
|
393
|
+
test '#extract_placeholders logs warn message with not replaced key if variables exist and chunk_key is not empty' do
|
394
|
+
@i.configure(config_element('ROOT', '', {}, [config_element('buffer', 'key1')]))
|
395
|
+
tmpl = "/mypath/${key1}/${key2}/test"
|
396
|
+
t = event_time('2016-04-11 20:30:00 +0900')
|
397
|
+
v = { key1: "value1" }
|
398
|
+
m = create_metadata(timekey: t, tag: 'fluentd.test.output', variables: v)
|
399
|
+
@i.extract_placeholders(tmpl, m)
|
400
|
+
logs = @i.log.out.logs
|
401
|
+
|
402
|
+
assert { logs.any? { |log| log.include?("chunk key placeholder 'key2' not replaced. template:#{tmpl}") } }
|
403
|
+
end
|
404
|
+
|
381
405
|
sub_test_case '#placeholder_validators' do
|
382
406
|
test 'returns validators for time, tag and keys when a template has placeholders even if plugin is not configured with these keys' do
|
383
407
|
@i.configure(config_element('ROOT', '', {}, [config_element('buffer', '')]))
|
@@ -870,7 +894,7 @@ class OutputTest < Test::Unit::TestCase
|
|
870
894
|
|
871
895
|
test 'raises an error if timekey is less than equal 0' do
|
872
896
|
i = create_output(:delayed)
|
873
|
-
assert_raise Fluent::ConfigError.new(
|
897
|
+
assert_raise Fluent::ConfigError.new("<buffer ...> argument includes 'time', but timekey is not configured") do
|
874
898
|
i.configure(config_element('ROOT','',{},[config_element('buffer', 'time', { "timekey" => nil })]))
|
875
899
|
end
|
876
900
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'fluent/supervisor'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class LoggerInitializerTest < ::Test::Unit::TestCase
|
6
|
+
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/logger_initializer#{ENV['TEST_ENV_NUMBER']}")
|
7
|
+
|
8
|
+
teardown do
|
9
|
+
begin
|
10
|
+
FileUtils.rm_rf(TMP_DIR)
|
11
|
+
rescue => _
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'when path is given' do
|
16
|
+
path = File.join(TMP_DIR, 'fluent_with_path.log')
|
17
|
+
|
18
|
+
assert_false File.exist?(TMP_DIR)
|
19
|
+
logger = Fluent::Supervisor::LoggerInitializer.new(path, Fluent::Log::LEVEL_DEBUG, nil, nil, {})
|
20
|
+
|
21
|
+
assert_nothing_raised do
|
22
|
+
logger.init(:supervisor, 0)
|
23
|
+
end
|
24
|
+
assert_true File.exist?(TMP_DIR)
|
25
|
+
end
|
26
|
+
end
|
data/test/test_supervisor.rb
CHANGED
@@ -372,46 +372,6 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
372
372
|
assert_equal Fluent::Log::LEVEL_INFO, se_config[:log_level]
|
373
373
|
end
|
374
374
|
|
375
|
-
def test_load_config_with_multibyte_string
|
376
|
-
tmp_path = "#{TMP_DIR}/dir/test_multibyte_config.conf"
|
377
|
-
conf_str = %[
|
378
|
-
<source>
|
379
|
-
@type forward
|
380
|
-
@id forward_input
|
381
|
-
@label @INPUT
|
382
|
-
</source>
|
383
|
-
<label @INPUT>
|
384
|
-
<filter>
|
385
|
-
@type record_transformer
|
386
|
-
<record>
|
387
|
-
message こんにちは. ${record["name"]} has made a order of ${record["item"]} just now.
|
388
|
-
</record>
|
389
|
-
</filter>
|
390
|
-
<match>
|
391
|
-
@type stdout
|
392
|
-
</match>
|
393
|
-
</label>
|
394
|
-
]
|
395
|
-
FileUtils.mkdir_p(File.dirname(tmp_path))
|
396
|
-
File.open(tmp_path, "w:utf-8") {|file| file.write(conf_str) }
|
397
|
-
|
398
|
-
params = {}
|
399
|
-
params['workers'] = 1
|
400
|
-
params['use_v1_config'] = true
|
401
|
-
params['log_path'] = 'test/tmp/supervisor/log'
|
402
|
-
params['suppress_repeated_stacktrace'] = true
|
403
|
-
params['log_level'] = Fluent::Log::LEVEL_INFO
|
404
|
-
params['conf_encoding'] = 'utf-8'
|
405
|
-
load_config_proc = Proc.new { Fluent::Supervisor.load_config(tmp_path, params) }
|
406
|
-
|
407
|
-
se_config = load_config_proc.call
|
408
|
-
conf = se_config[:fluentd_conf]
|
409
|
-
label = conf.elements.detect {|e| e.name == "label" }
|
410
|
-
filter = label.elements.detect {|e| e.name == "filter" }
|
411
|
-
record_transformer = filter.elements.detect {|e| e.name = "record_transformer" }
|
412
|
-
assert_equal(Encoding::UTF_8, record_transformer["message"].encoding)
|
413
|
-
end
|
414
|
-
|
415
375
|
def test_logger
|
416
376
|
opts = Fluent::Supervisor.default_options
|
417
377
|
sv = Fluent::Supervisor.new(opts)
|
@@ -448,6 +408,32 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
448
408
|
assert_equal 10, $log.out.instance_variable_get(:@shift_size)
|
449
409
|
end
|
450
410
|
|
411
|
+
def test_inline_config
|
412
|
+
opts = Fluent::Supervisor.default_options
|
413
|
+
opts[:inline_config] = '-'
|
414
|
+
sv = Fluent::Supervisor.new(opts)
|
415
|
+
assert_equal '-', sv.instance_variable_get(:@inline_config)
|
416
|
+
|
417
|
+
inline_config = '<match *>\n@type stdout\n</match>'
|
418
|
+
stub(STDIN).read { inline_config }
|
419
|
+
stub(sv).read_config # to skip
|
420
|
+
stub(sv).build_system_config { Fluent::SystemConfig.new } # to skip
|
421
|
+
|
422
|
+
sv.configure
|
423
|
+
assert_equal inline_config, sv.instance_variable_get(:@inline_config)
|
424
|
+
end
|
425
|
+
|
426
|
+
def test_log_level_affects
|
427
|
+
opts = Fluent::Supervisor.default_options
|
428
|
+
sv = Fluent::Supervisor.new(opts)
|
429
|
+
|
430
|
+
c = Fluent::Config::Element.new('system', '', { 'log_level' => 'error' }, [])
|
431
|
+
stub(sv).read_config { config_element('ROOT', '', {}, [c]) }
|
432
|
+
|
433
|
+
sv.configure
|
434
|
+
assert_equal Fluent::Log::LEVEL_ERROR, $log.level
|
435
|
+
end
|
436
|
+
|
451
437
|
def create_debug_dummy_logger
|
452
438
|
dl_opts = {}
|
453
439
|
dl_opts[:log_level] = ServerEngine::DaemonLogger::DEBUG
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluentd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.0
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -808,6 +808,7 @@ files:
|
|
808
808
|
- test/test_formatter.rb
|
809
809
|
- test/test_input.rb
|
810
810
|
- test/test_log.rb
|
811
|
+
- test/test_logger_initializer.rb
|
811
812
|
- test/test_match.rb
|
812
813
|
- test/test_mixin.rb
|
813
814
|
- test/test_output.rb
|
@@ -837,9 +838,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
837
838
|
version: '2.1'
|
838
839
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
839
840
|
requirements:
|
840
|
-
- - "
|
841
|
+
- - ">="
|
841
842
|
- !ruby/object:Gem::Version
|
842
|
-
version:
|
843
|
+
version: '0'
|
843
844
|
requirements: []
|
844
845
|
rubygems_version: 3.0.3
|
845
846
|
signing_key:
|
@@ -1011,6 +1012,7 @@ test_files:
|
|
1011
1012
|
- test/test_formatter.rb
|
1012
1013
|
- test/test_input.rb
|
1013
1014
|
- test/test_log.rb
|
1015
|
+
- test/test_logger_initializer.rb
|
1014
1016
|
- test/test_match.rb
|
1015
1017
|
- test/test_mixin.rb
|
1016
1018
|
- test/test_output.rb
|