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,386 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/config/configure_proxy'
|
3
|
+
|
4
|
+
module Fluent::Config
|
5
|
+
class TestConfigureProxy < ::Test::Unit::TestCase
|
6
|
+
setup do
|
7
|
+
@type_lookup = ->(type) { Fluent::Configurable.lookup_type(type) }
|
8
|
+
end
|
9
|
+
|
10
|
+
sub_test_case 'to generate a instance' do
|
11
|
+
sub_test_case '#initialize' do
|
12
|
+
test 'has default values' do
|
13
|
+
proxy = Fluent::Config::ConfigureProxy.new('section', type_lookup: @type_lookup)
|
14
|
+
assert_equal(:section, proxy.name)
|
15
|
+
|
16
|
+
proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
17
|
+
assert_equal(:section, proxy.name)
|
18
|
+
assert_nil(proxy.param_name)
|
19
|
+
assert_equal(:section, proxy.variable_name)
|
20
|
+
assert_false(proxy.root?)
|
21
|
+
assert_nil(proxy.init)
|
22
|
+
assert_nil(proxy.required)
|
23
|
+
assert_false(proxy.required?)
|
24
|
+
assert_nil(proxy.multi)
|
25
|
+
assert_true(proxy.multi?)
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'can specify param_name/required/multi with optional arguments' do
|
29
|
+
proxy = Fluent::Config::ConfigureProxy.new(:section, param_name: 'sections', init: true, required: false, multi: true, type_lookup: @type_lookup)
|
30
|
+
assert_equal(:section, proxy.name)
|
31
|
+
assert_equal(:sections, proxy.param_name)
|
32
|
+
assert_equal(:sections, proxy.variable_name)
|
33
|
+
assert_false(proxy.required)
|
34
|
+
assert_false(proxy.required?)
|
35
|
+
assert_true(proxy.multi)
|
36
|
+
assert_true(proxy.multi?)
|
37
|
+
|
38
|
+
proxy = Fluent::Config::ConfigureProxy.new(:section, param_name: :sections, init: false, required: true, multi: false, type_lookup: @type_lookup)
|
39
|
+
assert_equal(:section, proxy.name)
|
40
|
+
assert_equal(:sections, proxy.param_name)
|
41
|
+
assert_equal(:sections, proxy.variable_name)
|
42
|
+
assert_true(proxy.required)
|
43
|
+
assert_true(proxy.required?)
|
44
|
+
assert_false(proxy.multi)
|
45
|
+
assert_false(proxy.multi?)
|
46
|
+
end
|
47
|
+
test 'raise error if both of init and required are true' do
|
48
|
+
assert_raise "init and required are exclusive" do
|
49
|
+
Fluent::Config::ConfigureProxy.new(:section, init: true, required: true, type_lookup: @type_lookup)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
sub_test_case '#merge' do
|
55
|
+
test 'generate a new instance which values are overwritten by the argument object' do
|
56
|
+
proxy = p1 = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
57
|
+
assert_equal(:section, proxy.name)
|
58
|
+
assert_nil(proxy.param_name)
|
59
|
+
assert_equal(:section, proxy.variable_name)
|
60
|
+
assert_nil(proxy.init)
|
61
|
+
assert_nil(proxy.required)
|
62
|
+
assert_false(proxy.required?)
|
63
|
+
assert_nil(proxy.multi)
|
64
|
+
assert_true(proxy.multi?)
|
65
|
+
assert_nil(proxy.configured_in_section)
|
66
|
+
|
67
|
+
p2 = Fluent::Config::ConfigureProxy.new(:section, init: false, required: true, multi: false, type_lookup: @type_lookup)
|
68
|
+
proxy = p1.merge(p2)
|
69
|
+
assert_equal(:section, proxy.name)
|
70
|
+
assert_nil(proxy.param_name)
|
71
|
+
assert_equal(:section, proxy.variable_name)
|
72
|
+
assert_false(proxy.init)
|
73
|
+
assert_false(proxy.init?)
|
74
|
+
assert_true(proxy.required)
|
75
|
+
assert_true(proxy.required?)
|
76
|
+
assert_false(proxy.multi)
|
77
|
+
assert_false(proxy.multi?)
|
78
|
+
assert_nil(proxy.configured_in_section)
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'does not overwrite with argument object without any specifications of required/multi' do
|
82
|
+
p1 = Fluent::Config::ConfigureProxy.new(:section1, param_name: :sections, type_lookup: @type_lookup)
|
83
|
+
p1.configured_in_section = :subsection
|
84
|
+
p2 = Fluent::Config::ConfigureProxy.new(:section2, init: false, required: true, multi: false, type_lookup: @type_lookup)
|
85
|
+
p3 = Fluent::Config::ConfigureProxy.new(:section3, type_lookup: @type_lookup)
|
86
|
+
proxy = p1.merge(p2).merge(p3)
|
87
|
+
assert_equal(:section1, proxy.name)
|
88
|
+
assert_equal(:sections, proxy.param_name)
|
89
|
+
assert_equal(:sections, proxy.variable_name)
|
90
|
+
assert_false(proxy.init)
|
91
|
+
assert_false(proxy.init?)
|
92
|
+
assert_true(proxy.required)
|
93
|
+
assert_true(proxy.required?)
|
94
|
+
assert_false(proxy.multi)
|
95
|
+
assert_false(proxy.multi?)
|
96
|
+
assert_equal :subsection, proxy.configured_in_section
|
97
|
+
end
|
98
|
+
|
99
|
+
test "does overwrite name of proxy for root sections which are used for plugins" do
|
100
|
+
# latest plugin class shows actual plugin implementation
|
101
|
+
p1 = Fluent::Config::ConfigureProxy.new('Fluent::Plugin::MyP1'.to_sym, root: true, required: true, multi: false, type_lookup: @type_lookup)
|
102
|
+
p1.config_param :key1, :integer
|
103
|
+
|
104
|
+
p2 = Fluent::Config::ConfigureProxy.new('Fluent::Plugin::MyP2'.to_sym, root: true, required: true, multi: false, type_lookup: @type_lookup)
|
105
|
+
p2.config_param :key2, :string, default: "value2"
|
106
|
+
|
107
|
+
merged = p1.merge(p2)
|
108
|
+
|
109
|
+
assert_equal 'Fluent::Plugin::MyP2'.to_sym, merged.name
|
110
|
+
assert_true merged.root?
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
sub_test_case '#overwrite_defaults' do
|
115
|
+
test 'overwrites only defaults with others defaults' do
|
116
|
+
type_lookup = ->(type) { Fluent::Configurable.lookup_type(type) }
|
117
|
+
p1 = Fluent::Config::ConfigureProxy.new(:mychild, type_lookup: type_lookup)
|
118
|
+
p1.configured_in_section = :child
|
119
|
+
p1.config_param(:k1a, :string)
|
120
|
+
p1.config_param(:k1b, :string)
|
121
|
+
p1.config_param(:k2a, :integer, default: 0)
|
122
|
+
p1.config_param(:k2b, :integer, default: 0)
|
123
|
+
p1.config_section(:sub1) do
|
124
|
+
config_param :k3, :time, default: 30
|
125
|
+
end
|
126
|
+
|
127
|
+
p0 = Fluent::Config::ConfigureProxy.new(:myparent, type_lookup: type_lookup)
|
128
|
+
p0.config_section(:child) do
|
129
|
+
config_set_default :k1a, "v1a"
|
130
|
+
config_param :k1b, :string, default: "v1b"
|
131
|
+
config_set_default :k2a, 21
|
132
|
+
config_param :k2b, :integer, default: 22
|
133
|
+
config_section :sub1 do
|
134
|
+
config_set_default :k3, 60
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
p1.overwrite_defaults(p0.sections[:child])
|
139
|
+
|
140
|
+
assert_equal "v1a", p1.defaults[:k1a]
|
141
|
+
assert_equal "v1b", p1.defaults[:k1b]
|
142
|
+
assert_equal 21, p1.defaults[:k2a]
|
143
|
+
assert_equal 22, p1.defaults[:k2b]
|
144
|
+
assert_equal 60, p1.sections[:sub1].defaults[:k3]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
sub_test_case '#configured_in' do
|
149
|
+
test 'sets a section name which have configuration parameters of target plugin in owners configuration' do
|
150
|
+
proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
151
|
+
proxy.configured_in(:mysection)
|
152
|
+
assert_equal :mysection, proxy.configured_in_section
|
153
|
+
end
|
154
|
+
|
155
|
+
test 'do not permit to be called twice' do
|
156
|
+
proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
157
|
+
proxy.configured_in(:mysection)
|
158
|
+
assert_raise(ArgumentError) { proxy.configured_in(:myothersection) }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
sub_test_case '#config_param / #config_set_default / #config_argument' do
|
163
|
+
setup do
|
164
|
+
@proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
165
|
+
end
|
166
|
+
|
167
|
+
test 'does not permit config_set_default for param w/ :default option' do
|
168
|
+
@proxy.config_param(:name, :string, default: "name1")
|
169
|
+
assert_raise(ArgumentError) { @proxy.config_set_default(:name, "name2") }
|
170
|
+
end
|
171
|
+
|
172
|
+
test 'does not permit default value specification twice' do
|
173
|
+
@proxy.config_param(:name, :string)
|
174
|
+
@proxy.config_set_default(:name, "name1")
|
175
|
+
assert_raise(ArgumentError) { @proxy.config_set_default(:name, "name2") }
|
176
|
+
end
|
177
|
+
|
178
|
+
test 'does not permit default value specification twice, even on config_argument' do
|
179
|
+
@proxy.config_param(:name, :string)
|
180
|
+
@proxy.config_set_default(:name, "name1")
|
181
|
+
|
182
|
+
@proxy.config_argument(:name)
|
183
|
+
assert_raise(ArgumentError) { @proxy.config_argument(:name, default: "name2") }
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
sub_test_case '#config_param without default values cause error if section is configured as init:true' do
|
188
|
+
setup do
|
189
|
+
@proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
190
|
+
end
|
191
|
+
|
192
|
+
test 'with simple config_param with default value' do
|
193
|
+
assert_nothing_raised do
|
194
|
+
@proxy.config_section :subsection, init: true do
|
195
|
+
config_param :param1, :integer, default: 1
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
test 'with simple config_param without default value' do
|
200
|
+
assert_raise ArgumentError do
|
201
|
+
@proxy.config_section :subsection, init: true do
|
202
|
+
config_param :param1, :integer
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
test 'with config_param with config_set_default' do
|
207
|
+
assert_nothing_raised do
|
208
|
+
@proxy.config_section :subsection, init: true do
|
209
|
+
config_param :param1, :integer
|
210
|
+
config_set_default :param1, 1
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
test 'with config_argument' do
|
215
|
+
assert_raise ArgumentError do
|
216
|
+
@proxy.config_section :subsection, init: true do
|
217
|
+
config_argument :param0, :string
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
test 'with config_argument with default value' do
|
222
|
+
assert_nothing_raised do
|
223
|
+
@proxy.config_section :subsection, init: true do
|
224
|
+
config_argument :param0, :string, default: ''
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
sub_test_case '#config_set_desc' do
|
231
|
+
setup do
|
232
|
+
@proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
233
|
+
end
|
234
|
+
|
235
|
+
test 'does not permit description specification twice w/ :desc option' do
|
236
|
+
@proxy.config_param(:name, :string, desc: "description")
|
237
|
+
assert_raise(ArgumentError) { @proxy.config_set_desc(:name, "description2") }
|
238
|
+
end
|
239
|
+
|
240
|
+
test 'does not permit description specification twice' do
|
241
|
+
@proxy.config_param(:name, :string)
|
242
|
+
@proxy.config_set_desc(:name, "description")
|
243
|
+
assert_raise(ArgumentError) { @proxy.config_set_desc(:name, "description2") }
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
sub_test_case '#desc' do
|
248
|
+
setup do
|
249
|
+
@proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
250
|
+
end
|
251
|
+
|
252
|
+
test 'permit to specify description twice' do
|
253
|
+
@proxy.desc("description1")
|
254
|
+
@proxy.desc("description2")
|
255
|
+
@proxy.config_param(:name, :string)
|
256
|
+
assert_equal("description2", @proxy.descriptions[:name])
|
257
|
+
end
|
258
|
+
|
259
|
+
test 'does not permit description specification twice' do
|
260
|
+
@proxy.desc("description1")
|
261
|
+
assert_raise(ArgumentError) do
|
262
|
+
@proxy.config_param(:name, :string, desc: "description2")
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
sub_test_case '#dump' do
|
268
|
+
setup do
|
269
|
+
@proxy = Fluent::Config::ConfigureProxy.new(:section, type_lookup: @type_lookup)
|
270
|
+
end
|
271
|
+
|
272
|
+
test 'empty proxy' do
|
273
|
+
assert_equal("", @proxy.dump)
|
274
|
+
end
|
275
|
+
|
276
|
+
test 'plain proxy w/o default value' do
|
277
|
+
@proxy.config_param(:name, :string)
|
278
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
279
|
+
name: string: <nil>
|
280
|
+
CONFIG
|
281
|
+
end
|
282
|
+
|
283
|
+
test 'plain proxy w/ default value' do
|
284
|
+
@proxy.config_param(:name, :string, default: "name1")
|
285
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
286
|
+
name: string: <"name1">
|
287
|
+
CONFIG
|
288
|
+
end
|
289
|
+
|
290
|
+
test 'plain proxy w/ default value using config_set_default' do
|
291
|
+
@proxy.config_param(:name, :string)
|
292
|
+
@proxy.config_set_default(:name, "name1")
|
293
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
294
|
+
name: string: <"name1">
|
295
|
+
CONFIG
|
296
|
+
end
|
297
|
+
|
298
|
+
test 'single sub proxy' do
|
299
|
+
@proxy.config_section(:sub) do
|
300
|
+
config_param(:name, :string, default: "name1")
|
301
|
+
end
|
302
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
303
|
+
sub
|
304
|
+
name: string: <"name1">
|
305
|
+
CONFIG
|
306
|
+
end
|
307
|
+
|
308
|
+
test 'nested sub proxy' do
|
309
|
+
@proxy.config_section(:sub) do
|
310
|
+
config_param(:name1, :string, default: "name1")
|
311
|
+
config_param(:name2, :string, default: "name2")
|
312
|
+
config_section(:sub2) do
|
313
|
+
config_param(:name3, :string, default: "name3")
|
314
|
+
config_param(:name4, :string, default: "name4")
|
315
|
+
end
|
316
|
+
end
|
317
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
318
|
+
sub
|
319
|
+
name1: string: <"name1">
|
320
|
+
name2: string: <"name2">
|
321
|
+
sub2
|
322
|
+
name3: string: <"name3">
|
323
|
+
name4: string: <"name4">
|
324
|
+
CONFIG
|
325
|
+
end
|
326
|
+
|
327
|
+
sub_test_case 'w/ description' do
|
328
|
+
test 'single proxy' do
|
329
|
+
@proxy.config_param(:name, :string, desc: "description for name")
|
330
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
331
|
+
name: string: <nil> # description for name
|
332
|
+
CONFIG
|
333
|
+
end
|
334
|
+
|
335
|
+
test 'single proxy using config_set_desc' do
|
336
|
+
@proxy.config_param(:name, :string)
|
337
|
+
@proxy.config_set_desc(:name, "description for name")
|
338
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
339
|
+
name: string: <nil> # description for name
|
340
|
+
CONFIG
|
341
|
+
end
|
342
|
+
|
343
|
+
test 'sub proxy' do
|
344
|
+
@proxy.config_section(:sub) do
|
345
|
+
config_param(:name1, :string, default: "name1", desc: "desc1")
|
346
|
+
config_param(:name2, :string, default: "name2", desc: "desc2")
|
347
|
+
config_section(:sub2) do
|
348
|
+
config_param(:name3, :string, default: "name3")
|
349
|
+
config_param(:name4, :string, default: "name4", desc: "desc4")
|
350
|
+
end
|
351
|
+
end
|
352
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
353
|
+
sub
|
354
|
+
name1: string: <"name1"> # desc1
|
355
|
+
name2: string: <"name2"> # desc2
|
356
|
+
sub2
|
357
|
+
name3: string: <"name3">
|
358
|
+
name4: string: <"name4"> # desc4
|
359
|
+
CONFIG
|
360
|
+
end
|
361
|
+
|
362
|
+
test 'sub proxy w/ desc method' do
|
363
|
+
@proxy.config_section(:sub) do
|
364
|
+
desc("desc1")
|
365
|
+
config_param(:name1, :string, default: "name1")
|
366
|
+
config_param(:name2, :string, default: "name2", desc: "desc2")
|
367
|
+
config_section(:sub2) do
|
368
|
+
config_param(:name3, :string, default: "name3")
|
369
|
+
desc("desc4")
|
370
|
+
config_param(:name4, :string, default: "name4")
|
371
|
+
end
|
372
|
+
end
|
373
|
+
assert_equal(<<CONFIG, @proxy.dump)
|
374
|
+
sub
|
375
|
+
name1: string: <"name1"> # desc1
|
376
|
+
name2: string: <"name2"> # desc2
|
377
|
+
sub2
|
378
|
+
name3: string: <"name3">
|
379
|
+
name4: string: <"name4"> # desc4
|
380
|
+
CONFIG
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
@@ -0,0 +1,415 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/config/element'
|
3
|
+
require "fluent/config/dsl"
|
4
|
+
|
5
|
+
TMP_DIR = File.dirname(__FILE__) + "/tmp/config_dsl#{ENV['TEST_ENV_NUMBER']}"
|
6
|
+
def write_config(path, data)
|
7
|
+
FileUtils.mkdir_p(File.dirname(path))
|
8
|
+
File.open(path, "w") {|f| f.write data }
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare_config1
|
12
|
+
write_config "#{TMP_DIR}/config_test_1.conf", %[
|
13
|
+
k1 root_config
|
14
|
+
include dir/config_test_2.conf #
|
15
|
+
@include #{TMP_DIR}/config_test_4.conf
|
16
|
+
include file://#{TMP_DIR}/config_test_5.conf
|
17
|
+
@include config.d/*.conf
|
18
|
+
]
|
19
|
+
write_config "#{TMP_DIR}/dir/config_test_2.conf", %[
|
20
|
+
k2 relative_path_include
|
21
|
+
@include ../config_test_3.conf
|
22
|
+
]
|
23
|
+
write_config "#{TMP_DIR}/config_test_3.conf", %[
|
24
|
+
k3 relative_include_in_included_file
|
25
|
+
]
|
26
|
+
write_config "#{TMP_DIR}/config_test_4.conf", %[
|
27
|
+
k4 absolute_path_include
|
28
|
+
]
|
29
|
+
write_config "#{TMP_DIR}/config_test_5.conf", %[
|
30
|
+
k5 uri_include
|
31
|
+
]
|
32
|
+
write_config "#{TMP_DIR}/config.d/config_test_6.conf", %[
|
33
|
+
k6 wildcard_include_1
|
34
|
+
<elem1 name>
|
35
|
+
include normal_parameter
|
36
|
+
</elem1>
|
37
|
+
]
|
38
|
+
write_config "#{TMP_DIR}/config.d/config_test_7.conf", %[
|
39
|
+
k7 wildcard_include_2
|
40
|
+
]
|
41
|
+
write_config "#{TMP_DIR}/config.d/config_test_8.conf", %[
|
42
|
+
<elem2 name>
|
43
|
+
@include ../dir/config_test_9.conf
|
44
|
+
</elem2>
|
45
|
+
]
|
46
|
+
write_config "#{TMP_DIR}/dir/config_test_9.conf", %[
|
47
|
+
k9 embeded
|
48
|
+
<elem3 name>
|
49
|
+
nested nested_value
|
50
|
+
include hoge
|
51
|
+
</elem3>
|
52
|
+
]
|
53
|
+
write_config "#{TMP_DIR}/config.d/00_config_test_8.conf", %[
|
54
|
+
k8 wildcard_include_3
|
55
|
+
<elem4 name>
|
56
|
+
include normal_parameter
|
57
|
+
</elem4>
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def prepare_config2
|
62
|
+
write_config "#{TMP_DIR}/config_test_1.rb", DSL_CONFIG_EXAMPLE
|
63
|
+
end
|
64
|
+
|
65
|
+
DSL_CONFIG_EXAMPLE = %q[
|
66
|
+
worker {
|
67
|
+
hostname = "myhostname"
|
68
|
+
|
69
|
+
(0..9).each { |i|
|
70
|
+
source {
|
71
|
+
type :tail
|
72
|
+
path "/var/log/httpd/access.part#{i}.log"
|
73
|
+
|
74
|
+
filter ('bar.**') {
|
75
|
+
type :hoge
|
76
|
+
val1 "moge"
|
77
|
+
val2 ["foo", "bar", "baz"]
|
78
|
+
val3 10
|
79
|
+
id :hoge
|
80
|
+
|
81
|
+
subsection {
|
82
|
+
foo "bar"
|
83
|
+
}
|
84
|
+
subsection {
|
85
|
+
foo "baz"
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
filter ('foo.**') {
|
90
|
+
type "pass"
|
91
|
+
}
|
92
|
+
|
93
|
+
match ('{foo,bar}.**') {
|
94
|
+
type "file"
|
95
|
+
path "/var/log/httpd/access.#{hostname}.#{i}.log"
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
]
|
101
|
+
|
102
|
+
DSL_CONFIG_EXAMPLE_WITHOUT_WORKER = %q[
|
103
|
+
hostname = "myhostname"
|
104
|
+
|
105
|
+
source {
|
106
|
+
type :tail
|
107
|
+
path "/var/log/httpd/access.part.log"
|
108
|
+
|
109
|
+
element {
|
110
|
+
name "foo"
|
111
|
+
}
|
112
|
+
|
113
|
+
match ('{foo,bar}.**') {
|
114
|
+
type "file"
|
115
|
+
path "/var/log/httpd/access.full.log"
|
116
|
+
}
|
117
|
+
}
|
118
|
+
]
|
119
|
+
|
120
|
+
DSL_CONFIG_EXAMPLE_FOR_INCLUDE_CONF = %q[
|
121
|
+
include "#{TMP_DIR}/config_test_1.conf"
|
122
|
+
]
|
123
|
+
|
124
|
+
DSL_CONFIG_EXAMPLE_FOR_INCLUDE_RB = %q[
|
125
|
+
include "#{TMP_DIR}/config_test_1.rb"
|
126
|
+
]
|
127
|
+
|
128
|
+
DSL_CONFIG_RETURNS_NON_ELEMENT = %q[
|
129
|
+
worker {
|
130
|
+
}
|
131
|
+
[]
|
132
|
+
]
|
133
|
+
|
134
|
+
DSL_CONFIG_WRONG_SYNTAX1 = %q[
|
135
|
+
match
|
136
|
+
]
|
137
|
+
DSL_CONFIG_WRONG_SYNTAX2 = %q[
|
138
|
+
match('aa','bb'){
|
139
|
+
type :null
|
140
|
+
}
|
141
|
+
]
|
142
|
+
DSL_CONFIG_WRONG_SYNTAX3 = %q[
|
143
|
+
match('aa','bb')
|
144
|
+
]
|
145
|
+
DSL_CONFIG_WRONG_SYNTAX4 = %q[
|
146
|
+
include
|
147
|
+
]
|
148
|
+
|
149
|
+
module Fluent::Config
|
150
|
+
class TestDSLParser < ::Test::Unit::TestCase
|
151
|
+
sub_test_case 'with worker tag on top level' do
|
152
|
+
def setup
|
153
|
+
@root = Fluent::Config::DSL::Parser.parse(DSL_CONFIG_EXAMPLE, 'dsl_config.rb')
|
154
|
+
end
|
155
|
+
|
156
|
+
sub_test_case '.parse' do
|
157
|
+
test 'makes root element' do
|
158
|
+
assert_equal('ROOT', @root.name)
|
159
|
+
assert_predicate(@root.arg, :empty?)
|
160
|
+
assert_equal(0, @root.keys.size)
|
161
|
+
end
|
162
|
+
|
163
|
+
test 'makes worker element for worker tag' do
|
164
|
+
assert_equal(1, @root.elements.size)
|
165
|
+
|
166
|
+
worker = @root.elements.first
|
167
|
+
assert_equal('worker', worker.name)
|
168
|
+
assert_predicate(worker.arg, :empty?)
|
169
|
+
assert_equal(0, worker.keys.size)
|
170
|
+
assert_equal(10, worker.elements.size)
|
171
|
+
end
|
172
|
+
|
173
|
+
test 'makes subsections for blocks, with variable substitution' do
|
174
|
+
ele4 = @root.elements.first.elements[4]
|
175
|
+
|
176
|
+
assert_equal('source', ele4.name)
|
177
|
+
assert_predicate(ele4.arg, :empty?)
|
178
|
+
assert_equal(2, ele4.keys.size)
|
179
|
+
assert_equal('tail', ele4['type'])
|
180
|
+
assert_equal("/var/log/httpd/access.part4.log", ele4['path'])
|
181
|
+
end
|
182
|
+
|
183
|
+
test 'makes user-defined sections with blocks' do
|
184
|
+
filter0 = @root.elements.first.elements[4].elements.first
|
185
|
+
|
186
|
+
assert_equal('filter', filter0.name)
|
187
|
+
assert_equal('bar.**', filter0.arg)
|
188
|
+
assert_equal('hoge', filter0['type'])
|
189
|
+
assert_equal('moge', filter0['val1'])
|
190
|
+
assert_equal(JSON.dump(['foo', 'bar', 'baz']), filter0['val2'])
|
191
|
+
assert_equal('10', filter0['val3'])
|
192
|
+
assert_equal('hoge', filter0['id'])
|
193
|
+
|
194
|
+
assert_equal(2, filter0.elements.size)
|
195
|
+
assert_equal('subsection', filter0.elements[0].name)
|
196
|
+
assert_equal('bar', filter0.elements[0]['foo'])
|
197
|
+
assert_equal('subsection', filter0.elements[1].name)
|
198
|
+
assert_equal('baz', filter0.elements[1]['foo'])
|
199
|
+
end
|
200
|
+
|
201
|
+
test 'makes values with user-assigned variable substitutions' do
|
202
|
+
match0 = @root.elements.first.elements[4].elements.last
|
203
|
+
|
204
|
+
assert_equal('match', match0.name)
|
205
|
+
assert_equal('{foo,bar}.**', match0.arg)
|
206
|
+
assert_equal('file', match0['type'])
|
207
|
+
assert_equal('/var/log/httpd/access.myhostname.4.log', match0['path'])
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
sub_test_case 'without worker tag on top level' do
|
213
|
+
def setup
|
214
|
+
@root = Fluent::Config::DSL::Parser.parse(DSL_CONFIG_EXAMPLE_WITHOUT_WORKER, 'dsl_config_without_worker.rb')
|
215
|
+
end
|
216
|
+
|
217
|
+
sub_test_case '.parse' do
|
218
|
+
test 'makes root element' do
|
219
|
+
assert_equal('ROOT', @root.name)
|
220
|
+
assert_predicate(@root.arg, :empty?)
|
221
|
+
assert_equal(0, @root.keys.size)
|
222
|
+
end
|
223
|
+
|
224
|
+
test 'does not make worker element implicitly because DSL configuration does not support v10 compat mode' do
|
225
|
+
assert_equal(1, @root.elements.size)
|
226
|
+
assert_equal('source', @root.elements.first.name)
|
227
|
+
refute(@root.elements.find { |e| e.name == 'worker' })
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
sub_test_case 'with include conf' do
|
233
|
+
def setup
|
234
|
+
prepare_config1
|
235
|
+
@root = Fluent::Config::DSL::Parser.parse(DSL_CONFIG_EXAMPLE_FOR_INCLUDE_CONF, 'dsl_config_for_include.conf')
|
236
|
+
end
|
237
|
+
test 'include config' do
|
238
|
+
assert_equal('root_config', @root['k1'])
|
239
|
+
assert_equal('relative_path_include', @root['k2'])
|
240
|
+
assert_equal('relative_include_in_included_file', @root['k3'])
|
241
|
+
assert_equal('absolute_path_include', @root['k4'])
|
242
|
+
assert_equal('uri_include', @root['k5'])
|
243
|
+
assert_equal('wildcard_include_1', @root['k6'])
|
244
|
+
assert_equal('wildcard_include_2', @root['k7'])
|
245
|
+
assert_equal('wildcard_include_3', @root['k8'])
|
246
|
+
assert_equal([
|
247
|
+
'k1',
|
248
|
+
'k2',
|
249
|
+
'k3',
|
250
|
+
'k4',
|
251
|
+
'k5',
|
252
|
+
'k8', # Because of the file name this comes first.
|
253
|
+
'k6',
|
254
|
+
'k7',
|
255
|
+
], @root.keys)
|
256
|
+
|
257
|
+
elem1 = @root.elements.find { |e| e.name == 'elem1' }
|
258
|
+
assert(elem1)
|
259
|
+
assert_equal('name', elem1.arg)
|
260
|
+
assert_equal('normal_parameter', elem1['include'])
|
261
|
+
|
262
|
+
elem2 = @root.elements.find { |e| e.name == 'elem2' }
|
263
|
+
assert(elem2)
|
264
|
+
assert_equal('name', elem2.arg)
|
265
|
+
assert_equal('embeded', elem2['k9'])
|
266
|
+
assert_not_include(elem2, 'include')
|
267
|
+
|
268
|
+
elem3 = elem2.elements.find { |e| e.name == 'elem3' }
|
269
|
+
assert(elem3)
|
270
|
+
assert_equal('nested_value', elem3['nested'])
|
271
|
+
assert_equal('hoge', elem3['include'])
|
272
|
+
end
|
273
|
+
|
274
|
+
# TODO: Add uri based include spec
|
275
|
+
end
|
276
|
+
|
277
|
+
sub_test_case 'with include rb' do
|
278
|
+
def setup
|
279
|
+
prepare_config2
|
280
|
+
@root = Fluent::Config::DSL::Parser.parse(DSL_CONFIG_EXAMPLE_FOR_INCLUDE_RB, 'dsl_config_for_include.rb')
|
281
|
+
end
|
282
|
+
sub_test_case '.parse' do
|
283
|
+
test 'makes root element' do
|
284
|
+
assert_equal('ROOT', @root.name)
|
285
|
+
assert_predicate(@root.arg, :empty?)
|
286
|
+
assert_equal(0, @root.keys.size)
|
287
|
+
end
|
288
|
+
|
289
|
+
test 'makes worker element for worker tag' do
|
290
|
+
assert_equal(1, @root.elements.size)
|
291
|
+
|
292
|
+
worker = @root.elements.first
|
293
|
+
assert_equal('worker', worker.name)
|
294
|
+
assert_predicate(worker.arg, :empty?)
|
295
|
+
assert_equal(0, worker.keys.size)
|
296
|
+
assert_equal(10, worker.elements.size)
|
297
|
+
end
|
298
|
+
|
299
|
+
test 'makes subsections for blocks, with variable substitution' do
|
300
|
+
ele4 = @root.elements.first.elements[4]
|
301
|
+
|
302
|
+
assert_equal('source', ele4.name)
|
303
|
+
assert_predicate(ele4.arg, :empty?)
|
304
|
+
assert_equal(2, ele4.keys.size)
|
305
|
+
assert_equal('tail', ele4['type'])
|
306
|
+
assert_equal("/var/log/httpd/access.part4.log", ele4['path'])
|
307
|
+
end
|
308
|
+
|
309
|
+
test 'makes user-defined sections with blocks' do
|
310
|
+
filter0 = @root.elements.first.elements[4].elements.first
|
311
|
+
|
312
|
+
assert_equal('filter', filter0.name)
|
313
|
+
assert_equal('bar.**', filter0.arg)
|
314
|
+
assert_equal('hoge', filter0['type'])
|
315
|
+
assert_equal('moge', filter0['val1'])
|
316
|
+
assert_equal(JSON.dump(['foo', 'bar', 'baz']), filter0['val2'])
|
317
|
+
assert_equal('10', filter0['val3'])
|
318
|
+
assert_equal('hoge', filter0['id'])
|
319
|
+
|
320
|
+
assert_equal(2, filter0.elements.size)
|
321
|
+
assert_equal('subsection', filter0.elements[0].name)
|
322
|
+
assert_equal('bar', filter0.elements[0]['foo'])
|
323
|
+
assert_equal('subsection', filter0.elements[1].name)
|
324
|
+
assert_equal('baz', filter0.elements[1]['foo'])
|
325
|
+
end
|
326
|
+
|
327
|
+
test 'makes values with user-assigned variable substitutions' do
|
328
|
+
match0 = @root.elements.first.elements[4].elements.last
|
329
|
+
|
330
|
+
assert_equal('match', match0.name)
|
331
|
+
assert_equal('{foo,bar}.**', match0.arg)
|
332
|
+
assert_equal('file', match0['type'])
|
333
|
+
assert_equal('/var/log/httpd/access.myhostname.4.log', match0['path'])
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
sub_test_case 'with configuration that returns non element on top' do
|
339
|
+
sub_test_case '.parse' do
|
340
|
+
test 'does not crash' do
|
341
|
+
Fluent::Config::DSL::Parser.parse(DSL_CONFIG_RETURNS_NON_ELEMENT, 'dsl_config_returns_non_element.rb')
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
sub_test_case 'with configuration with wrong arguments for specific elements' do
|
347
|
+
sub_test_case '.parse' do
|
348
|
+
test 'raises ArgumentError correctly' do
|
349
|
+
assert_raise(ArgumentError) { Fluent::Config::DSL::Parser.parse(DSL_CONFIG_WRONG_SYNTAX1, 'dsl_config_wrong_syntax1') }
|
350
|
+
assert_raise(ArgumentError) { Fluent::Config::DSL::Parser.parse(DSL_CONFIG_WRONG_SYNTAX2, 'dsl_config_wrong_syntax2') }
|
351
|
+
assert_raise(ArgumentError) { Fluent::Config::DSL::Parser.parse(DSL_CONFIG_WRONG_SYNTAX3, 'dsl_config_wrong_syntax3') }
|
352
|
+
assert_raise(ArgumentError) { Fluent::Config::DSL::Parser.parse(DSL_CONFIG_WRONG_SYNTAX4, 'dsl_config_wrong_syntax4') }
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
sub_test_case 'with ruby keyword, that provides ruby Kernel module features' do
|
358
|
+
sub_test_case '.parse' do
|
359
|
+
test 'can get result of Kernel.open() by ruby.open()' do
|
360
|
+
uname_string = `uname -a`
|
361
|
+
root = Fluent::Config::DSL::Parser.parse(<<DSL)
|
362
|
+
worker {
|
363
|
+
uname_str = ruby.open('|uname -a'){|out| out.read}
|
364
|
+
source {
|
365
|
+
uname uname_str
|
366
|
+
}
|
367
|
+
}
|
368
|
+
DSL
|
369
|
+
worker = root.elements.first
|
370
|
+
assert_equal('worker', worker.name)
|
371
|
+
source = worker.elements.first
|
372
|
+
assert_equal('source', source.name)
|
373
|
+
assert_equal(1, source.keys.size)
|
374
|
+
assert_equal(uname_string, source['uname'])
|
375
|
+
end
|
376
|
+
|
377
|
+
test 'accepts ruby keyword with block, which allow to use methods included from ::Kernel' do
|
378
|
+
root = Fluent::Config::DSL::Parser.parse(<<DSL)
|
379
|
+
worker {
|
380
|
+
ruby_version = ruby {
|
381
|
+
require 'erb'
|
382
|
+
ERB.new('<%= RUBY_VERSION %> from erb').result
|
383
|
+
}
|
384
|
+
source {
|
385
|
+
version ruby_version
|
386
|
+
}
|
387
|
+
}
|
388
|
+
DSL
|
389
|
+
worker = root.elements.first
|
390
|
+
assert_equal('worker', worker.name)
|
391
|
+
source = worker.elements.first
|
392
|
+
assert_equal('source', source.name)
|
393
|
+
assert_equal(1, source.keys.size)
|
394
|
+
assert_equal("#{RUBY_VERSION} from erb", source['version'])
|
395
|
+
end
|
396
|
+
|
397
|
+
test 'raises NoMethodError when configuration DSL elements are written in ruby block' do
|
398
|
+
conf = <<DSL
|
399
|
+
worker {
|
400
|
+
ruby {
|
401
|
+
source {
|
402
|
+
type "tail"
|
403
|
+
}
|
404
|
+
}
|
405
|
+
source {
|
406
|
+
uname uname_str
|
407
|
+
}
|
408
|
+
}
|
409
|
+
DSL
|
410
|
+
assert_raise(NoMethodError) { Fluent::Config::DSL::Parser.parse(conf) }
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|