fluentd 0.14.4-x64-mingw32
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 +7 -0
- data/.github/ISSUE_TEMPLATE.md +6 -0
- data/.gitignore +26 -0
- data/.travis.yml +45 -0
- data/AUTHORS +2 -0
- data/CONTRIBUTING.md +35 -0
- data/COPYING +14 -0
- data/ChangeLog +276 -0
- data/Gemfile +9 -0
- data/README.md +51 -0
- data/Rakefile +53 -0
- data/Vagrantfile +17 -0
- data/appveyor.yml +41 -0
- data/bin/fluent-debug +5 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/filter_stdout.conf +22 -0
- data/example/in_forward.conf +11 -0
- data/example/in_http.conf +14 -0
- data/example/in_out_forward.conf +17 -0
- data/example/in_syslog.conf +15 -0
- data/example/in_tail.conf +14 -0
- data/example/in_tcp.conf +13 -0
- data/example/in_udp.conf +13 -0
- data/example/multi_filters.conf +61 -0
- data/example/out_buffered_null.conf +32 -0
- data/example/out_copy.conf +20 -0
- data/example/out_file.conf +13 -0
- data/example/out_forward.conf +35 -0
- data/example/out_forward_buf_file.conf +23 -0
- data/example/v0_12_filter.conf +78 -0
- data/example/v1_literal_example.conf +36 -0
- data/fluent.conf +139 -0
- data/fluentd.gemspec +51 -0
- data/lib/fluent/agent.rb +194 -0
- data/lib/fluent/command/bundler_injection.rb +45 -0
- data/lib/fluent/command/cat.rb +319 -0
- data/lib/fluent/command/debug.rb +102 -0
- data/lib/fluent/command/fluentd.rb +273 -0
- data/lib/fluent/compat/call_super_mixin.rb +67 -0
- data/lib/fluent/compat/exec_util.rb +129 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +68 -0
- data/lib/fluent/compat/formatter.rb +111 -0
- data/lib/fluent/compat/formatter_utils.rb +85 -0
- data/lib/fluent/compat/handle_tag_and_time_mixin.rb +62 -0
- data/lib/fluent/compat/handle_tag_name_mixin.rb +53 -0
- data/lib/fluent/compat/input.rb +49 -0
- data/lib/fluent/compat/output.rb +677 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +180 -0
- data/lib/fluent/compat/parser_utils.rb +40 -0
- data/lib/fluent/compat/propagate_default.rb +62 -0
- data/lib/fluent/compat/record_filter_mixin.rb +34 -0
- data/lib/fluent/compat/set_tag_key_mixin.rb +50 -0
- data/lib/fluent/compat/set_time_key_mixin.rb +69 -0
- data/lib/fluent/compat/socket_util.rb +165 -0
- data/lib/fluent/compat/string_util.rb +34 -0
- data/lib/fluent/compat/structured_format_mixin.rb +26 -0
- data/lib/fluent/compat/type_converter.rb +90 -0
- data/lib/fluent/config.rb +56 -0
- data/lib/fluent/config/basic_parser.rb +123 -0
- data/lib/fluent/config/configure_proxy.rb +366 -0
- data/lib/fluent/config/dsl.rb +149 -0
- data/lib/fluent/config/element.rb +218 -0
- data/lib/fluent/config/error.rb +26 -0
- data/lib/fluent/config/literal_parser.rb +251 -0
- data/lib/fluent/config/parser.rb +107 -0
- data/lib/fluent/config/section.rb +212 -0
- data/lib/fluent/config/types.rb +136 -0
- data/lib/fluent/config/v1_parser.rb +190 -0
- data/lib/fluent/configurable.rb +176 -0
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/engine.rb +220 -0
- data/lib/fluent/env.rb +27 -0
- data/lib/fluent/event.rb +287 -0
- data/lib/fluent/event_router.rb +259 -0
- data/lib/fluent/filter.rb +21 -0
- data/lib/fluent/formatter.rb +23 -0
- data/lib/fluent/input.rb +21 -0
- data/lib/fluent/label.rb +38 -0
- data/lib/fluent/load.rb +36 -0
- data/lib/fluent/log.rb +445 -0
- data/lib/fluent/match.rb +141 -0
- data/lib/fluent/mixin.rb +31 -0
- data/lib/fluent/msgpack_factory.rb +62 -0
- data/lib/fluent/output.rb +26 -0
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +23 -0
- data/lib/fluent/plugin.rb +161 -0
- data/lib/fluent/plugin/bare_output.rb +63 -0
- data/lib/fluent/plugin/base.rb +130 -0
- data/lib/fluent/plugin/buf_file.rb +154 -0
- data/lib/fluent/plugin/buf_memory.rb +34 -0
- data/lib/fluent/plugin/buffer.rb +603 -0
- data/lib/fluent/plugin/buffer/chunk.rb +160 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +323 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +90 -0
- data/lib/fluent/plugin/exec_util.rb +22 -0
- data/lib/fluent/plugin/file_util.rb +22 -0
- data/lib/fluent/plugin/file_wrapper.rb +120 -0
- data/lib/fluent/plugin/filter.rb +93 -0
- data/lib/fluent/plugin/filter_grep.rb +75 -0
- data/lib/fluent/plugin/filter_record_transformer.rb +342 -0
- data/lib/fluent/plugin/filter_stdout.rb +53 -0
- data/lib/fluent/plugin/formatter.rb +45 -0
- data/lib/fluent/plugin/formatter_csv.rb +47 -0
- data/lib/fluent/plugin/formatter_hash.rb +29 -0
- data/lib/fluent/plugin/formatter_json.rb +44 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +41 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +29 -0
- data/lib/fluent/plugin/formatter_out_file.rb +78 -0
- data/lib/fluent/plugin/formatter_single_value.rb +34 -0
- data/lib/fluent/plugin/formatter_stdout.rb +74 -0
- data/lib/fluent/plugin/in_debug_agent.rb +64 -0
- data/lib/fluent/plugin/in_dummy.rb +135 -0
- data/lib/fluent/plugin/in_exec.rb +149 -0
- data/lib/fluent/plugin/in_forward.rb +366 -0
- data/lib/fluent/plugin/in_gc_stat.rb +52 -0
- data/lib/fluent/plugin/in_http.rb +422 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +401 -0
- data/lib/fluent/plugin/in_object_space.rb +90 -0
- data/lib/fluent/plugin/in_syslog.rb +204 -0
- data/lib/fluent/plugin/in_tail.rb +838 -0
- data/lib/fluent/plugin/in_tcp.rb +41 -0
- data/lib/fluent/plugin/in_udp.rb +37 -0
- data/lib/fluent/plugin/in_unix.rb +201 -0
- data/lib/fluent/plugin/input.rb +33 -0
- data/lib/fluent/plugin/multi_output.rb +95 -0
- data/lib/fluent/plugin/out_buffered_null.rb +59 -0
- data/lib/fluent/plugin/out_buffered_stdout.rb +70 -0
- data/lib/fluent/plugin/out_copy.rb +42 -0
- data/lib/fluent/plugin/out_exec.rb +114 -0
- data/lib/fluent/plugin/out_exec_filter.rb +393 -0
- data/lib/fluent/plugin/out_file.rb +167 -0
- data/lib/fluent/plugin/out_forward.rb +646 -0
- data/lib/fluent/plugin/out_null.rb +27 -0
- data/lib/fluent/plugin/out_relabel.rb +28 -0
- data/lib/fluent/plugin/out_roundrobin.rb +80 -0
- data/lib/fluent/plugin/out_stdout.rb +48 -0
- data/lib/fluent/plugin/out_stream.rb +130 -0
- data/lib/fluent/plugin/output.rb +1020 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +175 -0
- data/lib/fluent/plugin/parser_apache.rb +28 -0
- data/lib/fluent/plugin/parser_apache2.rb +84 -0
- data/lib/fluent/plugin/parser_apache_error.rb +26 -0
- data/lib/fluent/plugin/parser_csv.rb +33 -0
- data/lib/fluent/plugin/parser_json.rb +79 -0
- data/lib/fluent/plugin/parser_ltsv.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +104 -0
- data/lib/fluent/plugin/parser_nginx.rb +28 -0
- data/lib/fluent/plugin/parser_none.rb +36 -0
- data/lib/fluent/plugin/parser_regexp.rb +73 -0
- data/lib/fluent/plugin/parser_syslog.rb +82 -0
- data/lib/fluent/plugin/parser_tsv.rb +37 -0
- data/lib/fluent/plugin/socket_util.rb +22 -0
- data/lib/fluent/plugin/storage.rb +84 -0
- data/lib/fluent/plugin/storage_local.rb +132 -0
- data/lib/fluent/plugin/string_util.rb +22 -0
- data/lib/fluent/plugin_helper.rb +42 -0
- data/lib/fluent/plugin_helper/child_process.rb +298 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +224 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +80 -0
- data/lib/fluent/plugin_helper/event_loop.rb +118 -0
- data/lib/fluent/plugin_helper/formatter.rb +149 -0
- data/lib/fluent/plugin_helper/inject.rb +125 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/retry_state.rb +177 -0
- data/lib/fluent/plugin_helper/storage.rb +331 -0
- data/lib/fluent/plugin_helper/thread.rb +147 -0
- data/lib/fluent/plugin_helper/timer.rb +90 -0
- data/lib/fluent/plugin_id.rb +63 -0
- data/lib/fluent/process.rb +504 -0
- data/lib/fluent/registry.rb +99 -0
- data/lib/fluent/root_agent.rb +314 -0
- data/lib/fluent/rpc.rb +94 -0
- data/lib/fluent/supervisor.rb +680 -0
- data/lib/fluent/system_config.rb +122 -0
- data/lib/fluent/test.rb +56 -0
- data/lib/fluent/test/base.rb +85 -0
- data/lib/fluent/test/driver/base.rb +179 -0
- data/lib/fluent/test/driver/base_owned.rb +70 -0
- data/lib/fluent/test/driver/base_owner.rb +125 -0
- data/lib/fluent/test/driver/event_feeder.rb +98 -0
- data/lib/fluent/test/driver/filter.rb +57 -0
- data/lib/fluent/test/driver/formatter.rb +30 -0
- data/lib/fluent/test/driver/input.rb +31 -0
- data/lib/fluent/test/driver/multi_output.rb +52 -0
- data/lib/fluent/test/driver/output.rb +76 -0
- data/lib/fluent/test/driver/parser.rb +30 -0
- data/lib/fluent/test/driver/test_event_router.rb +45 -0
- data/lib/fluent/test/filter_test.rb +77 -0
- data/lib/fluent/test/formatter_test.rb +65 -0
- data/lib/fluent/test/helpers.rb +79 -0
- data/lib/fluent/test/input_test.rb +172 -0
- data/lib/fluent/test/log.rb +73 -0
- data/lib/fluent/test/output_test.rb +156 -0
- data/lib/fluent/test/parser_test.rb +70 -0
- data/lib/fluent/time.rb +175 -0
- data/lib/fluent/timezone.rb +133 -0
- data/lib/fluent/unique_id.rb +39 -0
- data/lib/fluent/version.rb +21 -0
- data/lib/fluent/winsvc.rb +71 -0
- data/test/compat/test_calls_super.rb +166 -0
- data/test/compat/test_parser.rb +82 -0
- data/test/config/assertions.rb +42 -0
- data/test/config/test_config_parser.rb +507 -0
- data/test/config/test_configurable.rb +1194 -0
- data/test/config/test_configure_proxy.rb +386 -0
- data/test/config/test_dsl.rb +415 -0
- data/test/config/test_element.rb +403 -0
- data/test/config/test_literal_parser.rb +297 -0
- data/test/config/test_section.rb +184 -0
- data/test/config/test_system_config.rb +120 -0
- data/test/config/test_types.rb +171 -0
- data/test/helper.rb +119 -0
- data/test/plugin/data/2010/01/20100102-030405.log +0 -0
- data/test/plugin/data/2010/01/20100102-030406.log +0 -0
- data/test/plugin/data/2010/01/20100102.log +0 -0
- data/test/plugin/data/log/bar +0 -0
- data/test/plugin/data/log/foo/bar.log +0 -0
- data/test/plugin/data/log/test.log +0 -0
- data/test/plugin/test_bare_output.rb +118 -0
- data/test/plugin/test_base.rb +75 -0
- data/test/plugin/test_buf_file.rb +571 -0
- data/test/plugin/test_buf_memory.rb +42 -0
- data/test/plugin/test_buffer.rb +1200 -0
- data/test/plugin/test_buffer_chunk.rb +168 -0
- data/test/plugin/test_buffer_file_chunk.rb +771 -0
- data/test/plugin/test_buffer_memory_chunk.rb +265 -0
- data/test/plugin/test_file_util.rb +96 -0
- data/test/plugin/test_filter.rb +353 -0
- data/test/plugin/test_filter_grep.rb +119 -0
- data/test/plugin/test_filter_record_transformer.rb +600 -0
- data/test/plugin/test_filter_stdout.rb +211 -0
- data/test/plugin/test_formatter_csv.rb +94 -0
- data/test/plugin/test_formatter_json.rb +30 -0
- data/test/plugin/test_formatter_ltsv.rb +52 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +95 -0
- data/test/plugin/test_formatter_single_value.rb +38 -0
- data/test/plugin/test_in_debug_agent.rb +28 -0
- data/test/plugin/test_in_dummy.rb +188 -0
- data/test/plugin/test_in_exec.rb +133 -0
- data/test/plugin/test_in_forward.rb +635 -0
- data/test/plugin/test_in_gc_stat.rb +39 -0
- data/test/plugin/test_in_http.rb +442 -0
- data/test/plugin/test_in_monitor_agent.rb +329 -0
- data/test/plugin/test_in_object_space.rb +64 -0
- data/test/plugin/test_in_syslog.rb +205 -0
- data/test/plugin/test_in_tail.rb +1001 -0
- data/test/plugin/test_in_tcp.rb +102 -0
- data/test/plugin/test_in_udp.rb +121 -0
- data/test/plugin/test_in_unix.rb +126 -0
- data/test/plugin/test_input.rb +122 -0
- data/test/plugin/test_multi_output.rb +180 -0
- data/test/plugin/test_out_buffered_null.rb +79 -0
- data/test/plugin/test_out_buffered_stdout.rb +122 -0
- data/test/plugin/test_out_copy.rb +160 -0
- data/test/plugin/test_out_exec.rb +155 -0
- data/test/plugin/test_out_exec_filter.rb +262 -0
- data/test/plugin/test_out_file.rb +383 -0
- data/test/plugin/test_out_forward.rb +590 -0
- data/test/plugin/test_out_null.rb +29 -0
- data/test/plugin/test_out_relabel.rb +28 -0
- data/test/plugin/test_out_roundrobin.rb +146 -0
- data/test/plugin/test_out_stdout.rb +92 -0
- data/test/plugin/test_out_stream.rb +93 -0
- data/test/plugin/test_output.rb +568 -0
- data/test/plugin/test_output_as_buffered.rb +1604 -0
- data/test/plugin/test_output_as_buffered_overflow.rb +250 -0
- data/test/plugin/test_output_as_buffered_retries.rb +839 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +817 -0
- data/test/plugin/test_output_as_standard.rb +374 -0
- data/test/plugin/test_owned_by.rb +35 -0
- data/test/plugin/test_parser_apache.rb +42 -0
- data/test/plugin/test_parser_apache2.rb +38 -0
- data/test/plugin/test_parser_apache_error.rb +45 -0
- data/test/plugin/test_parser_base.rb +32 -0
- data/test/plugin/test_parser_csv.rb +104 -0
- data/test/plugin/test_parser_json.rb +107 -0
- data/test/plugin/test_parser_labeled_tsv.rb +129 -0
- data/test/plugin/test_parser_multiline.rb +100 -0
- data/test/plugin/test_parser_nginx.rb +48 -0
- data/test/plugin/test_parser_none.rb +53 -0
- data/test/plugin/test_parser_regexp.rb +277 -0
- data/test/plugin/test_parser_syslog.rb +66 -0
- data/test/plugin/test_parser_time.rb +46 -0
- data/test/plugin/test_parser_tsv.rb +121 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +8 -0
- data/test/plugin/test_string_util.rb +26 -0
- data/test/plugin_helper/test_child_process.rb +608 -0
- data/test/plugin_helper/test_compat_parameters.rb +242 -0
- data/test/plugin_helper/test_event_emitter.rb +51 -0
- data/test/plugin_helper/test_event_loop.rb +52 -0
- data/test/plugin_helper/test_formatter.rb +252 -0
- data/test/plugin_helper/test_inject.rb +487 -0
- data/test/plugin_helper/test_parser.rb +263 -0
- data/test/plugin_helper/test_retry_state.rb +399 -0
- data/test/plugin_helper/test_storage.rb +521 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +131 -0
- data/test/scripts/exec_script.rb +32 -0
- data/test/scripts/fluent/plugin/formatter_known.rb +8 -0
- data/test/scripts/fluent/plugin/out_test.rb +81 -0
- data/test/scripts/fluent/plugin/out_test2.rb +80 -0
- data/test/scripts/fluent/plugin/parser_known.rb +4 -0
- data/test/test_config.rb +179 -0
- data/test/test_configdsl.rb +148 -0
- data/test/test_event.rb +329 -0
- data/test/test_event_router.rb +331 -0
- data/test/test_event_time.rb +184 -0
- data/test/test_filter.rb +121 -0
- data/test/test_formatter.rb +319 -0
- data/test/test_input.rb +31 -0
- data/test/test_log.rb +572 -0
- data/test/test_match.rb +137 -0
- data/test/test_mixin.rb +351 -0
- data/test/test_output.rb +214 -0
- data/test/test_plugin_classes.rb +136 -0
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_process.rb +48 -0
- data/test/test_root_agent.rb +278 -0
- data/test/test_supervisor.rb +339 -0
- data/test/test_time_formatter.rb +186 -0
- data/test/test_unique_id.rb +47 -0
- metadata +823 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/config/section'
|
3
|
+
|
4
|
+
module Fluent::Config
|
5
|
+
class TestSection < ::Test::Unit::TestCase
|
6
|
+
sub_test_case Fluent::Config::Section do
|
7
|
+
sub_test_case 'class' do
|
8
|
+
sub_test_case '.name' do
|
9
|
+
test 'returns its full module name as String' do
|
10
|
+
assert_equal('Fluent::Config::Section', Fluent::Config::Section.name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
sub_test_case 'instance object' do
|
16
|
+
sub_test_case '#initialize' do
|
17
|
+
test 'creates blank object without argument' do
|
18
|
+
s = Fluent::Config::Section.new
|
19
|
+
assert_equal({}, s.instance_eval{ @params })
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'creates object which contains specified hash object itself' do
|
23
|
+
hash = {
|
24
|
+
name: 'tagomoris',
|
25
|
+
age: 34,
|
26
|
+
send: 'email',
|
27
|
+
klass: 'normal',
|
28
|
+
keys: 5,
|
29
|
+
}
|
30
|
+
s1 = Fluent::Config::Section.new(hash)
|
31
|
+
assert_equal(hash, s1.instance_eval { @params })
|
32
|
+
assert_equal("tagomoris", s1[:name])
|
33
|
+
assert_equal(34, s1[:age])
|
34
|
+
assert_equal("email", s1[:send])
|
35
|
+
assert_equal("normal", s1[:klass])
|
36
|
+
assert_equal(5, s1[:keys])
|
37
|
+
|
38
|
+
assert_equal("tagomoris", s1.name)
|
39
|
+
assert_equal(34, s1.age)
|
40
|
+
assert_equal("email", s1.send)
|
41
|
+
assert_equal("normal", s1.klass)
|
42
|
+
assert_equal(5, s1.keys)
|
43
|
+
|
44
|
+
assert_raise(NoMethodError) { s1.dup }
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'creates object which contains specified hash object itself, including fields with at prefix' do
|
48
|
+
hash = {
|
49
|
+
name: 'tagomoris',
|
50
|
+
age: 34,
|
51
|
+
send: 'email',
|
52
|
+
klass: 'normal',
|
53
|
+
keys: 5,
|
54
|
+
}
|
55
|
+
hash['@id'.to_sym] = 'myid'
|
56
|
+
|
57
|
+
s1 = Fluent::Config::Section.new(hash)
|
58
|
+
assert_equal('myid', s1['@id'])
|
59
|
+
assert_equal('myid', s1['@id'.to_sym])
|
60
|
+
assert_equal('myid', s1.__send__('@id'.to_sym))
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'creates object and config element which corresponds to section object itself' do
|
64
|
+
hash = {
|
65
|
+
name: 'tagomoris',
|
66
|
+
age: 34,
|
67
|
+
send: 'email',
|
68
|
+
klass: 'normal',
|
69
|
+
keys: 5,
|
70
|
+
}
|
71
|
+
hash['@id'.to_sym] = 'myid'
|
72
|
+
conf = config_element('section', '', {'name' => 'tagomoris', 'age' => 34, 'send' => 'email', 'klass' => 'normal', 'keys' => 5})
|
73
|
+
s2 = Fluent::Config::Section.new(hash, conf)
|
74
|
+
assert s2.corresponding_config_element.is_a?(Fluent::Config::Element)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
sub_test_case '#class' do
|
79
|
+
test 'returns class constant' do
|
80
|
+
assert_equal Fluent::Config::Section, Fluent::Config::Section.new({}).class
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
sub_test_case '#object_id' do
|
85
|
+
test 'returns its object id' do
|
86
|
+
s1 = Fluent::Config::Section.new({})
|
87
|
+
assert s1.object_id
|
88
|
+
s2 = Fluent::Config::Section.new({})
|
89
|
+
assert s2.object_id
|
90
|
+
assert_not_equal s1.object_id, s2.object_id
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
sub_test_case '#to_h' do
|
95
|
+
test 'returns internal hash itself' do
|
96
|
+
hash = {
|
97
|
+
name: 'tagomoris',
|
98
|
+
age: 34,
|
99
|
+
send: 'email',
|
100
|
+
klass: 'normal',
|
101
|
+
keys: 5,
|
102
|
+
}
|
103
|
+
s = Fluent::Config::Section.new(hash)
|
104
|
+
assert_equal(hash, s.to_h)
|
105
|
+
assert_instance_of(Hash, s.to_h)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
sub_test_case '#instance_of?' do
|
110
|
+
test 'can judge whether it is a Section object or not' do
|
111
|
+
s = Fluent::Config::Section.new
|
112
|
+
assert_true(s.instance_of?(Fluent::Config::Section))
|
113
|
+
assert_false(s.instance_of?(BasicObject))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
sub_test_case '#is_a?' do
|
118
|
+
test 'can judge whether it belongs to or not' do
|
119
|
+
s = Fluent::Config::Section.new
|
120
|
+
assert_true(s.is_a?(Fluent::Config::Section))
|
121
|
+
assert_true(s.kind_of?(Fluent::Config::Section))
|
122
|
+
assert_true(s.is_a?(BasicObject))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
sub_test_case '#+' do
|
127
|
+
test 'can merge 2 sections: argument side is primary, internal hash is newly created' do
|
128
|
+
h1 = {name: "s1", num: 10, klass: "A"}
|
129
|
+
s1 = Fluent::Config::Section.new(h1)
|
130
|
+
|
131
|
+
h2 = {name: "s2", klass: "A", num2: "5", num3: "8"}
|
132
|
+
s2 = Fluent::Config::Section.new(h2)
|
133
|
+
s = s1 + s2
|
134
|
+
|
135
|
+
assert_not_equal(h1.object_id, s.to_h.object_id)
|
136
|
+
assert_not_equal(h2.object_id, s.to_h.object_id)
|
137
|
+
|
138
|
+
assert_equal("s2", s.name)
|
139
|
+
assert_equal(10, s.num)
|
140
|
+
assert_equal("A", s.klass)
|
141
|
+
assert_equal("5", s.num2)
|
142
|
+
assert_equal("8", s.num3)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
sub_test_case '#to_s' do
|
147
|
+
test '#to_s == #inspect' do
|
148
|
+
h1 = {name: "s1", num: 10, klass: "A"}
|
149
|
+
s1 = Fluent::Config::Section.new(h1)
|
150
|
+
|
151
|
+
assert_equal(s1.to_s, s1.inspect)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
data("inspect" => [:inspect, true],
|
156
|
+
"nil?" => [:nil?, true],
|
157
|
+
"to_h" => [:to_h, true],
|
158
|
+
"+" => [:+, true],
|
159
|
+
"instance_of?" => [:instance_of?, true],
|
160
|
+
"kind_of?" => [:kind_of?, true],
|
161
|
+
"[]" => [:[], true],
|
162
|
+
"respond_to?" => [:respond_to?, true],
|
163
|
+
"respond_to_missing?" => [:respond_to_missing?, true],
|
164
|
+
"!" => [:!, true],
|
165
|
+
"!=" => [:!=, true],
|
166
|
+
"==" => [:==, true],
|
167
|
+
"equal?" => [:equal?, true],
|
168
|
+
"instance_eval" => [:instance_eval, true],
|
169
|
+
"instance_exec" => [:instance_exec, true],
|
170
|
+
"method_missing" => [:method_missing, false],
|
171
|
+
"singleton_method_added" => [:singleton_method_added, false],
|
172
|
+
"singleton_method_removed" => [:singleton_method_removed, false],
|
173
|
+
"singleton_method_undefined" => [:singleton_method_undefined, false],
|
174
|
+
"no_such_method" => [:no_such_method, false])
|
175
|
+
test '#respond_to?' do |data|
|
176
|
+
method, expected = data
|
177
|
+
h1 = {name: "s1", num: 10, klass: "A"}
|
178
|
+
s1 = Fluent::Config::Section.new(h1)
|
179
|
+
assert_equal(expected, s1.respond_to?(method))
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/configurable'
|
3
|
+
require 'fluent/config/element'
|
4
|
+
require 'fluent/config/section'
|
5
|
+
require 'fluent/system_config'
|
6
|
+
|
7
|
+
module Fluent::Config
|
8
|
+
class FakeLoggerInitializer
|
9
|
+
attr_accessor :level
|
10
|
+
def initalize
|
11
|
+
@level = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class FakeSupervisor
|
16
|
+
def initialize
|
17
|
+
@log = FakeLoggerInitializer.new
|
18
|
+
@log_level = nil
|
19
|
+
@suppress_interval = nil
|
20
|
+
@suppress_config_dump = nil
|
21
|
+
@suppress_repeated_stacktrace = nil
|
22
|
+
@without_source = nil
|
23
|
+
@emit_error_log_interval = nil
|
24
|
+
@file_permission = nil
|
25
|
+
@dir_permission = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class TestSystemConfig < ::Test::Unit::TestCase
|
30
|
+
|
31
|
+
def parse_text(text)
|
32
|
+
basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
|
33
|
+
Fluent::Config.parse(text, '(test)', basepath, true).elements.find { |e| e.name == 'system' }
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'should not override default configurations when no parameters' do
|
37
|
+
conf = parse_text(<<-EOS)
|
38
|
+
<system>
|
39
|
+
</system>
|
40
|
+
EOS
|
41
|
+
s = FakeSupervisor.new
|
42
|
+
sc = Fluent::SystemConfig.new(conf)
|
43
|
+
sc.apply(s)
|
44
|
+
assert_nil(sc.log_level)
|
45
|
+
assert_nil(sc.suppress_repeated_stacktrace)
|
46
|
+
assert_nil(sc.emit_error_log_interval)
|
47
|
+
assert_nil(sc.suppress_config_dump)
|
48
|
+
assert_nil(sc.without_source)
|
49
|
+
assert_nil(s.instance_variable_get(:@log_level))
|
50
|
+
assert_nil(s.instance_variable_get(:@suppress_repeated_stacktrace))
|
51
|
+
assert_nil(s.instance_variable_get(:@emit_error_log_interval))
|
52
|
+
assert_nil(s.instance_variable_get(:@suppress_config_dump))
|
53
|
+
assert_nil(s.instance_variable_get(:@without_source))
|
54
|
+
assert_nil(s.instance_variable_get(:@file_permission))
|
55
|
+
assert_nil(s.instance_variable_get(:@dir_permission))
|
56
|
+
end
|
57
|
+
|
58
|
+
{'log_level' => 'error',
|
59
|
+
'suppress_repeated_stacktrace' => true,
|
60
|
+
'emit_error_log_interval' => 60,
|
61
|
+
'suppress_config_dump' => true,
|
62
|
+
'without_source' => true,
|
63
|
+
}.each { |k, v|
|
64
|
+
test "accepts #{k} parameter" do
|
65
|
+
conf = parse_text(<<-EOS)
|
66
|
+
<system>
|
67
|
+
#{k} #{v}
|
68
|
+
</system>
|
69
|
+
EOS
|
70
|
+
s = FakeSupervisor.new
|
71
|
+
sc = Fluent::SystemConfig.new(conf)
|
72
|
+
sc.apply(s)
|
73
|
+
assert_not_nil(sc.instance_variable_get("@#{k}"))
|
74
|
+
key = (k == 'emit_error_log_interval' ? 'suppress_interval' : k)
|
75
|
+
assert_not_nil(s.instance_variable_get("@#{key}"))
|
76
|
+
end
|
77
|
+
}
|
78
|
+
|
79
|
+
{'foo' => 'bar', 'hoge' => 'fuga'}.each { |k, v|
|
80
|
+
test "should not affect settable parameters with unknown #{k} parameter" do
|
81
|
+
s = FakeSupervisor.new
|
82
|
+
sc = Fluent::SystemConfig.new({k => v})
|
83
|
+
sc.apply(s)
|
84
|
+
assert_nil(s.instance_variable_get(:@log_level))
|
85
|
+
assert_nil(s.instance_variable_get(:@suppress_repeated_stacktrace))
|
86
|
+
assert_nil(s.instance_variable_get(:@emit_error_log_interval))
|
87
|
+
assert_nil(s.instance_variable_get(:@suppress_config_dump))
|
88
|
+
assert_nil(s.instance_variable_get(:@without_source))
|
89
|
+
assert_nil(s.instance_variable_get(:@file_permission))
|
90
|
+
assert_nil(s.instance_variable_get(:@dir_permission))
|
91
|
+
end
|
92
|
+
}
|
93
|
+
|
94
|
+
test 'log_level' do
|
95
|
+
conf = parse_text(<<-EOS)
|
96
|
+
<system>
|
97
|
+
log_level warn
|
98
|
+
</system>
|
99
|
+
EOS
|
100
|
+
s = FakeSupervisor.new
|
101
|
+
sc = Fluent::SystemConfig.new(conf)
|
102
|
+
sc.apply(s)
|
103
|
+
assert_equal(Fluent::Log::LEVEL_WARN, s.instance_variable_get("@log").level)
|
104
|
+
end
|
105
|
+
|
106
|
+
test 'process global overridable variables' do
|
107
|
+
conf = parse_text(<<-EOS)
|
108
|
+
<system>
|
109
|
+
file_permission 0655
|
110
|
+
dir_permission 0765
|
111
|
+
</system>
|
112
|
+
EOS
|
113
|
+
s = FakeSupervisor.new
|
114
|
+
sc = Fluent::SystemConfig.new(conf)
|
115
|
+
sc.apply(s)
|
116
|
+
assert_equal(0655, s.instance_variable_get(:@file_permission))
|
117
|
+
assert_equal(0765, s.instance_variable_get(:@dir_permission))
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fluent/config/types'
|
3
|
+
|
4
|
+
class TestConfigTypes < ::Test::Unit::TestCase
|
5
|
+
include Fluent
|
6
|
+
|
7
|
+
sub_test_case 'Config.size_value' do
|
8
|
+
test 'normal case' do
|
9
|
+
assert_equal(2048, Config.size_value("2k"))
|
10
|
+
assert_equal(2048, Config.size_value("2K"))
|
11
|
+
assert_equal(3145728, Config.size_value("3m"))
|
12
|
+
assert_equal(3145728, Config.size_value("3M"))
|
13
|
+
assert_equal(4294967296, Config.size_value("4g"))
|
14
|
+
assert_equal(4294967296, Config.size_value("4G"))
|
15
|
+
assert_equal(5497558138880, Config.size_value("5t"))
|
16
|
+
assert_equal(5497558138880, Config.size_value("5T"))
|
17
|
+
assert_equal(6, Config.size_value("6"))
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'not assumed case' do
|
21
|
+
assert_equal(6, Config.size_value(6))
|
22
|
+
assert_equal(0, Config.size_value("hoge"))
|
23
|
+
assert_equal(0, Config.size_value(""))
|
24
|
+
assert_equal(0, Config.size_value(nil))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
sub_test_case 'Config.time_value' do
|
29
|
+
test 'normal case' do
|
30
|
+
assert_equal(10, Config.time_value("10s"))
|
31
|
+
assert_equal(10, Config.time_value("10sec"))
|
32
|
+
assert_equal(120, Config.time_value("2m"))
|
33
|
+
assert_equal(10800, Config.time_value("3h"))
|
34
|
+
assert_equal(345600, Config.time_value("4d"))
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'not assumed case' do
|
38
|
+
assert_equal(4.0, Config.time_value(4))
|
39
|
+
assert_equal(0.4, Config.time_value(0.4))
|
40
|
+
assert_equal(0.0, Config.time_value("hoge"))
|
41
|
+
assert_equal(0.0, Config.time_value(""))
|
42
|
+
assert_equal(0.0, Config.time_value(nil))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
sub_test_case 'Config.bool_value' do
|
47
|
+
test 'normal case' do
|
48
|
+
assert_true Config.bool_value("true")
|
49
|
+
assert_true Config.bool_value("yes")
|
50
|
+
assert_true Config.bool_value("")
|
51
|
+
assert_false Config.bool_value("false")
|
52
|
+
assert_false Config.bool_value("no")
|
53
|
+
end
|
54
|
+
|
55
|
+
test 'not assumed case' do
|
56
|
+
assert_true Config.bool_value(true)
|
57
|
+
assert_false Config.bool_value(false)
|
58
|
+
assert_nil Config.bool_value("hoge")
|
59
|
+
assert_nil Config.bool_value(nil)
|
60
|
+
assert_nil Config.bool_value(10)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
sub_test_case 'type converters for config_param definitions' do
|
65
|
+
test 'string' do
|
66
|
+
assert_equal 'test', Config::STRING_TYPE.call('test', {})
|
67
|
+
assert_equal '1', Config::STRING_TYPE.call('1', {})
|
68
|
+
assert_equal ' ', Config::STRING_TYPE.call(' ', {})
|
69
|
+
end
|
70
|
+
|
71
|
+
test 'enum' do
|
72
|
+
assert_equal :val, Config::ENUM_TYPE.call('val', {list: [:val, :value, :v]})
|
73
|
+
assert_equal :v, Config::ENUM_TYPE.call('v', {list: [:val, :value, :v]})
|
74
|
+
assert_equal :value, Config::ENUM_TYPE.call('value', {list: [:val, :value, :v]})
|
75
|
+
assert_raises(Fluent::ConfigError.new("valid options are val,value,v but got x")){ Config::ENUM_TYPE.call('x', {list: [:val, :value, :v]}) }
|
76
|
+
assert_raises(RuntimeError.new("Plugin BUG: config type 'enum' requires :list of symbols")){ Config::ENUM_TYPE.call('val', {}) }
|
77
|
+
assert_raises(RuntimeError.new("Plugin BUG: config type 'enum' requires :list of symbols")){ Config::ENUM_TYPE.call('val', {list: ["val", "value", "v"]}) }
|
78
|
+
end
|
79
|
+
|
80
|
+
test 'integer' do
|
81
|
+
assert_equal 1, Config::INTEGER_TYPE.call('1', {})
|
82
|
+
assert_equal 1, Config::INTEGER_TYPE.call('1.0', {})
|
83
|
+
assert_equal 1000, Config::INTEGER_TYPE.call('1_000', {})
|
84
|
+
assert_equal 1, Config::INTEGER_TYPE.call('1x', {})
|
85
|
+
end
|
86
|
+
|
87
|
+
test 'float' do
|
88
|
+
assert_equal 1.0, Config::FLOAT_TYPE.call('1', {})
|
89
|
+
assert_equal 1.0, Config::FLOAT_TYPE.call('1.0', {})
|
90
|
+
assert_equal 1.0, Config::FLOAT_TYPE.call('1.00', {})
|
91
|
+
assert_equal 1.0, Config::FLOAT_TYPE.call('1e0', {})
|
92
|
+
end
|
93
|
+
|
94
|
+
test 'size' do
|
95
|
+
assert_equal 1000, Config::SIZE_TYPE.call('1000', {})
|
96
|
+
assert_equal 1024, Config::SIZE_TYPE.call('1k', {})
|
97
|
+
assert_equal 1024*1024, Config::SIZE_TYPE.call('1m', {})
|
98
|
+
end
|
99
|
+
|
100
|
+
test 'bool' do
|
101
|
+
assert_equal true, Config::BOOL_TYPE.call('true', {})
|
102
|
+
assert_equal true, Config::BOOL_TYPE.call('yes', {})
|
103
|
+
assert_equal false, Config::BOOL_TYPE.call('no', {})
|
104
|
+
assert_equal false, Config::BOOL_TYPE.call('false', {})
|
105
|
+
|
106
|
+
assert_equal nil, Config::BOOL_TYPE.call('TRUE', {})
|
107
|
+
assert_equal nil, Config::BOOL_TYPE.call('True', {})
|
108
|
+
assert_equal nil, Config::BOOL_TYPE.call('Yes', {})
|
109
|
+
assert_equal nil, Config::BOOL_TYPE.call('No', {})
|
110
|
+
|
111
|
+
assert_equal true, Config::BOOL_TYPE.call('', {})
|
112
|
+
assert_equal nil, Config::BOOL_TYPE.call('unexpected_string', {})
|
113
|
+
end
|
114
|
+
|
115
|
+
test 'time' do
|
116
|
+
assert_equal 0, Config::TIME_TYPE.call('0', {})
|
117
|
+
assert_equal 1.0, Config::TIME_TYPE.call('1', {})
|
118
|
+
assert_equal 1.01, Config::TIME_TYPE.call('1.01', {})
|
119
|
+
assert_equal 1, Config::TIME_TYPE.call('1s', {})
|
120
|
+
assert_equal 60, Config::TIME_TYPE.call('1m', {})
|
121
|
+
assert_equal 3600, Config::TIME_TYPE.call('1h', {})
|
122
|
+
assert_equal 86400, Config::TIME_TYPE.call('1d', {})
|
123
|
+
end
|
124
|
+
|
125
|
+
test 'hash' do
|
126
|
+
assert_equal({"x"=>"v","k"=>1}, Config::HASH_TYPE.call('{"x":"v","k":1}', {}))
|
127
|
+
assert_equal({"x"=>"v","k"=>"1"}, Config::HASH_TYPE.call('x:v,k:1', {}))
|
128
|
+
assert_equal({"x"=>"v","k"=>"1"}, Config::HASH_TYPE.call('x:v, k:1', {}))
|
129
|
+
assert_equal({"x"=>"v","k"=>"1"}, Config::HASH_TYPE.call(' x:v, k:1 ', {}))
|
130
|
+
assert_equal({"x"=>"v","k"=>"1"}, Config::HASH_TYPE.call('x:v , k:1 ', {}))
|
131
|
+
|
132
|
+
assert_equal({"x"=>"v:v","k"=>"1"}, Config::HASH_TYPE.call('x:v:v, k:1', {}))
|
133
|
+
|
134
|
+
assert_equal({x: "v", k: 1}, Config::HASH_TYPE.call('{"x":"v","k":1}', {symbolize_keys: true}))
|
135
|
+
assert_equal({x: "v", k: "1"}, Config::HASH_TYPE.call('x:v,k:1', {symbolize_keys: true, value_type: :string}))
|
136
|
+
assert_equal({x: "v", k: "1"}, Config::HASH_TYPE.call('{"x":"v","k":1}', {symbolize_keys: true, value_type: :string}))
|
137
|
+
assert_equal({x: 0, k: 1}, Config::HASH_TYPE.call('x:0,k:1', {symbolize_keys: true, value_type: :integer}))
|
138
|
+
|
139
|
+
assert_equal({"x"=>1,"y"=>60,"z"=>3600}, Config::HASH_TYPE.call('{"x":"1s","y":"1m","z":"1h"}', {value_type: :time}))
|
140
|
+
assert_equal({"x"=>1,"y"=>60,"z"=>3600}, Config::HASH_TYPE.call('x:1s,y:1m,z:1h', {value_type: :time}))
|
141
|
+
|
142
|
+
assert_raise(RuntimeError.new("unknown type in REFORMAT: foo")){ Config::HASH_TYPE.call("x:1,y:2", {value_type: :foo}) }
|
143
|
+
end
|
144
|
+
|
145
|
+
test 'array' do
|
146
|
+
assert_equal(["1","2",1], Config::ARRAY_TYPE.call('["1","2",1]', {}))
|
147
|
+
assert_equal(["1","2","1"], Config::ARRAY_TYPE.call('1,2,1', {}))
|
148
|
+
|
149
|
+
assert_equal(["a","b","c"], Config::ARRAY_TYPE.call('["a","b","c"]', {}))
|
150
|
+
assert_equal(["a","b","c"], Config::ARRAY_TYPE.call('a,b,c', {}))
|
151
|
+
assert_equal(["a","b","c"], Config::ARRAY_TYPE.call('a, b, c', {}))
|
152
|
+
assert_equal(["a","b","c"], Config::ARRAY_TYPE.call('a , b , c', {}))
|
153
|
+
|
154
|
+
assert_equal(["a a","b,b"," c "], Config::ARRAY_TYPE.call('["a a","b,b"," c "]', {}))
|
155
|
+
|
156
|
+
assert_equal(["a a","b","c"], Config::ARRAY_TYPE.call('a a,b,c', {}))
|
157
|
+
|
158
|
+
assert_equal([1,2,1], Config::ARRAY_TYPE.call('[1,2,1]', {}))
|
159
|
+
assert_equal([1,2,1], Config::ARRAY_TYPE.call('["1","2","1"]', {value_type: :integer}))
|
160
|
+
assert_equal([1,2,1], Config::ARRAY_TYPE.call('1,2,1', {value_type: :integer}))
|
161
|
+
|
162
|
+
array_options = {
|
163
|
+
default: [],
|
164
|
+
}
|
165
|
+
assert_equal(["1","2"], Config::ARRAY_TYPE.call('["1","2"]', array_options))
|
166
|
+
assert_equal(["3"], Config::ARRAY_TYPE.call('["3"]', array_options))
|
167
|
+
|
168
|
+
assert_raise(RuntimeError.new("unknown type in REFORMAT: foo")){ Config::ARRAY_TYPE.call("1,2", {value_type: :foo}) }
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|