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,125 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/test/driver/base'
|
18
|
+
require 'fluent/test/driver/test_event_router'
|
19
|
+
|
20
|
+
module Fluent
|
21
|
+
module Test
|
22
|
+
module Driver
|
23
|
+
class BaseOwner < Base
|
24
|
+
def initialize(klass, opts: {}, &block)
|
25
|
+
super
|
26
|
+
|
27
|
+
if opts
|
28
|
+
@instance.system_config_override(opts)
|
29
|
+
end
|
30
|
+
@instance.log = TestLogger.new
|
31
|
+
@logs = @instance.log.out.logs
|
32
|
+
|
33
|
+
@event_streams = nil
|
34
|
+
@error_events = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def configure(conf, syntax: :v1)
|
38
|
+
if conf.is_a?(Fluent::Config::Element)
|
39
|
+
@config = conf
|
40
|
+
else
|
41
|
+
@config = Config.parse(conf, "(test)", "(test_dir)", syntax: syntax)
|
42
|
+
end
|
43
|
+
|
44
|
+
if @instance.respond_to?(:router=)
|
45
|
+
@event_streams = []
|
46
|
+
@error_events = []
|
47
|
+
|
48
|
+
driver = self
|
49
|
+
mojule = Module.new do
|
50
|
+
define_method(:event_emitter_router) do |label_name|
|
51
|
+
TestEventRouter.new(driver)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
@instance.singleton_class.prepend mojule
|
55
|
+
end
|
56
|
+
|
57
|
+
@instance.configure(@config)
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
Emit = Struct.new(:tag, :es)
|
62
|
+
ErrorEvent = Struct.new(:tag, :time, :record, :error)
|
63
|
+
|
64
|
+
# via TestEventRouter
|
65
|
+
def emit_event_stream(tag, es)
|
66
|
+
@event_streams << Emit.new(tag, es)
|
67
|
+
end
|
68
|
+
|
69
|
+
def emit_error_event(tag, time, record, error)
|
70
|
+
@error_events << ErrorEvent.new(tag, time, record, error)
|
71
|
+
end
|
72
|
+
|
73
|
+
def events(tag: nil)
|
74
|
+
return [] if @event_streams.nil?
|
75
|
+
selected = @event_streams.select{|e| tag.nil? ? true : e.tag == tag }
|
76
|
+
if block_given?
|
77
|
+
selected.each do |e|
|
78
|
+
e.es.each do |time, record|
|
79
|
+
yield e.tag, time, record
|
80
|
+
end
|
81
|
+
end
|
82
|
+
else
|
83
|
+
list = []
|
84
|
+
selected.each do |e|
|
85
|
+
e.es.each do |time, record|
|
86
|
+
list << [e.tag, time, record]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
list
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def emit_count
|
94
|
+
@event_streams.size
|
95
|
+
end
|
96
|
+
|
97
|
+
def record_count
|
98
|
+
@event_streams.reduce(0) {|a, e| a + e.es.size }
|
99
|
+
end
|
100
|
+
|
101
|
+
def error_events(tag: nil)
|
102
|
+
selected = @error_events.select{|e| tag.nil? ? true : e.tag == tag }
|
103
|
+
if block_given?
|
104
|
+
selected.each do |e|
|
105
|
+
yield e.tag, e.time, e.record, e.error
|
106
|
+
end
|
107
|
+
else
|
108
|
+
selected.map{|e| [e.tag, e.time, e.record, e.error] }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def run(expect_emits: nil, expect_records: nil, timeout: nil, start: true, shutdown: true, &block)
|
113
|
+
if expect_emits
|
114
|
+
@run_post_conditions << ->(){ emit_count >= expect_emits }
|
115
|
+
end
|
116
|
+
if expect_records
|
117
|
+
@run_post_conditions << ->(){ record_count >= expect_records }
|
118
|
+
end
|
119
|
+
|
120
|
+
super(timeout: timeout, start: start, shutdown: shutdown, &block)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/event'
|
18
|
+
require 'fluent/time'
|
19
|
+
|
20
|
+
module Fluent
|
21
|
+
module Test
|
22
|
+
module Driver
|
23
|
+
module EventFeeder
|
24
|
+
def initialize(klass, opts: {}, &block)
|
25
|
+
super
|
26
|
+
@default_tag = nil
|
27
|
+
@feed_method = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def run(default_tag: nil, **kwargs, &block)
|
31
|
+
@feed_method = if @instance.respond_to?(:filter_stream)
|
32
|
+
:filter_stream
|
33
|
+
else
|
34
|
+
:emit_events
|
35
|
+
end
|
36
|
+
if default_tag
|
37
|
+
@default_tag = default_tag
|
38
|
+
end
|
39
|
+
super(**kwargs, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def feed_to_plugin(tag, es)
|
43
|
+
@instance.__send__(@feed_method, tag, es)
|
44
|
+
end
|
45
|
+
|
46
|
+
# d.run do
|
47
|
+
# d.feed('tag', time, {record})
|
48
|
+
# d.feed('tag', [ [time, {record}], [time, {record}], ... ])
|
49
|
+
# d.feed('tag', es)
|
50
|
+
# end
|
51
|
+
# d.run(default_tag: 'tag') do
|
52
|
+
# d.feed({record})
|
53
|
+
# d.feed(time, {record})
|
54
|
+
# d.feed([ [time, {record}], [time, {record}], ... ])
|
55
|
+
# d.feed(es)
|
56
|
+
# end
|
57
|
+
def feed(*args)
|
58
|
+
case args.size
|
59
|
+
when 1
|
60
|
+
raise ArgumentError, "tag not specified without default_tag" unless @default_tag
|
61
|
+
case args.first
|
62
|
+
when Fluent::EventStream
|
63
|
+
feed_to_plugin(@default_tag, args.first)
|
64
|
+
when Array
|
65
|
+
feed_to_plugin(@default_tag, ArrayEventStream.new(args.first))
|
66
|
+
when Hash
|
67
|
+
record = args.first
|
68
|
+
time = Fluent::EventTime.now
|
69
|
+
feed_to_plugin(@default_tag, OneEventStream.new(time, record))
|
70
|
+
else
|
71
|
+
raise ArgumentError, "unexpected events object (neither event(Hash), EventStream nor Array): #{args.first.class}"
|
72
|
+
end
|
73
|
+
when 2
|
74
|
+
if args[0].is_a?(String) && (args[1].is_a?(Array) || args[1].is_a?(Fluent::EventStream))
|
75
|
+
tag, es = args
|
76
|
+
es = ArrayEventStream.new(es) if es.is_a?(Array)
|
77
|
+
feed_to_plugin(tag, es)
|
78
|
+
elsif @default_tag && (args[0].is_a?(Fluent::EventTime) || args[0].is_a?(Integer)) && args[1].is_a?(Hash)
|
79
|
+
time, record = args
|
80
|
+
feed_to_plugin(@default_tag, OneEventStream.new(time, record))
|
81
|
+
else
|
82
|
+
raise ArgumentError, "unexpected values of argument: #{args[0].class}, #{args[1].class}"
|
83
|
+
end
|
84
|
+
when 3
|
85
|
+
tag, time, record = args
|
86
|
+
if tag.is_a?(String) && (time.is_a?(Fluent::EventTime) || time.is_a?(Integer)) && record.is_a?(Hash)
|
87
|
+
feed_to_plugin(tag, OneEventStream.new(time, record))
|
88
|
+
else
|
89
|
+
raise ArgumentError, "unexpected values of argument: #{tag.class}, #{time.class}, #{record.class}"
|
90
|
+
end
|
91
|
+
else
|
92
|
+
raise ArgumentError, "unexpected number of arguments: #{args}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/test/driver/base_owner'
|
18
|
+
require 'fluent/test/driver/event_feeder'
|
19
|
+
|
20
|
+
require 'fluent/plugin/filter'
|
21
|
+
|
22
|
+
module Fluent
|
23
|
+
module Test
|
24
|
+
module Driver
|
25
|
+
class Filter < BaseOwner
|
26
|
+
include EventFeeder
|
27
|
+
|
28
|
+
attr_reader :filtered
|
29
|
+
|
30
|
+
def initialize(klass, opts: {}, &block)
|
31
|
+
super
|
32
|
+
raise ArgumentError, "plugin is not an instance of Fluent::Plugin::Filter" unless @instance.is_a? Fluent::Plugin::Filter
|
33
|
+
@filtered = []
|
34
|
+
end
|
35
|
+
|
36
|
+
def filtered_records
|
37
|
+
@filtered.map {|_time, record| record }
|
38
|
+
end
|
39
|
+
|
40
|
+
def instance_hook_after_started
|
41
|
+
super
|
42
|
+
filter_hook = ->(time, record) { @filtered << [time, record] }
|
43
|
+
m = Module.new do
|
44
|
+
define_method(:filter_stream) do |tag, es|
|
45
|
+
new_es = super(tag, es)
|
46
|
+
new_es.each do |time, record|
|
47
|
+
filter_hook.call(time, record)
|
48
|
+
end
|
49
|
+
new_es
|
50
|
+
end
|
51
|
+
end
|
52
|
+
@instance.singleton_class.prepend(m)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/test/driver/base_owned'
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
module Test
|
21
|
+
module Driver
|
22
|
+
class Formatter < BaseOwned
|
23
|
+
def initialize(klass, **kwargs, &block)
|
24
|
+
super
|
25
|
+
@section_name = "format"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/test/driver/base_owner'
|
18
|
+
require 'fluent/plugin/input'
|
19
|
+
|
20
|
+
module Fluent
|
21
|
+
module Test
|
22
|
+
module Driver
|
23
|
+
class Input < BaseOwner
|
24
|
+
def initialize(klass, opts: {}, &block)
|
25
|
+
super
|
26
|
+
raise ArgumentError, "plugin is not an instance of Fluent::Plugin::Input" unless @instance.is_a? Fluent::Plugin::Input
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/test/driver/base_owner'
|
18
|
+
require 'fluent/test/driver/event_feeder'
|
19
|
+
|
20
|
+
require 'fluent/plugin/multi_output'
|
21
|
+
|
22
|
+
module Fluent
|
23
|
+
module Test
|
24
|
+
module Driver
|
25
|
+
class MultiOutput < BaseOwner
|
26
|
+
include EventFeeder
|
27
|
+
|
28
|
+
def initialize(klass, opts: {}, &block)
|
29
|
+
super
|
30
|
+
raise ArgumentError, "plugin is not an instance of Fluent::Plugin::MultiOutput" unless @instance.is_a? Fluent::Plugin::MultiOutput
|
31
|
+
@flush_buffer_at_cleanup = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def run(flush: true, **kwargs, &block)
|
35
|
+
@flush_buffer_at_cleanup = flush
|
36
|
+
super(**kwargs, &block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def run_actual(**kwargs, &block)
|
40
|
+
super(**kwargs, &block)
|
41
|
+
if @flush_buffer_at_cleanup
|
42
|
+
@instance.outputs.each{|o| o.force_flush }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def flush
|
47
|
+
@instance.outputs.each{|o| o.force_flush }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/test/driver/base_owner'
|
18
|
+
require 'fluent/test/driver/event_feeder'
|
19
|
+
|
20
|
+
require 'fluent/plugin/output'
|
21
|
+
|
22
|
+
module Fluent
|
23
|
+
module Test
|
24
|
+
module Driver
|
25
|
+
class Output < BaseOwner
|
26
|
+
include EventFeeder
|
27
|
+
|
28
|
+
def initialize(klass, opts: {}, &block)
|
29
|
+
super
|
30
|
+
raise ArgumentError, "plugin is not an instance of Fluent::Plugin::Output" unless @instance.is_a? Fluent::Plugin::Output
|
31
|
+
@instance.in_tests = true
|
32
|
+
@flush_buffer_at_cleanup = nil
|
33
|
+
@format_hook = nil
|
34
|
+
@format_results = []
|
35
|
+
end
|
36
|
+
|
37
|
+
def run(flush: true, **kwargs, &block)
|
38
|
+
@flush_buffer_at_cleanup = flush
|
39
|
+
super(**kwargs, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def run_actual(**kwargs, &block)
|
43
|
+
super(**kwargs, &block)
|
44
|
+
if @flush_buffer_at_cleanup
|
45
|
+
@instance.force_flush
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def formatted
|
50
|
+
@format_results
|
51
|
+
end
|
52
|
+
|
53
|
+
def flush
|
54
|
+
@instance.force_flush
|
55
|
+
end
|
56
|
+
|
57
|
+
def instance_hook_after_started
|
58
|
+
super
|
59
|
+
|
60
|
+
# it's decided after #start whether output plugin instances use @custom_format or not.
|
61
|
+
if @instance.instance_eval{ @custom_format }
|
62
|
+
@format_hook = format_hook = ->(result){ @format_results << result }
|
63
|
+
m = Module.new do
|
64
|
+
define_method(:format) do |tag, time, record|
|
65
|
+
result = super(tag, time, record)
|
66
|
+
format_hook.call(result)
|
67
|
+
result
|
68
|
+
end
|
69
|
+
end
|
70
|
+
@instance.singleton_class.prepend m
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|