fluentd 0.14.4-x86-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
data/test/test_config.rb
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'fluent/config'
|
3
|
+
require 'fluent/config/parser'
|
4
|
+
require 'fluent/supervisor'
|
5
|
+
require 'fluent/load'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
class ConfigTest < Test::Unit::TestCase
|
9
|
+
include Fluent
|
10
|
+
|
11
|
+
TMP_DIR = File.dirname(__FILE__) + "/tmp/config#{ENV['TEST_ENV_NUMBER']}"
|
12
|
+
|
13
|
+
def read_config(path)
|
14
|
+
path = File.expand_path(path)
|
15
|
+
File.open(path) { |io|
|
16
|
+
Fluent::Config::Parser.parse(io, File.basename(path), File.dirname(path))
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def prepare_config
|
21
|
+
write_config "#{TMP_DIR}/config_test_1.conf", %[
|
22
|
+
k1 root_config
|
23
|
+
include dir/config_test_2.conf #
|
24
|
+
include #{TMP_DIR}/config_test_4.conf
|
25
|
+
include file://#{TMP_DIR}/config_test_5.conf
|
26
|
+
<include config.d/*.conf />
|
27
|
+
]
|
28
|
+
write_config "#{TMP_DIR}/dir/config_test_2.conf", %[
|
29
|
+
k2 relative_path_include
|
30
|
+
include ../config_test_3.conf
|
31
|
+
]
|
32
|
+
write_config "#{TMP_DIR}/config_test_3.conf", %[
|
33
|
+
k3 relative_include_in_included_file
|
34
|
+
]
|
35
|
+
write_config "#{TMP_DIR}/config_test_4.conf", %[
|
36
|
+
k4 absolute_path_include
|
37
|
+
]
|
38
|
+
write_config "#{TMP_DIR}/config_test_5.conf", %[
|
39
|
+
k5 uri_include
|
40
|
+
]
|
41
|
+
write_config "#{TMP_DIR}/config.d/config_test_6.conf", %[
|
42
|
+
k6 wildcard_include_1
|
43
|
+
<elem1 name>
|
44
|
+
include normal_parameter
|
45
|
+
</elem1>
|
46
|
+
]
|
47
|
+
write_config "#{TMP_DIR}/config.d/config_test_7.conf", %[
|
48
|
+
k7 wildcard_include_2
|
49
|
+
]
|
50
|
+
write_config "#{TMP_DIR}/config.d/config_test_8.conf", %[
|
51
|
+
<elem2 name>
|
52
|
+
<include ../dir/config_test_9.conf />
|
53
|
+
</elem2>
|
54
|
+
]
|
55
|
+
write_config "#{TMP_DIR}/dir/config_test_9.conf", %[
|
56
|
+
k9 embeded
|
57
|
+
<elem3 name>
|
58
|
+
nested nested_value
|
59
|
+
include hoge
|
60
|
+
</elem3>
|
61
|
+
]
|
62
|
+
write_config "#{TMP_DIR}/config.d/00_config_test_8.conf", %[
|
63
|
+
k8 wildcard_include_3
|
64
|
+
<elem4 name>
|
65
|
+
include normal_parameter
|
66
|
+
</elem4>
|
67
|
+
]
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_include
|
72
|
+
prepare_config
|
73
|
+
c = read_config("#{TMP_DIR}/config_test_1.conf")
|
74
|
+
assert_equal 'root_config', c['k1']
|
75
|
+
assert_equal 'relative_path_include', c['k2']
|
76
|
+
assert_equal 'relative_include_in_included_file', c['k3']
|
77
|
+
assert_equal 'absolute_path_include', c['k4']
|
78
|
+
assert_equal 'uri_include', c['k5']
|
79
|
+
assert_equal 'wildcard_include_1', c['k6']
|
80
|
+
assert_equal 'wildcard_include_2', c['k7']
|
81
|
+
assert_equal 'wildcard_include_3', c['k8']
|
82
|
+
assert_equal [
|
83
|
+
'k1',
|
84
|
+
'k2',
|
85
|
+
'k3',
|
86
|
+
'k4',
|
87
|
+
'k5',
|
88
|
+
'k8', # Because of the file name this comes first.
|
89
|
+
'k6',
|
90
|
+
'k7',
|
91
|
+
], c.keys
|
92
|
+
|
93
|
+
elem1 = c.elements.find { |e| e.name == 'elem1' }
|
94
|
+
assert_not_nil elem1
|
95
|
+
assert_equal 'name', elem1.arg
|
96
|
+
assert_equal 'normal_parameter', elem1['include']
|
97
|
+
|
98
|
+
elem2 = c.elements.find { |e| e.name == 'elem2' }
|
99
|
+
assert_not_nil elem2
|
100
|
+
assert_equal 'name', elem2.arg
|
101
|
+
assert_equal 'embeded', elem2['k9']
|
102
|
+
assert !elem2.has_key?('include')
|
103
|
+
|
104
|
+
elem3 = elem2.elements.find { |e| e.name == 'elem3' }
|
105
|
+
assert_not_nil elem3
|
106
|
+
assert_equal 'nested_value', elem3['nested']
|
107
|
+
assert_equal 'hoge', elem3['include']
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_check_not_fetchd
|
111
|
+
write_config "#{TMP_DIR}/config_test_not_fetched.conf", %[
|
112
|
+
<match dummy>
|
113
|
+
type rewrite
|
114
|
+
add_prefix filtered
|
115
|
+
<rule>
|
116
|
+
key path
|
117
|
+
pattern ^[A-Z]+
|
118
|
+
replace
|
119
|
+
</rule>
|
120
|
+
</match>
|
121
|
+
]
|
122
|
+
root_conf = read_config("#{TMP_DIR}/config_test_not_fetched.conf")
|
123
|
+
match_conf = root_conf.elements.first
|
124
|
+
rule_conf = match_conf.elements.first
|
125
|
+
|
126
|
+
not_fetched = []; root_conf.check_not_fetched {|key, e| not_fetched << key }
|
127
|
+
assert_equal %w[type add_prefix key pattern replace], not_fetched
|
128
|
+
|
129
|
+
not_fetched = []; match_conf.check_not_fetched {|key, e| not_fetched << key }
|
130
|
+
assert_equal %w[type add_prefix key pattern replace], not_fetched
|
131
|
+
|
132
|
+
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
133
|
+
assert_equal %w[key pattern replace], not_fetched
|
134
|
+
|
135
|
+
# accessing should delete
|
136
|
+
match_conf['type']
|
137
|
+
rule_conf['key']
|
138
|
+
|
139
|
+
not_fetched = []; root_conf.check_not_fetched {|key, e| not_fetched << key }
|
140
|
+
assert_equal %w[add_prefix pattern replace], not_fetched
|
141
|
+
|
142
|
+
not_fetched = []; match_conf.check_not_fetched {|key, e| not_fetched << key }
|
143
|
+
assert_equal %w[add_prefix pattern replace], not_fetched
|
144
|
+
|
145
|
+
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
146
|
+
assert_equal %w[pattern replace], not_fetched
|
147
|
+
|
148
|
+
# repeateadly accessing should not grow memory usage
|
149
|
+
before_size = match_conf.unused.size
|
150
|
+
10.times { match_conf['type'] }
|
151
|
+
assert_equal before_size, match_conf.unused.size
|
152
|
+
end
|
153
|
+
|
154
|
+
def write_config(path, data)
|
155
|
+
FileUtils.mkdir_p(File.dirname(path))
|
156
|
+
File.open(path, "w") {|f| f.write data }
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_inline
|
160
|
+
prepare_config
|
161
|
+
opts = {
|
162
|
+
:config_path => "#{TMP_DIR}/config_test_1.conf",
|
163
|
+
:inline_config => "<source>\n type http\n port 2222\n </source>"
|
164
|
+
}
|
165
|
+
assert_nothing_raised do
|
166
|
+
Fluent::Supervisor.new(opts)
|
167
|
+
end
|
168
|
+
create_warn_dummy_logger
|
169
|
+
end
|
170
|
+
|
171
|
+
def create_warn_dummy_logger
|
172
|
+
dl_opts = {}
|
173
|
+
dl_opts[:log_level] = ServerEngine::DaemonLogger::WARN
|
174
|
+
logdev = Fluent::Test::DummyLogDevice.new
|
175
|
+
logger = ServerEngine::DaemonLogger.new(logdev, dl_opts)
|
176
|
+
$log = Fluent::Log.new(logger)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'fluent/config/dsl'
|
3
|
+
require 'fluent/test'
|
4
|
+
|
5
|
+
class ConfigDSLTest < Test::Unit::TestCase
|
6
|
+
# TEST_CONFIG1 = %[
|
7
|
+
# <source>
|
8
|
+
# type forward
|
9
|
+
# port 24224
|
10
|
+
# </source>
|
11
|
+
# <match test.**>
|
12
|
+
# type forward
|
13
|
+
# flush_interval 1s
|
14
|
+
# <server>
|
15
|
+
# host host0.example.com
|
16
|
+
# port 24224
|
17
|
+
# </server>
|
18
|
+
# <server>
|
19
|
+
# host host1.example.com
|
20
|
+
# port 24224
|
21
|
+
# </server>
|
22
|
+
# </match>
|
23
|
+
# ]
|
24
|
+
TEST_DSL_CONFIG1 = %q[
|
25
|
+
source {
|
26
|
+
type "forward"
|
27
|
+
port 24224
|
28
|
+
}
|
29
|
+
match('test.**') {
|
30
|
+
type "forward"
|
31
|
+
flush_interval "1s"
|
32
|
+
(0..1).each do |i|
|
33
|
+
server {
|
34
|
+
host "host#{i}.example.com"
|
35
|
+
port 24224
|
36
|
+
}
|
37
|
+
end
|
38
|
+
}
|
39
|
+
]
|
40
|
+
|
41
|
+
TEST_DSL_CONFIG2 = %q[
|
42
|
+
v = [0, 1, 2]
|
43
|
+
]
|
44
|
+
|
45
|
+
TEST_DSL_CONFIG3 = %q[
|
46
|
+
match
|
47
|
+
]
|
48
|
+
|
49
|
+
TEST_DSL_CONFIG4 = %q[
|
50
|
+
match('aa', 'bb'){
|
51
|
+
type :null
|
52
|
+
}
|
53
|
+
]
|
54
|
+
|
55
|
+
TEST_DSL_CONFIG5 = %q[
|
56
|
+
match('aa')
|
57
|
+
]
|
58
|
+
|
59
|
+
def test_parse
|
60
|
+
root = Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG1)
|
61
|
+
|
62
|
+
assert_equal 0, root.keys.size
|
63
|
+
assert_equal 2, root.elements.size
|
64
|
+
|
65
|
+
e0 = root.elements[0]
|
66
|
+
assert_equal 'source', e0.name
|
67
|
+
assert_equal '', e0.arg
|
68
|
+
assert_equal 'forward', e0['type']
|
69
|
+
assert_equal '24224', e0['port']
|
70
|
+
|
71
|
+
e1 = root.elements[1]
|
72
|
+
assert_equal 'match', e1.name
|
73
|
+
assert_equal 'test.**', e1.arg
|
74
|
+
assert_equal 'forward', e1['type']
|
75
|
+
assert_equal '1s', e1['flush_interval']
|
76
|
+
assert_equal 2, e1.elements.size
|
77
|
+
e1s0 = e1.elements[0]
|
78
|
+
assert_equal 'server', e1s0.name
|
79
|
+
assert_equal 'host0.example.com', e1s0['host']
|
80
|
+
assert_equal '24224', e1s0['port']
|
81
|
+
e1s1 = e1.elements[1]
|
82
|
+
assert_equal 'server', e1s1.name
|
83
|
+
assert_equal 'host1.example.com', e1s1['host']
|
84
|
+
assert_equal '24224', e1s1['port']
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_parse2
|
88
|
+
root = Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG2)
|
89
|
+
|
90
|
+
assert_equal 0, root.keys.size
|
91
|
+
assert_equal 0, root.elements.size
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_config_error
|
95
|
+
assert_raise(ArgumentError) {
|
96
|
+
Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG3)
|
97
|
+
}
|
98
|
+
|
99
|
+
assert_raise(ArgumentError) {
|
100
|
+
Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG4)
|
101
|
+
}
|
102
|
+
|
103
|
+
assert_raise(ArgumentError) {
|
104
|
+
Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG5)
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_with_ruby_keyword
|
109
|
+
uname_string = `uname -a`
|
110
|
+
root1 = Fluent::Config::DSL::Parser.parse(<<DSL)
|
111
|
+
uname_str = ruby.open('|uname -a'){|out| out.read}
|
112
|
+
source {
|
113
|
+
uname uname_str
|
114
|
+
}
|
115
|
+
DSL
|
116
|
+
source1 = root1.elements.first
|
117
|
+
assert_equal 'source', source1.name
|
118
|
+
assert_equal 1, source1.keys.size
|
119
|
+
assert_equal uname_string, source1['uname']
|
120
|
+
|
121
|
+
root2 = Fluent::Config::DSL::Parser.parse(<<DSL)
|
122
|
+
ruby_version = ruby {
|
123
|
+
require 'erb'
|
124
|
+
ERB.new('<%= RUBY_VERSION %> from erb').result
|
125
|
+
}
|
126
|
+
source {
|
127
|
+
version ruby_version
|
128
|
+
}
|
129
|
+
DSL
|
130
|
+
source2 = root2.elements.first
|
131
|
+
assert_equal 'source', source2.name
|
132
|
+
assert_equal 1, source2.keys.size
|
133
|
+
assert_equal "#{RUBY_VERSION} from erb", source2['version']
|
134
|
+
|
135
|
+
# Parser#parse raises NoMethodError when configuration dsl elements are written in ruby block
|
136
|
+
conf3 = <<DSL
|
137
|
+
ruby {
|
138
|
+
source {
|
139
|
+
type "tail"
|
140
|
+
}
|
141
|
+
}
|
142
|
+
source {
|
143
|
+
uname uname_str
|
144
|
+
}
|
145
|
+
DSL
|
146
|
+
assert_raise (NoMethodError) { Fluent::Config::DSL::Parser.parse(conf3) }
|
147
|
+
end
|
148
|
+
end
|
data/test/test_event.rb
ADDED
@@ -0,0 +1,329 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'fluent/event'
|
4
|
+
|
5
|
+
module EventTest
|
6
|
+
module DeepCopyAssertion
|
7
|
+
def assert_duplicated_records(es1, es2)
|
8
|
+
ary1 = []
|
9
|
+
es1.each do |_, record|
|
10
|
+
ary1 << record
|
11
|
+
end
|
12
|
+
ary2 = []
|
13
|
+
es2.each do |_, record|
|
14
|
+
ary2 << record
|
15
|
+
end
|
16
|
+
assert_equal ary1.size, ary2.size
|
17
|
+
ary1.each_with_index do |r, i|
|
18
|
+
assert_not_equal r.object_id, ary2[i].object_id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class OneEventStreamTest < ::Test::Unit::TestCase
|
24
|
+
include Fluent
|
25
|
+
include DeepCopyAssertion
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@time = event_time()
|
29
|
+
@record = {'k' => 'v', 'n' => 1}
|
30
|
+
@es = OneEventStream.new(@time, @record)
|
31
|
+
end
|
32
|
+
|
33
|
+
test 'empty?' do
|
34
|
+
assert_false @es.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'size' do
|
38
|
+
assert_equal 1, @es.size
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'repeatable?' do
|
42
|
+
assert_true @es.repeatable?
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'dup' do
|
46
|
+
dupped = @es.dup
|
47
|
+
assert_kind_of OneEventStream, dupped
|
48
|
+
assert_not_equal @es.object_id, dupped.object_id
|
49
|
+
assert_duplicated_records @es, dupped
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'slice' do
|
53
|
+
assert_equal 0, @es.slice(1, 1).size
|
54
|
+
assert_equal 0, @es.slice(0, 0).size
|
55
|
+
|
56
|
+
sliced = @es.slice(0, 1)
|
57
|
+
assert_kind_of EventStream, sliced
|
58
|
+
assert_equal 1, sliced.size
|
59
|
+
|
60
|
+
sliced.each do |time, record|
|
61
|
+
assert_equal @time, time
|
62
|
+
assert_equal @record, record
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'each' do
|
67
|
+
@es.each { |time, record|
|
68
|
+
assert_equal @time, time
|
69
|
+
assert_equal @record, record
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'to_msgpack_stream' do
|
74
|
+
stream = @es.to_msgpack_stream
|
75
|
+
Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
|
76
|
+
assert_equal @time, time
|
77
|
+
assert_equal @record, record
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'to_msgpack_stream with time_int argument' do
|
82
|
+
stream = @es.to_msgpack_stream(time_int: true)
|
83
|
+
Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
|
84
|
+
assert_equal @time.to_i, time
|
85
|
+
assert_equal @record, record
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class ArrayEventStreamTest < ::Test::Unit::TestCase
|
91
|
+
include Fluent
|
92
|
+
include DeepCopyAssertion
|
93
|
+
|
94
|
+
def setup
|
95
|
+
time = Engine.now
|
96
|
+
@times = [Fluent::EventTime.new(time.sec), Fluent::EventTime.new(time.sec + 1)]
|
97
|
+
@records = [{'k' => 'v1', 'n' => 1}, {'k' => 'v2', 'n' => 2}]
|
98
|
+
@es = ArrayEventStream.new(@times.zip(@records))
|
99
|
+
end
|
100
|
+
|
101
|
+
test 'repeatable?' do
|
102
|
+
assert_true @es.repeatable?
|
103
|
+
end
|
104
|
+
|
105
|
+
test 'dup' do
|
106
|
+
dupped = @es.dup
|
107
|
+
assert_kind_of ArrayEventStream, dupped
|
108
|
+
assert_not_equal @es.object_id, dupped.object_id
|
109
|
+
assert_duplicated_records @es, dupped
|
110
|
+
end
|
111
|
+
|
112
|
+
test 'empty?' do
|
113
|
+
assert_not_empty @es
|
114
|
+
assert_true ArrayEventStream.new([]).empty?
|
115
|
+
end
|
116
|
+
|
117
|
+
test 'size' do
|
118
|
+
assert_equal 2, @es.size
|
119
|
+
assert_equal 0, ArrayEventStream.new([]).size
|
120
|
+
end
|
121
|
+
|
122
|
+
test 'slice' do
|
123
|
+
sliced = @es.slice(1,1)
|
124
|
+
assert_kind_of EventStream, sliced
|
125
|
+
assert_equal 1, sliced.size
|
126
|
+
|
127
|
+
sliced.each do |time, record|
|
128
|
+
assert_equal @times[1], time
|
129
|
+
assert_equal 'v2', record['k']
|
130
|
+
assert_equal 2, record['n']
|
131
|
+
end
|
132
|
+
|
133
|
+
sliced = @es.slice(0,2)
|
134
|
+
assert_kind_of EventStream, sliced
|
135
|
+
assert_equal 2, sliced.size
|
136
|
+
|
137
|
+
counter = 0
|
138
|
+
sliced.each do |time, record|
|
139
|
+
assert_equal @times[counter], time
|
140
|
+
assert_equal @records[counter]['k'], record['k']
|
141
|
+
assert_equal @records[counter]['n'], record['n']
|
142
|
+
counter += 1
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
test 'each' do
|
147
|
+
i = 0
|
148
|
+
@es.each { |time, record|
|
149
|
+
assert_equal @times[i], time
|
150
|
+
assert_equal @records[i], record
|
151
|
+
i += 1
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
test 'to_msgpack_stream' do
|
156
|
+
i = 0
|
157
|
+
stream = @es.to_msgpack_stream
|
158
|
+
Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
|
159
|
+
assert_equal @times[i], time
|
160
|
+
assert_equal @records[i], record
|
161
|
+
i += 1
|
162
|
+
}
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
class MultiEventStreamTest < ::Test::Unit::TestCase
|
167
|
+
include Fluent
|
168
|
+
include DeepCopyAssertion
|
169
|
+
|
170
|
+
def setup
|
171
|
+
time = Engine.now
|
172
|
+
@times = [Fluent::EventTime.new(time.sec), Fluent::EventTime.new(time.sec + 1)]
|
173
|
+
@records = [{'k' => 'v1', 'n' => 1}, {'k' => 'v2', 'n' => 2}]
|
174
|
+
@es = MultiEventStream.new
|
175
|
+
@times.zip(@records).each { |_time, record|
|
176
|
+
@es.add(_time, record)
|
177
|
+
}
|
178
|
+
end
|
179
|
+
|
180
|
+
test 'repeatable?' do
|
181
|
+
assert_true @es.repeatable?
|
182
|
+
end
|
183
|
+
|
184
|
+
test 'dup' do
|
185
|
+
dupped = @es.dup
|
186
|
+
assert_kind_of MultiEventStream, dupped
|
187
|
+
assert_not_equal @es.object_id, dupped.object_id
|
188
|
+
assert_duplicated_records @es, dupped
|
189
|
+
end
|
190
|
+
|
191
|
+
test 'empty?' do
|
192
|
+
assert_not_empty @es
|
193
|
+
assert_true MultiEventStream.new.empty?
|
194
|
+
end
|
195
|
+
|
196
|
+
test 'size' do
|
197
|
+
assert_equal 2, @es.size
|
198
|
+
assert_equal 0, MultiEventStream.new.size
|
199
|
+
end
|
200
|
+
|
201
|
+
test 'slice' do
|
202
|
+
sliced = @es.slice(1,1)
|
203
|
+
assert_kind_of EventStream, sliced
|
204
|
+
assert_equal 1, sliced.size
|
205
|
+
|
206
|
+
sliced.each do |time, record|
|
207
|
+
assert_equal @times[1], time
|
208
|
+
assert_equal 'v2', record['k']
|
209
|
+
assert_equal 2, record['n']
|
210
|
+
end
|
211
|
+
|
212
|
+
sliced = @es.slice(0,2)
|
213
|
+
assert_kind_of EventStream, sliced
|
214
|
+
assert_equal 2, sliced.size
|
215
|
+
|
216
|
+
counter = 0
|
217
|
+
sliced.each do |time, record|
|
218
|
+
assert_equal @times[counter], time
|
219
|
+
assert_equal @records[counter]['k'], record['k']
|
220
|
+
assert_equal @records[counter]['n'], record['n']
|
221
|
+
counter += 1
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
test 'each' do
|
226
|
+
i = 0
|
227
|
+
@es.each { |time, record|
|
228
|
+
assert_equal @times[i], time
|
229
|
+
assert_equal @records[i], record
|
230
|
+
i += 1
|
231
|
+
}
|
232
|
+
end
|
233
|
+
|
234
|
+
test 'to_msgpack_stream' do
|
235
|
+
i = 0
|
236
|
+
stream = @es.to_msgpack_stream
|
237
|
+
Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
|
238
|
+
assert_equal @times[i], time
|
239
|
+
assert_equal @records[i], record
|
240
|
+
i += 1
|
241
|
+
}
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
class MessagePackEventStreamTest < ::Test::Unit::TestCase
|
246
|
+
include Fluent
|
247
|
+
include DeepCopyAssertion
|
248
|
+
|
249
|
+
def setup
|
250
|
+
pk = Fluent::Engine.msgpack_factory.packer
|
251
|
+
time = Engine.now
|
252
|
+
@times = [Fluent::EventTime.new(time.sec), Fluent::EventTime.new(time.sec + 1)]
|
253
|
+
@records = [{'k' => 'v1', 'n' => 1}, {'k' => 'v2', 'n' => 2}]
|
254
|
+
@times.zip(@records).each { |_time, record|
|
255
|
+
pk.write([_time, record])
|
256
|
+
}
|
257
|
+
@es = MessagePackEventStream.new(pk.to_s)
|
258
|
+
end
|
259
|
+
|
260
|
+
test 'dup' do
|
261
|
+
dupped = @es.dup
|
262
|
+
assert_kind_of MessagePackEventStream, dupped
|
263
|
+
assert_not_equal @es.object_id, dupped.object_id
|
264
|
+
assert_duplicated_records @es, dupped
|
265
|
+
|
266
|
+
# After iteration of events (done in assert_duplicated_records),
|
267
|
+
# duplicated event stream still has unpacked objects and correct size
|
268
|
+
dupped = @es.dup
|
269
|
+
assert_equal 2, dupped.instance_eval{ @size }
|
270
|
+
end
|
271
|
+
|
272
|
+
test 'empty?' do
|
273
|
+
assert_false @es.empty?
|
274
|
+
assert_true MessagePackEventStream.new('', 0).empty?
|
275
|
+
end
|
276
|
+
|
277
|
+
test 'size' do
|
278
|
+
assert_equal 2, @es.size
|
279
|
+
assert_equal 0, MessagePackEventStream.new('').size
|
280
|
+
end
|
281
|
+
|
282
|
+
test 'repeatable?' do
|
283
|
+
assert_true @es.repeatable?
|
284
|
+
end
|
285
|
+
|
286
|
+
test 'slice' do
|
287
|
+
sliced = @es.slice(1,1)
|
288
|
+
assert_kind_of EventStream, sliced
|
289
|
+
assert_equal 1, sliced.size
|
290
|
+
|
291
|
+
sliced.each do |time, record|
|
292
|
+
assert_equal @times[1], time
|
293
|
+
assert_equal 'v2', record['k']
|
294
|
+
assert_equal 2, record['n']
|
295
|
+
end
|
296
|
+
|
297
|
+
sliced = @es.slice(0,2)
|
298
|
+
assert_kind_of EventStream, sliced
|
299
|
+
assert_equal 2, sliced.size
|
300
|
+
|
301
|
+
counter = 0
|
302
|
+
sliced.each do |time, record|
|
303
|
+
assert_equal @times[counter], time
|
304
|
+
assert_equal @records[counter]['k'], record['k']
|
305
|
+
assert_equal @records[counter]['n'], record['n']
|
306
|
+
counter += 1
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
test 'each' do
|
311
|
+
i = 0
|
312
|
+
@es.each { |time, record|
|
313
|
+
assert_equal @times[i], time
|
314
|
+
assert_equal @records[i], record
|
315
|
+
i += 1
|
316
|
+
}
|
317
|
+
end
|
318
|
+
|
319
|
+
test 'to_msgpack_stream' do
|
320
|
+
i = 0
|
321
|
+
stream = @es.to_msgpack_stream
|
322
|
+
Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
|
323
|
+
assert_equal @times[i], time
|
324
|
+
assert_equal @records[i], record
|
325
|
+
i += 1
|
326
|
+
}
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|