dtomasgu-fluentd 1.14.7.pre.dev
Sign up to get free protection for your applications and to get access to all the features.
- 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 +34 -0
- data/.github/workflows/stale-actions.yml +22 -0
- data/.github/workflows/windows-test.yaml +49 -0
- data/.gitignore +30 -0
- data/.gitlab-ci.yml +103 -0
- data/ADOPTERS.md +5 -0
- data/AUTHORS +2 -0
- data/CHANGELOG.md +2453 -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 +76 -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 +57 -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 +180 -0
- data/lib/fluent/command/debug.rb +103 -0
- data/lib/fluent/command/fluentd.rb +388 -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 +44 -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/yaml_parser/fluent_value.rb +47 -0
- data/lib/fluent/config/yaml_parser/loader.rb +91 -0
- data/lib/fluent/config/yaml_parser/parser.rb +166 -0
- data/lib/fluent/config/yaml_parser/section_builder.rb +107 -0
- data/lib/fluent/config/yaml_parser.rb +56 -0
- data/lib/fluent/config.rb +89 -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 +315 -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 +132 -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 +677 -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/group_watch.rb +204 -0
- data/lib/fluent/plugin/in_tail/position_file.rb +255 -0
- data/lib/fluent/plugin/in_tail.rb +1247 -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 +142 -0
- data/lib/fluent/plugin/out_forward.rb +826 -0
- data/lib/fluent/plugin/out_http.rb +280 -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 +1566 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +274 -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 +219 -0
- data/lib/fluent/plugin_helper/server.rb +820 -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 +288 -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 +117 -0
- data/lib/fluent/root_agent.rb +372 -0
- data/lib/fluent/rpc.rb +95 -0
- data/lib/fluent/static_config_analysis.rb +194 -0
- data/lib/fluent/supervisor.rb +1141 -0
- data/lib/fluent/system_config.rb +188 -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 +105 -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 +56 -0
- data/test/command/test_fluentd.rb +1139 -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 +201 -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 +150 -0
- data/test/plugin/in_tail/test_position_file.rb +316 -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 +174 -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 +58 -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 +1178 -0
- data/test/plugin/test_in_gc_stat.rb +62 -0
- data/test/plugin/test_in_http.rb +1103 -0
- data/test/plugin/test_in_monitor_agent.rb +923 -0
- data/test/plugin/test_in_object_space.rb +66 -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 +2639 -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 +1358 -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 +966 -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 +852 -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 +1006 -0
- data/test/plugin_helper/test_server.rb +1841 -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 +333 -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 +348 -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 +791 -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 +1191 -0
@@ -0,0 +1,1139 @@
|
|
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
|
+
sub_test_case "YAML config format" do
|
593
|
+
test 'success to start the number of workers specified in configuration' do
|
594
|
+
conf = <<'CONF'
|
595
|
+
system:
|
596
|
+
workers: 2
|
597
|
+
root_dir: "#{@root_path}"
|
598
|
+
config:
|
599
|
+
- source:
|
600
|
+
$type: dummy
|
601
|
+
$id: !fluent/s "dummy.#{worker_id}" # check worker_id works or not with actual command
|
602
|
+
$label: '@dummydata'
|
603
|
+
tag: dummy
|
604
|
+
dummy: !fluent/json {"message": !fluent/s "yay from #{hostname}!"}
|
605
|
+
|
606
|
+
- label:
|
607
|
+
$name: '@dummydata'
|
608
|
+
config:
|
609
|
+
- match:
|
610
|
+
$tag: dummy
|
611
|
+
$type: "null"
|
612
|
+
$id: blackhole
|
613
|
+
CONF
|
614
|
+
conf_path = create_conf_file('workers1.yaml', conf)
|
615
|
+
assert Dir.exist?(@root_path)
|
616
|
+
|
617
|
+
assert_log_matches(
|
618
|
+
create_cmdline(conf_path),
|
619
|
+
"#0 fluentd worker is now running worker=0",
|
620
|
+
"#1 fluentd worker is now running worker=1"
|
621
|
+
)
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
625
|
+
test 'success to start the number of workers specified by command line option' do
|
626
|
+
conf = <<CONF
|
627
|
+
<system>
|
628
|
+
root_dir #{@root_path}
|
629
|
+
</system>
|
630
|
+
<source>
|
631
|
+
@type dummy
|
632
|
+
@id dummy
|
633
|
+
@label @dummydata
|
634
|
+
tag dummy
|
635
|
+
dummy {"message": "yay!"}
|
636
|
+
</source>
|
637
|
+
<label @dummydata>
|
638
|
+
<match dummy>
|
639
|
+
@type null
|
640
|
+
@id blackhole
|
641
|
+
</match>
|
642
|
+
</label>
|
643
|
+
CONF
|
644
|
+
conf_path = create_conf_file('workers2.conf', conf)
|
645
|
+
assert_log_matches(
|
646
|
+
create_cmdline(conf_path, '--workers', '2'),
|
647
|
+
"#0 fluentd worker is now running worker=0",
|
648
|
+
"#1 fluentd worker is now running worker=1"
|
649
|
+
)
|
650
|
+
end
|
651
|
+
|
652
|
+
test 'failed to start workers when configured plugins do not support multi worker configuration' do
|
653
|
+
script = "require 'fluent/plugin/input'\n"
|
654
|
+
script << "module Fluent::Plugin\n"
|
655
|
+
script << " class SingleInput < Input\n"
|
656
|
+
script << " Fluent::Plugin.register_input('single', self)\n"
|
657
|
+
script << " def multi_workers_ready?\n"
|
658
|
+
script << " false\n"
|
659
|
+
script << " end\n"
|
660
|
+
script << " end\n"
|
661
|
+
script << "end\n"
|
662
|
+
plugin_path = create_plugin_file('in_single.rb', script)
|
663
|
+
|
664
|
+
conf = <<CONF
|
665
|
+
<system>
|
666
|
+
workers 2
|
667
|
+
</system>
|
668
|
+
<source>
|
669
|
+
@type single
|
670
|
+
@id single
|
671
|
+
@label @dummydata
|
672
|
+
</source>
|
673
|
+
<label @dummydata>
|
674
|
+
<match dummy>
|
675
|
+
@type null
|
676
|
+
@id blackhole
|
677
|
+
</match>
|
678
|
+
</label>
|
679
|
+
CONF
|
680
|
+
conf_path = create_conf_file('workers_invalid1.conf', conf)
|
681
|
+
assert_fluentd_fails_to_start(
|
682
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
683
|
+
"Plugin 'single' does not support multi workers configuration (Fluent::Plugin::SingleInput)",
|
684
|
+
)
|
685
|
+
end
|
686
|
+
|
687
|
+
test 'failed to start workers when file buffer is configured in non-workers way' do
|
688
|
+
conf = <<CONF
|
689
|
+
<system>
|
690
|
+
workers 2
|
691
|
+
</system>
|
692
|
+
<source>
|
693
|
+
@type dummy
|
694
|
+
tag dummy
|
695
|
+
@id single
|
696
|
+
@label @dummydata
|
697
|
+
</source>
|
698
|
+
<label @dummydata>
|
699
|
+
<match dummy>
|
700
|
+
@type null
|
701
|
+
@id blackhole
|
702
|
+
<buffer>
|
703
|
+
@type file
|
704
|
+
path #{File.join(@root_path, "buf", "file.*.log")}
|
705
|
+
</buffer>
|
706
|
+
</match>
|
707
|
+
</label>
|
708
|
+
CONF
|
709
|
+
conf_path = create_conf_file('workers_invalid2.conf', conf)
|
710
|
+
assert_fluentd_fails_to_start(
|
711
|
+
create_cmdline(conf_path),
|
712
|
+
"[blackhole] file buffer with multi workers should be configured to use directory 'path', or system root_dir and plugin id",
|
713
|
+
"config error file=\"#{conf_path}\" error_class=Fluent::ConfigError error=\"Plugin 'file' does not support multi workers configuration (Fluent::Plugin::FileBuffer)\"",
|
714
|
+
)
|
715
|
+
end
|
716
|
+
|
717
|
+
test 'failed to start workers when configured plugins as children of MultiOutput do not support multi worker configuration' do
|
718
|
+
script = <<-EOC
|
719
|
+
require 'fluent/plugin/output'
|
720
|
+
module Fluent::Plugin
|
721
|
+
class SingleOutput < Output
|
722
|
+
Fluent::Plugin.register_output('single', self)
|
723
|
+
def multi_workers_ready?
|
724
|
+
false
|
725
|
+
end
|
726
|
+
def write(chunk)
|
727
|
+
end
|
728
|
+
end
|
729
|
+
end
|
730
|
+
EOC
|
731
|
+
plugin_path = create_plugin_file('out_single.rb', script)
|
732
|
+
|
733
|
+
conf = <<CONF
|
734
|
+
<system>
|
735
|
+
workers 2
|
736
|
+
</system>
|
737
|
+
<source>
|
738
|
+
@type dummy
|
739
|
+
tag dummy
|
740
|
+
@id single
|
741
|
+
@label @dummydata
|
742
|
+
</source>
|
743
|
+
<label @dummydata>
|
744
|
+
<match dummy>
|
745
|
+
@type copy
|
746
|
+
<store>
|
747
|
+
@type single
|
748
|
+
</store>
|
749
|
+
<store>
|
750
|
+
@type single
|
751
|
+
</store>
|
752
|
+
</match>
|
753
|
+
</label>
|
754
|
+
CONF
|
755
|
+
conf_path = create_conf_file('workers_invalid3.conf', conf)
|
756
|
+
assert_fluentd_fails_to_start(
|
757
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
758
|
+
"Plugin 'single' does not support multi workers configuration (Fluent::Plugin::SingleOutput)",
|
759
|
+
)
|
760
|
+
end
|
761
|
+
|
762
|
+
test 'success to start a worker2 with worker specific configuration' do
|
763
|
+
conf = <<CONF
|
764
|
+
<system>
|
765
|
+
root_dir #{@root_path}
|
766
|
+
dir_permission 0744
|
767
|
+
</system>
|
768
|
+
CONF
|
769
|
+
conf_path = create_conf_file('worker_section0.conf', conf)
|
770
|
+
|
771
|
+
FileUtils.rm_rf(@root_path) rescue nil
|
772
|
+
|
773
|
+
assert_path_not_exist(@root_path)
|
774
|
+
assert_log_matches(create_cmdline(conf_path), 'spawn command to main') # any message is ok
|
775
|
+
assert_path_exist(@root_path)
|
776
|
+
if Fluent.windows?
|
777
|
+
# In Windows, dir permission is always 755.
|
778
|
+
assert_equal '755', File.stat(@root_path).mode.to_s(8)[-3, 3]
|
779
|
+
else
|
780
|
+
assert_equal '744', File.stat(@root_path).mode.to_s(8)[-3, 3]
|
781
|
+
end
|
782
|
+
end
|
783
|
+
|
784
|
+
test 'success to start a worker with worker specific configuration' do
|
785
|
+
conf = <<CONF
|
786
|
+
<system>
|
787
|
+
workers 2
|
788
|
+
root_dir #{@root_path}
|
789
|
+
</system>
|
790
|
+
<source>
|
791
|
+
@type dummy
|
792
|
+
@id dummy
|
793
|
+
@label @dummydata
|
794
|
+
tag dummy
|
795
|
+
dummy {"message": "yay!"}
|
796
|
+
</source>
|
797
|
+
<worker 1>
|
798
|
+
<source>
|
799
|
+
@type dummy
|
800
|
+
@id dummy_in_worker
|
801
|
+
@label @dummydata
|
802
|
+
tag dummy
|
803
|
+
dummy {"message": "yay!"}
|
804
|
+
</source>
|
805
|
+
</worker>
|
806
|
+
<label @dummydata>
|
807
|
+
<match dummy>
|
808
|
+
@type null
|
809
|
+
@id blackhole
|
810
|
+
</match>
|
811
|
+
</label>
|
812
|
+
CONF
|
813
|
+
conf_path = create_conf_file('worker_section0.conf', conf)
|
814
|
+
assert Dir.exist?(@root_path)
|
815
|
+
|
816
|
+
assert_log_matches(
|
817
|
+
create_cmdline(conf_path),
|
818
|
+
"#0 fluentd worker is now running worker=0",
|
819
|
+
"#1 fluentd worker is now running worker=1",
|
820
|
+
/(?!#\d) adding source type="dummy"/,
|
821
|
+
'#1 adding source type="dummy"'
|
822
|
+
)
|
823
|
+
end
|
824
|
+
|
825
|
+
test 'success to start workers when configured plugins only for specific worker do not support multi worker configuration' do
|
826
|
+
script = <<-EOC
|
827
|
+
require 'fluent/plugin/input'
|
828
|
+
module Fluent::Plugin
|
829
|
+
class SingleInput < Input
|
830
|
+
Fluent::Plugin.register_input('single', self)
|
831
|
+
def multi_workers_ready?
|
832
|
+
false
|
833
|
+
end
|
834
|
+
end
|
835
|
+
end
|
836
|
+
EOC
|
837
|
+
plugin_path = create_plugin_file('in_single.rb', script)
|
838
|
+
|
839
|
+
conf = <<CONF
|
840
|
+
<system>
|
841
|
+
workers 2
|
842
|
+
</system>
|
843
|
+
<worker 1>
|
844
|
+
<source>
|
845
|
+
@type single
|
846
|
+
@id single
|
847
|
+
@label @dummydata
|
848
|
+
</source>
|
849
|
+
</worker>
|
850
|
+
<label @dummydata>
|
851
|
+
<match dummy>
|
852
|
+
@type null
|
853
|
+
@id blackhole
|
854
|
+
</match>
|
855
|
+
</label>
|
856
|
+
CONF
|
857
|
+
conf_path = create_conf_file('worker_section1.conf', conf)
|
858
|
+
assert Dir.exist?(@root_path)
|
859
|
+
|
860
|
+
assert_log_matches(
|
861
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
862
|
+
"#0 fluentd worker is now running worker=0",
|
863
|
+
"#1 fluentd worker is now running worker=1",
|
864
|
+
'#1 adding source type="single"'
|
865
|
+
)
|
866
|
+
end
|
867
|
+
|
868
|
+
test "multiple values are set to RUBYOPT" do
|
869
|
+
conf = <<CONF
|
870
|
+
<source>
|
871
|
+
@type dummy
|
872
|
+
tag dummy
|
873
|
+
</source>
|
874
|
+
<match>
|
875
|
+
@type null
|
876
|
+
</match>
|
877
|
+
CONF
|
878
|
+
conf_path = create_conf_file('rubyopt_test.conf', conf)
|
879
|
+
assert_log_matches(
|
880
|
+
create_cmdline(conf_path),
|
881
|
+
'#0 fluentd worker is now running worker=0',
|
882
|
+
patterns_not_match: ['(LoadError)'],
|
883
|
+
env: { 'RUBYOPT' => '-rtest-unit -rbundler/setup' },
|
884
|
+
)
|
885
|
+
end
|
886
|
+
|
887
|
+
data(
|
888
|
+
'-E' => '-Eutf-8',
|
889
|
+
'-encoding' => '--encoding=utf-8',
|
890
|
+
'-external-encoding' => '--external-encoding=utf-8',
|
891
|
+
'-internal-encoding' => '--internal-encoding=utf-8',
|
892
|
+
)
|
893
|
+
test "-E option is set to RUBYOPT" do |opt|
|
894
|
+
conf = <<CONF
|
895
|
+
<source>
|
896
|
+
@type dummy
|
897
|
+
tag dummy
|
898
|
+
</source>
|
899
|
+
<match>
|
900
|
+
@type null
|
901
|
+
</match>
|
902
|
+
CONF
|
903
|
+
conf_path = create_conf_file('rubyopt_test.conf', conf)
|
904
|
+
opt << " #{ENV['RUBYOPT']}" if ENV['RUBYOPT']
|
905
|
+
assert_log_matches(
|
906
|
+
create_cmdline(conf_path),
|
907
|
+
*opt.split(' '),
|
908
|
+
patterns_not_match: ['-Eascii-8bit:ascii-8bit'],
|
909
|
+
env: { 'RUBYOPT' => opt },
|
910
|
+
)
|
911
|
+
end
|
912
|
+
|
913
|
+
test "without RUBYOPT" do
|
914
|
+
saved_ruby_opt = ENV["RUBYOPT"]
|
915
|
+
ENV["RUBYOPT"] = nil
|
916
|
+
conf = <<CONF
|
917
|
+
<source>
|
918
|
+
@type dummy
|
919
|
+
tag dummy
|
920
|
+
</source>
|
921
|
+
<match>
|
922
|
+
@type null
|
923
|
+
</match>
|
924
|
+
CONF
|
925
|
+
conf_path = create_conf_file('rubyopt_test.conf', conf)
|
926
|
+
assert_log_matches(create_cmdline(conf_path), '-Eascii-8bit:ascii-8bit')
|
927
|
+
ensure
|
928
|
+
ENV["RUBYOPT"] = saved_ruby_opt
|
929
|
+
end
|
930
|
+
|
931
|
+
test 'invalid values are set to RUBYOPT' do
|
932
|
+
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?
|
933
|
+
conf = <<CONF
|
934
|
+
<source>
|
935
|
+
@type dummy
|
936
|
+
tag dummy
|
937
|
+
</source>
|
938
|
+
<match>
|
939
|
+
@type null
|
940
|
+
</match>
|
941
|
+
CONF
|
942
|
+
conf_path = create_conf_file('rubyopt_invalid_test.conf', conf)
|
943
|
+
assert_log_matches(
|
944
|
+
create_cmdline(conf_path),
|
945
|
+
'Invalid option is passed to RUBYOPT',
|
946
|
+
env: { 'RUBYOPT' => 'a' },
|
947
|
+
)
|
948
|
+
end
|
949
|
+
|
950
|
+
# https://github.com/fluent/fluentd/issues/2915
|
951
|
+
test "ruby path contains spaces" do
|
952
|
+
saved_ruby_opt = ENV["RUBYOPT"]
|
953
|
+
ENV["RUBYOPT"] = nil
|
954
|
+
conf = <<CONF
|
955
|
+
<source>
|
956
|
+
@type dummy
|
957
|
+
tag dummy
|
958
|
+
</source>
|
959
|
+
<match>
|
960
|
+
@type null
|
961
|
+
</match>
|
962
|
+
CONF
|
963
|
+
ruby_path = ServerEngine.ruby_bin_path
|
964
|
+
tmp_ruby_path = File.join(TMP_DIR, "ruby with spaces")
|
965
|
+
if Fluent.windows?
|
966
|
+
tmp_ruby_path << ".bat"
|
967
|
+
File.open(tmp_ruby_path, "w") do |file|
|
968
|
+
file.write "#{ruby_path} %*"
|
969
|
+
end
|
970
|
+
else
|
971
|
+
FileUtils.ln_sf(ruby_path, tmp_ruby_path)
|
972
|
+
end
|
973
|
+
ENV["TEST_RUBY_PATH"] = tmp_ruby_path
|
974
|
+
cmd_path = File.expand_path(File.dirname(__FILE__) + "../../../bin/fluentd")
|
975
|
+
conf_path = create_conf_file('space_mixed_ruby_path_test.conf', conf)
|
976
|
+
args = ["bundle", "exec", tmp_ruby_path, cmd_path, "-c", conf_path]
|
977
|
+
assert_log_matches(
|
978
|
+
args,
|
979
|
+
'spawn command to main:',
|
980
|
+
'-Eascii-8bit:ascii-8bit'
|
981
|
+
)
|
982
|
+
ensure
|
983
|
+
ENV["RUBYOPT"] = saved_ruby_opt
|
984
|
+
end
|
985
|
+
|
986
|
+
test 'success to start workers when file buffer is configured in non-workers way only for specific worker' do
|
987
|
+
conf = <<CONF
|
988
|
+
<system>
|
989
|
+
workers 2
|
990
|
+
</system>
|
991
|
+
<source>
|
992
|
+
@type dummy
|
993
|
+
@id dummy
|
994
|
+
tag dummy
|
995
|
+
dummy {"message": "yay!"}
|
996
|
+
</source>
|
997
|
+
<worker 1>
|
998
|
+
<match dummy>
|
999
|
+
@type null
|
1000
|
+
@id blackhole
|
1001
|
+
<buffer>
|
1002
|
+
@type file
|
1003
|
+
path #{File.join(@root_path, "buf")}
|
1004
|
+
</buffer>
|
1005
|
+
</match>
|
1006
|
+
</worker>
|
1007
|
+
CONF
|
1008
|
+
conf_path = create_conf_file('worker_section2.conf', conf)
|
1009
|
+
assert_log_matches(
|
1010
|
+
create_cmdline(conf_path),
|
1011
|
+
"#0 fluentd worker is now running worker=0",
|
1012
|
+
"#1 fluentd worker is now running worker=1",
|
1013
|
+
'#1 adding match pattern="dummy" type="null"'
|
1014
|
+
)
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
test 'success to start workers when configured plugins as a children of MultiOutput only for specific worker do not support multi worker configuration' do
|
1018
|
+
script = <<-EOC
|
1019
|
+
require 'fluent/plugin/output'
|
1020
|
+
module Fluent::Plugin
|
1021
|
+
class SingleOutput < Output
|
1022
|
+
Fluent::Plugin.register_output('single', self)
|
1023
|
+
def multi_workers_ready?
|
1024
|
+
false
|
1025
|
+
end
|
1026
|
+
def write(chunk)
|
1027
|
+
end
|
1028
|
+
end
|
1029
|
+
end
|
1030
|
+
EOC
|
1031
|
+
plugin_path = create_plugin_file('out_single.rb', script)
|
1032
|
+
|
1033
|
+
conf = <<CONF
|
1034
|
+
<system>
|
1035
|
+
workers 2
|
1036
|
+
</system>
|
1037
|
+
<source>
|
1038
|
+
@type dummy
|
1039
|
+
@id dummy
|
1040
|
+
tag dummy
|
1041
|
+
dummy {"message": "yay!"}
|
1042
|
+
</source>
|
1043
|
+
<worker 1>
|
1044
|
+
<match dummy>
|
1045
|
+
@type copy
|
1046
|
+
<store>
|
1047
|
+
@type single
|
1048
|
+
</store>
|
1049
|
+
<store>
|
1050
|
+
@type single
|
1051
|
+
</store>
|
1052
|
+
</match>
|
1053
|
+
</worker>
|
1054
|
+
CONF
|
1055
|
+
conf_path = create_conf_file('worker_section3.conf', conf)
|
1056
|
+
assert_log_matches(
|
1057
|
+
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
1058
|
+
"#0 fluentd worker is now running worker=0",
|
1059
|
+
"#1 fluentd worker is now running worker=1",
|
1060
|
+
'#1 adding match pattern="dummy" type="copy"'
|
1061
|
+
)
|
1062
|
+
end
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
sub_test_case 'config dump' do
|
1066
|
+
test 'all secret parameters in worker section is sealed' do
|
1067
|
+
script = <<-EOC
|
1068
|
+
require 'fluent/plugin/input'
|
1069
|
+
module Fluent::Plugin
|
1070
|
+
class FakeInput < Input
|
1071
|
+
Fluent::Plugin.register_input('fake', self)
|
1072
|
+
config_param :secret, :string, secret: true
|
1073
|
+
def multi_workers_ready?; true; end
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
EOC
|
1077
|
+
plugin_path = create_plugin_file('in_fake.rb', script)
|
1078
|
+
|
1079
|
+
conf = <<CONF
|
1080
|
+
<system>
|
1081
|
+
workers 2
|
1082
|
+
</system>
|
1083
|
+
<worker 0>
|
1084
|
+
<source>
|
1085
|
+
@type fake
|
1086
|
+
secret secret0
|
1087
|
+
</source>
|
1088
|
+
<match>
|
1089
|
+
@type null
|
1090
|
+
</match>
|
1091
|
+
</worker>
|
1092
|
+
<worker 1>
|
1093
|
+
<source>
|
1094
|
+
@type fake
|
1095
|
+
secret secret1
|
1096
|
+
</source>
|
1097
|
+
<match>
|
1098
|
+
@type null
|
1099
|
+
</match>
|
1100
|
+
</worker>
|
1101
|
+
CONF
|
1102
|
+
conf_path = create_conf_file('secret_in_worker.conf', conf)
|
1103
|
+
assert File.exist?(conf_path)
|
1104
|
+
|
1105
|
+
assert_log_matches(create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
1106
|
+
"secret xxxxxx", patterns_not_match: ["secret secret0", "secret secret1"])
|
1107
|
+
end
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
sub_test_case 'sahred socket options' do
|
1111
|
+
test 'enable shared socket by default' do
|
1112
|
+
conf = ""
|
1113
|
+
conf_path = create_conf_file('empty.conf', conf)
|
1114
|
+
assert File.exist?(conf_path)
|
1115
|
+
assert_log_matches(create_cmdline(conf_path),
|
1116
|
+
patterns_not_match: ["shared socket for multiple workers is disabled"])
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
test 'disable shared socket by command line option' do
|
1120
|
+
conf = ""
|
1121
|
+
conf_path = create_conf_file('empty.conf', conf)
|
1122
|
+
assert File.exist?(conf_path)
|
1123
|
+
assert_log_matches(create_cmdline(conf_path, "--disable-shared-socket"),
|
1124
|
+
"shared socket for multiple workers is disabled",)
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
test 'disable shared socket by system config' do
|
1128
|
+
conf = <<CONF
|
1129
|
+
<system>
|
1130
|
+
disable_shared_socket
|
1131
|
+
</system>
|
1132
|
+
CONF
|
1133
|
+
conf_path = create_conf_file('empty.conf', conf)
|
1134
|
+
assert File.exist?(conf_path)
|
1135
|
+
assert_log_matches(create_cmdline(conf_path, "--disable-shared-socket"),
|
1136
|
+
"shared socket for multiple workers is disabled",)
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
end
|