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,923 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/input'
|
3
|
+
require 'fluent/plugin/in_monitor_agent'
|
4
|
+
require 'fluent/engine'
|
5
|
+
require 'fluent/config'
|
6
|
+
require 'fluent/event_router'
|
7
|
+
require 'fluent/supervisor'
|
8
|
+
require 'net/http'
|
9
|
+
require 'json'
|
10
|
+
require_relative '../test_plugin_classes'
|
11
|
+
|
12
|
+
class MonitorAgentInputTest < Test::Unit::TestCase
|
13
|
+
include FuzzyAssert
|
14
|
+
|
15
|
+
CONFIG_DIR = File.expand_path('../tmp/in_monitor_agent', __dir__)
|
16
|
+
|
17
|
+
def setup
|
18
|
+
Fluent::Test.setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_driver(conf = '')
|
22
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::MonitorAgentInput).configure(conf)
|
23
|
+
end
|
24
|
+
|
25
|
+
def configure_ra(ra, conf_str)
|
26
|
+
conf = Fluent::Config.parse(conf_str, "(test)", "(test_dir)", true)
|
27
|
+
ra.configure(conf)
|
28
|
+
ra
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_configure
|
32
|
+
d = create_driver
|
33
|
+
assert_equal("0.0.0.0", d.instance.bind)
|
34
|
+
assert_equal(24220, d.instance.port)
|
35
|
+
assert_equal(nil, d.instance.tag)
|
36
|
+
assert_equal(60, d.instance.emit_interval)
|
37
|
+
assert_true d.instance.include_config
|
38
|
+
end
|
39
|
+
|
40
|
+
sub_test_case "collect in_monitor_agent plugin statistics" do
|
41
|
+
# Input Test Driver does not register metric callbacks.
|
42
|
+
# We should stub them here.
|
43
|
+
class TestEventMetricRouter < Fluent::Test::Driver::TestEventRouter
|
44
|
+
def initialize(driver)
|
45
|
+
super
|
46
|
+
|
47
|
+
raise ArgumentError, "plugin does not respond metric_callback method" unless @driver.instance.respond_to?(:metric_callback)
|
48
|
+
end
|
49
|
+
|
50
|
+
def emit(tag, time, record)
|
51
|
+
super
|
52
|
+
@driver.instance.metric_callback(OneEventStream.new(time, record))
|
53
|
+
end
|
54
|
+
|
55
|
+
def emit_array(tag, array)
|
56
|
+
super
|
57
|
+
@driver.instance.metric_callback(ArrayEventStream.new(array))
|
58
|
+
end
|
59
|
+
|
60
|
+
def emit_stream(tag, es)
|
61
|
+
super
|
62
|
+
@driver.instance.metric_callback(es)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class MetricInputDriver < Fluent::Test::Driver::Input
|
67
|
+
def configure(conf, syntax: :v1)
|
68
|
+
if conf.is_a?(Fluent::Config::Element)
|
69
|
+
@config = conf
|
70
|
+
else
|
71
|
+
@config = Fluent::Config.parse(conf, "(test)", "(test_dir)", syntax: syntax)
|
72
|
+
end
|
73
|
+
|
74
|
+
if @instance.respond_to?(:router=)
|
75
|
+
@event_streams = []
|
76
|
+
@error_events = []
|
77
|
+
|
78
|
+
driver = self
|
79
|
+
mojule = Module.new do
|
80
|
+
define_method(:event_emitter_router) do |label_name|
|
81
|
+
TestEventMetricRouter.new(driver)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
@instance.singleton_class.prepend mojule
|
85
|
+
end
|
86
|
+
|
87
|
+
@instance.configure(@config)
|
88
|
+
self
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
setup do
|
93
|
+
# check @type and type in one configuration
|
94
|
+
conf = <<-EOC
|
95
|
+
<source>
|
96
|
+
@type test_in_gen
|
97
|
+
@id test_in_gen
|
98
|
+
num 10
|
99
|
+
</source>
|
100
|
+
<filter>
|
101
|
+
@type test_filter
|
102
|
+
@id test_filter
|
103
|
+
</filter>
|
104
|
+
<match **>
|
105
|
+
@type relabel
|
106
|
+
@id test_relabel
|
107
|
+
@label @test
|
108
|
+
</match>
|
109
|
+
<label @test>
|
110
|
+
<match **>
|
111
|
+
@type test_out
|
112
|
+
@id test_out
|
113
|
+
</match>
|
114
|
+
</label>
|
115
|
+
<label @copy>
|
116
|
+
<match **>
|
117
|
+
@type copy
|
118
|
+
<store>
|
119
|
+
@type test_out
|
120
|
+
@id copy_out_1
|
121
|
+
</store>
|
122
|
+
<store>
|
123
|
+
@type test_out
|
124
|
+
@id copy_out_2
|
125
|
+
</store>
|
126
|
+
</match>
|
127
|
+
</label>
|
128
|
+
<label @ERROR>
|
129
|
+
<match>
|
130
|
+
@type null
|
131
|
+
@id null
|
132
|
+
</match>
|
133
|
+
</label>
|
134
|
+
EOC
|
135
|
+
@ra = Fluent::RootAgent.new(log: $log)
|
136
|
+
stub(Fluent::Engine).root_agent { @ra }
|
137
|
+
@ra = configure_ra(@ra, conf)
|
138
|
+
end
|
139
|
+
|
140
|
+
data(:with_config_yes => true,
|
141
|
+
:with_config_no => false)
|
142
|
+
def test_enable_input_metrics(with_config)
|
143
|
+
monitor_agent_conf = <<-CONF
|
144
|
+
tag test.monitor
|
145
|
+
emit_interval 1
|
146
|
+
CONF
|
147
|
+
@ra.inputs.first.context_router.emit("test.event", Fluent::Engine.now, {"message":"ok"})
|
148
|
+
d = MetricInputDriver.new(Fluent::Plugin::MonitorAgentInput).configure(monitor_agent_conf)
|
149
|
+
d.run(expect_emits: 1, timeout: 3)
|
150
|
+
|
151
|
+
test_label = @ra.labels['@test']
|
152
|
+
error_label = @ra.labels['@ERROR']
|
153
|
+
input_info = {
|
154
|
+
"output_plugin" => false,
|
155
|
+
"plugin_category"=> "input",
|
156
|
+
"plugin_id" => "test_in_gen",
|
157
|
+
"retry_count" => nil,
|
158
|
+
"type" => "test_in_gen",
|
159
|
+
"emit_records" => 0, # This field is not updated due to not to be assigned metric callback.
|
160
|
+
"emit_size" => 0, # Ditto.
|
161
|
+
}
|
162
|
+
input_info.merge!("config" => {"@id" => "test_in_gen", "@type" => "test_in_gen", "num" => "10"}) if with_config
|
163
|
+
filter_info = {
|
164
|
+
"output_plugin" => false,
|
165
|
+
"plugin_category" => "filter",
|
166
|
+
"plugin_id" => "test_filter",
|
167
|
+
"retry_count" => nil,
|
168
|
+
"type" => "test_filter",
|
169
|
+
"emit_records" => Integer,
|
170
|
+
"emit_size" => Integer,
|
171
|
+
}
|
172
|
+
filter_info.merge!("config" => {"@id" => "test_filter", "@type" => "test_filter"}) if with_config
|
173
|
+
output_info = {
|
174
|
+
"output_plugin" => true,
|
175
|
+
"plugin_category" => "output",
|
176
|
+
"plugin_id" => "test_out",
|
177
|
+
"retry_count" => 0,
|
178
|
+
"type" => "test_out",
|
179
|
+
"emit_count" => Integer,
|
180
|
+
"emit_records" => Integer,
|
181
|
+
"emit_size" => Integer,
|
182
|
+
"write_count" => Integer,
|
183
|
+
"rollback_count" => Integer,
|
184
|
+
"slow_flush_count" => Integer,
|
185
|
+
"flush_time_count" => Integer,
|
186
|
+
}
|
187
|
+
output_info.merge!("config" => {"@id" => "test_out", "@type" => "test_out"}) if with_config
|
188
|
+
error_label_info = {
|
189
|
+
"buffer_queue_length" => 0,
|
190
|
+
"buffer_timekeys" => [],
|
191
|
+
"buffer_total_queued_size" => 0,
|
192
|
+
"output_plugin" => true,
|
193
|
+
"plugin_category" => "output",
|
194
|
+
"plugin_id" => "null",
|
195
|
+
"retry_count" => 0,
|
196
|
+
"type" => "null",
|
197
|
+
"buffer_available_buffer_space_ratios" => Float,
|
198
|
+
"buffer_queue_byte_size" => Integer,
|
199
|
+
"buffer_stage_byte_size" => Integer,
|
200
|
+
"buffer_stage_length" => Integer,
|
201
|
+
"emit_count" => Integer,
|
202
|
+
"emit_records" => Integer,
|
203
|
+
"emit_size" => Integer,
|
204
|
+
"write_count" => Integer,
|
205
|
+
"rollback_count" => Integer,
|
206
|
+
"slow_flush_count" => Integer,
|
207
|
+
"flush_time_count" => Integer,
|
208
|
+
}
|
209
|
+
error_label_info.merge!("config" => {"@id"=>"null", "@type" => "null"}) if with_config
|
210
|
+
opts = {with_config: with_config}
|
211
|
+
assert_equal(input_info, d.instance.get_monitor_info(@ra.inputs.first, opts))
|
212
|
+
assert_fuzzy_equal(filter_info, d.instance.get_monitor_info(@ra.filters.first, opts))
|
213
|
+
assert_fuzzy_equal(output_info, d.instance.get_monitor_info(test_label.outputs.first, opts))
|
214
|
+
assert_fuzzy_equal(error_label_info, d.instance.get_monitor_info(error_label.outputs.first, opts))
|
215
|
+
monitor_agent_emit_info = {
|
216
|
+
"emit_records" => Integer,
|
217
|
+
"emit_size" => Integer,
|
218
|
+
}
|
219
|
+
filter_statistics_info = {
|
220
|
+
"emit_records" => Integer,
|
221
|
+
"emit_size" => Integer,
|
222
|
+
}
|
223
|
+
assert_fuzzy_equal(monitor_agent_emit_info, d.instance.statistics["input"])
|
224
|
+
assert_fuzzy_equal(filter_statistics_info, @ra.filters.first.statistics["filter"])
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
sub_test_case "collect plugin information" do
|
229
|
+
setup do
|
230
|
+
# check @type and type in one configuration
|
231
|
+
conf = <<-EOC
|
232
|
+
<source>
|
233
|
+
@type test_in
|
234
|
+
@id test_in
|
235
|
+
</source>
|
236
|
+
<filter>
|
237
|
+
@type test_filter
|
238
|
+
@id test_filter
|
239
|
+
</filter>
|
240
|
+
<match **>
|
241
|
+
@type relabel
|
242
|
+
@id test_relabel
|
243
|
+
@label @test
|
244
|
+
</match>
|
245
|
+
<label @test>
|
246
|
+
<match **>
|
247
|
+
@type test_out
|
248
|
+
@id test_out
|
249
|
+
</match>
|
250
|
+
</label>
|
251
|
+
<label @copy>
|
252
|
+
<match **>
|
253
|
+
@type copy
|
254
|
+
<store>
|
255
|
+
@type test_out
|
256
|
+
@id copy_out_1
|
257
|
+
</store>
|
258
|
+
<store>
|
259
|
+
@type test_out
|
260
|
+
@id copy_out_2
|
261
|
+
</store>
|
262
|
+
</match>
|
263
|
+
</label>
|
264
|
+
<label @ERROR>
|
265
|
+
<match>
|
266
|
+
@type null
|
267
|
+
@id null
|
268
|
+
</match>
|
269
|
+
</label>
|
270
|
+
EOC
|
271
|
+
@ra = Fluent::RootAgent.new(log: $log)
|
272
|
+
stub(Fluent::Engine).root_agent { @ra }
|
273
|
+
@ra = configure_ra(@ra, conf)
|
274
|
+
end
|
275
|
+
|
276
|
+
test "plugin_category" do
|
277
|
+
d = create_driver
|
278
|
+
test_label = @ra.labels['@test']
|
279
|
+
error_label = @ra.labels['@ERROR']
|
280
|
+
assert_equal("input", d.instance.plugin_category(@ra.inputs.first))
|
281
|
+
assert_equal("filter", d.instance.plugin_category(@ra.filters.first))
|
282
|
+
assert_equal("output", d.instance.plugin_category(test_label.outputs.first))
|
283
|
+
assert_equal("output", d.instance.plugin_category(error_label.outputs.first))
|
284
|
+
end
|
285
|
+
|
286
|
+
data(:with_config_yes => true,
|
287
|
+
:with_config_no => false)
|
288
|
+
test "get_monitor_info" do |with_config|
|
289
|
+
d = create_driver
|
290
|
+
test_label = @ra.labels['@test']
|
291
|
+
error_label = @ra.labels['@ERROR']
|
292
|
+
input_info = {
|
293
|
+
"output_plugin" => false,
|
294
|
+
"plugin_category"=> "input",
|
295
|
+
"plugin_id" => "test_in",
|
296
|
+
"retry_count" => nil,
|
297
|
+
"type" => "test_in",
|
298
|
+
"emit_records" => 0,
|
299
|
+
"emit_size" => 0,
|
300
|
+
}
|
301
|
+
input_info.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
|
302
|
+
filter_info = {
|
303
|
+
"output_plugin" => false,
|
304
|
+
"plugin_category" => "filter",
|
305
|
+
"plugin_id" => "test_filter",
|
306
|
+
"retry_count" => nil,
|
307
|
+
"type" => "test_filter",
|
308
|
+
"emit_records" => 0,
|
309
|
+
"emit_size" => 0,
|
310
|
+
}
|
311
|
+
filter_info.merge!("config" => {"@id" => "test_filter", "@type" => "test_filter"}) if with_config
|
312
|
+
output_info = {
|
313
|
+
"output_plugin" => true,
|
314
|
+
"plugin_category" => "output",
|
315
|
+
"plugin_id" => "test_out",
|
316
|
+
"retry_count" => 0,
|
317
|
+
"type" => "test_out",
|
318
|
+
"emit_count" => Integer,
|
319
|
+
"emit_records" => Integer,
|
320
|
+
"emit_size" => Integer,
|
321
|
+
"write_count" => Integer,
|
322
|
+
"rollback_count" => Integer,
|
323
|
+
"slow_flush_count" => Integer,
|
324
|
+
"flush_time_count" => Integer,
|
325
|
+
}
|
326
|
+
output_info.merge!("config" => {"@id" => "test_out", "@type" => "test_out"}) if with_config
|
327
|
+
error_label_info = {
|
328
|
+
"buffer_queue_length" => 0,
|
329
|
+
"buffer_timekeys" => [],
|
330
|
+
"buffer_total_queued_size" => 0,
|
331
|
+
"output_plugin" => true,
|
332
|
+
"plugin_category" => "output",
|
333
|
+
"plugin_id" => "null",
|
334
|
+
"retry_count" => 0,
|
335
|
+
"type" => "null",
|
336
|
+
"buffer_available_buffer_space_ratios" => Float,
|
337
|
+
"buffer_queue_byte_size" => Integer,
|
338
|
+
"buffer_stage_byte_size" => Integer,
|
339
|
+
"buffer_stage_length" => Integer,
|
340
|
+
"emit_count" => Integer,
|
341
|
+
"emit_records" => Integer,
|
342
|
+
"emit_size" => Integer,
|
343
|
+
"write_count" => Integer,
|
344
|
+
"rollback_count" => Integer,
|
345
|
+
"slow_flush_count" => Integer,
|
346
|
+
"flush_time_count" => Integer,
|
347
|
+
}
|
348
|
+
error_label_info.merge!("config" => {"@id"=>"null", "@type" => "null"}) if with_config
|
349
|
+
opts = {with_config: with_config}
|
350
|
+
assert_equal(input_info, d.instance.get_monitor_info(@ra.inputs.first, opts))
|
351
|
+
assert_fuzzy_equal(filter_info, d.instance.get_monitor_info(@ra.filters.first, opts))
|
352
|
+
assert_fuzzy_equal(output_info, d.instance.get_monitor_info(test_label.outputs.first, opts))
|
353
|
+
assert_fuzzy_equal(error_label_info, d.instance.get_monitor_info(error_label.outputs.first, opts))
|
354
|
+
end
|
355
|
+
|
356
|
+
test "fluentd opts" do
|
357
|
+
d = create_driver
|
358
|
+
opts = Fluent::Supervisor.default_options
|
359
|
+
|
360
|
+
filepath = nil
|
361
|
+
begin
|
362
|
+
FileUtils.mkdir_p(CONFIG_DIR)
|
363
|
+
filepath = File.expand_path('fluentd.conf', CONFIG_DIR)
|
364
|
+
FileUtils.touch(filepath)
|
365
|
+
s = Fluent::Supervisor.new(opts.merge(config_path: filepath))
|
366
|
+
s.configure
|
367
|
+
ensure
|
368
|
+
FileUtils.rm_r(CONFIG_DIR) rescue _
|
369
|
+
end
|
370
|
+
|
371
|
+
expected_opts = {
|
372
|
+
"config_path" => filepath,
|
373
|
+
"pid_file" => nil,
|
374
|
+
"plugin_dirs" => ["/etc/fluent/plugin"],
|
375
|
+
"log_path" => nil,
|
376
|
+
"root_dir" => nil,
|
377
|
+
}
|
378
|
+
assert_equal(expected_opts, d.instance.fluentd_opts)
|
379
|
+
end
|
380
|
+
|
381
|
+
test "all_plugins" do
|
382
|
+
d = create_driver
|
383
|
+
plugins = []
|
384
|
+
d.instance.all_plugins.each {|plugin| plugins << plugin.class }
|
385
|
+
assert_equal([FluentTest::FluentTestInput,
|
386
|
+
Fluent::Plugin::RelabelOutput,
|
387
|
+
FluentTest::FluentTestFilter,
|
388
|
+
FluentTest::FluentTestOutput, # in label @test
|
389
|
+
Fluent::Plugin::CopyOutput,
|
390
|
+
FluentTest::FluentTestOutput, # in label @copy 1
|
391
|
+
FluentTest::FluentTestOutput, # in label @copy 2
|
392
|
+
Fluent::Plugin::NullOutput], plugins)
|
393
|
+
end
|
394
|
+
|
395
|
+
test "emit" do
|
396
|
+
port = unused_port
|
397
|
+
d = create_driver("
|
398
|
+
@type monitor_agent
|
399
|
+
bind '127.0.0.1'
|
400
|
+
port #{port}
|
401
|
+
tag monitor
|
402
|
+
emit_interval 1
|
403
|
+
")
|
404
|
+
d.instance.start
|
405
|
+
d.end_if do
|
406
|
+
d.events.size >= 5
|
407
|
+
end
|
408
|
+
d.run
|
409
|
+
expect_relabel_record = {
|
410
|
+
"plugin_id" => "test_relabel",
|
411
|
+
"plugin_category" => "output",
|
412
|
+
"type" => "relabel",
|
413
|
+
"output_plugin" => true,
|
414
|
+
"retry_count" => 0,
|
415
|
+
"emit_count" => Integer,
|
416
|
+
"emit_records" => Integer,
|
417
|
+
"emit_size" => Integer,
|
418
|
+
"write_count" => Integer,
|
419
|
+
"rollback_count" => Integer,
|
420
|
+
"slow_flush_count" => Integer,
|
421
|
+
"flush_time_count" => Integer,
|
422
|
+
}
|
423
|
+
expect_test_out_record = {
|
424
|
+
"plugin_id" => "test_out",
|
425
|
+
"plugin_category" => "output",
|
426
|
+
"type" => "test_out",
|
427
|
+
"output_plugin" => true,
|
428
|
+
"retry_count" => 0,
|
429
|
+
"emit_count" => Integer,
|
430
|
+
"emit_records" => Integer,
|
431
|
+
"emit_size" => Integer,
|
432
|
+
"write_count" => Integer,
|
433
|
+
"rollback_count" => Integer,
|
434
|
+
"slow_flush_count" => Integer,
|
435
|
+
"flush_time_count" => Integer,
|
436
|
+
}
|
437
|
+
assert_fuzzy_equal(expect_relabel_record, d.events[1][2])
|
438
|
+
assert_fuzzy_equal(expect_test_out_record, d.events[3][2])
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
def get(uri, header = {})
|
443
|
+
url = URI.parse(uri)
|
444
|
+
req = Net::HTTP::Get.new(url, header)
|
445
|
+
unless header.has_key?('Content-Type')
|
446
|
+
header['Content-Type'] = 'application/octet-stream'
|
447
|
+
end
|
448
|
+
Net::HTTP.start(url.host, url.port) {|http|
|
449
|
+
http.request(req)
|
450
|
+
}
|
451
|
+
end
|
452
|
+
|
453
|
+
sub_test_case "servlets" do
|
454
|
+
setup do
|
455
|
+
@port = unused_port
|
456
|
+
# check @type and type in one configuration
|
457
|
+
conf = <<-EOC
|
458
|
+
<source>
|
459
|
+
@type test_in
|
460
|
+
@id test_in
|
461
|
+
</source>
|
462
|
+
<source>
|
463
|
+
@type monitor_agent
|
464
|
+
bind "127.0.0.1"
|
465
|
+
port #{@port}
|
466
|
+
tag monitor
|
467
|
+
@id monitor_agent
|
468
|
+
</source>
|
469
|
+
<filter>
|
470
|
+
@type test_filter
|
471
|
+
@id test_filter
|
472
|
+
</filter>
|
473
|
+
<match **>
|
474
|
+
@type relabel
|
475
|
+
@id test_relabel
|
476
|
+
@label @test
|
477
|
+
</match>
|
478
|
+
<label @test>
|
479
|
+
<match **>
|
480
|
+
@type test_out
|
481
|
+
@id test_out
|
482
|
+
</match>
|
483
|
+
</label>
|
484
|
+
<label @ERROR>
|
485
|
+
<match>
|
486
|
+
@type null
|
487
|
+
@id null
|
488
|
+
</match>
|
489
|
+
</label>
|
490
|
+
EOC
|
491
|
+
|
492
|
+
|
493
|
+
begin
|
494
|
+
@ra = Fluent::RootAgent.new(log: $log)
|
495
|
+
stub(Fluent::Engine).root_agent { @ra }
|
496
|
+
@ra = configure_ra(@ra, conf)
|
497
|
+
# store Supervisor instance to avoid collected by GC
|
498
|
+
|
499
|
+
FileUtils.mkdir_p(CONFIG_DIR)
|
500
|
+
@filepath = File.expand_path('fluentd.conf', CONFIG_DIR)
|
501
|
+
File.open(@filepath, 'w') do |v|
|
502
|
+
v.puts(conf)
|
503
|
+
end
|
504
|
+
|
505
|
+
@supervisor = Fluent::Supervisor.new(Fluent::Supervisor.default_options.merge(config_path: @filepath))
|
506
|
+
@supervisor.configure
|
507
|
+
ensure
|
508
|
+
FileUtils.rm_r(CONFIG_DIR) rescue _
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
512
|
+
test "/api/plugins" do
|
513
|
+
d = create_driver("
|
514
|
+
@type monitor_agent
|
515
|
+
bind '127.0.0.1'
|
516
|
+
port #{@port}
|
517
|
+
tag monitor
|
518
|
+
")
|
519
|
+
d.instance.start
|
520
|
+
expected_test_in_response = "\
|
521
|
+
plugin_id:test_in\tplugin_category:input\ttype:test_in\toutput_plugin:false\tretry_count:\temit_records:0\temit_size:0"
|
522
|
+
expected_test_filter_response = "\
|
523
|
+
plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:false\tretry_count:\temit_records:0\temit_size:0"
|
524
|
+
|
525
|
+
response = get("http://127.0.0.1:#{@port}/api/plugins").body
|
526
|
+
test_in = response.split("\n")[0]
|
527
|
+
test_filter = response.split("\n")[3]
|
528
|
+
assert_equal(expected_test_in_response, test_in)
|
529
|
+
assert_equal(expected_test_filter_response, test_filter)
|
530
|
+
end
|
531
|
+
|
532
|
+
data(:include_config_and_retry_yes => [true, true, "include_config yes", "include_retry yes"],
|
533
|
+
:include_config_and_retry_no => [false, false, "include_config no", "include_retry no"],)
|
534
|
+
test "/api/plugins.json" do |(with_config, with_retry, include_conf, retry_conf)|
|
535
|
+
d = create_driver("
|
536
|
+
@type monitor_agent
|
537
|
+
bind '127.0.0.1'
|
538
|
+
port #{@port}
|
539
|
+
tag monitor
|
540
|
+
#{include_conf}
|
541
|
+
#{retry_conf}
|
542
|
+
")
|
543
|
+
d.instance.start
|
544
|
+
expected_test_in_response = {
|
545
|
+
"output_plugin" => false,
|
546
|
+
"plugin_category" => "input",
|
547
|
+
"plugin_id" => "test_in",
|
548
|
+
"retry_count" => nil,
|
549
|
+
"type" => "test_in",
|
550
|
+
"emit_records" => 0,
|
551
|
+
"emit_size" => 0,
|
552
|
+
}
|
553
|
+
expected_test_in_response.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
|
554
|
+
expected_null_response = {
|
555
|
+
"buffer_queue_length" => 0,
|
556
|
+
"buffer_timekeys" => [],
|
557
|
+
"buffer_total_queued_size" => 0,
|
558
|
+
"output_plugin" => true,
|
559
|
+
"plugin_category" => "output",
|
560
|
+
"plugin_id" => "null",
|
561
|
+
"retry_count" => 0,
|
562
|
+
"type" => "null",
|
563
|
+
"buffer_available_buffer_space_ratios" => Float,
|
564
|
+
"buffer_queue_byte_size" => Integer,
|
565
|
+
"buffer_stage_byte_size" => Integer,
|
566
|
+
"buffer_stage_length" => Integer,
|
567
|
+
"emit_count" => Integer,
|
568
|
+
"emit_records" => Integer,
|
569
|
+
"emit_size" => Integer,
|
570
|
+
"write_count" => Integer,
|
571
|
+
"rollback_count" => Integer,
|
572
|
+
"slow_flush_count" => Integer,
|
573
|
+
"flush_time_count" => Integer,
|
574
|
+
}
|
575
|
+
expected_null_response.merge!("config" => {"@id" => "null", "@type" => "null"}) if with_config
|
576
|
+
expected_null_response.merge!("retry" => {}) if with_retry
|
577
|
+
response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json").body)
|
578
|
+
test_in_response = response["plugins"][0]
|
579
|
+
null_response = response["plugins"][5]
|
580
|
+
assert_equal(expected_test_in_response, test_in_response)
|
581
|
+
assert_fuzzy_equal(expected_null_response, null_response)
|
582
|
+
end
|
583
|
+
|
584
|
+
test "/api/plugins.json/not_found" do
|
585
|
+
d = create_driver("
|
586
|
+
@type monitor_agent
|
587
|
+
bind '127.0.0.1'
|
588
|
+
port #{@port}
|
589
|
+
tag monitor
|
590
|
+
")
|
591
|
+
d.instance.start
|
592
|
+
resp = get("http://127.0.0.1:#{@port}/api/plugins.json/not_found")
|
593
|
+
assert_equal('404', resp.code)
|
594
|
+
body = JSON.parse(resp.body)
|
595
|
+
assert_equal(body['message'], 'Not found')
|
596
|
+
end
|
597
|
+
|
598
|
+
data(:with_config_and_retry_yes => [true, true, "?with_config=yes&with_retry"],
|
599
|
+
:with_config_and_retry_no => [false, false, "?with_config=no&with_retry=no"])
|
600
|
+
test "/api/plugins.json with query parameter. query parameter is preferred than include_config" do |(with_config, with_retry, query_param)|
|
601
|
+
|
602
|
+
d = create_driver("
|
603
|
+
@type monitor_agent
|
604
|
+
bind '127.0.0.1'
|
605
|
+
port #{@port}
|
606
|
+
tag monitor
|
607
|
+
")
|
608
|
+
d.instance.start
|
609
|
+
expected_test_in_response = {
|
610
|
+
"output_plugin" => false,
|
611
|
+
"plugin_category" => "input",
|
612
|
+
"plugin_id" => "test_in",
|
613
|
+
"retry_count" => nil,
|
614
|
+
"type" => "test_in",
|
615
|
+
"emit_records" => 0,
|
616
|
+
"emit_size" => 0,
|
617
|
+
}
|
618
|
+
expected_test_in_response.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
|
619
|
+
expected_null_response = {
|
620
|
+
"buffer_queue_length" => 0,
|
621
|
+
"buffer_timekeys" => [],
|
622
|
+
"buffer_total_queued_size" => 0,
|
623
|
+
"output_plugin" => true,
|
624
|
+
"plugin_category" => "output",
|
625
|
+
"plugin_id" => "null",
|
626
|
+
"retry_count" => 0,
|
627
|
+
"type" => "null",
|
628
|
+
"buffer_available_buffer_space_ratios" => Float,
|
629
|
+
"buffer_queue_byte_size" => Integer,
|
630
|
+
"buffer_stage_byte_size" => Integer,
|
631
|
+
"buffer_stage_length" => Integer,
|
632
|
+
"emit_count" => Integer,
|
633
|
+
"emit_records" => Integer,
|
634
|
+
"emit_size" => Integer,
|
635
|
+
"write_count" => Integer,
|
636
|
+
"rollback_count" => Integer,
|
637
|
+
"slow_flush_count" => Integer,
|
638
|
+
"flush_time_count" => Integer,
|
639
|
+
}
|
640
|
+
expected_null_response.merge!("config" => {"@id" => "null", "@type" => "null"}) if with_config
|
641
|
+
expected_null_response.merge!("retry" => {}) if with_retry
|
642
|
+
response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json#{query_param}").body)
|
643
|
+
test_in_response = response["plugins"][0]
|
644
|
+
null_response = response["plugins"][5]
|
645
|
+
assert_equal(expected_test_in_response, test_in_response)
|
646
|
+
assert_fuzzy_include(expected_null_response, null_response)
|
647
|
+
end
|
648
|
+
|
649
|
+
test "/api/plugins.json with 'with_ivars'. response contains specified instance variables of each plugin" do
|
650
|
+
d = create_driver("
|
651
|
+
@type monitor_agent
|
652
|
+
bind '127.0.0.1'
|
653
|
+
port #{@port}
|
654
|
+
tag monitor
|
655
|
+
")
|
656
|
+
d.instance.start
|
657
|
+
expected_test_in_response = {
|
658
|
+
"output_plugin" => false,
|
659
|
+
"plugin_category" => "input",
|
660
|
+
"plugin_id" => "test_in",
|
661
|
+
"retry_count" => nil,
|
662
|
+
"type" => "test_in",
|
663
|
+
"instance_variables" => {"id" => "test_in"},
|
664
|
+
"emit_records" => 0,
|
665
|
+
"emit_size" => 0,
|
666
|
+
}
|
667
|
+
expected_null_response = {
|
668
|
+
"buffer_queue_length" => 0,
|
669
|
+
"buffer_timekeys" => [],
|
670
|
+
"buffer_total_queued_size" => 0,
|
671
|
+
"output_plugin" => true,
|
672
|
+
"plugin_category" => "output",
|
673
|
+
"plugin_id" => "null",
|
674
|
+
"retry_count" => 0,
|
675
|
+
"type" => "null",
|
676
|
+
"instance_variables" => {"id" => "null"},
|
677
|
+
"buffer_available_buffer_space_ratios" => Float,
|
678
|
+
"buffer_queue_byte_size" => Integer,
|
679
|
+
"buffer_stage_byte_size" => Integer,
|
680
|
+
"buffer_stage_length" => Integer,
|
681
|
+
"emit_count" => Integer,
|
682
|
+
"emit_records" => Integer,
|
683
|
+
"emit_size" => Integer,
|
684
|
+
"write_count" => Integer,
|
685
|
+
"rollback_count" => Integer,
|
686
|
+
"slow_flush_count" => Integer,
|
687
|
+
"flush_time_count" => Integer,
|
688
|
+
}
|
689
|
+
response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json?with_config=no&with_retry=no&with_ivars=id,num_errors").body)
|
690
|
+
test_in_response = response["plugins"][0]
|
691
|
+
null_response = response["plugins"][5]
|
692
|
+
assert_equal(expected_test_in_response, test_in_response)
|
693
|
+
assert_fuzzy_equal(expected_null_response, null_response)
|
694
|
+
end
|
695
|
+
|
696
|
+
test "/api/config" do
|
697
|
+
d = create_driver("
|
698
|
+
@type monitor_agent
|
699
|
+
bind '127.0.0.1'
|
700
|
+
port #{@port}
|
701
|
+
tag monitor
|
702
|
+
")
|
703
|
+
d.instance.start
|
704
|
+
expected_response_regex = %r{pid:\d+\tppid:\d+\tversion:#{Fluent::VERSION}\tconfig_path:#{@filepath}\tpid_file:\tplugin_dirs:/etc/fluent/plugin\tlog_path:}
|
705
|
+
assert_match(expected_response_regex,
|
706
|
+
get("http://127.0.0.1:#{@port}/api/config").body)
|
707
|
+
end
|
708
|
+
|
709
|
+
test "/api/config.json" do
|
710
|
+
d = create_driver("
|
711
|
+
@type monitor_agent
|
712
|
+
bind '127.0.0.1'
|
713
|
+
port #{@port}
|
714
|
+
tag monitor
|
715
|
+
")
|
716
|
+
d.instance.start
|
717
|
+
res = JSON.parse(get("http://127.0.0.1:#{@port}/api/config.json").body)
|
718
|
+
assert_equal(@filepath, res["config_path"])
|
719
|
+
assert_nil(res["pid_file"])
|
720
|
+
assert_equal(["/etc/fluent/plugin"], res["plugin_dirs"])
|
721
|
+
assert_nil(res["log_path"])
|
722
|
+
assert_equal(Fluent::VERSION, res["version"])
|
723
|
+
end
|
724
|
+
|
725
|
+
test "/api/config.json?debug=1" do
|
726
|
+
d = create_driver("
|
727
|
+
@type monitor_agent
|
728
|
+
bind '127.0.0.1'
|
729
|
+
port #{@port}
|
730
|
+
tag monitor
|
731
|
+
")
|
732
|
+
d.instance.start
|
733
|
+
# To check pretty print
|
734
|
+
assert_true !get("http://127.0.0.1:#{@port}/api/config.json").body.include?("\n")
|
735
|
+
assert_true get("http://127.0.0.1:#{@port}/api/config.json?debug=1").body.include?("\n")
|
736
|
+
end
|
737
|
+
|
738
|
+
test "/api/config.json/not_found" do
|
739
|
+
d = create_driver("
|
740
|
+
@type monitor_agent
|
741
|
+
bind '127.0.0.1'
|
742
|
+
port #{@port}
|
743
|
+
tag monitor
|
744
|
+
")
|
745
|
+
d.instance.start
|
746
|
+
resp = get("http://127.0.0.1:#{@port}/api/config.json/not_found")
|
747
|
+
assert_equal('404', resp.code)
|
748
|
+
body = JSON.parse(resp.body)
|
749
|
+
assert_equal(body['message'], 'Not found')
|
750
|
+
end
|
751
|
+
end
|
752
|
+
|
753
|
+
sub_test_case "check retry of buffered plugins" do
|
754
|
+
class FluentTestFailWriteOutput < ::Fluent::Plugin::Output
|
755
|
+
::Fluent::Plugin.register_output('test_out_fail_write', self)
|
756
|
+
|
757
|
+
def write(chunk)
|
758
|
+
raise "chunk error!"
|
759
|
+
end
|
760
|
+
end
|
761
|
+
|
762
|
+
setup do
|
763
|
+
@port = unused_port
|
764
|
+
# check @type and type in one configuration
|
765
|
+
conf = <<-EOC
|
766
|
+
<source>
|
767
|
+
@type monitor_agent
|
768
|
+
@id monitor_agent
|
769
|
+
bind "127.0.0.1"
|
770
|
+
port #{@port}
|
771
|
+
</source>
|
772
|
+
<match **>
|
773
|
+
@type test_out_fail_write
|
774
|
+
@id test_out_fail_write
|
775
|
+
<buffer time>
|
776
|
+
timekey 1m
|
777
|
+
flush_mode immediate
|
778
|
+
</buffer>
|
779
|
+
</match>
|
780
|
+
EOC
|
781
|
+
@ra = Fluent::RootAgent.new(log: $log)
|
782
|
+
stub(Fluent::Engine).root_agent { @ra }
|
783
|
+
@ra = configure_ra(@ra, conf)
|
784
|
+
end
|
785
|
+
|
786
|
+
test "/api/plugins.json retry object should be filled if flush was failed" do
|
787
|
+
|
788
|
+
d = create_driver("
|
789
|
+
@type monitor_agent
|
790
|
+
bind '127.0.0.1'
|
791
|
+
port #{@port}
|
792
|
+
include_config no
|
793
|
+
")
|
794
|
+
d.instance.start
|
795
|
+
output = @ra.outputs[0]
|
796
|
+
output.start
|
797
|
+
output.after_start
|
798
|
+
expected_test_out_fail_write_response = {
|
799
|
+
"buffer_queue_length" => 1,
|
800
|
+
"buffer_timekeys" => [output.calculate_timekey(event_time)],
|
801
|
+
"buffer_total_queued_size" => 40,
|
802
|
+
"output_plugin" => true,
|
803
|
+
"plugin_category" => "output",
|
804
|
+
"plugin_id" => "test_out_fail_write",
|
805
|
+
"type" => "test_out_fail_write",
|
806
|
+
"buffer_newest_timekey" => output.calculate_timekey(event_time),
|
807
|
+
"buffer_oldest_timekey" => output.calculate_timekey(event_time),
|
808
|
+
"buffer_available_buffer_space_ratios" => Float,
|
809
|
+
"buffer_queue_byte_size" => Integer,
|
810
|
+
"buffer_stage_byte_size" => Integer,
|
811
|
+
"buffer_stage_length" => Integer,
|
812
|
+
"emit_count" => Integer,
|
813
|
+
"emit_records" => Integer,
|
814
|
+
"emit_size" => Integer,
|
815
|
+
"write_count" => Integer,
|
816
|
+
"rollback_count" => Integer,
|
817
|
+
'slow_flush_count' => Integer,
|
818
|
+
'flush_time_count' => Integer,
|
819
|
+
}
|
820
|
+
output.emit_events('test.tag', Fluent::ArrayEventStream.new([[event_time, {"message" => "test failed flush 1"}]]))
|
821
|
+
# flush few times to check steps
|
822
|
+
2.times do
|
823
|
+
output.force_flush
|
824
|
+
# output.force_flush calls #submit_flush_all, but #submit_flush_all skips to call #submit_flush_once when @retry exists.
|
825
|
+
# So that forced flush in retry state should be done by calling #submit_flush_once directly.
|
826
|
+
output.submit_flush_once
|
827
|
+
sleep 0.1 until output.buffer.queued?
|
828
|
+
end
|
829
|
+
response = JSON.parse(get("http://127.0.0.1:#{@port}/api/plugins.json").body)
|
830
|
+
test_out_fail_write_response = response["plugins"][1]
|
831
|
+
# remove dynamic keys
|
832
|
+
response_retry_count = test_out_fail_write_response.delete("retry_count")
|
833
|
+
response_retry = test_out_fail_write_response.delete("retry")
|
834
|
+
assert_fuzzy_equal(expected_test_out_fail_write_response, test_out_fail_write_response)
|
835
|
+
assert{ response_retry.has_key?("steps") }
|
836
|
+
# it's very hard to check exact retry count (because retries are called by output flush thread scheduling)
|
837
|
+
assert{ response_retry_count >= 1 && response_retry["steps"] >= 0 }
|
838
|
+
assert{ response_retry_count == response_retry["steps"] + 1 }
|
839
|
+
end
|
840
|
+
end
|
841
|
+
|
842
|
+
sub_test_case "check the port number of http server" do
|
843
|
+
test "on single worker environment" do
|
844
|
+
port = unused_port
|
845
|
+
d = create_driver("
|
846
|
+
@type monitor_agent
|
847
|
+
bind '127.0.0.1'
|
848
|
+
port #{port}
|
849
|
+
")
|
850
|
+
d.instance.start
|
851
|
+
assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins").code)
|
852
|
+
end
|
853
|
+
|
854
|
+
test "worker_id = 2 on multi worker environment" do
|
855
|
+
port = unused_port
|
856
|
+
Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
|
857
|
+
d = Fluent::Test::Driver::Input.new(Fluent::Plugin::MonitorAgentInput)
|
858
|
+
d.instance.instance_eval{ @_fluentd_worker_id = 2 }
|
859
|
+
d.configure("
|
860
|
+
@type monitor_agent
|
861
|
+
bind '127.0.0.1'
|
862
|
+
port #{port - 2}
|
863
|
+
")
|
864
|
+
d.instance.start
|
865
|
+
end
|
866
|
+
assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins").code)
|
867
|
+
end
|
868
|
+
end
|
869
|
+
|
870
|
+
sub_test_case "check NoMethodError does not happen" do
|
871
|
+
class FluentTestBufferVariableOutput < ::Fluent::Plugin::Output
|
872
|
+
::Fluent::Plugin.register_output('test_out_buffer_variable', self)
|
873
|
+
def configure(conf)
|
874
|
+
super
|
875
|
+
@buffer = []
|
876
|
+
end
|
877
|
+
|
878
|
+
def write(chunk)
|
879
|
+
end
|
880
|
+
end
|
881
|
+
class FluentTestBufferVariableFilter < ::Fluent::Plugin::Filter
|
882
|
+
::Fluent::Plugin.register_filter("test_filter_buffer_variable", self)
|
883
|
+
def initialize
|
884
|
+
super
|
885
|
+
@buffer = {}
|
886
|
+
end
|
887
|
+
def filter(tag, time, record)
|
888
|
+
record
|
889
|
+
end
|
890
|
+
end
|
891
|
+
|
892
|
+
setup do
|
893
|
+
conf = <<-EOC
|
894
|
+
<match **>
|
895
|
+
@type test_out_buffer_variable
|
896
|
+
@id test_out_buffer_variable
|
897
|
+
</match>
|
898
|
+
<filter **>
|
899
|
+
@type test_filter_buffer_variable
|
900
|
+
@id test_filter_buffer_variable
|
901
|
+
</filter>
|
902
|
+
EOC
|
903
|
+
@ra = Fluent::RootAgent.new(log: $log)
|
904
|
+
stub(Fluent::Engine).root_agent { @ra }
|
905
|
+
@ra = configure_ra(@ra, conf)
|
906
|
+
end
|
907
|
+
|
908
|
+
test "plugins have a variable named buffer does not throws NoMethodError" do
|
909
|
+
port = unused_port
|
910
|
+
d = create_driver("
|
911
|
+
@type monitor_agent
|
912
|
+
bind '127.0.0.1'
|
913
|
+
port #{port}
|
914
|
+
include_config no
|
915
|
+
")
|
916
|
+
d.instance.start
|
917
|
+
|
918
|
+
assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins.json").code)
|
919
|
+
assert{ d.logs.none?{|log| log.include?("NoMethodError") } }
|
920
|
+
assert_equal(false, d.instance.instance_variable_get(:@first_warn))
|
921
|
+
end
|
922
|
+
end
|
923
|
+
end
|