fluentd-hubspot 0.14.14.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.github/ISSUE_TEMPLATE.md +6 -0
- data/.gitignore +28 -0
- data/.travis.yml +51 -0
- data/AUTHORS +2 -0
- data/CONTRIBUTING.md +42 -0
- data/COPYING +14 -0
- data/ChangeLog +593 -0
- data/Gemfile +9 -0
- data/README.md +76 -0
- data/Rakefile +74 -0
- data/Vagrantfile +17 -0
- data/appveyor.yml +43 -0
- data/bin/fluent-binlog-reader +7 -0
- data/bin/fluent-debug +5 -0
- data/bin/fluent-plugin-config-format +5 -0
- data/bin/fluent-plugin-generate +5 -0
- data/code-of-conduct.md +3 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/filter_stdout.conf +22 -0
- data/example/in_dummy_blocks.conf +17 -0
- data/example/in_dummy_with_compression.conf +23 -0
- data/example/in_forward.conf +14 -0
- data/example/in_forward_client.conf +37 -0
- data/example/in_forward_shared_key.conf +15 -0
- data/example/in_forward_tls.conf +14 -0
- data/example/in_forward_users.conf +24 -0
- data/example/in_forward_workers.conf +21 -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/logevents.conf +25 -0
- data/example/multi_filters.conf +61 -0
- data/example/out_copy.conf +20 -0
- data/example/out_exec_filter.conf +42 -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/out_forward_client.conf +109 -0
- data/example/out_forward_heartbeat_none.conf +16 -0
- data/example/out_forward_shared_key.conf +36 -0
- data/example/out_forward_tls.conf +18 -0
- data/example/out_forward_users.conf +65 -0
- data/example/out_null.conf +36 -0
- data/example/secondary_file.conf +41 -0
- data/example/suppress_config_dump.conf +7 -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 +163 -0
- data/lib/fluent/clock.rb +62 -0
- data/lib/fluent/command/binlog_reader.rb +234 -0
- data/lib/fluent/command/bundler_injection.rb +45 -0
- data/lib/fluent/command/cat.rb +330 -0
- data/lib/fluent/command/debug.rb +102 -0
- data/lib/fluent/command/fluentd.rb +301 -0
- data/lib/fluent/command/plugin_config_formatter.rb +258 -0
- data/lib/fluent/command/plugin_generator.rb +301 -0
- data/lib/fluent/compat/call_super_mixin.rb +67 -0
- data/lib/fluent/compat/detach_process_mixin.rb +25 -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 +59 -0
- data/lib/fluent/compat/output.rb +728 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +310 -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 +418 -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 +223 -0
- data/lib/fluent/config/types.rb +136 -0
- data/lib/fluent/config/v1_parser.rb +190 -0
- data/lib/fluent/configurable.rb +200 -0
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/engine.rb +266 -0
- data/lib/fluent/env.rb +28 -0
- data/lib/fluent/error.rb +30 -0
- data/lib/fluent/event.rb +334 -0
- data/lib/fluent/event_router.rb +269 -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 +46 -0
- data/lib/fluent/load.rb +35 -0
- data/lib/fluent/log.rb +546 -0
- data/lib/fluent/match.rb +178 -0
- data/lib/fluent/mixin.rb +31 -0
- data/lib/fluent/msgpack_factory.rb +62 -0
- data/lib/fluent/output.rb +29 -0
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +23 -0
- data/lib/fluent/plugin.rb +183 -0
- data/lib/fluent/plugin/bare_output.rb +63 -0
- data/lib/fluent/plugin/base.rb +165 -0
- data/lib/fluent/plugin/buf_file.rb +184 -0
- data/lib/fluent/plugin/buf_memory.rb +34 -0
- data/lib/fluent/plugin/buffer.rb +617 -0
- data/lib/fluent/plugin/buffer/chunk.rb +221 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +364 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +90 -0
- data/lib/fluent/plugin/compressable.rb +92 -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_parser.rb +119 -0
- data/lib/fluent/plugin/filter_record_transformer.rb +322 -0
- data/lib/fluent/plugin/filter_stdout.rb +53 -0
- data/lib/fluent/plugin/formatter.rb +50 -0
- data/lib/fluent/plugin/formatter_csv.rb +52 -0
- data/lib/fluent/plugin/formatter_hash.rb +33 -0
- data/lib/fluent/plugin/formatter_json.rb +55 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +42 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +33 -0
- data/lib/fluent/plugin/formatter_out_file.rb +51 -0
- data/lib/fluent/plugin/formatter_single_value.rb +34 -0
- data/lib/fluent/plugin/formatter_stdout.rb +75 -0
- data/lib/fluent/plugin/formatter_tsv.rb +34 -0
- data/lib/fluent/plugin/in_debug_agent.rb +64 -0
- data/lib/fluent/plugin/in_dummy.rb +139 -0
- data/lib/fluent/plugin/in_exec.rb +108 -0
- data/lib/fluent/plugin/in_forward.rb +455 -0
- data/lib/fluent/plugin/in_gc_stat.rb +56 -0
- data/lib/fluent/plugin/in_http.rb +433 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +448 -0
- data/lib/fluent/plugin/in_object_space.rb +93 -0
- data/lib/fluent/plugin/in_syslog.rb +209 -0
- data/lib/fluent/plugin/in_tail.rb +905 -0
- data/lib/fluent/plugin/in_tcp.rb +85 -0
- data/lib/fluent/plugin/in_udp.rb +81 -0
- data/lib/fluent/plugin/in_unix.rb +201 -0
- data/lib/fluent/plugin/input.rb +37 -0
- data/lib/fluent/plugin/multi_output.rb +157 -0
- data/lib/fluent/plugin/out_copy.rb +46 -0
- data/lib/fluent/plugin/out_exec.rb +105 -0
- data/lib/fluent/plugin/out_exec_filter.rb +317 -0
- data/lib/fluent/plugin/out_file.rb +302 -0
- data/lib/fluent/plugin/out_forward.rb +912 -0
- data/lib/fluent/plugin/out_null.rb +74 -0
- data/lib/fluent/plugin/out_relabel.rb +32 -0
- data/lib/fluent/plugin/out_roundrobin.rb +84 -0
- data/lib/fluent/plugin/out_secondary_file.rb +133 -0
- data/lib/fluent/plugin/out_stdout.rb +75 -0
- data/lib/fluent/plugin/out_stream.rb +130 -0
- data/lib/fluent/plugin/output.rb +1291 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +191 -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 +39 -0
- data/lib/fluent/plugin/parser_json.rb +81 -0
- data/lib/fluent/plugin/parser_ltsv.rb +42 -0
- data/lib/fluent/plugin/parser_msgpack.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +105 -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 +63 -0
- data/lib/fluent/plugin/parser_syslog.rb +121 -0
- data/lib/fluent/plugin/parser_tsv.rb +42 -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 +159 -0
- data/lib/fluent/plugin/string_util.rb +22 -0
- data/lib/fluent/plugin_helper.rb +70 -0
- data/lib/fluent/plugin_helper/cert_option.rb +159 -0
- data/lib/fluent/plugin_helper/child_process.rb +364 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +331 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +93 -0
- data/lib/fluent/plugin_helper/event_loop.rb +161 -0
- data/lib/fluent/plugin_helper/extract.rb +104 -0
- data/lib/fluent/plugin_helper/formatter.rb +147 -0
- data/lib/fluent/plugin_helper/inject.rb +151 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/retry_state.rb +201 -0
- data/lib/fluent/plugin_helper/server.rb +738 -0
- data/lib/fluent/plugin_helper/socket.rb +241 -0
- data/lib/fluent/plugin_helper/socket_option.rb +69 -0
- data/lib/fluent/plugin_helper/storage.rb +349 -0
- data/lib/fluent/plugin_helper/thread.rb +179 -0
- data/lib/fluent/plugin_helper/timer.rb +91 -0
- data/lib/fluent/plugin_id.rb +80 -0
- data/lib/fluent/process.rb +22 -0
- data/lib/fluent/registry.rb +116 -0
- data/lib/fluent/root_agent.rb +323 -0
- data/lib/fluent/rpc.rb +94 -0
- data/lib/fluent/supervisor.rb +741 -0
- data/lib/fluent/system_config.rb +159 -0
- data/lib/fluent/test.rb +58 -0
- data/lib/fluent/test/base.rb +78 -0
- data/lib/fluent/test/driver/base.rb +224 -0
- data/lib/fluent/test/driver/base_owned.rb +70 -0
- data/lib/fluent/test/driver/base_owner.rb +135 -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 +53 -0
- data/lib/fluent/test/driver/output.rb +102 -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 +134 -0
- data/lib/fluent/test/input_test.rb +174 -0
- data/lib/fluent/test/log.rb +79 -0
- data/lib/fluent/test/output_test.rb +156 -0
- data/lib/fluent/test/parser_test.rb +70 -0
- data/lib/fluent/test/startup_shutdown.rb +46 -0
- data/lib/fluent/time.rb +412 -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/templates/new_gem/Gemfile +3 -0
- data/templates/new_gem/README.md.erb +43 -0
- data/templates/new_gem/Rakefile +13 -0
- data/templates/new_gem/fluent-plugin.gemspec.erb +27 -0
- data/templates/new_gem/lib/fluent/plugin/filter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/formatter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/input.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/output.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/parser.rb.erb +15 -0
- data/templates/new_gem/test/helper.rb.erb +8 -0
- data/templates/new_gem/test/plugin/test_filter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_formatter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_input.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_output.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_parser.rb.erb +18 -0
- data/templates/plugin_config_formatter/param.md-compact.erb +25 -0
- data/templates/plugin_config_formatter/param.md.erb +34 -0
- data/templates/plugin_config_formatter/section.md.erb +12 -0
- data/test/command/test_binlog_reader.rb +346 -0
- data/test/command/test_fluentd.rb +618 -0
- data/test/command/test_plugin_config_formatter.rb +275 -0
- data/test/command/test_plugin_generator.rb +66 -0
- data/test/compat/test_calls_super.rb +166 -0
- data/test/compat/test_parser.rb +92 -0
- data/test/config/assertions.rb +42 -0
- data/test/config/test_config_parser.rb +513 -0
- data/test/config/test_configurable.rb +1587 -0
- data/test/config/test_configure_proxy.rb +566 -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 +168 -0
- data/test/config/test_types.rb +191 -0
- data/test/helper.rb +153 -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/foo/bar2 +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 +115 -0
- data/test/plugin/test_buf_file.rb +843 -0
- data/test/plugin/test_buf_memory.rb +42 -0
- data/test/plugin/test_buffer.rb +1220 -0
- data/test/plugin/test_buffer_chunk.rb +198 -0
- data/test/plugin/test_buffer_file_chunk.rb +844 -0
- data/test/plugin/test_buffer_memory_chunk.rb +338 -0
- data/test/plugin/test_compressable.rb +84 -0
- data/test/plugin/test_file_util.rb +96 -0
- data/test/plugin/test_filter.rb +357 -0
- data/test/plugin/test_filter_grep.rb +119 -0
- data/test/plugin/test_filter_parser.rb +700 -0
- data/test/plugin/test_filter_record_transformer.rb +556 -0
- data/test/plugin/test_filter_stdout.rb +202 -0
- data/test/plugin/test_formatter_csv.rb +111 -0
- data/test/plugin/test_formatter_hash.rb +35 -0
- data/test/plugin/test_formatter_json.rb +51 -0
- data/test/plugin/test_formatter_ltsv.rb +59 -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 +192 -0
- data/test/plugin/test_in_exec.rb +245 -0
- data/test/plugin/test_in_forward.rb +1120 -0
- data/test/plugin/test_in_gc_stat.rb +39 -0
- data/test/plugin/test_in_http.rb +588 -0
- data/test/plugin/test_in_monitor_agent.rb +516 -0
- data/test/plugin/test_in_object_space.rb +64 -0
- data/test/plugin/test_in_syslog.rb +271 -0
- data/test/plugin/test_in_tail.rb +1216 -0
- data/test/plugin/test_in_tcp.rb +118 -0
- data/test/plugin/test_in_udp.rb +152 -0
- data/test/plugin/test_in_unix.rb +126 -0
- data/test/plugin/test_input.rb +126 -0
- data/test/plugin/test_multi_output.rb +180 -0
- data/test/plugin/test_out_copy.rb +160 -0
- data/test/plugin/test_out_exec.rb +310 -0
- data/test/plugin/test_out_exec_filter.rb +613 -0
- data/test/plugin/test_out_file.rb +873 -0
- data/test/plugin/test_out_forward.rb +685 -0
- data/test/plugin/test_out_null.rb +105 -0
- data/test/plugin/test_out_relabel.rb +28 -0
- data/test/plugin/test_out_roundrobin.rb +146 -0
- data/test/plugin/test_out_secondary_file.rb +442 -0
- data/test/plugin/test_out_stdout.rb +170 -0
- data/test/plugin/test_out_stream.rb +93 -0
- data/test/plugin/test_output.rb +870 -0
- data/test/plugin/test_output_as_buffered.rb +1932 -0
- data/test/plugin/test_output_as_buffered_compress.rb +165 -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 +877 -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.rb +359 -0
- data/test/plugin/test_parser_apache.rb +42 -0
- data/test/plugin/test_parser_apache2.rb +46 -0
- data/test/plugin/test_parser_apache_error.rb +45 -0
- data/test/plugin/test_parser_csv.rb +103 -0
- data/test/plugin/test_parser_json.rb +114 -0
- data/test/plugin/test_parser_labeled_tsv.rb +128 -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 +52 -0
- data/test/plugin/test_parser_regexp.rb +281 -0
- data/test/plugin/test_parser_syslog.rb +242 -0
- data/test/plugin/test_parser_tsv.rb +122 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +335 -0
- data/test/plugin/test_string_util.rb +26 -0
- data/test/plugin_helper/test_child_process.rb +794 -0
- data/test/plugin_helper/test_compat_parameters.rb +331 -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_extract.rb +194 -0
- data/test/plugin_helper/test_formatter.rb +255 -0
- data/test/plugin_helper/test_inject.rb +519 -0
- data/test/plugin_helper/test_parser.rb +264 -0
- data/test/plugin_helper/test_retry_state.rb +422 -0
- data/test/plugin_helper/test_server.rb +1677 -0
- data/test/plugin_helper/test_storage.rb +542 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +132 -0
- data/test/scripts/exec_script.rb +32 -0
- data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +7 -0
- data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +7 -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_clock.rb +164 -0
- data/test/test_config.rb +179 -0
- data/test/test_configdsl.rb +148 -0
- data/test/test_event.rb +515 -0
- data/test/test_event_router.rb +331 -0
- data/test/test_event_time.rb +186 -0
- data/test/test_filter.rb +121 -0
- data/test/test_formatter.rb +312 -0
- data/test/test_input.rb +31 -0
- data/test/test_log.rb +828 -0
- data/test/test_match.rb +137 -0
- data/test/test_mixin.rb +351 -0
- data/test/test_output.rb +273 -0
- data/test/test_plugin.rb +251 -0
- data/test/test_plugin_classes.rb +253 -0
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_plugin_id.rb +101 -0
- data/test/test_process.rb +14 -0
- data/test/test_root_agent.rb +611 -0
- data/test/test_supervisor.rb +373 -0
- data/test/test_test_drivers.rb +135 -0
- data/test/test_time_formatter.rb +282 -0
- data/test/test_time_parser.rb +211 -0
- data/test/test_unique_id.rb +47 -0
- metadata +898 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/output'
|
3
|
+
require 'fluent/plugin/out_null'
|
4
|
+
|
5
|
+
class NullOutputTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Fluent::Test.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_driver(conf = "")
|
11
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::NullOutput).configure(conf)
|
12
|
+
end
|
13
|
+
|
14
|
+
sub_test_case 'non-buffered' do
|
15
|
+
test 'configure' do
|
16
|
+
assert_nothing_raised do
|
17
|
+
create_driver
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'process' do
|
22
|
+
d = create_driver
|
23
|
+
assert_nothing_raised do
|
24
|
+
d.run do
|
25
|
+
d.feed("test", Fluent::EventTime.now, {"test" => "null"})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
assert_equal([], d.events(tag: "test"))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
sub_test_case 'buffered' do
|
33
|
+
test 'default chunk limit size is 100' do
|
34
|
+
d = create_driver(config_element("ROOT", "", {}, [config_element("buffer")]))
|
35
|
+
assert_equal 10 * 1024, d.instance.buffer_config.chunk_limit_size
|
36
|
+
assert d.instance.buffer_config.flush_at_shutdown
|
37
|
+
assert_equal ['tag'], d.instance.buffer_config.chunk_keys
|
38
|
+
assert d.instance.chunk_key_tag
|
39
|
+
assert !d.instance.chunk_key_time
|
40
|
+
assert_equal [], d.instance.chunk_keys
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'writes standard formattted chunks' do
|
44
|
+
d = create_driver(config_element("ROOT", "", {}, [config_element("buffer")]))
|
45
|
+
t = event_time("2016-05-23 00:22:13 -0800")
|
46
|
+
d.run(default_tag: 'test', flush: true) do
|
47
|
+
d.feed(t, {"message" => "null null null"})
|
48
|
+
d.feed(t, {"message" => "null null"})
|
49
|
+
d.feed(t, {"message" => "null"})
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_equal 3, d.instance.emit_count
|
53
|
+
assert_equal 3, d.instance.emit_records
|
54
|
+
end
|
55
|
+
|
56
|
+
test 'check for chunk passed to #write' do
|
57
|
+
d = create_driver(config_element("ROOT", "", {}, [config_element("buffer")]))
|
58
|
+
data = []
|
59
|
+
d.instance.feed_proc = ->(chunk){ data << [chunk.unique_id, chunk.metadata.tag, chunk.read] }
|
60
|
+
|
61
|
+
t = event_time("2016-05-23 00:22:13 -0800")
|
62
|
+
d.run(default_tag: 'test', flush: true) do
|
63
|
+
d.feed(t, {"message" => "null null null"})
|
64
|
+
d.feed(t, {"message" => "null null"})
|
65
|
+
d.feed(t, {"message" => "null"})
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal 1, data.size
|
69
|
+
_, tag, binary = data.first
|
70
|
+
events = []
|
71
|
+
Fluent::MessagePackFactory.unpacker.feed_each(binary){|obj| events << obj }
|
72
|
+
assert_equal 'test', tag
|
73
|
+
assert_equal [ [t, {"message" => "null null null"}], [t, {"message" => "null null"}], [t, {"message" => "null"}] ], events
|
74
|
+
end
|
75
|
+
|
76
|
+
test 'check for chunk passed to #try_write' do
|
77
|
+
d = create_driver(config_element("ROOT", "", {}, [config_element("buffer")]))
|
78
|
+
data = []
|
79
|
+
d.instance.feed_proc = ->(chunk){ data << [chunk.unique_id, chunk.metadata.tag, chunk.read] }
|
80
|
+
d.instance.delayed = true
|
81
|
+
|
82
|
+
t = event_time("2016-05-23 00:22:13 -0800")
|
83
|
+
d.run(default_tag: 'test', flush: true, wait_flush_completion: false, shutdown: false) do
|
84
|
+
d.feed(t, {"message" => "null null null"})
|
85
|
+
d.feed(t, {"message" => "null null"})
|
86
|
+
d.feed(t, {"message" => "null"})
|
87
|
+
end
|
88
|
+
|
89
|
+
assert_equal 1, data.size
|
90
|
+
chunk_id, tag, binary = data.first
|
91
|
+
events = []
|
92
|
+
Fluent::MessagePackFactory.unpacker.feed_each(binary){|obj| events << obj }
|
93
|
+
assert_equal 'test', tag
|
94
|
+
assert_equal [ [t, {"message" => "null null null"}], [t, {"message" => "null null"}], [t, {"message" => "null"}] ], events
|
95
|
+
|
96
|
+
assert_equal [chunk_id], d.instance.buffer.dequeued.keys
|
97
|
+
|
98
|
+
d.instance.commit_write(chunk_id)
|
99
|
+
|
100
|
+
assert_equal [], d.instance.buffer.dequeued.keys
|
101
|
+
|
102
|
+
d.instance_shutdown
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/output'
|
3
|
+
require 'fluent/plugin/out_relabel'
|
4
|
+
|
5
|
+
class RelabelOutputTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Fluent::Test.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def default_config
|
11
|
+
config_element('ROOT', '', {"@type"=>"relabel", "@label"=>"@RELABELED"})
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_driver(conf = default_config)
|
15
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::RelabelOutput).configure(conf)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_process
|
19
|
+
d = create_driver
|
20
|
+
|
21
|
+
time = event_time("2011-01-02 13:14:15 UTC")
|
22
|
+
d.run(default_tag: 'test') do
|
23
|
+
d.feed(time, {"a"=>1})
|
24
|
+
d.feed(time, {"a"=>2})
|
25
|
+
end
|
26
|
+
assert_equal [["test", time, {"a"=>1}], ["test", time, {"a"=>2}]], d.events
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/multi_output'
|
3
|
+
require 'fluent/plugin/out_roundrobin'
|
4
|
+
|
5
|
+
class RoundRobinOutputTest < Test::Unit::TestCase
|
6
|
+
class << self
|
7
|
+
def startup
|
8
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'scripts'))
|
9
|
+
require 'fluent/plugin/out_test'
|
10
|
+
require 'fluent/plugin/out_test2'
|
11
|
+
end
|
12
|
+
|
13
|
+
def shutdown
|
14
|
+
$LOAD_PATH.shift
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
Fluent::Test.setup
|
20
|
+
end
|
21
|
+
|
22
|
+
CONFIG = %[
|
23
|
+
<store>
|
24
|
+
@type test
|
25
|
+
name c0
|
26
|
+
</store>
|
27
|
+
<store>
|
28
|
+
@type test2
|
29
|
+
name c1
|
30
|
+
</store>
|
31
|
+
<store>
|
32
|
+
@type test
|
33
|
+
name c2
|
34
|
+
</store>
|
35
|
+
]
|
36
|
+
CONFIG_WITH_WEIGHT = %[
|
37
|
+
<store>
|
38
|
+
@type test
|
39
|
+
name c0
|
40
|
+
weight 3
|
41
|
+
</store>
|
42
|
+
<store>
|
43
|
+
@type test2
|
44
|
+
name c1
|
45
|
+
weight 3
|
46
|
+
</store>
|
47
|
+
<store>
|
48
|
+
@type test
|
49
|
+
name c2
|
50
|
+
</store>
|
51
|
+
]
|
52
|
+
|
53
|
+
def create_driver(conf = CONFIG)
|
54
|
+
Fluent::Test::Driver::MultiOutput.new(Fluent::Plugin::RoundRobinOutput).configure(conf)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_configure
|
58
|
+
d = create_driver
|
59
|
+
|
60
|
+
outputs = d.instance.outputs
|
61
|
+
assert_equal 3, outputs.size
|
62
|
+
|
63
|
+
assert_equal Fluent::Plugin::TestOutput, outputs[0].class
|
64
|
+
assert_equal Fluent::Plugin::Test2Output, outputs[1].class
|
65
|
+
assert_equal Fluent::Plugin::TestOutput, outputs[2].class
|
66
|
+
|
67
|
+
assert !outputs[0].has_router?
|
68
|
+
assert outputs[1].has_router?
|
69
|
+
assert outputs[1].router
|
70
|
+
assert !outputs[2].has_router?
|
71
|
+
|
72
|
+
assert_equal "c0", outputs[0].name
|
73
|
+
assert_equal "c1", outputs[1].name
|
74
|
+
assert_equal "c2", outputs[2].name
|
75
|
+
|
76
|
+
weights = d.instance.weights
|
77
|
+
assert_equal 3, weights.size
|
78
|
+
assert_equal 1, weights[0]
|
79
|
+
assert_equal 1, weights[1]
|
80
|
+
assert_equal 1, weights[2]
|
81
|
+
|
82
|
+
d = create_driver(CONFIG_WITH_WEIGHT)
|
83
|
+
|
84
|
+
outputs = d.instance.outputs
|
85
|
+
assert_equal 3, outputs.size
|
86
|
+
|
87
|
+
assert_equal Fluent::Plugin::TestOutput, outputs[0].class
|
88
|
+
assert_equal Fluent::Plugin::Test2Output, outputs[1].class
|
89
|
+
assert_equal Fluent::Plugin::TestOutput, outputs[2].class
|
90
|
+
|
91
|
+
assert_equal "c0", outputs[0].name
|
92
|
+
assert_equal "c1", outputs[1].name
|
93
|
+
assert_equal "c2", outputs[2].name
|
94
|
+
|
95
|
+
weights = d.instance.weights
|
96
|
+
assert_equal 3, weights.size
|
97
|
+
assert_equal 3, weights[0]
|
98
|
+
assert_equal 3, weights[1]
|
99
|
+
assert_equal 1, weights[2]
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_events_feeded_to_plugins_by_roundrobin
|
103
|
+
d = create_driver
|
104
|
+
|
105
|
+
time = event_time("2011-01-02 13:14:15 UTC")
|
106
|
+
d.run(default_tag: 'test') do
|
107
|
+
d.feed(time, {"a" => 1})
|
108
|
+
d.feed(time, {"a" => 2})
|
109
|
+
d.feed(time, {"a" => 3})
|
110
|
+
d.feed(time, {"a" => 4})
|
111
|
+
end
|
112
|
+
|
113
|
+
os = d.instance.outputs
|
114
|
+
|
115
|
+
assert_equal [
|
116
|
+
[time, {"a"=>1}],
|
117
|
+
[time, {"a"=>4}],
|
118
|
+
], os[0].events
|
119
|
+
|
120
|
+
assert_equal [
|
121
|
+
[time, {"a"=>2}],
|
122
|
+
], os[1].events
|
123
|
+
|
124
|
+
assert_equal [
|
125
|
+
[time, {"a"=>3}],
|
126
|
+
], os[2].events
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_events_feeded_with_specified_weights
|
130
|
+
d = create_driver(CONFIG_WITH_WEIGHT)
|
131
|
+
|
132
|
+
time = event_time("2011-01-02 13:14:15 UTC")
|
133
|
+
d.run(default_tag: 'test') do
|
134
|
+
14.times do |i|
|
135
|
+
d.feed(time, {"a" => i})
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
os = d.instance.outputs
|
140
|
+
|
141
|
+
assert_equal 6, os[0].events.size # weight=3
|
142
|
+
assert_equal 6, os[1].events.size # weight=3
|
143
|
+
assert_equal 2, os[2].events.size # weight=1
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
@@ -0,0 +1,442 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'time'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'fluent/event'
|
5
|
+
require 'fluent/unique_id'
|
6
|
+
require 'fluent/plugin/buffer'
|
7
|
+
require 'fluent/plugin/out_secondary_file'
|
8
|
+
require 'fluent/plugin/buffer/memory_chunk'
|
9
|
+
require 'fluent/test/driver/output'
|
10
|
+
|
11
|
+
class FileOutputSecondaryTest < Test::Unit::TestCase
|
12
|
+
include Fluent::UniqueId::Mixin
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Fluent::Test.setup
|
16
|
+
FileUtils.rm_rf(TMP_DIR)
|
17
|
+
FileUtils.mkdir_p(TMP_DIR)
|
18
|
+
end
|
19
|
+
|
20
|
+
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/out_secondary_file#{ENV['TEST_ENV_NUMBER']}")
|
21
|
+
|
22
|
+
CONFIG = %[
|
23
|
+
directory #{TMP_DIR}
|
24
|
+
basename out_file_test
|
25
|
+
compress gzip
|
26
|
+
]
|
27
|
+
|
28
|
+
class DummyOutput < Fluent::Plugin::Output
|
29
|
+
def write(chunk); end
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_primary(buffer_cofig = config_element('buffer'))
|
33
|
+
DummyOutput.new.configure(config_element('ROOT','',{}, [buffer_cofig]))
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_driver(conf = CONFIG, primary = create_primary)
|
37
|
+
c = Fluent::Test::Driver::Output.new(Fluent::Plugin::SecondaryFileOutput)
|
38
|
+
c.instance.acts_as_secondary(primary)
|
39
|
+
c.configure(conf)
|
40
|
+
end
|
41
|
+
|
42
|
+
sub_test_case 'configture' do
|
43
|
+
test 'default configuration' do
|
44
|
+
d = create_driver %[directory #{TMP_DIR}]
|
45
|
+
assert_equal 'dump.bin', d.instance.basename
|
46
|
+
assert_equal TMP_DIR, d.instance.directory
|
47
|
+
assert_equal :text, d.instance.compress
|
48
|
+
assert_equal false, d.instance.append
|
49
|
+
end
|
50
|
+
|
51
|
+
test 'should be configurable' do
|
52
|
+
d = create_driver %[
|
53
|
+
directory #{TMP_DIR}
|
54
|
+
basename out_file_test
|
55
|
+
compress gzip
|
56
|
+
append true
|
57
|
+
]
|
58
|
+
assert_equal 'out_file_test', d.instance.basename
|
59
|
+
assert_equal TMP_DIR, d.instance.directory
|
60
|
+
assert_equal :gzip, d.instance.compress
|
61
|
+
assert_equal true, d.instance.append
|
62
|
+
end
|
63
|
+
|
64
|
+
test 'should only use in secondary' do
|
65
|
+
c = Fluent::Test::Driver::Output.new(Fluent::Plugin::SecondaryFileOutput)
|
66
|
+
assert_raise Fluent::ConfigError.new("This plugin can only be used in the <secondary> section") do
|
67
|
+
c.configure(CONFIG)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
test 'basename should not include `/`' do
|
72
|
+
assert_raise Fluent::ConfigError.new("basename should not include `/`") do
|
73
|
+
create_driver %[
|
74
|
+
directory #{TMP_DIR}
|
75
|
+
basename out/file
|
76
|
+
]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
test 'directory should be writable' do
|
81
|
+
assert_nothing_raised do
|
82
|
+
create_driver %[directory #{TMP_DIR}/test_dir/foo/bar/]
|
83
|
+
end
|
84
|
+
|
85
|
+
assert_nothing_raised do
|
86
|
+
FileUtils.mkdir_p("#{TMP_DIR}/test_dir")
|
87
|
+
File.chmod(0777, "#{TMP_DIR}/test_dir")
|
88
|
+
create_driver %[directory #{TMP_DIR}/test_dir/foo/bar/]
|
89
|
+
end
|
90
|
+
|
91
|
+
assert_raise Fluent::ConfigError.new("out_secondary_file: `#{TMP_DIR}/test_dir/foo/bar/` should be writable") do
|
92
|
+
FileUtils.mkdir_p("#{TMP_DIR}/test_dir")
|
93
|
+
File.chmod(0555, "#{TMP_DIR}/test_dir")
|
94
|
+
create_driver %[directory #{TMP_DIR}/test_dir/foo/bar/]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'should be passed directory' do
|
99
|
+
assert_raise Fluent::ConfigError do
|
100
|
+
i = Fluent::Plugin::SecondaryFileOutput.new
|
101
|
+
i.acts_as_secondary(create_primary)
|
102
|
+
i.configure(config_element())
|
103
|
+
end
|
104
|
+
|
105
|
+
assert_nothing_raised do
|
106
|
+
create_driver %[directory #{TMP_DIR}/test_dir/foo/bar/]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def check_gzipped_result(path, expect)
|
112
|
+
# Zlib::GzipReader has a bug of concatenated file: https://bugs.ruby-lang.org/issues/9790
|
113
|
+
# Following code from https://www.ruby-forum.com/topic/971591#979520
|
114
|
+
result = ""
|
115
|
+
waiting(10) do
|
116
|
+
# we can expect that GzipReader#read can wait unflushed raw data of `io` on disk
|
117
|
+
File.open(path, "rb") { |io|
|
118
|
+
loop do
|
119
|
+
gzr = Zlib::GzipReader.new(io)
|
120
|
+
result << gzr.read
|
121
|
+
unused = gzr.unused
|
122
|
+
gzr.finish
|
123
|
+
break if unused.nil?
|
124
|
+
io.pos -= unused.length
|
125
|
+
end
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
assert_equal expect, result
|
130
|
+
end
|
131
|
+
|
132
|
+
def create_chunk(primary, metadata, es)
|
133
|
+
primary.buffer.generate_chunk(metadata).tap do |c|
|
134
|
+
c.concat(es.to_msgpack_stream, es.size) # to_msgpack_stream is standard_format
|
135
|
+
c.commit
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
sub_test_case 'write' do
|
140
|
+
setup do
|
141
|
+
@record = { 'key' => 'value' }
|
142
|
+
@time = event_time
|
143
|
+
@es = Fluent::OneEventStream.new(@time, @record)
|
144
|
+
@primary = create_primary
|
145
|
+
metadata = @primary.buffer.new_metadata
|
146
|
+
@chunk = create_chunk(@primary, metadata, @es)
|
147
|
+
end
|
148
|
+
|
149
|
+
test 'should output compressed file when compress option is gzip' do
|
150
|
+
d = create_driver(CONFIG, @primary)
|
151
|
+
path = d.instance.write(@chunk)
|
152
|
+
|
153
|
+
assert_equal "#{TMP_DIR}/out_file_test.0.gz", path
|
154
|
+
check_gzipped_result(path, @es.to_msgpack_stream.force_encoding('ASCII-8BIT'))
|
155
|
+
end
|
156
|
+
|
157
|
+
test 'should output plain text when compress option is default(text)' do
|
158
|
+
d = create_driver(%[
|
159
|
+
directory #{TMP_DIR}/
|
160
|
+
basename out_file_test
|
161
|
+
], @primary)
|
162
|
+
|
163
|
+
msgpack_binary = @es.to_msgpack_stream.force_encoding('ASCII-8BIT')
|
164
|
+
|
165
|
+
path = d.instance.write(@chunk)
|
166
|
+
assert_equal "#{TMP_DIR}/out_file_test.0", path
|
167
|
+
waiting(5) do
|
168
|
+
sleep 0.1 until File.stat(path).size == msgpack_binary.size
|
169
|
+
end
|
170
|
+
|
171
|
+
assert_equal msgpack_binary, File.binread(path)
|
172
|
+
end
|
173
|
+
|
174
|
+
test 'path should be incremental when append option is false' do
|
175
|
+
d = create_driver(CONFIG, @primary)
|
176
|
+
packed_value = @es.to_msgpack_stream.force_encoding('ASCII-8BIT')
|
177
|
+
|
178
|
+
5.times do |i|
|
179
|
+
path = d.instance.write(@chunk)
|
180
|
+
assert_equal "#{TMP_DIR}/out_file_test.#{i}.gz", path
|
181
|
+
check_gzipped_result(path, packed_value)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
test 'path should be unchanged when append option is true' do
|
186
|
+
d = create_driver(CONFIG + %[append true], @primary)
|
187
|
+
packed_value = @es.to_msgpack_stream.force_encoding('ASCII-8BIT')
|
188
|
+
|
189
|
+
[*1..5].each do |i|
|
190
|
+
path = d.instance.write(@chunk)
|
191
|
+
assert_equal "#{TMP_DIR}/out_file_test.gz", path
|
192
|
+
check_gzipped_result(path, packed_value * i)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
sub_test_case 'Syntax of placeholders' do
|
198
|
+
data(
|
199
|
+
tag: '${tag}',
|
200
|
+
tag_index: '${tag[0]}',
|
201
|
+
tag_index1: '${tag[10]}',
|
202
|
+
variable: '${key1}',
|
203
|
+
variable2: '${key@value}',
|
204
|
+
variable3: '${key_value}',
|
205
|
+
variable4: '${key.value}',
|
206
|
+
variable5: '${key-value}',
|
207
|
+
variable6: '${KEYVALUE}',
|
208
|
+
variable7: '${tags}',
|
209
|
+
variable8: '${tag${key}', # matched ${key}
|
210
|
+
)
|
211
|
+
test 'matches with a valid placeholder' do |path|
|
212
|
+
assert Fluent::Plugin::SecondaryFileOutput::PLACEHOLDER_REGEX.match(path)
|
213
|
+
end
|
214
|
+
|
215
|
+
data(
|
216
|
+
invalid_tag: 'tag',
|
217
|
+
invalid_tag2: '{tag}',
|
218
|
+
invalid_tag3: '${tag',
|
219
|
+
invalid_tag4: '${tag0]}',
|
220
|
+
invalid_tag5: '${tag[]]}',
|
221
|
+
invalid_variable: '${key[0]}',
|
222
|
+
invalid_variable2: '${key{key2}}',
|
223
|
+
)
|
224
|
+
test "doesn't match with an invalid placeholder" do |path|
|
225
|
+
assert !Fluent::Plugin::SecondaryFileOutput::PLACEHOLDER_REGEX.match(path)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
sub_test_case 'path' do
|
230
|
+
setup do
|
231
|
+
@record = { 'key' => 'value' }
|
232
|
+
@time = event_time
|
233
|
+
@es = Fluent::OneEventStream.new(@time, @record)
|
234
|
+
primary = create_primary
|
235
|
+
m = primary.buffer.new_metadata
|
236
|
+
@c = create_chunk(primary, m, @es)
|
237
|
+
end
|
238
|
+
|
239
|
+
test 'normal path when compress option is gzip' do
|
240
|
+
d = create_driver
|
241
|
+
path = d.instance.write(@c)
|
242
|
+
assert_equal "#{TMP_DIR}/out_file_test.0.gz", path
|
243
|
+
end
|
244
|
+
|
245
|
+
test 'normal path when compress option is default' do
|
246
|
+
d = create_driver %[
|
247
|
+
directory #{TMP_DIR}
|
248
|
+
basename out_file_test
|
249
|
+
]
|
250
|
+
path = d.instance.write(@c)
|
251
|
+
assert_equal "#{TMP_DIR}/out_file_test.0", path
|
252
|
+
end
|
253
|
+
|
254
|
+
test 'normal path when append option is true' do
|
255
|
+
d = create_driver %[
|
256
|
+
directory #{TMP_DIR}
|
257
|
+
append true
|
258
|
+
]
|
259
|
+
path = d.instance.write(@c)
|
260
|
+
assert_equal "#{TMP_DIR}/dump.bin", path
|
261
|
+
end
|
262
|
+
|
263
|
+
data(
|
264
|
+
invalid_tag: [/tag/, '${tag}'],
|
265
|
+
invalid_tag0: [/tag\[0\]/, '${tag[0]}'],
|
266
|
+
invalid_variable: [/dummy/, '${dummy}'],
|
267
|
+
invalid_timeformat: [/time/, '%Y%m%d'],
|
268
|
+
)
|
269
|
+
test 'raise an error when basename includes incompatible placeholder' do |(expected_message, invalid_basename)|
|
270
|
+
c = Fluent::Test::Driver::Output.new(Fluent::Plugin::SecondaryFileOutput)
|
271
|
+
c.instance.acts_as_secondary(DummyOutput.new)
|
272
|
+
|
273
|
+
assert_raise_message(expected_message) do
|
274
|
+
c.configure %[
|
275
|
+
directory #{TMP_DIR}/
|
276
|
+
basename #{invalid_basename}
|
277
|
+
compress gzip
|
278
|
+
]
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
data(
|
283
|
+
invalid_tag: [/tag/, '${tag}'],
|
284
|
+
invalid_tag0: [/tag\[0\]/, '${tag[0]}'],
|
285
|
+
invalid_variable: [/dummy/, '${dummy}'],
|
286
|
+
invalid_timeformat: [/time/, '%Y%m%d'],
|
287
|
+
)
|
288
|
+
test 'raise an error when directory includes incompatible placeholder' do |(expected_message, invalid_directory)|
|
289
|
+
c = Fluent::Test::Driver::Output.new(Fluent::Plugin::SecondaryFileOutput)
|
290
|
+
c.instance.acts_as_secondary(DummyOutput.new)
|
291
|
+
|
292
|
+
assert_raise_message(expected_message) do
|
293
|
+
c.configure %[
|
294
|
+
directory #{invalid_directory}/
|
295
|
+
compress gzip
|
296
|
+
]
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
test 'basename includes tag' do
|
301
|
+
primary = create_primary(config_element('buffer', 'tag'))
|
302
|
+
|
303
|
+
d = create_driver(%[
|
304
|
+
directory #{TMP_DIR}/
|
305
|
+
basename cool_${tag}
|
306
|
+
compress gzip
|
307
|
+
], primary)
|
308
|
+
|
309
|
+
m = primary.buffer.new_metadata(tag: 'test.dummy')
|
310
|
+
c = create_chunk(primary, m, @es)
|
311
|
+
|
312
|
+
path = d.instance.write(c)
|
313
|
+
assert_equal "#{TMP_DIR}/cool_test.dummy.0.gz", path
|
314
|
+
end
|
315
|
+
|
316
|
+
test 'basename includes /tag[\d+]/' do
|
317
|
+
primary = create_primary(config_element('buffer', 'tag'))
|
318
|
+
|
319
|
+
d = create_driver(%[
|
320
|
+
directory #{TMP_DIR}/
|
321
|
+
basename cool_${tag[0]}_${tag[1]}
|
322
|
+
compress gzip
|
323
|
+
], primary)
|
324
|
+
|
325
|
+
m = primary.buffer.new_metadata(tag: 'test.dummy')
|
326
|
+
c = create_chunk(primary, m, @es)
|
327
|
+
|
328
|
+
path = d.instance.write(c)
|
329
|
+
assert_equal "#{TMP_DIR}/cool_test_dummy.0.gz", path
|
330
|
+
end
|
331
|
+
|
332
|
+
test 'basename includes time format' do
|
333
|
+
primary = create_primary(
|
334
|
+
config_element('buffer', 'time', { 'timekey_zone' => '+0900', 'timekey' => 1 })
|
335
|
+
)
|
336
|
+
|
337
|
+
d = create_driver(%[
|
338
|
+
directory #{TMP_DIR}/
|
339
|
+
basename cool_%Y%m%d%H
|
340
|
+
compress gzip
|
341
|
+
], primary)
|
342
|
+
|
343
|
+
m = primary.buffer.new_metadata(timekey: event_time("2011-01-02 13:14:15 UTC"))
|
344
|
+
c = create_chunk(primary, m, @es)
|
345
|
+
|
346
|
+
path = d.instance.write(c)
|
347
|
+
assert_equal "#{TMP_DIR}/cool_2011010222.0.gz", path
|
348
|
+
end
|
349
|
+
|
350
|
+
test 'basename includes time format with timekey_use_utc option' do
|
351
|
+
primary = create_primary(
|
352
|
+
config_element('buffer', 'time', { 'timekey_zone' => '+0900', 'timekey' => 1, 'timekey_use_utc' => true })
|
353
|
+
)
|
354
|
+
|
355
|
+
d = create_driver(%[
|
356
|
+
directory #{TMP_DIR}/
|
357
|
+
basename cool_%Y%m%d%H
|
358
|
+
compress gzip
|
359
|
+
], primary)
|
360
|
+
|
361
|
+
m = primary.buffer.new_metadata(timekey: event_time("2011-01-02 13:14:15 UTC"))
|
362
|
+
c = create_chunk(primary, m, @es)
|
363
|
+
|
364
|
+
path = d.instance.write(c)
|
365
|
+
assert_equal "#{TMP_DIR}/cool_2011010213.0.gz", path
|
366
|
+
end
|
367
|
+
|
368
|
+
test 'basename includes variable' do
|
369
|
+
primary = create_primary(config_element('buffer', 'test1'))
|
370
|
+
|
371
|
+
d = create_driver(%[
|
372
|
+
directory #{TMP_DIR}/
|
373
|
+
basename cool_${test1}
|
374
|
+
compress gzip
|
375
|
+
], primary)
|
376
|
+
|
377
|
+
m = primary.buffer.new_metadata(variables: { "test1".to_sym => "dummy" })
|
378
|
+
c = create_chunk(primary, m, @es)
|
379
|
+
|
380
|
+
path = d.instance.write(c)
|
381
|
+
assert_equal "#{TMP_DIR}/cool_dummy.0.gz", path
|
382
|
+
end
|
383
|
+
|
384
|
+
test 'basename includes unnecessary variable' do
|
385
|
+
primary = create_primary(config_element('buffer', 'test1'))
|
386
|
+
c = Fluent::Test::Driver::Output.new(Fluent::Plugin::SecondaryFileOutput)
|
387
|
+
c.instance.acts_as_secondary(primary)
|
388
|
+
|
389
|
+
assert_raise_message(/test2/) do
|
390
|
+
c.configure %[
|
391
|
+
directory #{TMP_DIR}/
|
392
|
+
basename ${test1}_${test2}
|
393
|
+
compress gzip
|
394
|
+
]
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
test 'basename includes tag, time format, and variables' do
|
399
|
+
primary = create_primary(
|
400
|
+
config_element('buffer', 'time,tag,test1', { 'timekey_zone' => '+0000', 'timekey' => 1 })
|
401
|
+
)
|
402
|
+
|
403
|
+
d = create_driver(%[
|
404
|
+
directory #{TMP_DIR}/
|
405
|
+
basename cool_%Y%m%d%H_${tag}_${test1}
|
406
|
+
compress gzip
|
407
|
+
], primary)
|
408
|
+
|
409
|
+
m = primary.buffer.new_metadata(
|
410
|
+
timekey: event_time("2011-01-02 13:14:15 UTC"),
|
411
|
+
tag: 'test.tag',
|
412
|
+
variables: { "test1".to_sym => "dummy" }
|
413
|
+
)
|
414
|
+
|
415
|
+
c = create_chunk(primary, m, @es)
|
416
|
+
|
417
|
+
path = d.instance.write(c)
|
418
|
+
assert_equal "#{TMP_DIR}/cool_2011010213_test.tag_dummy.0.gz", path
|
419
|
+
end
|
420
|
+
|
421
|
+
test 'directory includes tag, time format, and variables' do
|
422
|
+
primary = create_primary(
|
423
|
+
config_element('buffer', 'time,tag,test1', { 'timekey_zone' => '+0000', 'timekey' => 1 })
|
424
|
+
)
|
425
|
+
|
426
|
+
d = create_driver(%[
|
427
|
+
directory #{TMP_DIR}/%Y%m%d%H/${tag}/${test1}
|
428
|
+
compress gzip
|
429
|
+
], primary)
|
430
|
+
|
431
|
+
m = primary.buffer.new_metadata(
|
432
|
+
timekey: event_time("2011-01-02 13:14:15 UTC"),
|
433
|
+
tag: 'test.tag',
|
434
|
+
variables: { "test1".to_sym => "dummy" }
|
435
|
+
)
|
436
|
+
c = create_chunk(primary, m, @es)
|
437
|
+
|
438
|
+
path = d.instance.write(c)
|
439
|
+
assert_equal "#{TMP_DIR}/2011010213/test.tag/dummy/dump.bin.0.gz", path
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|