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,618 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
|
3
|
+
# require 'fluent/command/fluentd'
|
4
|
+
# don't require it... it runs immediately
|
5
|
+
|
6
|
+
require 'fileutils'
|
7
|
+
require 'timeout'
|
8
|
+
|
9
|
+
class TestFluentdCommand < ::Test::Unit::TestCase
|
10
|
+
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/command/fluentd#{ENV['TEST_ENV_NUMBER']}")
|
11
|
+
SUPERVISOR_PID_PATTERN = /starting fluentd-[.0-9]+ pid=(\d+)/
|
12
|
+
WORKER_PID_PATTERN = /starting fluentd worker pid=(\d+) /
|
13
|
+
|
14
|
+
setup do
|
15
|
+
FileUtils.rm_rf(TMP_DIR)
|
16
|
+
FileUtils.mkdir_p(TMP_DIR)
|
17
|
+
@supervisor_pid = nil
|
18
|
+
@worker_pids = []
|
19
|
+
end
|
20
|
+
|
21
|
+
def process_exist?(pid)
|
22
|
+
begin
|
23
|
+
r = Process.waitpid(pid, Process::WNOHANG)
|
24
|
+
return true if r.nil?
|
25
|
+
false
|
26
|
+
rescue SystemCallError
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_conf_file(name, content)
|
32
|
+
conf_path = File.join(TMP_DIR, name)
|
33
|
+
File.open(conf_path, 'w') do |file|
|
34
|
+
file.write content
|
35
|
+
end
|
36
|
+
conf_path
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_plugin_file(name, content)
|
40
|
+
file_path = File.join(TMP_DIR, 'plugin', name)
|
41
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
42
|
+
File.open(file_path, 'w') do |file|
|
43
|
+
file.write content
|
44
|
+
end
|
45
|
+
file_path
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_cmdline(conf_path, *fluentd_options)
|
49
|
+
cmd_path = File.expand_path(File.dirname(__FILE__) + "../../../bin/fluentd")
|
50
|
+
["bundle", "exec", "ruby", cmd_path, "-c", conf_path, *fluentd_options]
|
51
|
+
end
|
52
|
+
|
53
|
+
def execute_command(cmdline, chdir=TMP_DIR)
|
54
|
+
null_stream = File.open(File::NULL, 'w')
|
55
|
+
gemfile_path = File.expand_path(File.dirname(__FILE__) + "../../../Gemfile")
|
56
|
+
|
57
|
+
env = {
|
58
|
+
"BUNDLE_GEMFILE" => gemfile_path,
|
59
|
+
}
|
60
|
+
cmdname = cmdline.shift
|
61
|
+
arg0 = "testing-fluentd"
|
62
|
+
# p(here: "executing process", env: env, cmdname: cmdname, arg0: arg0, args: cmdline)
|
63
|
+
IO.popen(env, [[cmdname, arg0], *cmdline], chdir: chdir, err: [:child, :out]) do |io|
|
64
|
+
pid = io.pid
|
65
|
+
begin
|
66
|
+
yield pid, io
|
67
|
+
# p(here: "execute command", pid: pid, worker_pids: @worker_pids)
|
68
|
+
ensure
|
69
|
+
Process.kill(:KILL, pid) rescue nil
|
70
|
+
if @supervisor_pid
|
71
|
+
Process.kill(:KILL, @supervisor_pid) rescue nil
|
72
|
+
end
|
73
|
+
@worker_pids.each do |cpid|
|
74
|
+
Process.kill(:KILL, cpid) rescue nil
|
75
|
+
end
|
76
|
+
# p(here: "execute command", pid: pid, exist: process_exist?(pid), worker_pids: @worker_pids, exists: @worker_pids.map{|i| process_exist?(i) })
|
77
|
+
Timeout.timeout(10){ sleep 0.1 while process_exist?(pid) }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
ensure
|
81
|
+
null_stream.close rescue nil
|
82
|
+
end
|
83
|
+
|
84
|
+
def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 10)
|
85
|
+
matched = false
|
86
|
+
assert_error_msg = "matched correctly"
|
87
|
+
stdio_buf = ""
|
88
|
+
begin
|
89
|
+
execute_command(cmdline) do |pid, stdout|
|
90
|
+
begin
|
91
|
+
waiting(timeout) do
|
92
|
+
while process_exist?(pid) && !matched
|
93
|
+
readables, _, _ = IO.select([stdout], nil, nil, 1)
|
94
|
+
next unless readables
|
95
|
+
break if readables.first.eof?
|
96
|
+
|
97
|
+
buf = readables.first.readpartial(1024)
|
98
|
+
# puts buf
|
99
|
+
stdio_buf << buf
|
100
|
+
lines = stdio_buf.split("\n")
|
101
|
+
if pattern_list.all?{|ptn| lines.any?{|line| ptn.is_a?(Regexp) ? ptn.match(line) : line.include?(ptn) } }
|
102
|
+
matched = true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
ensure
|
107
|
+
if SUPERVISOR_PID_PATTERN =~ stdio_buf
|
108
|
+
@supervisor_pid = $1.to_i
|
109
|
+
end
|
110
|
+
stdio_buf.scan(WORKER_PID_PATTERN) do |worker_pid|
|
111
|
+
@worker_pids << worker_pid.first.to_i
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
rescue Timeout::Error
|
116
|
+
assert_error_msg = "execution timeout with command out:\n" + stdio_buf
|
117
|
+
rescue => e
|
118
|
+
assert_error_msg = "unexpected error in launching fluentd: #{e.inspect}\n" + stdio_buf
|
119
|
+
end
|
120
|
+
assert matched, assert_error_msg
|
121
|
+
|
122
|
+
unless patterns_not_match.empty?
|
123
|
+
lines = stdio_buf.split("\n")
|
124
|
+
patterns_not_match.each do |ptn|
|
125
|
+
matched_wrongly = if ptn.is_a? Regexp
|
126
|
+
lines.any?{|line| ptn.match(line) }
|
127
|
+
else
|
128
|
+
lines.any?{|line| line.include?(ptn) }
|
129
|
+
end
|
130
|
+
assert_false matched_wrongly, "pattern exists in logs wrongly:\n" + stdio_buf
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 10)
|
136
|
+
# empty_list.all?{ ... } is always true
|
137
|
+
matched = false
|
138
|
+
running = false
|
139
|
+
assert_error_msg = "failed to start correctly"
|
140
|
+
stdio_buf = ""
|
141
|
+
begin
|
142
|
+
execute_command(cmdline) do |pid, stdout|
|
143
|
+
begin
|
144
|
+
waiting(timeout) do
|
145
|
+
while process_exist?(pid) && !running
|
146
|
+
readables, _, _ = IO.select([stdout], nil, nil, 1)
|
147
|
+
next unless readables
|
148
|
+
next if readables.first.eof?
|
149
|
+
|
150
|
+
stdio_buf << readables.first.readpartial(1024)
|
151
|
+
lines = stdio_buf.split("\n")
|
152
|
+
if lines.any?{|line| line.include?("fluentd worker is now running") }
|
153
|
+
running = true
|
154
|
+
end
|
155
|
+
if pattern_list.all?{|ptn| lines.any?{|line| ptn.is_a?(Regexp) ? ptn.match(line) : line.include?(ptn) } }
|
156
|
+
matched = true
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
ensure
|
161
|
+
if SUPERVISOR_PID_PATTERN =~ stdio_buf
|
162
|
+
@supervisor_pid = $1.to_i
|
163
|
+
end
|
164
|
+
stdio_buf.scan(WORKER_PID_PATTERN) do |worker_pid|
|
165
|
+
@worker_pids << worker_pid.first.to_i
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
rescue Timeout::Error
|
170
|
+
assert_error_msg = "execution timeout with command out:\n" + stdio_buf
|
171
|
+
rescue => e
|
172
|
+
assert_error_msg = "unexpected error in launching fluentd: #{e.inspect}\n" + stdio_buf
|
173
|
+
assert false, assert_error_msg
|
174
|
+
end
|
175
|
+
assert !running, "fluentd started to run incorrectly:\n" + stdio_buf
|
176
|
+
unless matched
|
177
|
+
assert_error_msg = "fluentd failed to start, without specified regular expressions:\n" + stdio_buf
|
178
|
+
end
|
179
|
+
assert matched, assert_error_msg
|
180
|
+
end
|
181
|
+
|
182
|
+
sub_test_case 'with valid configuration' do
|
183
|
+
test 'runs successfully' do
|
184
|
+
conf = <<CONF
|
185
|
+
<source>
|
186
|
+
@type dummy
|
187
|
+
@id dummy
|
188
|
+
@label @dummydata
|
189
|
+
tag dummy
|
190
|
+
dummy {"message": "yay!"}
|
191
|
+
</source>
|
192
|
+
<label @dummydata>
|
193
|
+
<match dummy>
|
194
|
+
@type null
|
195
|
+
@id blackhole
|
196
|
+
</match>
|
197
|
+
</label>
|
198
|
+
CONF
|
199
|
+
conf_path = create_conf_file('valid.conf', conf)
|
200
|
+
assert File.exist?(conf_path)
|
201
|
+
|
202
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", 'worker=0')
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
sub_test_case 'with system configuration about root directory' do
|
207
|
+
setup do
|
208
|
+
@root_path = File.join(TMP_DIR, "rootpath")
|
209
|
+
FileUtils.rm_rf(@root_path)
|
210
|
+
@conf = <<CONF
|
211
|
+
<system>
|
212
|
+
root_dir #{@root_path}
|
213
|
+
</system>
|
214
|
+
<source>
|
215
|
+
@type dummy
|
216
|
+
@id dummy
|
217
|
+
@label @dummydata
|
218
|
+
tag dummy
|
219
|
+
dummy {"message": "yay!"}
|
220
|
+
</source>
|
221
|
+
<label @dummydata>
|
222
|
+
<match dummy>
|
223
|
+
@type null
|
224
|
+
@id blackhole
|
225
|
+
</match>
|
226
|
+
</label>
|
227
|
+
CONF
|
228
|
+
end
|
229
|
+
|
230
|
+
test 'use the specified existing directory as root' do
|
231
|
+
FileUtils.mkdir_p(@root_path)
|
232
|
+
conf_path = create_conf_file('existing_root_dir.conf', @conf)
|
233
|
+
assert Dir.exist?(@root_path)
|
234
|
+
|
235
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", 'worker=0')
|
236
|
+
end
|
237
|
+
|
238
|
+
test 'creates the specified root directory if missing' do
|
239
|
+
conf_path = create_conf_file('missing_root_dir.conf', @conf)
|
240
|
+
assert_false Dir.exist?(@root_path)
|
241
|
+
|
242
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", 'worker=0')
|
243
|
+
assert Dir.exist?(@root_path)
|
244
|
+
end
|
245
|
+
|
246
|
+
test 'fails to launch fluentd if specified root path is invalid path for directory' do
|
247
|
+
File.open(@root_path, 'w') do |_|
|
248
|
+
# create file and close it
|
249
|
+
end
|
250
|
+
conf_path = create_conf_file('existing_root_dir.conf', @conf)
|
251
|
+
|
252
|
+
assert_fluentd_fails_to_start(
|
253
|
+
create_cmdline(conf_path),
|
254
|
+
"non directory entry exists:#{@root_path} (Fluent::InvalidRootDirectory)",
|
255
|
+
)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
sub_test_case 'configured to route log events to plugins' do
|
260
|
+
setup do
|
261
|
+
@basic_conf = <<CONF
|
262
|
+
<source>
|
263
|
+
@type dummy
|
264
|
+
@id dummy
|
265
|
+
tag dummy
|
266
|
+
dummy {"message": "yay!"}
|
267
|
+
</source>
|
268
|
+
<match dummy>
|
269
|
+
@type null
|
270
|
+
@id blackhole
|
271
|
+
</match>
|
272
|
+
CONF
|
273
|
+
end
|
274
|
+
|
275
|
+
test 'by top level <match fluent.*> section' do
|
276
|
+
conf = @basic_conf + <<CONF
|
277
|
+
<match fluent.**>
|
278
|
+
@type stdout
|
279
|
+
</match>
|
280
|
+
CONF
|
281
|
+
conf_path = create_conf_file('logevent_1.conf', conf)
|
282
|
+
assert_log_matches(
|
283
|
+
create_cmdline(conf_path),
|
284
|
+
"fluentd worker is now running",
|
285
|
+
'fluent.info: {"worker":0,"message":"fluentd worker is now running worker=0"}',
|
286
|
+
patterns_not_match: ['[warn]: some tags for log events are not defined (to be ignored) tags=["fluent.trace", "fluent.debug"]'],
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
test 'by top level <match> section with warning for missing log levels (and warnings for each log event records)' do
|
291
|
+
conf = @basic_conf + <<CONF
|
292
|
+
<match fluent.warn fluent.error fluent.fatal>
|
293
|
+
@type stdout
|
294
|
+
</match>
|
295
|
+
CONF
|
296
|
+
conf_path = create_conf_file('logevent_2.conf', conf)
|
297
|
+
assert_log_matches(
|
298
|
+
create_cmdline(conf_path),
|
299
|
+
"fluentd worker is now running",
|
300
|
+
'[warn]: match for some tags of log events are not defined (to be ignored) tags=["fluent.trace", "fluent.debug", "fluent.info"]',
|
301
|
+
'[warn]: #0 no patterns matched tag="fluent.info"',
|
302
|
+
)
|
303
|
+
end
|
304
|
+
|
305
|
+
test 'by <label @FLUENT_LOG> section' do
|
306
|
+
conf = @basic_conf + <<CONF
|
307
|
+
<label @FLUENT_LOG>
|
308
|
+
<match **>
|
309
|
+
@type stdout
|
310
|
+
</match>
|
311
|
+
</label>
|
312
|
+
CONF
|
313
|
+
conf_path = create_conf_file('logevent_3.conf', conf)
|
314
|
+
assert_log_matches(
|
315
|
+
create_cmdline(conf_path),
|
316
|
+
"fluentd worker is now running",
|
317
|
+
'fluent.info: {"worker":0,"message":"fluentd worker is now running worker=0"}',
|
318
|
+
patterns_not_match: ['[warn]: some tags for log events are not defined (to be ignored)'],
|
319
|
+
)
|
320
|
+
end
|
321
|
+
|
322
|
+
test 'by <label> section with warning for missing log levels' do
|
323
|
+
conf = @basic_conf + <<CONF
|
324
|
+
<label @FLUENT_LOG>
|
325
|
+
<match fluent.{trace,debug}>
|
326
|
+
@type null
|
327
|
+
</match>
|
328
|
+
<match fluent.warn fluent.error>
|
329
|
+
@type stdout
|
330
|
+
</match>
|
331
|
+
</label>
|
332
|
+
CONF
|
333
|
+
conf_path = create_conf_file('logevent_4.conf', conf)
|
334
|
+
assert_log_matches(
|
335
|
+
create_cmdline(conf_path),
|
336
|
+
"fluentd worker is now running",
|
337
|
+
'[warn]: match for some tags of log events are not defined (to be ignored) tags=["fluent.info", "fluent.fatal"]',
|
338
|
+
patterns_not_match: ['[warn]: no patterns matched tag="fluent.info"'],
|
339
|
+
)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
sub_test_case 'configured to suppress configration dump' do
|
344
|
+
setup do
|
345
|
+
@basic_conf = <<CONF
|
346
|
+
<source>
|
347
|
+
@type dummy
|
348
|
+
@id dummy
|
349
|
+
@label @dummydata
|
350
|
+
tag dummy
|
351
|
+
dummy {"message": "yay!"}
|
352
|
+
</source>
|
353
|
+
<label @dummydata>
|
354
|
+
<match dummy>
|
355
|
+
@type null
|
356
|
+
@id blackhole
|
357
|
+
</match>
|
358
|
+
</label>
|
359
|
+
CONF
|
360
|
+
end
|
361
|
+
|
362
|
+
test 'configured by system config' do
|
363
|
+
conf = <<SYSTEM + @basic_conf
|
364
|
+
<system>
|
365
|
+
suppress_config_dump
|
366
|
+
</system>
|
367
|
+
SYSTEM
|
368
|
+
conf_path = create_conf_file('suppress_conf_dump_1.conf', conf)
|
369
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", patterns_not_match: ["tag dummy"])
|
370
|
+
end
|
371
|
+
|
372
|
+
test 'configured by command line option' do
|
373
|
+
conf_path = create_conf_file('suppress_conf_dump_2.conf', @basic_conf)
|
374
|
+
assert_log_matches(create_cmdline(conf_path, '--suppress-config-dump'), "fluentd worker is now running", patterns_not_match: ["tag dummy"])
|
375
|
+
end
|
376
|
+
|
377
|
+
test 'configured as false by system config, but overridden as true by command line option' do
|
378
|
+
conf = <<SYSTEM + @basic_conf
|
379
|
+
<system>
|
380
|
+
suppress_config_dump false
|
381
|
+
</system>
|
382
|
+
SYSTEM
|
383
|
+
conf_path = create_conf_file('suppress_conf_dump_3.conf', conf)
|
384
|
+
assert_log_matches(create_cmdline(conf_path, '--suppress-config-dump'), "fluentd worker is now running", patterns_not_match: ["tag dummy"])
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
sub_test_case 'configuration with wrong plugin type' do
|
389
|
+
test 'failed to start' do
|
390
|
+
conf = <<CONF
|
391
|
+
<source>
|
392
|
+
@type
|
393
|
+
@id dummy
|
394
|
+
@label @dummydata
|
395
|
+
tag dummy
|
396
|
+
dummy {"message": "yay!"}
|
397
|
+
</source>
|
398
|
+
<label @dummydata>
|
399
|
+
<match dummy>
|
400
|
+
@type null
|
401
|
+
@id blackhole
|
402
|
+
</match>
|
403
|
+
</label>
|
404
|
+
CONF
|
405
|
+
conf_path = create_conf_file('type_missing.conf', conf)
|
406
|
+
assert File.exist?(conf_path)
|
407
|
+
|
408
|
+
assert_fluentd_fails_to_start(
|
409
|
+
create_cmdline(conf_path),
|
410
|
+
"config error",
|
411
|
+
"error=\"Unknown input plugin ''. Run 'gem search -rd fluent-plugin' to find plugins",
|
412
|
+
)
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
sub_test_case 'configuration to load plugin file with syntax error' do
|
417
|
+
test 'failed to start' do
|
418
|
+
script = "require 'fluent/plugin/input'\n"
|
419
|
+
script << "module Fluent::Plugin\n"
|
420
|
+
script << " class BuggyInput < Input\n"
|
421
|
+
script << " Fluent::Plugin.register_input('buggy', self)\n"
|
422
|
+
script << " end\n"
|
423
|
+
plugin_path = create_plugin_file('in_buggy.rb', script)
|
424
|
+
|
425
|
+
conf = <<CONF
|
426
|
+
<source>
|
427
|
+
@type buggy
|
428
|
+
@id dummy
|
429
|
+
@label @dummydata
|
430
|
+
tag dummy
|
431
|
+
dummy {"message": "yay!"}
|
432
|
+
</source>
|
433
|
+
<label @dummydata>
|
434
|
+
<match dummy>
|
435
|
+
@type null
|
436
|
+
@id blackhole
|
437
|
+
</match>
|
438
|
+
</label>
|
439
|
+
CONF
|
440
|
+
conf_path = create_conf_file('buggy_plugin.conf', conf)
|
441
|
+
assert File.exist?(conf_path)
|
442
|
+
|
443
|
+
assert_fluentd_fails_to_start(
|
444
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
445
|
+
"error_class=SyntaxError",
|
446
|
+
"in_buggy.rb:5: syntax error, unexpected end-of-input, expecting keyword_end",
|
447
|
+
)
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
sub_test_case 'configuration to load plugin which raises unrecoverable error in #start' do
|
452
|
+
test 'failed to start' do
|
453
|
+
script = "require 'fluent/plugin/input'\n"
|
454
|
+
script << "require 'fluent/error'\n"
|
455
|
+
script << "module Fluent::Plugin\n"
|
456
|
+
script << " class CrashingInput < Input\n"
|
457
|
+
script << " Fluent::Plugin.register_input('crashing', self)\n"
|
458
|
+
script << " def start\n"
|
459
|
+
script << " raise Fluent::UnrecoverableError"
|
460
|
+
script << " end\n"
|
461
|
+
script << " end\n"
|
462
|
+
script << "end\n"
|
463
|
+
plugin_path = create_plugin_file('in_crashing.rb', script)
|
464
|
+
|
465
|
+
conf = <<CONF
|
466
|
+
<source>
|
467
|
+
@type crashing
|
468
|
+
@id dummy
|
469
|
+
@label @dummydata
|
470
|
+
tag dummy
|
471
|
+
dummy {"message": "yay!"}
|
472
|
+
</source>
|
473
|
+
<label @dummydata>
|
474
|
+
<match dummy>
|
475
|
+
@type null
|
476
|
+
@id blackhole
|
477
|
+
</match>
|
478
|
+
</label>
|
479
|
+
CONF
|
480
|
+
conf_path = create_conf_file('crashing_plugin.conf', conf)
|
481
|
+
assert File.exist?(conf_path)
|
482
|
+
|
483
|
+
assert_fluentd_fails_to_start(
|
484
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
485
|
+
'unexpected error error_class=Fluent::UnrecoverableError error="an unrecoverable error occurs in Fluentd process"',
|
486
|
+
)
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
sub_test_case 'configured to run 2 workers' do
|
491
|
+
setup do
|
492
|
+
@root_path = File.join(TMP_DIR, "rootpath")
|
493
|
+
FileUtils.rm_rf(@root_path)
|
494
|
+
FileUtils.mkdir_p(@root_path)
|
495
|
+
end
|
496
|
+
|
497
|
+
test 'success to start the number of workers specified in configuration' do
|
498
|
+
conf = <<CONF
|
499
|
+
<system>
|
500
|
+
workers 2
|
501
|
+
root_dir #{@root_path}
|
502
|
+
</system>
|
503
|
+
<source>
|
504
|
+
@type dummy
|
505
|
+
@id dummy
|
506
|
+
@label @dummydata
|
507
|
+
tag dummy
|
508
|
+
dummy {"message": "yay!"}
|
509
|
+
</source>
|
510
|
+
<label @dummydata>
|
511
|
+
<match dummy>
|
512
|
+
@type null
|
513
|
+
@id blackhole
|
514
|
+
</match>
|
515
|
+
</label>
|
516
|
+
CONF
|
517
|
+
conf_path = create_conf_file('workers1.conf', conf)
|
518
|
+
assert Dir.exist?(@root_path)
|
519
|
+
|
520
|
+
assert_log_matches(
|
521
|
+
create_cmdline(conf_path),
|
522
|
+
"#0 fluentd worker is now running worker=0",
|
523
|
+
"#1 fluentd worker is now running worker=1"
|
524
|
+
)
|
525
|
+
end
|
526
|
+
|
527
|
+
test 'success to start the number of workers specified by command line option' do
|
528
|
+
conf = <<CONF
|
529
|
+
<system>
|
530
|
+
root_dir #{@root_path}
|
531
|
+
</system>
|
532
|
+
<source>
|
533
|
+
@type dummy
|
534
|
+
@id dummy
|
535
|
+
@label @dummydata
|
536
|
+
tag dummy
|
537
|
+
dummy {"message": "yay!"}
|
538
|
+
</source>
|
539
|
+
<label @dummydata>
|
540
|
+
<match dummy>
|
541
|
+
@type null
|
542
|
+
@id blackhole
|
543
|
+
</match>
|
544
|
+
</label>
|
545
|
+
CONF
|
546
|
+
conf_path = create_conf_file('workers2.conf', conf)
|
547
|
+
assert_log_matches(
|
548
|
+
create_cmdline(conf_path, '--workers', '2'),
|
549
|
+
"#0 fluentd worker is now running worker=0",
|
550
|
+
"#1 fluentd worker is now running worker=1"
|
551
|
+
)
|
552
|
+
end
|
553
|
+
|
554
|
+
test 'failed to start workers when configured plugins do not support multi worker configuration' do
|
555
|
+
script = "require 'fluent/plugin/input'\n"
|
556
|
+
script << "module Fluent::Plugin\n"
|
557
|
+
script << " class SingleInput < Input\n"
|
558
|
+
script << " Fluent::Plugin.register_input('single', self)\n"
|
559
|
+
script << " def multi_workers_ready?\n"
|
560
|
+
script << " false\n"
|
561
|
+
script << " end\n"
|
562
|
+
script << " end\n"
|
563
|
+
script << "end\n"
|
564
|
+
plugin_path = create_plugin_file('in_single.rb', script)
|
565
|
+
|
566
|
+
conf = <<CONF
|
567
|
+
<system>
|
568
|
+
workers 2
|
569
|
+
</system>
|
570
|
+
<source>
|
571
|
+
@type single
|
572
|
+
@id single
|
573
|
+
@label @dummydata
|
574
|
+
</source>
|
575
|
+
<label @dummydata>
|
576
|
+
<match dummy>
|
577
|
+
@type null
|
578
|
+
@id blackhole
|
579
|
+
</match>
|
580
|
+
</label>
|
581
|
+
CONF
|
582
|
+
conf_path = create_conf_file('workers_invalid1.conf', conf)
|
583
|
+
assert_fluentd_fails_to_start(
|
584
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
585
|
+
"Plugin 'single' does not support multi workers configuration (Fluent::Plugin::SingleInput)",
|
586
|
+
)
|
587
|
+
end
|
588
|
+
|
589
|
+
test 'failed to start workers when file buffer is configured in non-workers way' do
|
590
|
+
conf = <<CONF
|
591
|
+
<system>
|
592
|
+
workers 2
|
593
|
+
</system>
|
594
|
+
<source>
|
595
|
+
@type single
|
596
|
+
@id single
|
597
|
+
@label @dummydata
|
598
|
+
</source>
|
599
|
+
<label @dummydata>
|
600
|
+
<match dummy>
|
601
|
+
@type null
|
602
|
+
@id blackhole
|
603
|
+
<buffer>
|
604
|
+
@type file
|
605
|
+
path #{File.join(@root_path, "buf", "file.*.log")}
|
606
|
+
</buffer>
|
607
|
+
</match>
|
608
|
+
</label>
|
609
|
+
CONF
|
610
|
+
conf_path = create_conf_file('workers_invalid2.conf', conf)
|
611
|
+
assert_fluentd_fails_to_start(
|
612
|
+
create_cmdline(conf_path),
|
613
|
+
"[blackhole] file buffer with multi workers should be configured to use directory 'path', or system root_dir and plugin id",
|
614
|
+
"config error file=\"#{conf_path}\" error_class=Fluent::ConfigError error=\"Plugin 'file' does not support multi workers configuration (Fluent::Plugin::FileBuffer)\"",
|
615
|
+
)
|
616
|
+
end
|
617
|
+
end
|
618
|
+
end
|