fluentd 1.14.4-x64-mingw-ucrt
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/.deepsource.toml +13 -0
- data/.drone.yml +35 -0
- data/.github/ISSUE_TEMPLATE/bug_report.yaml +70 -0
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yaml +38 -0
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- data/.github/workflows/issue-auto-closer.yml +12 -0
- data/.github/workflows/linux-test.yaml +36 -0
- data/.github/workflows/macos-test.yaml +30 -0
- data/.github/workflows/stale-actions.yml +22 -0
- data/.github/workflows/windows-test.yaml +46 -0
- data/.gitignore +30 -0
- data/.gitlab-ci.yml +103 -0
- data/ADOPTERS.md +5 -0
- data/AUTHORS +2 -0
- data/CHANGELOG.md +2409 -0
- data/CONTRIBUTING.md +45 -0
- data/GOVERNANCE.md +55 -0
- data/Gemfile +9 -0
- data/GithubWorkflow.md +78 -0
- data/LICENSE +202 -0
- data/MAINTAINERS.md +11 -0
- data/README.md +97 -0
- data/Rakefile +79 -0
- data/SECURITY.md +18 -0
- data/bin/fluent-binlog-reader +7 -0
- data/bin/fluent-ca-generate +6 -0
- data/bin/fluent-cap-ctl +7 -0
- data/bin/fluent-cat +5 -0
- data/bin/fluent-ctl +7 -0
- data/bin/fluent-debug +5 -0
- data/bin/fluent-gem +9 -0
- data/bin/fluent-plugin-config-format +5 -0
- data/bin/fluent-plugin-generate +5 -0
- data/bin/fluentd +15 -0
- data/code-of-conduct.md +3 -0
- data/docs/SECURITY_AUDIT.pdf +0 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/counter.conf +18 -0
- data/example/filter_stdout.conf +22 -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 +16 -0
- data/example/in_out_forward.conf +17 -0
- data/example/in_sample_blocks.conf +17 -0
- data/example/in_sample_with_compression.conf +23 -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_sd.conf +17 -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/sd.yaml +8 -0
- data/example/secondary_file.conf +42 -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/example/worker_section.conf +36 -0
- data/fluent.conf +139 -0
- data/fluentd.gemspec +55 -0
- data/lib/fluent/agent.rb +168 -0
- data/lib/fluent/capability.rb +87 -0
- data/lib/fluent/clock.rb +66 -0
- data/lib/fluent/command/binlog_reader.rb +244 -0
- data/lib/fluent/command/bundler_injection.rb +45 -0
- data/lib/fluent/command/ca_generate.rb +184 -0
- data/lib/fluent/command/cap_ctl.rb +174 -0
- data/lib/fluent/command/cat.rb +365 -0
- data/lib/fluent/command/ctl.rb +177 -0
- data/lib/fluent/command/debug.rb +103 -0
- data/lib/fluent/command/fluentd.rb +374 -0
- data/lib/fluent/command/plugin_config_formatter.rb +308 -0
- data/lib/fluent/command/plugin_generator.rb +365 -0
- data/lib/fluent/compat/call_super_mixin.rb +76 -0
- data/lib/fluent/compat/detach_process_mixin.rb +33 -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 +721 -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/basic_parser.rb +123 -0
- data/lib/fluent/config/configure_proxy.rb +424 -0
- data/lib/fluent/config/dsl.rb +152 -0
- data/lib/fluent/config/element.rb +265 -0
- data/lib/fluent/config/error.rb +32 -0
- data/lib/fluent/config/literal_parser.rb +286 -0
- data/lib/fluent/config/parser.rb +107 -0
- data/lib/fluent/config/section.rb +272 -0
- data/lib/fluent/config/types.rb +249 -0
- data/lib/fluent/config/v1_parser.rb +192 -0
- data/lib/fluent/config.rb +76 -0
- data/lib/fluent/configurable.rb +201 -0
- data/lib/fluent/counter/base_socket.rb +44 -0
- data/lib/fluent/counter/client.rb +297 -0
- data/lib/fluent/counter/error.rb +86 -0
- data/lib/fluent/counter/mutex_hash.rb +163 -0
- data/lib/fluent/counter/server.rb +273 -0
- data/lib/fluent/counter/store.rb +205 -0
- data/lib/fluent/counter/validator.rb +145 -0
- data/lib/fluent/counter.rb +23 -0
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/daemonizer.rb +88 -0
- data/lib/fluent/engine.rb +253 -0
- data/lib/fluent/env.rb +40 -0
- data/lib/fluent/error.rb +34 -0
- data/lib/fluent/event.rb +326 -0
- data/lib/fluent/event_router.rb +297 -0
- data/lib/fluent/ext_monitor_require.rb +28 -0
- data/lib/fluent/filter.rb +21 -0
- data/lib/fluent/fluent_log_event_router.rb +141 -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 +34 -0
- data/lib/fluent/log.rb +713 -0
- data/lib/fluent/match.rb +187 -0
- data/lib/fluent/mixin.rb +31 -0
- data/lib/fluent/msgpack_factory.rb +106 -0
- data/lib/fluent/oj_options.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/bare_output.rb +104 -0
- data/lib/fluent/plugin/base.rb +197 -0
- data/lib/fluent/plugin/buf_file.rb +213 -0
- data/lib/fluent/plugin/buf_file_single.rb +225 -0
- data/lib/fluent/plugin/buf_memory.rb +34 -0
- data/lib/fluent/plugin/buffer/chunk.rb +240 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +413 -0
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +311 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +91 -0
- data/lib/fluent/plugin/buffer.rb +918 -0
- data/lib/fluent/plugin/compressable.rb +96 -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 +187 -0
- data/lib/fluent/plugin/filter.rb +127 -0
- data/lib/fluent/plugin/filter_grep.rb +189 -0
- data/lib/fluent/plugin/filter_parser.rb +130 -0
- data/lib/fluent/plugin/filter_record_transformer.rb +324 -0
- data/lib/fluent/plugin/filter_stdout.rb +53 -0
- data/lib/fluent/plugin/formatter.rb +75 -0
- data/lib/fluent/plugin/formatter_csv.rb +78 -0
- data/lib/fluent/plugin/formatter_hash.rb +35 -0
- data/lib/fluent/plugin/formatter_json.rb +59 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +44 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +33 -0
- data/lib/fluent/plugin/formatter_out_file.rb +53 -0
- data/lib/fluent/plugin/formatter_single_value.rb +36 -0
- data/lib/fluent/plugin/formatter_stdout.rb +76 -0
- data/lib/fluent/plugin/formatter_tsv.rb +40 -0
- data/lib/fluent/plugin/in_debug_agent.rb +71 -0
- data/lib/fluent/plugin/in_dummy.rb +18 -0
- data/lib/fluent/plugin/in_exec.rb +110 -0
- data/lib/fluent/plugin/in_forward.rb +473 -0
- data/lib/fluent/plugin/in_gc_stat.rb +72 -0
- data/lib/fluent/plugin/in_http.rb +667 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +412 -0
- data/lib/fluent/plugin/in_object_space.rb +93 -0
- data/lib/fluent/plugin/in_sample.rb +141 -0
- data/lib/fluent/plugin/in_syslog.rb +276 -0
- data/lib/fluent/plugin/in_tail/position_file.rb +269 -0
- data/lib/fluent/plugin/in_tail.rb +1228 -0
- data/lib/fluent/plugin/in_tcp.rb +181 -0
- data/lib/fluent/plugin/in_udp.rb +92 -0
- data/lib/fluent/plugin/in_unix.rb +195 -0
- data/lib/fluent/plugin/input.rb +75 -0
- data/lib/fluent/plugin/metrics.rb +119 -0
- data/lib/fluent/plugin/metrics_local.rb +96 -0
- data/lib/fluent/plugin/multi_output.rb +195 -0
- data/lib/fluent/plugin/out_copy.rb +120 -0
- data/lib/fluent/plugin/out_exec.rb +105 -0
- data/lib/fluent/plugin/out_exec_filter.rb +319 -0
- data/lib/fluent/plugin/out_file.rb +334 -0
- data/lib/fluent/plugin/out_forward/ack_handler.rb +161 -0
- data/lib/fluent/plugin/out_forward/connection_manager.rb +113 -0
- data/lib/fluent/plugin/out_forward/error.rb +28 -0
- data/lib/fluent/plugin/out_forward/failure_detector.rb +84 -0
- data/lib/fluent/plugin/out_forward/handshake_protocol.rb +125 -0
- data/lib/fluent/plugin/out_forward/load_balancer.rb +114 -0
- data/lib/fluent/plugin/out_forward/socket_cache.rb +140 -0
- data/lib/fluent/plugin/out_forward.rb +826 -0
- data/lib/fluent/plugin/out_http.rb +275 -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 +131 -0
- data/lib/fluent/plugin/out_stdout.rb +74 -0
- data/lib/fluent/plugin/out_stream.rb +130 -0
- data/lib/fluent/plugin/output.rb +1556 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +275 -0
- data/lib/fluent/plugin/parser_apache.rb +28 -0
- data/lib/fluent/plugin/parser_apache2.rb +88 -0
- data/lib/fluent/plugin/parser_apache_error.rb +26 -0
- data/lib/fluent/plugin/parser_csv.rb +114 -0
- data/lib/fluent/plugin/parser_json.rb +96 -0
- data/lib/fluent/plugin/parser_ltsv.rb +51 -0
- data/lib/fluent/plugin/parser_msgpack.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +152 -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 +68 -0
- data/lib/fluent/plugin/parser_syslog.rb +496 -0
- data/lib/fluent/plugin/parser_tsv.rb +42 -0
- data/lib/fluent/plugin/sd_file.rb +156 -0
- data/lib/fluent/plugin/sd_srv.rb +135 -0
- data/lib/fluent/plugin/sd_static.rb +58 -0
- data/lib/fluent/plugin/service_discovery.rb +65 -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 +162 -0
- data/lib/fluent/plugin/string_util.rb +22 -0
- data/lib/fluent/plugin.rb +206 -0
- data/lib/fluent/plugin_helper/cert_option.rb +191 -0
- data/lib/fluent/plugin_helper/child_process.rb +366 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +343 -0
- data/lib/fluent/plugin_helper/counter.rb +51 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +100 -0
- data/lib/fluent/plugin_helper/event_loop.rb +170 -0
- data/lib/fluent/plugin_helper/extract.rb +104 -0
- data/lib/fluent/plugin_helper/formatter.rb +147 -0
- data/lib/fluent/plugin_helper/http_server/app.rb +79 -0
- data/lib/fluent/plugin_helper/http_server/compat/server.rb +92 -0
- data/lib/fluent/plugin_helper/http_server/compat/ssl_context_extractor.rb +52 -0
- data/lib/fluent/plugin_helper/http_server/compat/webrick_handler.rb +58 -0
- data/lib/fluent/plugin_helper/http_server/methods.rb +35 -0
- data/lib/fluent/plugin_helper/http_server/request.rb +42 -0
- data/lib/fluent/plugin_helper/http_server/router.rb +54 -0
- data/lib/fluent/plugin_helper/http_server/server.rb +93 -0
- data/lib/fluent/plugin_helper/http_server/ssl_context_builder.rb +41 -0
- data/lib/fluent/plugin_helper/http_server.rb +135 -0
- data/lib/fluent/plugin_helper/inject.rb +154 -0
- data/lib/fluent/plugin_helper/metrics.rb +129 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/record_accessor.rb +207 -0
- data/lib/fluent/plugin_helper/retry_state.rb +209 -0
- data/lib/fluent/plugin_helper/server.rb +801 -0
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +146 -0
- data/lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb +43 -0
- data/lib/fluent/plugin_helper/service_discovery.rb +125 -0
- data/lib/fluent/plugin_helper/socket.rb +277 -0
- data/lib/fluent/plugin_helper/socket_option.rb +98 -0
- data/lib/fluent/plugin_helper/storage.rb +349 -0
- data/lib/fluent/plugin_helper/thread.rb +180 -0
- data/lib/fluent/plugin_helper/timer.rb +92 -0
- data/lib/fluent/plugin_helper.rb +75 -0
- data/lib/fluent/plugin_id.rb +93 -0
- data/lib/fluent/process.rb +22 -0
- data/lib/fluent/registry.rb +116 -0
- data/lib/fluent/root_agent.rb +372 -0
- data/lib/fluent/rpc.rb +94 -0
- data/lib/fluent/static_config_analysis.rb +194 -0
- data/lib/fluent/supervisor.rb +1054 -0
- data/lib/fluent/system_config.rb +187 -0
- data/lib/fluent/test/base.rb +78 -0
- data/lib/fluent/test/driver/base.rb +225 -0
- data/lib/fluent/test/driver/base_owned.rb +83 -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/storage.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/test.rb +58 -0
- data/lib/fluent/time.rb +512 -0
- data/lib/fluent/timezone.rb +171 -0
- data/lib/fluent/tls.rb +81 -0
- data/lib/fluent/unique_id.rb +39 -0
- data/lib/fluent/variable_store.rb +40 -0
- data/lib/fluent/version.rb +21 -0
- data/lib/fluent/winsvc.rb +103 -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/lib/fluent/plugin/storage.rb.erb +40 -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/new_gem/test/plugin/test_storage.rb.erb +18 -0
- data/templates/plugin_config_formatter/param.md-compact.erb +25 -0
- data/templates/plugin_config_formatter/param.md-table.erb +10 -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 +362 -0
- data/test/command/test_ca_generate.rb +70 -0
- data/test/command/test_cap_ctl.rb +100 -0
- data/test/command/test_cat.rb +128 -0
- data/test/command/test_ctl.rb +57 -0
- data/test/command/test_fluentd.rb +1106 -0
- data/test/command/test_plugin_config_formatter.rb +398 -0
- data/test/command/test_plugin_generator.rb +109 -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 +551 -0
- data/test/config/test_configurable.rb +1784 -0
- data/test/config/test_configure_proxy.rb +604 -0
- data/test/config/test_dsl.rb +415 -0
- data/test/config/test_element.rb +518 -0
- data/test/config/test_literal_parser.rb +309 -0
- data/test/config/test_plugin_configuration.rb +56 -0
- data/test/config/test_section.rb +191 -0
- data/test/config/test_system_config.rb +199 -0
- data/test/config/test_types.rb +408 -0
- data/test/counter/test_client.rb +563 -0
- data/test/counter/test_error.rb +44 -0
- data/test/counter/test_mutex_hash.rb +179 -0
- data/test/counter/test_server.rb +589 -0
- data/test/counter/test_store.rb +258 -0
- data/test/counter/test_validator.rb +137 -0
- data/test/helper.rb +155 -0
- data/test/helpers/fuzzy_assert.rb +89 -0
- data/test/helpers/process_extenstion.rb +33 -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/data/sd_file/config +11 -0
- data/test/plugin/data/sd_file/config.json +17 -0
- data/test/plugin/data/sd_file/config.yaml +11 -0
- data/test/plugin/data/sd_file/config.yml +11 -0
- data/test/plugin/data/sd_file/invalid_config.yml +7 -0
- data/test/plugin/in_tail/test_fifo.rb +121 -0
- data/test/plugin/in_tail/test_io_handler.rb +140 -0
- data/test/plugin/in_tail/test_position_file.rb +379 -0
- data/test/plugin/out_forward/test_ack_handler.rb +101 -0
- data/test/plugin/out_forward/test_connection_manager.rb +145 -0
- data/test/plugin/out_forward/test_handshake_protocol.rb +112 -0
- data/test/plugin/out_forward/test_load_balancer.rb +106 -0
- data/test/plugin/out_forward/test_socket_cache.rb +149 -0
- data/test/plugin/test_bare_output.rb +131 -0
- data/test/plugin/test_base.rb +115 -0
- data/test/plugin/test_buf_file.rb +1275 -0
- data/test/plugin/test_buf_file_single.rb +833 -0
- data/test/plugin/test_buf_memory.rb +42 -0
- data/test/plugin/test_buffer.rb +1383 -0
- data/test/plugin/test_buffer_chunk.rb +198 -0
- data/test/plugin/test_buffer_file_chunk.rb +871 -0
- data/test/plugin/test_buffer_file_single_chunk.rb +611 -0
- data/test/plugin/test_buffer_memory_chunk.rb +339 -0
- data/test/plugin/test_compressable.rb +87 -0
- data/test/plugin/test_file_util.rb +96 -0
- data/test/plugin/test_file_wrapper.rb +126 -0
- data/test/plugin/test_filter.rb +368 -0
- data/test/plugin/test_filter_grep.rb +697 -0
- data/test/plugin/test_filter_parser.rb +731 -0
- data/test/plugin/test_filter_record_transformer.rb +577 -0
- data/test/plugin/test_filter_stdout.rb +207 -0
- data/test/plugin/test_formatter_csv.rb +136 -0
- data/test/plugin/test_formatter_hash.rb +38 -0
- data/test/plugin/test_formatter_json.rb +61 -0
- data/test/plugin/test_formatter_ltsv.rb +70 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +116 -0
- data/test/plugin/test_formatter_single_value.rb +44 -0
- data/test/plugin/test_formatter_tsv.rb +76 -0
- data/test/plugin/test_in_debug_agent.rb +49 -0
- data/test/plugin/test_in_exec.rb +261 -0
- data/test/plugin/test_in_forward.rb +1180 -0
- data/test/plugin/test_in_gc_stat.rb +62 -0
- data/test/plugin/test_in_http.rb +1080 -0
- data/test/plugin/test_in_monitor_agent.rb +923 -0
- data/test/plugin/test_in_object_space.rb +60 -0
- data/test/plugin/test_in_sample.rb +190 -0
- data/test/plugin/test_in_syslog.rb +505 -0
- data/test/plugin/test_in_tail.rb +2363 -0
- data/test/plugin/test_in_tcp.rb +243 -0
- data/test/plugin/test_in_udp.rb +268 -0
- data/test/plugin/test_in_unix.rb +181 -0
- data/test/plugin/test_input.rb +137 -0
- data/test/plugin/test_metadata.rb +89 -0
- data/test/plugin/test_metrics.rb +294 -0
- data/test/plugin/test_metrics_local.rb +96 -0
- data/test/plugin/test_multi_output.rb +204 -0
- data/test/plugin/test_out_copy.rb +308 -0
- data/test/plugin/test_out_exec.rb +312 -0
- data/test/plugin/test_out_exec_filter.rb +606 -0
- data/test/plugin/test_out_file.rb +1037 -0
- data/test/plugin/test_out_forward.rb +1348 -0
- data/test/plugin/test_out_http.rb +428 -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 +458 -0
- data/test/plugin/test_out_stdout.rb +205 -0
- data/test/plugin/test_out_stream.rb +103 -0
- data/test/plugin/test_output.rb +1065 -0
- data/test/plugin/test_output_as_buffered.rb +2024 -0
- data/test/plugin/test_output_as_buffered_backup.rb +363 -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 +919 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +882 -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 +399 -0
- data/test/plugin/test_parser_apache.rb +42 -0
- data/test/plugin/test_parser_apache2.rb +47 -0
- data/test/plugin/test_parser_apache_error.rb +45 -0
- data/test/plugin/test_parser_csv.rb +200 -0
- data/test/plugin/test_parser_json.rb +138 -0
- data/test/plugin/test_parser_labeled_tsv.rb +160 -0
- data/test/plugin/test_parser_multiline.rb +111 -0
- data/test/plugin/test_parser_nginx.rb +88 -0
- data/test/plugin/test_parser_none.rb +52 -0
- data/test/plugin/test_parser_regexp.rb +289 -0
- data/test/plugin/test_parser_syslog.rb +650 -0
- data/test/plugin/test_parser_tsv.rb +122 -0
- data/test/plugin/test_sd_file.rb +228 -0
- data/test/plugin/test_sd_srv.rb +230 -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/data/cert/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert-with-CRLF.pem +19 -0
- data/test/plugin_helper/data/cert/cert-with-no-newline.pem +19 -0
- data/test/plugin_helper/data/cert/cert.pem +19 -0
- data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +20 -0
- data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert_chains/cert.pem +40 -0
- data/test/plugin_helper/data/cert/empty.pem +0 -0
- data/test/plugin_helper/data/cert/generate_cert.rb +125 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +30 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +20 -0
- data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +20 -0
- data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +30 -0
- data/test/plugin_helper/data/cert/with_ca/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +21 -0
- data/test/plugin_helper/data/cert/with_ca/cert.pem +21 -0
- data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +30 -0
- data/test/plugin_helper/data/cert/without_ca/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +20 -0
- data/test/plugin_helper/data/cert/without_ca/cert.pem +20 -0
- data/test/plugin_helper/http_server/test_app.rb +65 -0
- data/test/plugin_helper/http_server/test_route.rb +32 -0
- data/test/plugin_helper/service_discovery/test_manager.rb +93 -0
- data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +21 -0
- data/test/plugin_helper/test_cert_option.rb +25 -0
- data/test/plugin_helper/test_child_process.rb +840 -0
- data/test/plugin_helper/test_compat_parameters.rb +358 -0
- data/test/plugin_helper/test_event_emitter.rb +80 -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_http_server_helper.rb +372 -0
- data/test/plugin_helper/test_inject.rb +561 -0
- data/test/plugin_helper/test_metrics.rb +137 -0
- data/test/plugin_helper/test_parser.rb +264 -0
- data/test/plugin_helper/test_record_accessor.rb +238 -0
- data/test/plugin_helper/test_retry_state.rb +442 -0
- data/test/plugin_helper/test_server.rb +1823 -0
- data/test/plugin_helper/test_service_discovery.rb +165 -0
- data/test/plugin_helper/test_socket.rb +146 -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 +130 -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_capability.rb +74 -0
- data/test/test_clock.rb +164 -0
- data/test/test_config.rb +202 -0
- data/test/test_configdsl.rb +148 -0
- data/test/test_daemonizer.rb +91 -0
- data/test/test_engine.rb +203 -0
- data/test/test_event.rb +531 -0
- data/test/test_event_router.rb +331 -0
- data/test/test_event_time.rb +199 -0
- data/test/test_filter.rb +121 -0
- data/test/test_fluent_log_event_router.rb +99 -0
- data/test/test_formatter.rb +366 -0
- data/test/test_input.rb +31 -0
- data/test/test_log.rb +994 -0
- data/test/test_logger_initializer.rb +46 -0
- data/test/test_match.rb +148 -0
- data/test/test_mixin.rb +351 -0
- data/test/test_msgpack_factory.rb +18 -0
- data/test/test_oj_options.rb +55 -0
- data/test/test_output.rb +278 -0
- data/test/test_plugin.rb +251 -0
- data/test/test_plugin_classes.rb +370 -0
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_plugin_id.rb +119 -0
- data/test/test_process.rb +14 -0
- data/test/test_root_agent.rb +951 -0
- data/test/test_static_config_analysis.rb +177 -0
- data/test/test_supervisor.rb +601 -0
- data/test/test_test_drivers.rb +136 -0
- data/test/test_time_formatter.rb +301 -0
- data/test/test_time_parser.rb +362 -0
- data/test/test_tls.rb +65 -0
- data/test/test_unique_id.rb +47 -0
- data/test/test_variable_store.rb +65 -0
- metadata +1261 -0
@@ -0,0 +1,1106 @@
|
|
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
|
+
ENV["TEST_RUBY_PATH"] = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def process_exist?(pid)
|
23
|
+
begin
|
24
|
+
r = Process.waitpid(pid, Process::WNOHANG)
|
25
|
+
return true if r.nil?
|
26
|
+
false
|
27
|
+
rescue SystemCallError
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_conf_file(name, content, ext_enc = 'utf-8')
|
33
|
+
conf_path = File.join(TMP_DIR, name)
|
34
|
+
File.open(conf_path, "w:#{ext_enc}:utf-8") do |file|
|
35
|
+
file.write content
|
36
|
+
end
|
37
|
+
conf_path
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_plugin_file(name, content)
|
41
|
+
file_path = File.join(TMP_DIR, 'plugin', name)
|
42
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
43
|
+
File.open(file_path, 'w') do |file|
|
44
|
+
file.write content
|
45
|
+
end
|
46
|
+
file_path
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_cmdline(conf_path, *fluentd_options)
|
50
|
+
if Fluent.windows?
|
51
|
+
cmd_path = File.expand_path(File.dirname(__FILE__) + "../../../bin/fluentd")
|
52
|
+
["bundle", "exec", ServerEngine.ruby_bin_path, cmd_path, "-c", conf_path, *fluentd_options]
|
53
|
+
else
|
54
|
+
cmd_path = File.expand_path(File.dirname(__FILE__) + "../../../bin/fluentd")
|
55
|
+
["bundle", "exec", cmd_path, "-c", conf_path, *fluentd_options]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def execute_command(cmdline, chdir=TMP_DIR, env = {})
|
60
|
+
null_stream = File.open(File::NULL, 'w')
|
61
|
+
gemfile_path = File.expand_path(File.dirname(__FILE__) + "../../../Gemfile")
|
62
|
+
|
63
|
+
env = { "BUNDLE_GEMFILE" => gemfile_path }.merge(env)
|
64
|
+
cmdname = cmdline.shift
|
65
|
+
arg0 = "testing-fluentd"
|
66
|
+
# p(here: "executing process", env: env, cmdname: cmdname, arg0: arg0, args: cmdline)
|
67
|
+
IO.popen(env, [[cmdname, arg0], *cmdline], chdir: chdir, err: [:child, :out]) do |io|
|
68
|
+
pid = io.pid
|
69
|
+
begin
|
70
|
+
yield pid, io
|
71
|
+
# p(here: "execute command", pid: pid, worker_pids: @worker_pids)
|
72
|
+
ensure
|
73
|
+
Process.kill(:KILL, pid) rescue nil
|
74
|
+
if @supervisor_pid
|
75
|
+
Process.kill(:KILL, @supervisor_pid) rescue nil
|
76
|
+
end
|
77
|
+
@worker_pids.each do |cpid|
|
78
|
+
Process.kill(:KILL, cpid) rescue nil
|
79
|
+
end
|
80
|
+
# p(here: "execute command", pid: pid, exist: process_exist?(pid), worker_pids: @worker_pids, exists: @worker_pids.map{|i| process_exist?(i) })
|
81
|
+
Timeout.timeout(10){ sleep 0.1 while process_exist?(pid) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
ensure
|
85
|
+
null_stream.close rescue nil
|
86
|
+
end
|
87
|
+
|
88
|
+
def eager_read(io)
|
89
|
+
buf = +''
|
90
|
+
|
91
|
+
loop do
|
92
|
+
b = io.read_nonblock(1024, nil, exception: false)
|
93
|
+
if b == :wait_readable || b.nil?
|
94
|
+
return buf
|
95
|
+
end
|
96
|
+
buf << b
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 10, env: {})
|
101
|
+
matched = false
|
102
|
+
matched_wrongly = false
|
103
|
+
assert_error_msg = ""
|
104
|
+
stdio_buf = ""
|
105
|
+
begin
|
106
|
+
execute_command(cmdline, TMP_DIR, env) do |pid, stdout|
|
107
|
+
begin
|
108
|
+
waiting(timeout) do
|
109
|
+
while process_exist?(pid) && !matched
|
110
|
+
readables, _, _ = IO.select([stdout], nil, nil, 1)
|
111
|
+
next unless readables
|
112
|
+
break if readables.first.eof?
|
113
|
+
|
114
|
+
buf = eager_read(readables.first)
|
115
|
+
# puts buf
|
116
|
+
stdio_buf << buf
|
117
|
+
lines = stdio_buf.split("\n")
|
118
|
+
if pattern_list.all?{|ptn| lines.any?{|line| ptn.is_a?(Regexp) ? ptn.match(line) : line.include?(ptn) } }
|
119
|
+
matched = true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
ensure
|
124
|
+
if SUPERVISOR_PID_PATTERN =~ stdio_buf
|
125
|
+
@supervisor_pid = $1.to_i
|
126
|
+
end
|
127
|
+
stdio_buf.scan(WORKER_PID_PATTERN) do |worker_pid|
|
128
|
+
@worker_pids << worker_pid.first.to_i
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
rescue Timeout::Error
|
133
|
+
assert_error_msg = "execution timeout"
|
134
|
+
rescue => e
|
135
|
+
assert_error_msg = "unexpected error in launching fluentd: #{e.inspect}"
|
136
|
+
else
|
137
|
+
assert_error_msg = "log doesn't match" unless matched
|
138
|
+
end
|
139
|
+
|
140
|
+
if patterns_not_match.empty?
|
141
|
+
assert_error_msg = build_message(assert_error_msg,
|
142
|
+
"<?>\nwas expected to include:\n<?>",
|
143
|
+
stdio_buf, pattern_list)
|
144
|
+
else
|
145
|
+
lines = stdio_buf.split("\n")
|
146
|
+
patterns_not_match.each do |ptn|
|
147
|
+
matched_wrongly = if ptn.is_a? Regexp
|
148
|
+
lines.any?{|line| ptn.match(line) }
|
149
|
+
else
|
150
|
+
lines.any?{|line| line.include?(ptn) }
|
151
|
+
end
|
152
|
+
if matched_wrongly
|
153
|
+
assert_error_msg << "\n" unless assert_error_msg.empty?
|
154
|
+
assert_error_msg << "pattern exists in logs wrongly: #{ptn}"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
assert_error_msg = build_message(assert_error_msg,
|
158
|
+
"<?>\nwas expected to include:\n<?>\nand not include:\n<?>",
|
159
|
+
stdio_buf, pattern_list, patterns_not_match)
|
160
|
+
end
|
161
|
+
|
162
|
+
assert matched && !matched_wrongly, assert_error_msg
|
163
|
+
end
|
164
|
+
|
165
|
+
def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 10)
|
166
|
+
# empty_list.all?{ ... } is always true
|
167
|
+
matched = false
|
168
|
+
running = false
|
169
|
+
assert_error_msg = "failed to start correctly"
|
170
|
+
stdio_buf = ""
|
171
|
+
begin
|
172
|
+
execute_command(cmdline) do |pid, stdout|
|
173
|
+
begin
|
174
|
+
waiting(timeout) do
|
175
|
+
while process_exist?(pid) && !running
|
176
|
+
readables, _, _ = IO.select([stdout], nil, nil, 1)
|
177
|
+
next unless readables
|
178
|
+
next if readables.first.eof?
|
179
|
+
|
180
|
+
stdio_buf << eager_read(readables.first)
|
181
|
+
lines = stdio_buf.split("\n")
|
182
|
+
if lines.any?{|line| line.include?("fluentd worker is now running") }
|
183
|
+
running = true
|
184
|
+
end
|
185
|
+
if pattern_list.all?{|ptn| lines.any?{|line| ptn.is_a?(Regexp) ? ptn.match(line) : line.include?(ptn) } }
|
186
|
+
matched = true
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
ensure
|
191
|
+
if SUPERVISOR_PID_PATTERN =~ stdio_buf
|
192
|
+
@supervisor_pid = $1.to_i
|
193
|
+
end
|
194
|
+
stdio_buf.scan(WORKER_PID_PATTERN) do |worker_pid|
|
195
|
+
@worker_pids << worker_pid.first.to_i
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
rescue Timeout::Error
|
200
|
+
assert_error_msg = "execution timeout with command out:\n" + stdio_buf
|
201
|
+
rescue => e
|
202
|
+
assert_error_msg = "unexpected error in launching fluentd: #{e.inspect}\n" + stdio_buf
|
203
|
+
assert false, assert_error_msg
|
204
|
+
end
|
205
|
+
assert !running, "fluentd started to run incorrectly:\n" + stdio_buf
|
206
|
+
unless matched
|
207
|
+
assert_error_msg = "fluentd failed to start, without specified regular expressions:\n" + stdio_buf
|
208
|
+
end
|
209
|
+
assert matched, assert_error_msg
|
210
|
+
end
|
211
|
+
|
212
|
+
sub_test_case 'with valid configuration' do
|
213
|
+
test 'runs successfully' do
|
214
|
+
conf = <<CONF
|
215
|
+
<source>
|
216
|
+
@type dummy
|
217
|
+
@id dummy
|
218
|
+
@label @dummydata
|
219
|
+
tag dummy
|
220
|
+
dummy {"message": "yay!"}
|
221
|
+
</source>
|
222
|
+
<label @dummydata>
|
223
|
+
<match dummy>
|
224
|
+
@type null
|
225
|
+
@id blackhole
|
226
|
+
</match>
|
227
|
+
</label>
|
228
|
+
CONF
|
229
|
+
conf_path = create_conf_file('valid.conf', conf)
|
230
|
+
assert File.exist?(conf_path)
|
231
|
+
|
232
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", 'worker=0')
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
sub_test_case 'with --conf-encoding' do
|
237
|
+
test 'runs successfully' do
|
238
|
+
conf = <<CONF
|
239
|
+
# テスト
|
240
|
+
<source>
|
241
|
+
@type dummy
|
242
|
+
tag dummy
|
243
|
+
dummy {"message": "yay!"}
|
244
|
+
</source>
|
245
|
+
<match dummy>
|
246
|
+
@type null
|
247
|
+
</match>
|
248
|
+
CONF
|
249
|
+
conf_path = create_conf_file('shift_jis.conf', conf, 'shift_jis')
|
250
|
+
assert_log_matches(create_cmdline(conf_path, '--conf-encoding', 'shift_jis'), "fluentd worker is now running", 'worker=0')
|
251
|
+
end
|
252
|
+
|
253
|
+
test 'failed to run by invalid encoding' do
|
254
|
+
conf = <<CONF
|
255
|
+
# テスト
|
256
|
+
<source>
|
257
|
+
@type dummy
|
258
|
+
tag dummy
|
259
|
+
dummy {"message": "yay!"}
|
260
|
+
</source>
|
261
|
+
<match dummy>
|
262
|
+
@type null
|
263
|
+
</match>
|
264
|
+
CONF
|
265
|
+
conf_path = create_conf_file('shift_jis.conf', conf, 'shift_jis')
|
266
|
+
assert_fluentd_fails_to_start(create_cmdline(conf_path), "invalid byte sequence in UTF-8")
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
sub_test_case 'with system configuration about root directory' do
|
271
|
+
setup do
|
272
|
+
@root_path = File.join(TMP_DIR, "rootpath")
|
273
|
+
FileUtils.rm_rf(@root_path)
|
274
|
+
@conf = <<CONF
|
275
|
+
<system>
|
276
|
+
root_dir #{@root_path}
|
277
|
+
</system>
|
278
|
+
<source>
|
279
|
+
@type dummy
|
280
|
+
@id dummy
|
281
|
+
@label @dummydata
|
282
|
+
tag dummy
|
283
|
+
dummy {"message": "yay!"}
|
284
|
+
</source>
|
285
|
+
<label @dummydata>
|
286
|
+
<match dummy>
|
287
|
+
@type null
|
288
|
+
@id blackhole
|
289
|
+
</match>
|
290
|
+
</label>
|
291
|
+
CONF
|
292
|
+
end
|
293
|
+
|
294
|
+
test 'use the specified existing directory as root' do
|
295
|
+
FileUtils.mkdir_p(@root_path)
|
296
|
+
conf_path = create_conf_file('existing_root_dir.conf', @conf)
|
297
|
+
assert Dir.exist?(@root_path)
|
298
|
+
|
299
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", 'worker=0')
|
300
|
+
end
|
301
|
+
|
302
|
+
test 'creates the specified root directory if missing' do
|
303
|
+
conf_path = create_conf_file('missing_root_dir.conf', @conf)
|
304
|
+
assert_false Dir.exist?(@root_path)
|
305
|
+
|
306
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", 'worker=0')
|
307
|
+
assert Dir.exist?(@root_path)
|
308
|
+
end
|
309
|
+
|
310
|
+
test 'fails to launch fluentd if specified root path is invalid path for directory' do
|
311
|
+
File.open(@root_path, 'w') do |_|
|
312
|
+
# create file and close it
|
313
|
+
end
|
314
|
+
conf_path = create_conf_file('existing_root_dir.conf', @conf)
|
315
|
+
|
316
|
+
assert_fluentd_fails_to_start(
|
317
|
+
create_cmdline(conf_path),
|
318
|
+
"non directory entry exists:#{@root_path}",
|
319
|
+
)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
sub_test_case 'configured to route log events to plugins' do
|
324
|
+
setup do
|
325
|
+
@basic_conf = <<CONF
|
326
|
+
<source>
|
327
|
+
@type dummy
|
328
|
+
@id dummy
|
329
|
+
tag dummy
|
330
|
+
dummy {"message": "yay!"}
|
331
|
+
</source>
|
332
|
+
<match dummy>
|
333
|
+
@type null
|
334
|
+
@id blackhole
|
335
|
+
</match>
|
336
|
+
CONF
|
337
|
+
end
|
338
|
+
|
339
|
+
test 'by top level <match fluent.*> section' do
|
340
|
+
conf = @basic_conf + <<CONF
|
341
|
+
<match fluent.**>
|
342
|
+
@type stdout
|
343
|
+
</match>
|
344
|
+
CONF
|
345
|
+
conf_path = create_conf_file('logevent_1.conf', conf)
|
346
|
+
assert_log_matches(
|
347
|
+
create_cmdline(conf_path),
|
348
|
+
"fluentd worker is now running",
|
349
|
+
'fluent.info: {"worker":0,"message":"fluentd worker is now running worker=0"}',
|
350
|
+
"define <match fluent.**> to capture fluentd logs in top level is deprecated. Use <label @FLUENT_LOG> instead",
|
351
|
+
patterns_not_match: ['[warn]: some tags for log events are not defined in top level (to be ignored) tags=["fluent.trace", "fluent.debug"]'],
|
352
|
+
)
|
353
|
+
end
|
354
|
+
|
355
|
+
test 'by top level <match> section with warning for missing log levels (and warnings for each log event records)' do
|
356
|
+
conf = @basic_conf + <<CONF
|
357
|
+
<match fluent.warn fluent.error fluent.fatal>
|
358
|
+
@type stdout
|
359
|
+
</match>
|
360
|
+
CONF
|
361
|
+
conf_path = create_conf_file('logevent_2.conf', conf)
|
362
|
+
assert_log_matches(
|
363
|
+
create_cmdline(conf_path),
|
364
|
+
"fluentd worker is now running",
|
365
|
+
'[warn]: #0 match for some tags of log events are not defined in top level (to be ignored) tags=["fluent.trace", "fluent.debug", "fluent.info"]',
|
366
|
+
"define <match fluent.warn>, <match fluent.error>, <match fluent.fatal> to capture fluentd logs in top level is deprecated. Use <label @FLUENT_LOG> instead",
|
367
|
+
'[warn]: #0 no patterns matched tag="fluent.info"',
|
368
|
+
)
|
369
|
+
end
|
370
|
+
|
371
|
+
test 'by <label @FLUENT_LOG> section' do
|
372
|
+
conf = @basic_conf + <<CONF
|
373
|
+
<label @FLUENT_LOG>
|
374
|
+
<match **>
|
375
|
+
@type stdout
|
376
|
+
</match>
|
377
|
+
</label>
|
378
|
+
CONF
|
379
|
+
conf_path = create_conf_file('logevent_3.conf', conf)
|
380
|
+
assert_log_matches(
|
381
|
+
create_cmdline(conf_path),
|
382
|
+
"fluentd worker is now running",
|
383
|
+
'fluent.info: {"worker":0,"message":"fluentd worker is now running worker=0"}',
|
384
|
+
patterns_not_match: ['[warn]: some tags for log events are not defined in @FLUENT_LOG label (to be ignored)'],
|
385
|
+
)
|
386
|
+
end
|
387
|
+
|
388
|
+
test 'by <label> section with warning for missing log levels' do
|
389
|
+
conf = @basic_conf + <<CONF
|
390
|
+
<label @FLUENT_LOG>
|
391
|
+
<match fluent.{trace,debug}>
|
392
|
+
@type null
|
393
|
+
</match>
|
394
|
+
<match fluent.warn fluent.error>
|
395
|
+
@type stdout
|
396
|
+
</match>
|
397
|
+
</label>
|
398
|
+
CONF
|
399
|
+
conf_path = create_conf_file('logevent_4.conf', conf)
|
400
|
+
assert_log_matches(
|
401
|
+
create_cmdline(conf_path),
|
402
|
+
"fluentd worker is now running",
|
403
|
+
'[warn]: #0 match for some tags of log events are not defined in @FLUENT_LOG label (to be ignored) tags=["fluent.info", "fluent.fatal"]',
|
404
|
+
patterns_not_match: ['[warn]: no patterns matched tag="fluent.info"'],
|
405
|
+
)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
sub_test_case 'configured to suppress configuration dump' do
|
410
|
+
setup do
|
411
|
+
@basic_conf = <<CONF
|
412
|
+
<source>
|
413
|
+
@type dummy
|
414
|
+
@id dummy
|
415
|
+
@label @dummydata
|
416
|
+
tag dummy
|
417
|
+
dummy {"message": "yay!"}
|
418
|
+
</source>
|
419
|
+
<label @dummydata>
|
420
|
+
<match dummy>
|
421
|
+
@type null
|
422
|
+
@id blackhole
|
423
|
+
</match>
|
424
|
+
</label>
|
425
|
+
CONF
|
426
|
+
end
|
427
|
+
|
428
|
+
test 'configured by system config' do
|
429
|
+
conf = <<SYSTEM + @basic_conf
|
430
|
+
<system>
|
431
|
+
suppress_config_dump
|
432
|
+
</system>
|
433
|
+
SYSTEM
|
434
|
+
conf_path = create_conf_file('suppress_conf_dump_1.conf', conf)
|
435
|
+
assert_log_matches(create_cmdline(conf_path), "fluentd worker is now running", patterns_not_match: ["tag dummy"])
|
436
|
+
end
|
437
|
+
|
438
|
+
test 'configured by command line option' do
|
439
|
+
conf_path = create_conf_file('suppress_conf_dump_2.conf', @basic_conf)
|
440
|
+
assert_log_matches(create_cmdline(conf_path, '--suppress-config-dump'), "fluentd worker is now running", patterns_not_match: ["tag dummy"])
|
441
|
+
end
|
442
|
+
|
443
|
+
test 'configured as false by system config, but overridden as true by command line option' do
|
444
|
+
conf = <<SYSTEM + @basic_conf
|
445
|
+
<system>
|
446
|
+
suppress_config_dump false
|
447
|
+
</system>
|
448
|
+
SYSTEM
|
449
|
+
conf_path = create_conf_file('suppress_conf_dump_3.conf', conf)
|
450
|
+
assert_log_matches(create_cmdline(conf_path, '--suppress-config-dump'), "fluentd worker is now running", patterns_not_match: ["tag dummy"])
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
sub_test_case 'configuration with wrong plugin type' do
|
455
|
+
test 'failed to start' do
|
456
|
+
conf = <<CONF
|
457
|
+
<source>
|
458
|
+
@type
|
459
|
+
@id dummy
|
460
|
+
@label @dummydata
|
461
|
+
tag dummy
|
462
|
+
dummy {"message": "yay!"}
|
463
|
+
</source>
|
464
|
+
<label @dummydata>
|
465
|
+
<match dummy>
|
466
|
+
@type null
|
467
|
+
@id blackhole
|
468
|
+
</match>
|
469
|
+
</label>
|
470
|
+
CONF
|
471
|
+
conf_path = create_conf_file('type_missing.conf', conf)
|
472
|
+
assert File.exist?(conf_path)
|
473
|
+
|
474
|
+
assert_fluentd_fails_to_start(
|
475
|
+
create_cmdline(conf_path),
|
476
|
+
"config error",
|
477
|
+
"error=\"Unknown input plugin ''. Run 'gem search -rd fluent-plugin' to find plugins",
|
478
|
+
)
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
sub_test_case 'configuration to load plugin file with syntax error' do
|
483
|
+
test 'failed to start' do
|
484
|
+
script = "require 'fluent/plugin/input'\n"
|
485
|
+
script << "module Fluent::Plugin\n"
|
486
|
+
script << " class BuggyInput < Input\n"
|
487
|
+
script << " Fluent::Plugin.register_input('buggy', self)\n"
|
488
|
+
script << " end\n"
|
489
|
+
plugin_path = create_plugin_file('in_buggy.rb', script)
|
490
|
+
|
491
|
+
conf = <<CONF
|
492
|
+
<source>
|
493
|
+
@type buggy
|
494
|
+
@id dummy
|
495
|
+
@label @dummydata
|
496
|
+
tag dummy
|
497
|
+
dummy {"message": "yay!"}
|
498
|
+
</source>
|
499
|
+
<label @dummydata>
|
500
|
+
<match dummy>
|
501
|
+
@type null
|
502
|
+
@id blackhole
|
503
|
+
</match>
|
504
|
+
</label>
|
505
|
+
CONF
|
506
|
+
conf_path = create_conf_file('buggy_plugin.conf', conf)
|
507
|
+
assert File.exist?(conf_path)
|
508
|
+
|
509
|
+
assert_fluentd_fails_to_start(
|
510
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
511
|
+
"in_buggy.rb:5: syntax error, unexpected end-of-input, expecting"
|
512
|
+
)
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
sub_test_case 'configuration to load plugin which raises unrecoverable error in #start' do
|
517
|
+
test 'failed to start' do
|
518
|
+
script = "require 'fluent/plugin/input'\n"
|
519
|
+
script << "require 'fluent/error'\n"
|
520
|
+
script << "module Fluent::Plugin\n"
|
521
|
+
script << " class CrashingInput < Input\n"
|
522
|
+
script << " Fluent::Plugin.register_input('crashing', self)\n"
|
523
|
+
script << " def start\n"
|
524
|
+
script << " raise Fluent::UnrecoverableError"
|
525
|
+
script << " end\n"
|
526
|
+
script << " end\n"
|
527
|
+
script << "end\n"
|
528
|
+
plugin_path = create_plugin_file('in_crashing.rb', script)
|
529
|
+
|
530
|
+
conf = <<CONF
|
531
|
+
<source>
|
532
|
+
@type crashing
|
533
|
+
@id dummy
|
534
|
+
@label @dummydata
|
535
|
+
tag dummy
|
536
|
+
dummy {"message": "yay!"}
|
537
|
+
</source>
|
538
|
+
<label @dummydata>
|
539
|
+
<match dummy>
|
540
|
+
@type null
|
541
|
+
@id blackhole
|
542
|
+
</match>
|
543
|
+
</label>
|
544
|
+
CONF
|
545
|
+
conf_path = create_conf_file('crashing_plugin.conf', conf)
|
546
|
+
assert File.exist?(conf_path)
|
547
|
+
|
548
|
+
assert_fluentd_fails_to_start(
|
549
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
550
|
+
'unexpected error error_class=Fluent::UnrecoverableError error="an unrecoverable error occurs in Fluentd process"',
|
551
|
+
)
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
sub_test_case 'configured to run 2 workers' do
|
556
|
+
setup do
|
557
|
+
@root_path = File.join(TMP_DIR, "rootpath")
|
558
|
+
FileUtils.rm_rf(@root_path)
|
559
|
+
FileUtils.mkdir_p(@root_path)
|
560
|
+
end
|
561
|
+
|
562
|
+
test 'success to start the number of workers specified in configuration' do
|
563
|
+
conf = <<'CONF'
|
564
|
+
<system>
|
565
|
+
workers 2
|
566
|
+
root_dir #{@root_path}
|
567
|
+
</system>
|
568
|
+
<source>
|
569
|
+
@type dummy
|
570
|
+
@id "dummy#{worker_id}" # check worker_id works or not with actual command
|
571
|
+
@label @dummydata
|
572
|
+
tag dummy
|
573
|
+
dummy {"message": "yay!"}
|
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('workers1.conf', conf)
|
583
|
+
assert Dir.exist?(@root_path)
|
584
|
+
|
585
|
+
assert_log_matches(
|
586
|
+
create_cmdline(conf_path),
|
587
|
+
"#0 fluentd worker is now running worker=0",
|
588
|
+
"#1 fluentd worker is now running worker=1"
|
589
|
+
)
|
590
|
+
end
|
591
|
+
|
592
|
+
test 'success to start the number of workers specified by command line option' do
|
593
|
+
conf = <<CONF
|
594
|
+
<system>
|
595
|
+
root_dir #{@root_path}
|
596
|
+
</system>
|
597
|
+
<source>
|
598
|
+
@type dummy
|
599
|
+
@id dummy
|
600
|
+
@label @dummydata
|
601
|
+
tag dummy
|
602
|
+
dummy {"message": "yay!"}
|
603
|
+
</source>
|
604
|
+
<label @dummydata>
|
605
|
+
<match dummy>
|
606
|
+
@type null
|
607
|
+
@id blackhole
|
608
|
+
</match>
|
609
|
+
</label>
|
610
|
+
CONF
|
611
|
+
conf_path = create_conf_file('workers2.conf', conf)
|
612
|
+
assert_log_matches(
|
613
|
+
create_cmdline(conf_path, '--workers', '2'),
|
614
|
+
"#0 fluentd worker is now running worker=0",
|
615
|
+
"#1 fluentd worker is now running worker=1"
|
616
|
+
)
|
617
|
+
end
|
618
|
+
|
619
|
+
test 'failed to start workers when configured plugins do not support multi worker configuration' do
|
620
|
+
script = "require 'fluent/plugin/input'\n"
|
621
|
+
script << "module Fluent::Plugin\n"
|
622
|
+
script << " class SingleInput < Input\n"
|
623
|
+
script << " Fluent::Plugin.register_input('single', self)\n"
|
624
|
+
script << " def multi_workers_ready?\n"
|
625
|
+
script << " false\n"
|
626
|
+
script << " end\n"
|
627
|
+
script << " end\n"
|
628
|
+
script << "end\n"
|
629
|
+
plugin_path = create_plugin_file('in_single.rb', script)
|
630
|
+
|
631
|
+
conf = <<CONF
|
632
|
+
<system>
|
633
|
+
workers 2
|
634
|
+
</system>
|
635
|
+
<source>
|
636
|
+
@type single
|
637
|
+
@id single
|
638
|
+
@label @dummydata
|
639
|
+
</source>
|
640
|
+
<label @dummydata>
|
641
|
+
<match dummy>
|
642
|
+
@type null
|
643
|
+
@id blackhole
|
644
|
+
</match>
|
645
|
+
</label>
|
646
|
+
CONF
|
647
|
+
conf_path = create_conf_file('workers_invalid1.conf', conf)
|
648
|
+
assert_fluentd_fails_to_start(
|
649
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
650
|
+
"Plugin 'single' does not support multi workers configuration (Fluent::Plugin::SingleInput)",
|
651
|
+
)
|
652
|
+
end
|
653
|
+
|
654
|
+
test 'failed to start workers when file buffer is configured in non-workers way' do
|
655
|
+
conf = <<CONF
|
656
|
+
<system>
|
657
|
+
workers 2
|
658
|
+
</system>
|
659
|
+
<source>
|
660
|
+
@type dummy
|
661
|
+
tag dummy
|
662
|
+
@id single
|
663
|
+
@label @dummydata
|
664
|
+
</source>
|
665
|
+
<label @dummydata>
|
666
|
+
<match dummy>
|
667
|
+
@type null
|
668
|
+
@id blackhole
|
669
|
+
<buffer>
|
670
|
+
@type file
|
671
|
+
path #{File.join(@root_path, "buf", "file.*.log")}
|
672
|
+
</buffer>
|
673
|
+
</match>
|
674
|
+
</label>
|
675
|
+
CONF
|
676
|
+
conf_path = create_conf_file('workers_invalid2.conf', conf)
|
677
|
+
assert_fluentd_fails_to_start(
|
678
|
+
create_cmdline(conf_path),
|
679
|
+
"[blackhole] file buffer with multi workers should be configured to use directory 'path', or system root_dir and plugin id",
|
680
|
+
"config error file=\"#{conf_path}\" error_class=Fluent::ConfigError error=\"Plugin 'file' does not support multi workers configuration (Fluent::Plugin::FileBuffer)\"",
|
681
|
+
)
|
682
|
+
end
|
683
|
+
|
684
|
+
test 'failed to start workers when configured plugins as children of MultiOutput do not support multi worker configuration' do
|
685
|
+
script = <<-EOC
|
686
|
+
require 'fluent/plugin/output'
|
687
|
+
module Fluent::Plugin
|
688
|
+
class SingleOutput < Output
|
689
|
+
Fluent::Plugin.register_output('single', self)
|
690
|
+
def multi_workers_ready?
|
691
|
+
false
|
692
|
+
end
|
693
|
+
def write(chunk)
|
694
|
+
end
|
695
|
+
end
|
696
|
+
end
|
697
|
+
EOC
|
698
|
+
plugin_path = create_plugin_file('out_single.rb', script)
|
699
|
+
|
700
|
+
conf = <<CONF
|
701
|
+
<system>
|
702
|
+
workers 2
|
703
|
+
</system>
|
704
|
+
<source>
|
705
|
+
@type dummy
|
706
|
+
tag dummy
|
707
|
+
@id single
|
708
|
+
@label @dummydata
|
709
|
+
</source>
|
710
|
+
<label @dummydata>
|
711
|
+
<match dummy>
|
712
|
+
@type copy
|
713
|
+
<store>
|
714
|
+
@type single
|
715
|
+
</store>
|
716
|
+
<store>
|
717
|
+
@type single
|
718
|
+
</store>
|
719
|
+
</match>
|
720
|
+
</label>
|
721
|
+
CONF
|
722
|
+
conf_path = create_conf_file('workers_invalid3.conf', conf)
|
723
|
+
assert_fluentd_fails_to_start(
|
724
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
725
|
+
"Plugin 'single' does not support multi workers configuration (Fluent::Plugin::SingleOutput)",
|
726
|
+
)
|
727
|
+
end
|
728
|
+
|
729
|
+
test 'success to start a worker2 with worker specific configuration' do
|
730
|
+
conf = <<CONF
|
731
|
+
<system>
|
732
|
+
root_dir #{@root_path}
|
733
|
+
dir_permission 0744
|
734
|
+
</system>
|
735
|
+
CONF
|
736
|
+
conf_path = create_conf_file('worker_section0.conf', conf)
|
737
|
+
|
738
|
+
FileUtils.rm_rf(@root_path) rescue nil
|
739
|
+
|
740
|
+
assert_path_not_exist(@root_path)
|
741
|
+
assert_log_matches(create_cmdline(conf_path), 'spawn command to main') # any message is ok
|
742
|
+
assert_path_exist(@root_path)
|
743
|
+
if Fluent.windows?
|
744
|
+
# In Windows, dir permission is always 755.
|
745
|
+
assert_equal '755', File.stat(@root_path).mode.to_s(8)[-3, 3]
|
746
|
+
else
|
747
|
+
assert_equal '744', File.stat(@root_path).mode.to_s(8)[-3, 3]
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
test 'success to start a worker with worker specific configuration' do
|
752
|
+
conf = <<CONF
|
753
|
+
<system>
|
754
|
+
workers 2
|
755
|
+
root_dir #{@root_path}
|
756
|
+
</system>
|
757
|
+
<source>
|
758
|
+
@type dummy
|
759
|
+
@id dummy
|
760
|
+
@label @dummydata
|
761
|
+
tag dummy
|
762
|
+
dummy {"message": "yay!"}
|
763
|
+
</source>
|
764
|
+
<worker 1>
|
765
|
+
<source>
|
766
|
+
@type dummy
|
767
|
+
@id dummy_in_worker
|
768
|
+
@label @dummydata
|
769
|
+
tag dummy
|
770
|
+
dummy {"message": "yay!"}
|
771
|
+
</source>
|
772
|
+
</worker>
|
773
|
+
<label @dummydata>
|
774
|
+
<match dummy>
|
775
|
+
@type null
|
776
|
+
@id blackhole
|
777
|
+
</match>
|
778
|
+
</label>
|
779
|
+
CONF
|
780
|
+
conf_path = create_conf_file('worker_section0.conf', conf)
|
781
|
+
assert Dir.exist?(@root_path)
|
782
|
+
|
783
|
+
assert_log_matches(
|
784
|
+
create_cmdline(conf_path),
|
785
|
+
"#0 fluentd worker is now running worker=0",
|
786
|
+
"#1 fluentd worker is now running worker=1",
|
787
|
+
/(?!#\d) adding source type="dummy"/,
|
788
|
+
'#1 adding source type="dummy"'
|
789
|
+
)
|
790
|
+
end
|
791
|
+
|
792
|
+
test 'success to start workers when configured plugins only for specific worker do not support multi worker configuration' do
|
793
|
+
script = <<-EOC
|
794
|
+
require 'fluent/plugin/input'
|
795
|
+
module Fluent::Plugin
|
796
|
+
class SingleInput < Input
|
797
|
+
Fluent::Plugin.register_input('single', self)
|
798
|
+
def multi_workers_ready?
|
799
|
+
false
|
800
|
+
end
|
801
|
+
end
|
802
|
+
end
|
803
|
+
EOC
|
804
|
+
plugin_path = create_plugin_file('in_single.rb', script)
|
805
|
+
|
806
|
+
conf = <<CONF
|
807
|
+
<system>
|
808
|
+
workers 2
|
809
|
+
</system>
|
810
|
+
<worker 1>
|
811
|
+
<source>
|
812
|
+
@type single
|
813
|
+
@id single
|
814
|
+
@label @dummydata
|
815
|
+
</source>
|
816
|
+
</worker>
|
817
|
+
<label @dummydata>
|
818
|
+
<match dummy>
|
819
|
+
@type null
|
820
|
+
@id blackhole
|
821
|
+
</match>
|
822
|
+
</label>
|
823
|
+
CONF
|
824
|
+
conf_path = create_conf_file('worker_section1.conf', conf)
|
825
|
+
assert Dir.exist?(@root_path)
|
826
|
+
|
827
|
+
assert_log_matches(
|
828
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
829
|
+
"#0 fluentd worker is now running worker=0",
|
830
|
+
"#1 fluentd worker is now running worker=1",
|
831
|
+
'#1 adding source type="single"'
|
832
|
+
)
|
833
|
+
end
|
834
|
+
|
835
|
+
test "multiple values are set to RUBYOPT" do
|
836
|
+
conf = <<CONF
|
837
|
+
<source>
|
838
|
+
@type dummy
|
839
|
+
tag dummy
|
840
|
+
</source>
|
841
|
+
<match>
|
842
|
+
@type null
|
843
|
+
</match>
|
844
|
+
CONF
|
845
|
+
conf_path = create_conf_file('rubyopt_test.conf', conf)
|
846
|
+
assert_log_matches(
|
847
|
+
create_cmdline(conf_path),
|
848
|
+
'#0 fluentd worker is now running worker=0',
|
849
|
+
patterns_not_match: ['(LoadError)'],
|
850
|
+
env: { 'RUBYOPT' => '-rtest-unit -rbundler/setup' },
|
851
|
+
)
|
852
|
+
end
|
853
|
+
|
854
|
+
data(
|
855
|
+
'-E' => '-Eutf-8',
|
856
|
+
'-encoding' => '--encoding=utf-8',
|
857
|
+
'-external-encoding' => '--external-encoding=utf-8',
|
858
|
+
'-internal-encoding' => '--internal-encoding=utf-8',
|
859
|
+
)
|
860
|
+
test "-E option is set to RUBYOPT" do |opt|
|
861
|
+
conf = <<CONF
|
862
|
+
<source>
|
863
|
+
@type dummy
|
864
|
+
tag dummy
|
865
|
+
</source>
|
866
|
+
<match>
|
867
|
+
@type null
|
868
|
+
</match>
|
869
|
+
CONF
|
870
|
+
conf_path = create_conf_file('rubyopt_test.conf', conf)
|
871
|
+
opt << " #{ENV['RUBYOPT']}" if ENV['RUBYOPT']
|
872
|
+
assert_log_matches(
|
873
|
+
create_cmdline(conf_path),
|
874
|
+
*opt.split(' '),
|
875
|
+
patterns_not_match: ['-Eascii-8bit:ascii-8bit'],
|
876
|
+
env: { 'RUBYOPT' => opt },
|
877
|
+
)
|
878
|
+
end
|
879
|
+
|
880
|
+
test "without RUBYOPT" do
|
881
|
+
saved_ruby_opt = ENV["RUBYOPT"]
|
882
|
+
ENV["RUBYOPT"] = nil
|
883
|
+
conf = <<CONF
|
884
|
+
<source>
|
885
|
+
@type dummy
|
886
|
+
tag dummy
|
887
|
+
</source>
|
888
|
+
<match>
|
889
|
+
@type null
|
890
|
+
</match>
|
891
|
+
CONF
|
892
|
+
conf_path = create_conf_file('rubyopt_test.conf', conf)
|
893
|
+
assert_log_matches(create_cmdline(conf_path), '-Eascii-8bit:ascii-8bit')
|
894
|
+
ensure
|
895
|
+
ENV["RUBYOPT"] = saved_ruby_opt
|
896
|
+
end
|
897
|
+
|
898
|
+
test 'invalid values are set to RUBYOPT' do
|
899
|
+
omit "hard to run correctly because RUBYOPT=-r/path/to/bundler/setup is required on Windows while this test set invalid RUBYOPT" if Fluent.windows?
|
900
|
+
conf = <<CONF
|
901
|
+
<source>
|
902
|
+
@type dummy
|
903
|
+
tag dummy
|
904
|
+
</source>
|
905
|
+
<match>
|
906
|
+
@type null
|
907
|
+
</match>
|
908
|
+
CONF
|
909
|
+
conf_path = create_conf_file('rubyopt_invalid_test.conf', conf)
|
910
|
+
assert_log_matches(
|
911
|
+
create_cmdline(conf_path),
|
912
|
+
'Invalid option is passed to RUBYOPT',
|
913
|
+
env: { 'RUBYOPT' => 'a' },
|
914
|
+
)
|
915
|
+
end
|
916
|
+
|
917
|
+
# https://github.com/fluent/fluentd/issues/2915
|
918
|
+
test "ruby path contains spaces" do
|
919
|
+
saved_ruby_opt = ENV["RUBYOPT"]
|
920
|
+
ENV["RUBYOPT"] = nil
|
921
|
+
conf = <<CONF
|
922
|
+
<source>
|
923
|
+
@type dummy
|
924
|
+
tag dummy
|
925
|
+
</source>
|
926
|
+
<match>
|
927
|
+
@type null
|
928
|
+
</match>
|
929
|
+
CONF
|
930
|
+
ruby_path = ServerEngine.ruby_bin_path
|
931
|
+
tmp_ruby_path = File.join(TMP_DIR, "ruby with spaces")
|
932
|
+
if Fluent.windows?
|
933
|
+
tmp_ruby_path << ".bat"
|
934
|
+
File.open(tmp_ruby_path, "w") do |file|
|
935
|
+
file.write "#{ruby_path} %*"
|
936
|
+
end
|
937
|
+
else
|
938
|
+
FileUtils.ln_sf(ruby_path, tmp_ruby_path)
|
939
|
+
end
|
940
|
+
ENV["TEST_RUBY_PATH"] = tmp_ruby_path
|
941
|
+
cmd_path = File.expand_path(File.dirname(__FILE__) + "../../../bin/fluentd")
|
942
|
+
conf_path = create_conf_file('space_mixed_ruby_path_test.conf', conf)
|
943
|
+
args = ["bundle", "exec", tmp_ruby_path, cmd_path, "-c", conf_path]
|
944
|
+
assert_log_matches(
|
945
|
+
args,
|
946
|
+
'spawn command to main:',
|
947
|
+
'-Eascii-8bit:ascii-8bit'
|
948
|
+
)
|
949
|
+
ensure
|
950
|
+
ENV["RUBYOPT"] = saved_ruby_opt
|
951
|
+
end
|
952
|
+
|
953
|
+
test 'success to start workers when file buffer is configured in non-workers way only for specific worker' do
|
954
|
+
conf = <<CONF
|
955
|
+
<system>
|
956
|
+
workers 2
|
957
|
+
</system>
|
958
|
+
<source>
|
959
|
+
@type dummy
|
960
|
+
@id dummy
|
961
|
+
tag dummy
|
962
|
+
dummy {"message": "yay!"}
|
963
|
+
</source>
|
964
|
+
<worker 1>
|
965
|
+
<match dummy>
|
966
|
+
@type null
|
967
|
+
@id blackhole
|
968
|
+
<buffer>
|
969
|
+
@type file
|
970
|
+
path #{File.join(@root_path, "buf")}
|
971
|
+
</buffer>
|
972
|
+
</match>
|
973
|
+
</worker>
|
974
|
+
CONF
|
975
|
+
conf_path = create_conf_file('worker_section2.conf', conf)
|
976
|
+
assert_log_matches(
|
977
|
+
create_cmdline(conf_path),
|
978
|
+
"#0 fluentd worker is now running worker=0",
|
979
|
+
"#1 fluentd worker is now running worker=1",
|
980
|
+
'#1 adding match pattern="dummy" type="null"'
|
981
|
+
)
|
982
|
+
end
|
983
|
+
|
984
|
+
test 'success to start workers when configured plugins as a children of MultiOutput only for specific worker do not support multi worker configuration' do
|
985
|
+
script = <<-EOC
|
986
|
+
require 'fluent/plugin/output'
|
987
|
+
module Fluent::Plugin
|
988
|
+
class SingleOutput < Output
|
989
|
+
Fluent::Plugin.register_output('single', self)
|
990
|
+
def multi_workers_ready?
|
991
|
+
false
|
992
|
+
end
|
993
|
+
def write(chunk)
|
994
|
+
end
|
995
|
+
end
|
996
|
+
end
|
997
|
+
EOC
|
998
|
+
plugin_path = create_plugin_file('out_single.rb', script)
|
999
|
+
|
1000
|
+
conf = <<CONF
|
1001
|
+
<system>
|
1002
|
+
workers 2
|
1003
|
+
</system>
|
1004
|
+
<source>
|
1005
|
+
@type dummy
|
1006
|
+
@id dummy
|
1007
|
+
tag dummy
|
1008
|
+
dummy {"message": "yay!"}
|
1009
|
+
</source>
|
1010
|
+
<worker 1>
|
1011
|
+
<match dummy>
|
1012
|
+
@type copy
|
1013
|
+
<store>
|
1014
|
+
@type single
|
1015
|
+
</store>
|
1016
|
+
<store>
|
1017
|
+
@type single
|
1018
|
+
</store>
|
1019
|
+
</match>
|
1020
|
+
</worker>
|
1021
|
+
CONF
|
1022
|
+
conf_path = create_conf_file('worker_section3.conf', conf)
|
1023
|
+
assert_log_matches(
|
1024
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
1025
|
+
"#0 fluentd worker is now running worker=0",
|
1026
|
+
"#1 fluentd worker is now running worker=1",
|
1027
|
+
'#1 adding match pattern="dummy" type="copy"'
|
1028
|
+
)
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
sub_test_case 'config dump' do
|
1033
|
+
test 'all secret parameters in worker section is sealed' do
|
1034
|
+
script = <<-EOC
|
1035
|
+
require 'fluent/plugin/input'
|
1036
|
+
module Fluent::Plugin
|
1037
|
+
class FakeInput < Input
|
1038
|
+
Fluent::Plugin.register_input('fake', self)
|
1039
|
+
config_param :secret, :string, secret: true
|
1040
|
+
def multi_workers_ready?; true; end
|
1041
|
+
end
|
1042
|
+
end
|
1043
|
+
EOC
|
1044
|
+
plugin_path = create_plugin_file('in_fake.rb', script)
|
1045
|
+
|
1046
|
+
conf = <<CONF
|
1047
|
+
<system>
|
1048
|
+
workers 2
|
1049
|
+
</system>
|
1050
|
+
<worker 0>
|
1051
|
+
<source>
|
1052
|
+
@type fake
|
1053
|
+
secret secret0
|
1054
|
+
</source>
|
1055
|
+
<match>
|
1056
|
+
@type null
|
1057
|
+
</match>
|
1058
|
+
</worker>
|
1059
|
+
<worker 1>
|
1060
|
+
<source>
|
1061
|
+
@type fake
|
1062
|
+
secret secret1
|
1063
|
+
</source>
|
1064
|
+
<match>
|
1065
|
+
@type null
|
1066
|
+
</match>
|
1067
|
+
</worker>
|
1068
|
+
CONF
|
1069
|
+
conf_path = create_conf_file('secret_in_worker.conf', conf)
|
1070
|
+
assert File.exist?(conf_path)
|
1071
|
+
|
1072
|
+
assert_log_matches(create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
1073
|
+
"secret xxxxxx", patterns_not_match: ["secret secret0", "secret secret1"])
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
sub_test_case 'sahred socket options' do
|
1078
|
+
test 'enable shared socket by default' do
|
1079
|
+
conf = ""
|
1080
|
+
conf_path = create_conf_file('empty.conf', conf)
|
1081
|
+
assert File.exist?(conf_path)
|
1082
|
+
assert_log_matches(create_cmdline(conf_path),
|
1083
|
+
patterns_not_match: ["shared socket for multiple workers is disabled"])
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
test 'disable shared socket by command line option' do
|
1087
|
+
conf = ""
|
1088
|
+
conf_path = create_conf_file('empty.conf', conf)
|
1089
|
+
assert File.exist?(conf_path)
|
1090
|
+
assert_log_matches(create_cmdline(conf_path, "--disable-shared-socket"),
|
1091
|
+
"shared socket for multiple workers is disabled",)
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
test 'disable shared socket by system config' do
|
1095
|
+
conf = <<CONF
|
1096
|
+
<system>
|
1097
|
+
disable_shared_socket
|
1098
|
+
</system>
|
1099
|
+
CONF
|
1100
|
+
conf_path = create_conf_file('empty.conf', conf)
|
1101
|
+
assert File.exist?(conf_path)
|
1102
|
+
assert_log_matches(create_cmdline(conf_path, "--disable-shared-socket"),
|
1103
|
+
"shared socket for multiple workers is disabled",)
|
1104
|
+
end
|
1105
|
+
end
|
1106
|
+
end
|