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,102 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'fluent/plugin/in_tcp'
|
4
|
+
|
5
|
+
class TcpInputTest < Test::Unit::TestCase
|
6
|
+
class << self
|
7
|
+
def startup
|
8
|
+
socket_manager_path = ServerEngine::SocketManager::Server.generate_path
|
9
|
+
@server = ServerEngine::SocketManager::Server.open(socket_manager_path)
|
10
|
+
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = socket_manager_path.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def shutdown
|
14
|
+
@server.close
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
Fluent::Test.setup
|
20
|
+
end
|
21
|
+
|
22
|
+
PORT = unused_port
|
23
|
+
BASE_CONFIG = %[
|
24
|
+
port #{PORT}
|
25
|
+
tag tcp
|
26
|
+
]
|
27
|
+
CONFIG = BASE_CONFIG + %[
|
28
|
+
bind 127.0.0.1
|
29
|
+
format none
|
30
|
+
]
|
31
|
+
IPv6_CONFIG = BASE_CONFIG + %[
|
32
|
+
bind ::1
|
33
|
+
format none
|
34
|
+
]
|
35
|
+
|
36
|
+
def create_driver(conf)
|
37
|
+
Fluent::Test::InputTestDriver.new(Fluent::TcpInput).configure(conf)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_configure
|
41
|
+
configs = {'127.0.0.1' => CONFIG}
|
42
|
+
configs.merge!('::1' => IPv6_CONFIG) if ipv6_enabled?
|
43
|
+
|
44
|
+
configs.each_pair { |k, v|
|
45
|
+
d = create_driver(v)
|
46
|
+
assert_equal PORT, d.instance.port
|
47
|
+
assert_equal k, d.instance.bind
|
48
|
+
assert_equal "\n", d.instance.delimiter
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
{
|
53
|
+
'none' => [
|
54
|
+
{'msg' => "tcptest1\n", 'expected' => 'tcptest1'},
|
55
|
+
{'msg' => "tcptest2\n", 'expected' => 'tcptest2'},
|
56
|
+
],
|
57
|
+
'json' => [
|
58
|
+
{'msg' => {'k' => 123, 'message' => 'tcptest1'}.to_json + "\n", 'expected' => 'tcptest1'},
|
59
|
+
{'msg' => {'k' => 'tcptest2', 'message' => 456}.to_json + "\n", 'expected' => 456},
|
60
|
+
]
|
61
|
+
}.each { |format, test_cases|
|
62
|
+
define_method("test_msg_size_#{format}") do
|
63
|
+
d = create_driver(BASE_CONFIG + "format #{format}")
|
64
|
+
tests = test_cases
|
65
|
+
|
66
|
+
d.run do
|
67
|
+
tests.each {|test|
|
68
|
+
TCPSocket.open('127.0.0.1', PORT) do |s|
|
69
|
+
s.send(test['msg'], 0)
|
70
|
+
end
|
71
|
+
}
|
72
|
+
sleep 1
|
73
|
+
end
|
74
|
+
|
75
|
+
compare_test_result(d.emits, tests)
|
76
|
+
end
|
77
|
+
|
78
|
+
define_method("test_msg_size_with_same_connection_#{format}") do
|
79
|
+
d = create_driver(BASE_CONFIG + "format #{format}")
|
80
|
+
tests = test_cases
|
81
|
+
|
82
|
+
d.run do
|
83
|
+
TCPSocket.open('127.0.0.1', PORT) do |s|
|
84
|
+
tests.each {|test|
|
85
|
+
s.send(test['msg'], 0)
|
86
|
+
}
|
87
|
+
end
|
88
|
+
sleep 1
|
89
|
+
end
|
90
|
+
|
91
|
+
compare_test_result(d.emits, tests)
|
92
|
+
end
|
93
|
+
}
|
94
|
+
|
95
|
+
def compare_test_result(emits, tests)
|
96
|
+
assert_equal(2, emits.size)
|
97
|
+
emits.each_index {|i|
|
98
|
+
assert_equal(tests[i]['expected'], emits[i][2]['message'])
|
99
|
+
assert(emits[i][1].is_a?(Fluent::EventTime))
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'fluent/plugin/in_udp'
|
4
|
+
|
5
|
+
class UdpInputTest < Test::Unit::TestCase
|
6
|
+
class << self
|
7
|
+
def startup
|
8
|
+
socket_manager_path = ServerEngine::SocketManager::Server.generate_path
|
9
|
+
@server = ServerEngine::SocketManager::Server.open(socket_manager_path)
|
10
|
+
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = socket_manager_path.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def shutdown
|
14
|
+
@server.close
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
Fluent::Test.setup
|
20
|
+
end
|
21
|
+
|
22
|
+
PORT = unused_port
|
23
|
+
BASE_CONFIG = %[
|
24
|
+
port #{PORT}
|
25
|
+
tag udp
|
26
|
+
]
|
27
|
+
CONFIG = BASE_CONFIG + %!
|
28
|
+
bind 127.0.0.1
|
29
|
+
format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
|
30
|
+
!
|
31
|
+
IPv6_CONFIG = BASE_CONFIG + %!
|
32
|
+
bind ::1
|
33
|
+
format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
|
34
|
+
!
|
35
|
+
|
36
|
+
def create_driver(conf)
|
37
|
+
Fluent::Test::InputTestDriver.new(Fluent::UdpInput).configure(conf)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_configure
|
41
|
+
configs = {'127.0.0.1' => CONFIG}
|
42
|
+
configs.merge!('::1' => IPv6_CONFIG) if ipv6_enabled?
|
43
|
+
|
44
|
+
configs.each_pair { |k, v|
|
45
|
+
d = create_driver(v)
|
46
|
+
assert_equal PORT, d.instance.port
|
47
|
+
assert_equal k, d.instance.bind
|
48
|
+
assert_equal 4096, d.instance.body_size_limit
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_time_format
|
53
|
+
configs = {'127.0.0.1' => CONFIG}
|
54
|
+
configs.merge!('::1' => IPv6_CONFIG) if ipv6_enabled?
|
55
|
+
|
56
|
+
configs.each_pair { |k, v|
|
57
|
+
d = create_driver(v)
|
58
|
+
|
59
|
+
tests = [
|
60
|
+
{'msg' => '[Sep 11 00:00:00] localhost logger: foo', 'expected' => Fluent::EventTime.from_time(Time.strptime('Sep 11 00:00:00', '%b %d %H:%M:%S'))},
|
61
|
+
{'msg' => '[Sep 1 00:00:00] localhost logger: foo', 'expected' => Fluent::EventTime.from_time(Time.strptime('Sep 1 00:00:00', '%b %d %H:%M:%S'))},
|
62
|
+
]
|
63
|
+
|
64
|
+
d.run do
|
65
|
+
u = Fluent::SocketUtil.create_udp_socket(k)
|
66
|
+
u.connect(k, PORT)
|
67
|
+
tests.each {|test|
|
68
|
+
u.send(test['msg'], 0)
|
69
|
+
}
|
70
|
+
u.close
|
71
|
+
sleep 1
|
72
|
+
end
|
73
|
+
|
74
|
+
emits = d.emits
|
75
|
+
emits.each_index {|i|
|
76
|
+
assert_equal_event_time(tests[i]['expected'], emits[i][1])
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
{
|
83
|
+
'none' => [
|
84
|
+
{'msg' => "tcptest1\n", 'expected' => 'tcptest1'},
|
85
|
+
{'msg' => "tcptest2\n", 'expected' => 'tcptest2'},
|
86
|
+
],
|
87
|
+
'json' => [
|
88
|
+
{'msg' => {'k' => 123, 'message' => 'tcptest1'}.to_json + "\n", 'expected' => 'tcptest1'},
|
89
|
+
{'msg' => {'k' => 'tcptest2', 'message' => 456}.to_json + "\n", 'expected' => 456},
|
90
|
+
],
|
91
|
+
'/^\\[(?<time>[^\\]]*)\\] (?<message>.*)/' => [
|
92
|
+
{'msg' => '[Sep 10 00:00:00] localhost: ' + 'x' * 100 + "\n", 'expected' => 'localhost: ' + 'x' * 100},
|
93
|
+
{'msg' => '[Sep 10 00:00:00] localhost: ' + 'x' * 1024 + "\n", 'expected' => 'localhost: ' + 'x' * 1024},
|
94
|
+
]
|
95
|
+
}.each { |format, test_cases|
|
96
|
+
define_method("test_msg_size_#{format[0] == '/' ? 'regexp' : format}") do
|
97
|
+
d = create_driver(BASE_CONFIG + "format #{format}")
|
98
|
+
tests = test_cases
|
99
|
+
|
100
|
+
d.run do
|
101
|
+
u = UDPSocket.new
|
102
|
+
u.connect('127.0.0.1', PORT)
|
103
|
+
tests.each { |test|
|
104
|
+
u.send(test['msg'], 0)
|
105
|
+
}
|
106
|
+
u.close
|
107
|
+
sleep 1
|
108
|
+
end
|
109
|
+
|
110
|
+
compare_test_result(d.emits, tests)
|
111
|
+
end
|
112
|
+
}
|
113
|
+
|
114
|
+
def compare_test_result(emits, tests)
|
115
|
+
assert_equal(2, emits.size)
|
116
|
+
emits.each_index {|i|
|
117
|
+
assert_equal(tests[i]['expected'], emits[i][2]['message'])
|
118
|
+
assert(emits[i][1].is_a?(Fluent::EventTime))
|
119
|
+
}
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'fluent/plugin/in_unix'
|
4
|
+
|
5
|
+
module StreamInputTest
|
6
|
+
def setup
|
7
|
+
Fluent::Test.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_time
|
11
|
+
d = create_driver
|
12
|
+
|
13
|
+
time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
|
14
|
+
Fluent::Engine.now = time
|
15
|
+
|
16
|
+
d.expect_emit "tag1", time, {"a"=>1}
|
17
|
+
d.expect_emit "tag2", time, {"a"=>2}
|
18
|
+
|
19
|
+
d.run do
|
20
|
+
d.expected_emits.each {|tag,_time,record|
|
21
|
+
send_data Fluent::Engine.msgpack_factory.packer.write([tag, 0, record]).to_s
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_message
|
27
|
+
d = create_driver
|
28
|
+
|
29
|
+
time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
|
30
|
+
|
31
|
+
d.expect_emit "tag1", time, {"a"=>1}
|
32
|
+
d.expect_emit "tag2", time, {"a"=>2}
|
33
|
+
|
34
|
+
d.run do
|
35
|
+
d.expected_emits.each {|tag,_time,record|
|
36
|
+
send_data Fluent::Engine.msgpack_factory.packer.write([tag, _time, record]).to_s
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_forward
|
42
|
+
d = create_driver
|
43
|
+
|
44
|
+
time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
|
45
|
+
|
46
|
+
d.expect_emit "tag1", time, {"a"=>1}
|
47
|
+
d.expect_emit "tag1", time, {"a"=>2}
|
48
|
+
|
49
|
+
d.run do
|
50
|
+
entries = []
|
51
|
+
d.expected_emits.each {|tag,_time,record|
|
52
|
+
entries << [_time, record]
|
53
|
+
}
|
54
|
+
send_data Fluent::Engine.msgpack_factory.packer.write(["tag1", entries]).to_s
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_packed_forward
|
59
|
+
d = create_driver
|
60
|
+
|
61
|
+
time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
|
62
|
+
|
63
|
+
d.expect_emit "tag1", time, {"a"=>1}
|
64
|
+
d.expect_emit "tag1", time, {"a"=>2}
|
65
|
+
|
66
|
+
d.run do
|
67
|
+
entries = ''
|
68
|
+
d.expected_emits.each {|tag,_time,record|
|
69
|
+
Fluent::Engine.msgpack_factory.packer(entries).write([_time, record]).flush
|
70
|
+
}
|
71
|
+
send_data Fluent::Engine.msgpack_factory.packer.write(["tag1", entries]).to_s
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_message_json
|
76
|
+
d = create_driver
|
77
|
+
|
78
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
79
|
+
|
80
|
+
d.expect_emit "tag1", time, {"a"=>1}
|
81
|
+
d.expect_emit "tag2", time, {"a"=>2}
|
82
|
+
|
83
|
+
d.run do
|
84
|
+
d.expected_emits.each {|tag,_time,record|
|
85
|
+
send_data [tag, time, record].to_json
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_driver(klass, conf)
|
91
|
+
Fluent::Test::InputTestDriver.new(klass).configure(conf)
|
92
|
+
end
|
93
|
+
|
94
|
+
def send_data(data)
|
95
|
+
io = connect
|
96
|
+
begin
|
97
|
+
io.write data
|
98
|
+
ensure
|
99
|
+
io.close
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class UnixInputTest < Test::Unit::TestCase
|
105
|
+
include StreamInputTest
|
106
|
+
|
107
|
+
TMP_DIR = File.dirname(__FILE__) + "/../tmp/in_unix#{ENV['TEST_ENV_NUMBER']}"
|
108
|
+
CONFIG = %[
|
109
|
+
path #{TMP_DIR}/unix
|
110
|
+
backlog 1000
|
111
|
+
]
|
112
|
+
|
113
|
+
def create_driver(conf=CONFIG)
|
114
|
+
super(Fluent::UnixInput, conf)
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_configure
|
118
|
+
d = create_driver
|
119
|
+
assert_equal "#{TMP_DIR}/unix", d.instance.path
|
120
|
+
assert_equal 1000, d.instance.backlog
|
121
|
+
end
|
122
|
+
|
123
|
+
def connect
|
124
|
+
UNIXSocket.new("#{TMP_DIR}/unix")
|
125
|
+
end
|
126
|
+
end unless Fluent.windows?
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/plugin/input'
|
3
|
+
require 'flexmock/test_unit'
|
4
|
+
|
5
|
+
module FluentPluginInputTest
|
6
|
+
class DummyPlugin < Fluent::Plugin::Input
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class InputTest < Test::Unit::TestCase
|
11
|
+
setup do
|
12
|
+
Fluent::Test.setup
|
13
|
+
@p = FluentPluginInputTest::DummyPlugin.new
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'has healthy lifecycle' do
|
17
|
+
assert !@p.configured?
|
18
|
+
@p.configure(config_element())
|
19
|
+
assert @p.configured?
|
20
|
+
|
21
|
+
assert !@p.started?
|
22
|
+
@p.start
|
23
|
+
assert @p.start
|
24
|
+
|
25
|
+
assert !@p.stopped?
|
26
|
+
@p.stop
|
27
|
+
assert @p.stopped?
|
28
|
+
|
29
|
+
assert !@p.before_shutdown?
|
30
|
+
@p.before_shutdown
|
31
|
+
assert @p.before_shutdown?
|
32
|
+
|
33
|
+
assert !@p.shutdown?
|
34
|
+
@p.shutdown
|
35
|
+
assert @p.shutdown?
|
36
|
+
|
37
|
+
assert !@p.after_shutdown?
|
38
|
+
@p.after_shutdown
|
39
|
+
assert @p.after_shutdown?
|
40
|
+
|
41
|
+
assert !@p.closed?
|
42
|
+
@p.close
|
43
|
+
assert @p.closed?
|
44
|
+
|
45
|
+
assert !@p.terminated?
|
46
|
+
@p.terminate
|
47
|
+
assert @p.terminated?
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'has plugin_id automatically generated' do
|
51
|
+
assert @p.respond_to?(:plugin_id_configured?)
|
52
|
+
assert @p.respond_to?(:plugin_id)
|
53
|
+
|
54
|
+
@p.configure(config_element())
|
55
|
+
|
56
|
+
assert !@p.plugin_id_configured?
|
57
|
+
assert @p.plugin_id
|
58
|
+
assert{ @p.plugin_id != 'mytest' }
|
59
|
+
end
|
60
|
+
|
61
|
+
test 'has plugin_id manually configured' do
|
62
|
+
@p.configure(config_element('ROOT', '', {'@id' => 'mytest'}))
|
63
|
+
assert @p.plugin_id_configured?
|
64
|
+
assert_equal 'mytest', @p.plugin_id
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'has plugin logger' do
|
68
|
+
assert @p.respond_to?(:log)
|
69
|
+
assert @p.log
|
70
|
+
|
71
|
+
# default logger
|
72
|
+
original_logger = @p.log
|
73
|
+
|
74
|
+
@p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
|
75
|
+
|
76
|
+
assert{ @p.log.object_id != original_logger.object_id }
|
77
|
+
assert_equal Fluent::Log::LEVEL_DEBUG, @p.log.level
|
78
|
+
end
|
79
|
+
|
80
|
+
test 'can load plugin helpers' do
|
81
|
+
assert_nothing_raised do
|
82
|
+
class FluentPluginInputTest::DummyPlugin2 < Fluent::Plugin::Input
|
83
|
+
helpers :storage
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
test 'has router and can emit into it' do
|
89
|
+
assert @p.has_router?
|
90
|
+
|
91
|
+
@p.configure(config_element())
|
92
|
+
assert @p.router
|
93
|
+
|
94
|
+
DummyRouter = Struct.new(:emits) do
|
95
|
+
def emit(tag, es)
|
96
|
+
self.emits << [tag, es]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
@p.router = DummyRouter.new([])
|
100
|
+
@p.router.emit('mytag', [])
|
101
|
+
@p.router.emit('mytag.testing', ['it is not es, but no problem for tests'])
|
102
|
+
|
103
|
+
assert_equal ['mytag', []], @p.router.emits[0]
|
104
|
+
assert_equal ['mytag.testing', ['it is not es, but no problem for tests']], @p.router.emits[1]
|
105
|
+
end
|
106
|
+
|
107
|
+
test 'has router for specified label if configured' do
|
108
|
+
@p.configure(config_element())
|
109
|
+
original_router = @p.router
|
110
|
+
|
111
|
+
router_mock = flexmock('mytest')
|
112
|
+
router_mock.should_receive(:emit).once.with('mytag.testing', ['for mock'])
|
113
|
+
label_mock = flexmock('mylabel')
|
114
|
+
label_mock.should_receive(:event_router).once.and_return(router_mock)
|
115
|
+
Fluent::Engine.root_agent.labels['@mytest'] = label_mock
|
116
|
+
|
117
|
+
@p.configure(config_element('ROOT', '', {'@label' => '@mytest'}))
|
118
|
+
assert{ @p.router.object_id != original_router.object_id }
|
119
|
+
|
120
|
+
@p.router.emit('mytag.testing', ['for mock'])
|
121
|
+
end
|
122
|
+
end
|