fluentd222 1.16.2-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.deepsource.toml +13 -0
 - data/.github/ISSUE_TEMPLATE/bug_report.yaml +71 -0
 - data/.github/ISSUE_TEMPLATE/config.yml +5 -0
 - data/.github/ISSUE_TEMPLATE/feature_request.yaml +39 -0
 - data/.github/ISSUE_TEMPLATE.md +17 -0
 - data/.github/PULL_REQUEST_TEMPLATE.md +14 -0
 - data/.github/workflows/stale-actions.yml +24 -0
 - data/.github/workflows/test-ruby-head.yaml +31 -0
 - data/.github/workflows/test.yaml +32 -0
 - data/.gitignore +30 -0
 - data/ADOPTERS.md +5 -0
 - data/AUTHORS +2 -0
 - data/CHANGELOG.md +2720 -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 +13 -0
 - data/README.md +75 -0
 - data/Rakefile +79 -0
 - data/SECURITY.md +14 -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 +54 -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 +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 +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 +108 -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 +13 -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 +37 -0
 - data/lib/fluent/event.rb +330 -0
 - data/lib/fluent/event_router.rb +315 -0
 - data/lib/fluent/ext_monitor_require.rb +28 -0
 - data/lib/fluent/file_wrapper.rb +137 -0
 - data/lib/fluent/filter.rb +21 -0
 - data/lib/fluent/fluent_log_event_router.rb +139 -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/console_adapter.rb +66 -0
 - data/lib/fluent/log.rb +752 -0
 - data/lib/fluent/match.rb +187 -0
 - data/lib/fluent/mixin.rb +31 -0
 - data/lib/fluent/msgpack_factory.rb +111 -0
 - data/lib/fluent/oj_options.rb +61 -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 +214 -0
 - data/lib/fluent/plugin/buf_file.rb +242 -0
 - data/lib/fluent/plugin/buf_file_single.rb +254 -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 +310 -0
 - data/lib/fluent/plugin/buffer/memory_chunk.rb +91 -0
 - data/lib/fluent/plugin/buffer.rb +941 -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/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 +269 -0
 - data/lib/fluent/plugin/in_tail.rb +1299 -0
 - data/lib/fluent/plugin/in_tcp.rb +226 -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 +340 -0
 - data/lib/fluent/plugin/out_forward/ack_handler.rb +176 -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 +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 +148 -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 +1603 -0
 - data/lib/fluent/plugin/owned_by_mixin.rb +41 -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 +369 -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 +94 -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 +828 -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 +1076 -0
 - data/lib/fluent/system_config.rb +189 -0
 - data/lib/fluent/test/base.rb +78 -0
 - data/lib/fluent/test/driver/base.rb +231 -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 +61 -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 +44 -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/win32api.rb +38 -0
 - data/lib/fluent/winsvc.rb +100 -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 +7 -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 +1291 -0
 - data/test/command/test_plugin_config_formatter.rb +397 -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 +195 -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/log/test_console_adapter.rb +110 -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 +346 -0
 - data/test/plugin/out_forward/test_ack_handler.rb +140 -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 +247 -0
 - data/test/plugin/test_buf_file.rb +1314 -0
 - data/test/plugin/test_buf_file_single.rb +898 -0
 - data/test/plugin/test_buf_memory.rb +42 -0
 - data/test/plugin/test_buffer.rb +1434 -0
 - data/test/plugin/test_buffer_chunk.rb +209 -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_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 +1102 -0
 - data/test/plugin/test_in_monitor_agent.rb +922 -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 +3125 -0
 - data/test/plugin/test_in_tcp.rb +328 -0
 - data/test/plugin/test_in_udp.rb +296 -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 +1038 -0
 - data/test/plugin/test_out_forward.rb +1361 -0
 - data/test/plugin/test_out_http.rb +429 -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 +1334 -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 +179 -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 +34 -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 +284 -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 +166 -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 +862 -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 +1895 -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 +369 -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_file_wrapper.rb +53 -0
 - data/test/test_filter.rb +121 -0
 - data/test/test_fluent_log_event_router.rb +99 -0
 - data/test/test_formatter.rb +369 -0
 - data/test/test_input.rb +31 -0
 - data/test/test_log.rb +1076 -0
 - data/test/test_match.rb +148 -0
 - data/test/test_mixin.rb +351 -0
 - data/test/test_msgpack_factory.rb +50 -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 +821 -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 +1183 -0
 
| 
         @@ -0,0 +1,1361 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require_relative '../helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'fluent/test/driver/output'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'fluent/plugin/out_forward'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'flexmock/test_unit'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require 'fluent/test/driver/input'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'fluent/plugin/in_forward'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            class ForwardOutputTest < Test::Unit::TestCase
         
     | 
| 
      
 10 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 11 
     | 
    
         
            +
                Fluent::Test.setup
         
     | 
| 
      
 12 
     | 
    
         
            +
                FileUtils.rm_rf(TMP_DIR)
         
     | 
| 
      
 13 
     | 
    
         
            +
                FileUtils.mkdir_p(TMP_DIR)
         
     | 
| 
      
 14 
     | 
    
         
            +
                @d = nil
         
     | 
| 
      
 15 
     | 
    
         
            +
                @target_port = unused_port
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 19 
     | 
    
         
            +
                @d.instance_shutdown if @d
         
     | 
| 
      
 20 
     | 
    
         
            +
                @port = nil
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              TMP_DIR = File.join(__dir__, "../tmp/out_forward#{ENV['TEST_ENV_NUMBER']}")
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              TARGET_HOST = '127.0.0.1'
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def config
         
     | 
| 
      
 28 
     | 
    
         
            +
                %[
         
     | 
| 
      
 29 
     | 
    
         
            +
                  send_timeout 51
         
     | 
| 
      
 30 
     | 
    
         
            +
                  heartbeat_type udp
         
     | 
| 
      
 31 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 32 
     | 
    
         
            +
                    name test
         
     | 
| 
      
 33 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 34 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 35 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 36 
     | 
    
         
            +
                ]
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def target_config
         
     | 
| 
      
 40 
     | 
    
         
            +
                %[
         
     | 
| 
      
 41 
     | 
    
         
            +
                  port #{@target_port}
         
     | 
| 
      
 42 
     | 
    
         
            +
                  bind #{TARGET_HOST}
         
     | 
| 
      
 43 
     | 
    
         
            +
                ]
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def create_driver(conf=config)
         
     | 
| 
      
 47 
     | 
    
         
            +
                Fluent::Test::Driver::Output.new(Fluent::Plugin::ForwardOutput) {
         
     | 
| 
      
 48 
     | 
    
         
            +
                  attr_reader :sent_chunk_ids, :ack_handler, :discovery_manager
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  def initialize
         
     | 
| 
      
 51 
     | 
    
         
            +
                    super
         
     | 
| 
      
 52 
     | 
    
         
            +
                    @sent_chunk_ids = []
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  def try_write(chunk)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    retval = super
         
     | 
| 
      
 57 
     | 
    
         
            +
                    @sent_chunk_ids << chunk.unique_id
         
     | 
| 
      
 58 
     | 
    
         
            +
                    retval
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                }.configure(conf)
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              test 'configure' do
         
     | 
| 
      
 64 
     | 
    
         
            +
                @d = d = create_driver(%[
         
     | 
| 
      
 65 
     | 
    
         
            +
                  self_hostname localhost
         
     | 
| 
      
 66 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 67 
     | 
    
         
            +
                    name test
         
     | 
| 
      
 68 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 69 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 70 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 71 
     | 
    
         
            +
                ])
         
     | 
| 
      
 72 
     | 
    
         
            +
                nodes = d.instance.nodes
         
     | 
| 
      
 73 
     | 
    
         
            +
                assert_equal 60, d.instance.send_timeout
         
     | 
| 
      
 74 
     | 
    
         
            +
                assert_equal :transport, d.instance.heartbeat_type
         
     | 
| 
      
 75 
     | 
    
         
            +
                assert_equal 1, nodes.length
         
     | 
| 
      
 76 
     | 
    
         
            +
                assert_nil d.instance.connect_timeout
         
     | 
| 
      
 77 
     | 
    
         
            +
                node = nodes.first
         
     | 
| 
      
 78 
     | 
    
         
            +
                assert_equal "test", node.name
         
     | 
| 
      
 79 
     | 
    
         
            +
                assert_equal '127.0.0.1', node.host
         
     | 
| 
      
 80 
     | 
    
         
            +
                assert_equal @target_port, node.port
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              test 'configure_traditional' do
         
     | 
| 
      
 84 
     | 
    
         
            +
                @d = d = create_driver(<<EOL)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  self_hostname localhost
         
     | 
| 
      
 86 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 87 
     | 
    
         
            +
                    name test
         
     | 
| 
      
 88 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 89 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 90 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 91 
     | 
    
         
            +
                  buffer_chunk_limit 10m
         
     | 
| 
      
 92 
     | 
    
         
            +
            EOL
         
     | 
| 
      
 93 
     | 
    
         
            +
                instance = d.instance
         
     | 
| 
      
 94 
     | 
    
         
            +
                assert instance.chunk_key_tag
         
     | 
| 
      
 95 
     | 
    
         
            +
                assert !instance.chunk_key_time
         
     | 
| 
      
 96 
     | 
    
         
            +
                assert_equal [], instance.chunk_keys
         
     | 
| 
      
 97 
     | 
    
         
            +
                assert{ instance.buffer.is_a?(Fluent::Plugin::MemoryBuffer) }
         
     | 
| 
      
 98 
     | 
    
         
            +
                assert_equal( 10*1024*1024, instance.buffer.chunk_limit_size )
         
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              test 'configure timeouts' do
         
     | 
| 
      
 102 
     | 
    
         
            +
                @d = d = create_driver(%[
         
     | 
| 
      
 103 
     | 
    
         
            +
                  send_timeout 30
         
     | 
| 
      
 104 
     | 
    
         
            +
                  connect_timeout 10
         
     | 
| 
      
 105 
     | 
    
         
            +
                  hard_timeout 15
         
     | 
| 
      
 106 
     | 
    
         
            +
                  ack_response_timeout 20
         
     | 
| 
      
 107 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 108 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 109 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 110 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 111 
     | 
    
         
            +
                ])
         
     | 
| 
      
 112 
     | 
    
         
            +
                assert_equal 30, d.instance.send_timeout
         
     | 
| 
      
 113 
     | 
    
         
            +
                assert_equal 10, d.instance.connect_timeout
         
     | 
| 
      
 114 
     | 
    
         
            +
                assert_equal 15, d.instance.hard_timeout
         
     | 
| 
      
 115 
     | 
    
         
            +
                assert_equal 20, d.instance.ack_response_timeout
         
     | 
| 
      
 116 
     | 
    
         
            +
              end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              test 'configure_udp_heartbeat' do
         
     | 
| 
      
 119 
     | 
    
         
            +
                @d = d = create_driver(config + "\nheartbeat_type udp")
         
     | 
| 
      
 120 
     | 
    
         
            +
                assert_equal :udp, d.instance.heartbeat_type
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
              test 'configure_none_heartbeat' do
         
     | 
| 
      
 124 
     | 
    
         
            +
                @d = d = create_driver(config + "\nheartbeat_type none")
         
     | 
| 
      
 125 
     | 
    
         
            +
                assert_equal :none, d.instance.heartbeat_type
         
     | 
| 
      
 126 
     | 
    
         
            +
              end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
              test 'configure_expire_dns_cache' do
         
     | 
| 
      
 129 
     | 
    
         
            +
                @d = d = create_driver(config + "\nexpire_dns_cache 5")
         
     | 
| 
      
 130 
     | 
    
         
            +
                assert_equal 5, d.instance.expire_dns_cache
         
     | 
| 
      
 131 
     | 
    
         
            +
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
              test 'configure_dns_round_robin udp' do
         
     | 
| 
      
 134 
     | 
    
         
            +
                assert_raise(Fluent::ConfigError) do
         
     | 
| 
      
 135 
     | 
    
         
            +
                  create_driver(config + "\nheartbeat_type udp\ndns_round_robin true")
         
     | 
| 
      
 136 
     | 
    
         
            +
                end
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
              test 'configure_dns_round_robin transport' do
         
     | 
| 
      
 140 
     | 
    
         
            +
                @d = d = create_driver(config + "\nheartbeat_type transport\ndns_round_robin true")
         
     | 
| 
      
 141 
     | 
    
         
            +
                assert_equal true, d.instance.dns_round_robin
         
     | 
| 
      
 142 
     | 
    
         
            +
              end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
              test 'configure_dns_round_robin none' do
         
     | 
| 
      
 145 
     | 
    
         
            +
                @d = d = create_driver(config + "\nheartbeat_type none\ndns_round_robin true")
         
     | 
| 
      
 146 
     | 
    
         
            +
                assert_equal true, d.instance.dns_round_robin
         
     | 
| 
      
 147 
     | 
    
         
            +
              end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
              test 'configure_no_server' do
         
     | 
| 
      
 150 
     | 
    
         
            +
                assert_raise(Fluent::ConfigError, 'forward output plugin requires at least one <server> is required') do
         
     | 
| 
      
 151 
     | 
    
         
            +
                  create_driver('')
         
     | 
| 
      
 152 
     | 
    
         
            +
                end
         
     | 
| 
      
 153 
     | 
    
         
            +
              end
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
              test 'configure with ignore_network_errors_at_startup' do
         
     | 
| 
      
 156 
     | 
    
         
            +
                normal_conf = config_element('match', '**', {}, [
         
     | 
| 
      
 157 
     | 
    
         
            +
                    config_element('server', '', {'name' => 'test', 'host' => 'unexisting.yaaaaaaaaaaaaaay.host.example.com'})
         
     | 
| 
      
 158 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                if Socket.const_defined?(:ResolutionError) # as of Ruby 3.3
         
     | 
| 
      
 161 
     | 
    
         
            +
                  error_class = Socket::ResolutionError
         
     | 
| 
      
 162 
     | 
    
         
            +
                else
         
     | 
| 
      
 163 
     | 
    
         
            +
                  error_class = SocketError
         
     | 
| 
      
 164 
     | 
    
         
            +
                end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                assert_raise error_class do
         
     | 
| 
      
 167 
     | 
    
         
            +
                  create_driver(normal_conf)
         
     | 
| 
      
 168 
     | 
    
         
            +
                end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                conf = config_element('match', '**', {'ignore_network_errors_at_startup' => 'true'}, [
         
     | 
| 
      
 171 
     | 
    
         
            +
                    config_element('server', '', {'name' => 'test', 'host' => 'unexisting.yaaaaaaaaaaaaaay.host.example.com'})
         
     | 
| 
      
 172 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 173 
     | 
    
         
            +
                @d = d = create_driver(conf)
         
     | 
| 
      
 174 
     | 
    
         
            +
                expected_log = "failed to resolve node name when configured"
         
     | 
| 
      
 175 
     | 
    
         
            +
                expected_detail = "server=\"test\" error_class=#{error_class.name}"
         
     | 
| 
      
 176 
     | 
    
         
            +
                logs = d.logs
         
     | 
| 
      
 177 
     | 
    
         
            +
                assert{ logs.any?{|log| log.include?(expected_log) && log.include?(expected_detail) } }
         
     | 
| 
      
 178 
     | 
    
         
            +
              end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
              data('CA cert'     => 'tls_ca_cert_path',
         
     | 
| 
      
 181 
     | 
    
         
            +
                   'non CA cert' => 'tls_cert_path')
         
     | 
| 
      
 182 
     | 
    
         
            +
              test 'configure tls_cert_path/tls_ca_cert_path' do |param|
         
     | 
| 
      
 183 
     | 
    
         
            +
                dummy_cert_path = File.join(TMP_DIR, "dummy_cert.pem")
         
     | 
| 
      
 184 
     | 
    
         
            +
                FileUtils.touch(dummy_cert_path)
         
     | 
| 
      
 185 
     | 
    
         
            +
                conf = %[
         
     | 
| 
      
 186 
     | 
    
         
            +
                  send_timeout 5
         
     | 
| 
      
 187 
     | 
    
         
            +
                  transport tls
         
     | 
| 
      
 188 
     | 
    
         
            +
                  tls_insecure_mode true
         
     | 
| 
      
 189 
     | 
    
         
            +
                  #{param} #{dummy_cert_path}
         
     | 
| 
      
 190 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 191 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 192 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 193 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 194 
     | 
    
         
            +
                ]
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
                @d = d = create_driver(conf)
         
     | 
| 
      
 197 
     | 
    
         
            +
                # In the plugin, tls_ca_cert_path is used for both cases
         
     | 
| 
      
 198 
     | 
    
         
            +
                assert_equal([dummy_cert_path], d.instance.tls_ca_cert_path)
         
     | 
| 
      
 199 
     | 
    
         
            +
              end
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
              sub_test_case "certstore loading parameters for Windows" do
         
     | 
| 
      
 202 
     | 
    
         
            +
                test 'certstore related config parameters' do
         
     | 
| 
      
 203 
     | 
    
         
            +
                  omit "certstore related values raise error on not Windows" if Fluent.windows?
         
     | 
| 
      
 204 
     | 
    
         
            +
                  conf = %[
         
     | 
| 
      
 205 
     | 
    
         
            +
                    send_timeout 5
         
     | 
| 
      
 206 
     | 
    
         
            +
                    transport tls
         
     | 
| 
      
 207 
     | 
    
         
            +
                    tls_cert_logical_store_name Root
         
     | 
| 
      
 208 
     | 
    
         
            +
                    tls_cert_thumbprint a909502dd82ae41433e6f83886b00d4277a32a7b
         
     | 
| 
      
 209 
     | 
    
         
            +
                    <server>
         
     | 
| 
      
 210 
     | 
    
         
            +
                      host #{TARGET_HOST}
         
     | 
| 
      
 211 
     | 
    
         
            +
                      port #{@target_port}
         
     | 
| 
      
 212 
     | 
    
         
            +
                    </server>
         
     | 
| 
      
 213 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                  assert_raise(Fluent::ConfigError) do
         
     | 
| 
      
 216 
     | 
    
         
            +
                    create_driver(conf)
         
     | 
| 
      
 217 
     | 
    
         
            +
                  end
         
     | 
| 
      
 218 
     | 
    
         
            +
                end
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                test 'cert_logical_store_name and tls_cert_thumbprint default values' do
         
     | 
| 
      
 221 
     | 
    
         
            +
                  conf = %[
         
     | 
| 
      
 222 
     | 
    
         
            +
                    send_timeout 5
         
     | 
| 
      
 223 
     | 
    
         
            +
                    transport tls
         
     | 
| 
      
 224 
     | 
    
         
            +
                    <server>
         
     | 
| 
      
 225 
     | 
    
         
            +
                      host #{TARGET_HOST}
         
     | 
| 
      
 226 
     | 
    
         
            +
                      port #{@target_port}
         
     | 
| 
      
 227 
     | 
    
         
            +
                    </server>
         
     | 
| 
      
 228 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                  @d = d = create_driver(conf)
         
     | 
| 
      
 231 
     | 
    
         
            +
                  assert_nil d.instance.tls_cert_logical_store_name
         
     | 
| 
      
 232 
     | 
    
         
            +
                  assert_nil d.instance.tls_cert_thumbprint
         
     | 
| 
      
 233 
     | 
    
         
            +
                end
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
                data('CA cert'     => 'tls_ca_cert_path',
         
     | 
| 
      
 236 
     | 
    
         
            +
                     'non CA cert' => 'tls_cert_path')
         
     | 
| 
      
 237 
     | 
    
         
            +
                test 'specify tls_cert_logical_store_name and tls_cert_path should raise error' do |param|
         
     | 
| 
      
 238 
     | 
    
         
            +
                  omit "Loading CertStore feature works only Windows" unless Fluent.windows?
         
     | 
| 
      
 239 
     | 
    
         
            +
                  dummy_cert_path = File.join(TMP_DIR, "dummy_cert.pem")
         
     | 
| 
      
 240 
     | 
    
         
            +
                  FileUtils.touch(dummy_cert_path)
         
     | 
| 
      
 241 
     | 
    
         
            +
                  conf = %[
         
     | 
| 
      
 242 
     | 
    
         
            +
                    send_timeout 5
         
     | 
| 
      
 243 
     | 
    
         
            +
                    transport tls
         
     | 
| 
      
 244 
     | 
    
         
            +
                    #{param} #{dummy_cert_path}
         
     | 
| 
      
 245 
     | 
    
         
            +
                    tls_cert_logical_store_name Root
         
     | 
| 
      
 246 
     | 
    
         
            +
                    <server>
         
     | 
| 
      
 247 
     | 
    
         
            +
                      host #{TARGET_HOST}
         
     | 
| 
      
 248 
     | 
    
         
            +
                      port #{@target_port}
         
     | 
| 
      
 249 
     | 
    
         
            +
                    </server>
         
     | 
| 
      
 250 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
                  assert_raise(Fluent::ConfigError) do
         
     | 
| 
      
 253 
     | 
    
         
            +
                    create_driver(conf)
         
     | 
| 
      
 254 
     | 
    
         
            +
                  end
         
     | 
| 
      
 255 
     | 
    
         
            +
                end
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
                test 'configure cert_logical_store_name and tls_cert_thumbprint' do
         
     | 
| 
      
 258 
     | 
    
         
            +
                  omit "Loading CertStore feature works only Windows" unless Fluent.windows?
         
     | 
| 
      
 259 
     | 
    
         
            +
                  conf = %[
         
     | 
| 
      
 260 
     | 
    
         
            +
                    send_timeout 5
         
     | 
| 
      
 261 
     | 
    
         
            +
                    transport tls
         
     | 
| 
      
 262 
     | 
    
         
            +
                    tls_cert_logical_store_name Root
         
     | 
| 
      
 263 
     | 
    
         
            +
                    tls_cert_thumbprint a909502dd82ae41433e6f83886b00d4277a32a7b
         
     | 
| 
      
 264 
     | 
    
         
            +
                    <server>
         
     | 
| 
      
 265 
     | 
    
         
            +
                      host #{TARGET_HOST}
         
     | 
| 
      
 266 
     | 
    
         
            +
                      port #{@target_port}
         
     | 
| 
      
 267 
     | 
    
         
            +
                    </server>
         
     | 
| 
      
 268 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
                  @d = d = create_driver(conf)
         
     | 
| 
      
 271 
     | 
    
         
            +
                  assert_equal "Root", d.instance.tls_cert_logical_store_name
         
     | 
| 
      
 272 
     | 
    
         
            +
                  assert_equal "a909502dd82ae41433e6f83886b00d4277a32a7b", d.instance.tls_cert_thumbprint
         
     | 
| 
      
 273 
     | 
    
         
            +
                end
         
     | 
| 
      
 274 
     | 
    
         
            +
              end
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
              test 'server is an abbreviation of static type of service_discovery' do
         
     | 
| 
      
 277 
     | 
    
         
            +
                @d = d = create_driver(%[
         
     | 
| 
      
 278 
     | 
    
         
            +
            <server>
         
     | 
| 
      
 279 
     | 
    
         
            +
              host 127.0.0.1
         
     | 
| 
      
 280 
     | 
    
         
            +
              port 1234
         
     | 
| 
      
 281 
     | 
    
         
            +
            </server>
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
            <service_discovery>
         
     | 
| 
      
 284 
     | 
    
         
            +
              @type static
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
              <service>
         
     | 
| 
      
 287 
     | 
    
         
            +
                host 127.0.0.1
         
     | 
| 
      
 288 
     | 
    
         
            +
                port 1235
         
     | 
| 
      
 289 
     | 
    
         
            +
              </service>
         
     | 
| 
      
 290 
     | 
    
         
            +
            </service_discovery>
         
     | 
| 
      
 291 
     | 
    
         
            +
                ])
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 295 
     | 
    
         
            +
                  [
         
     | 
| 
      
 296 
     | 
    
         
            +
                    { host: '127.0.0.1', port: 1234 },
         
     | 
| 
      
 297 
     | 
    
         
            +
                    { host: '127.0.0.1', port: 1235 },
         
     | 
| 
      
 298 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 299 
     | 
    
         
            +
                  d.instance.discovery_manager.services.collect do |service|
         
     | 
| 
      
 300 
     | 
    
         
            +
                    { host: service.host, port: service.port }
         
     | 
| 
      
 301 
     | 
    
         
            +
                  end
         
     | 
| 
      
 302 
     | 
    
         
            +
                )
         
     | 
| 
      
 303 
     | 
    
         
            +
              end
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
              test 'pass username and password as empty string to HandshakeProtocol' do
         
     | 
| 
      
 306 
     | 
    
         
            +
                config_path = File.join(TMP_DIR, "sd_file.conf")
         
     | 
| 
      
 307 
     | 
    
         
            +
                File.open(config_path, 'w') do |file|
         
     | 
| 
      
 308 
     | 
    
         
            +
                  file.write(%[
         
     | 
| 
      
 309 
     | 
    
         
            +
            - 'host': 127.0.0.1
         
     | 
| 
      
 310 
     | 
    
         
            +
              'port': 1234
         
     | 
| 
      
 311 
     | 
    
         
            +
              'weight': 1
         
     | 
| 
      
 312 
     | 
    
         
            +
            ])
         
     | 
| 
      
 313 
     | 
    
         
            +
                end
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
                mock(Fluent::Plugin::ForwardOutput::HandshakeProtocol).new(log: anything, hostname: nil, shared_key: anything, password: '', username: '')
         
     | 
| 
      
 316 
     | 
    
         
            +
                @d = d = create_driver(%[
         
     | 
| 
      
 317 
     | 
    
         
            +
            <service_discovery>
         
     | 
| 
      
 318 
     | 
    
         
            +
              @type file
         
     | 
| 
      
 319 
     | 
    
         
            +
              path #{config_path}
         
     | 
| 
      
 320 
     | 
    
         
            +
            </service_discovery>
         
     | 
| 
      
 321 
     | 
    
         
            +
                ])
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
                assert_equal 1, d.instance.discovery_manager.services.size
         
     | 
| 
      
 324 
     | 
    
         
            +
                assert_equal '127.0.0.1', d.instance.discovery_manager.services[0].host
         
     | 
| 
      
 325 
     | 
    
         
            +
                assert_equal 1234, d.instance.discovery_manager.services[0].port
         
     | 
| 
      
 326 
     | 
    
         
            +
              end
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
              test 'compress_default_value' do
         
     | 
| 
      
 329 
     | 
    
         
            +
                @d = d = create_driver
         
     | 
| 
      
 330 
     | 
    
         
            +
                assert_equal :text, d.instance.compress
         
     | 
| 
      
 331 
     | 
    
         
            +
             
     | 
| 
      
 332 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 333 
     | 
    
         
            +
                assert_equal :text, node.instance_variable_get(:@compress)
         
     | 
| 
      
 334 
     | 
    
         
            +
              end
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
              test 'set_compress_is_gzip' do
         
     | 
| 
      
 337 
     | 
    
         
            +
                @d = d = create_driver(config + %[compress gzip])
         
     | 
| 
      
 338 
     | 
    
         
            +
                assert_equal :gzip, d.instance.compress
         
     | 
| 
      
 339 
     | 
    
         
            +
                assert_equal :gzip, d.instance.buffer.compress
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 342 
     | 
    
         
            +
                assert_equal :gzip, node.instance_variable_get(:@compress)
         
     | 
| 
      
 343 
     | 
    
         
            +
              end
         
     | 
| 
      
 344 
     | 
    
         
            +
             
     | 
| 
      
 345 
     | 
    
         
            +
              test 'set_compress_is_gzip_in_buffer_section' do
         
     | 
| 
      
 346 
     | 
    
         
            +
                mock = flexmock($log)
         
     | 
| 
      
 347 
     | 
    
         
            +
                mock.should_receive(:log).with("buffer is compressed.  If you also want to save the bandwidth of a network, Add `compress` configuration in <match>")
         
     | 
| 
      
 348 
     | 
    
         
            +
             
     | 
| 
      
 349 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 350 
     | 
    
         
            +
                   <buffer>
         
     | 
| 
      
 351 
     | 
    
         
            +
                     type memory
         
     | 
| 
      
 352 
     | 
    
         
            +
                     compress gzip
         
     | 
| 
      
 353 
     | 
    
         
            +
                   </buffer>
         
     | 
| 
      
 354 
     | 
    
         
            +
                 ])
         
     | 
| 
      
 355 
     | 
    
         
            +
                assert_equal :text, d.instance.compress
         
     | 
| 
      
 356 
     | 
    
         
            +
                assert_equal :gzip, d.instance.buffer.compress
         
     | 
| 
      
 357 
     | 
    
         
            +
             
     | 
| 
      
 358 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 359 
     | 
    
         
            +
                assert_equal :text, node.instance_variable_get(:@compress)
         
     | 
| 
      
 360 
     | 
    
         
            +
              end
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
              test 'phi_failure_detector disabled' do
         
     | 
| 
      
 363 
     | 
    
         
            +
                @d = d = create_driver(config + %[phi_failure_detector false \n phi_threshold 0])
         
     | 
| 
      
 364 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 365 
     | 
    
         
            +
                stub(node.failure).phi { raise 'Should not be called' }
         
     | 
| 
      
 366 
     | 
    
         
            +
                node.tick
         
     | 
| 
      
 367 
     | 
    
         
            +
                assert_true node.available?
         
     | 
| 
      
 368 
     | 
    
         
            +
              end
         
     | 
| 
      
 369 
     | 
    
         
            +
             
     | 
| 
      
 370 
     | 
    
         
            +
              test 'phi_failure_detector enabled' do
         
     | 
| 
      
 371 
     | 
    
         
            +
                @d = d = create_driver(config + %[phi_failure_detector true \n phi_threshold 0])
         
     | 
| 
      
 372 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 373 
     | 
    
         
            +
                node.tick
         
     | 
| 
      
 374 
     | 
    
         
            +
                assert_false node.available?
         
     | 
| 
      
 375 
     | 
    
         
            +
              end
         
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
      
 377 
     | 
    
         
            +
              test 'require_ack_response is disabled in default' do
         
     | 
| 
      
 378 
     | 
    
         
            +
                @d = d = create_driver(config)
         
     | 
| 
      
 379 
     | 
    
         
            +
                assert_equal false, d.instance.require_ack_response
         
     | 
| 
      
 380 
     | 
    
         
            +
                assert_equal 190, d.instance.ack_response_timeout
         
     | 
| 
      
 381 
     | 
    
         
            +
              end
         
     | 
| 
      
 382 
     | 
    
         
            +
             
     | 
| 
      
 383 
     | 
    
         
            +
              test 'require_ack_response can be enabled' do
         
     | 
| 
      
 384 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 385 
     | 
    
         
            +
                  require_ack_response true
         
     | 
| 
      
 386 
     | 
    
         
            +
                  ack_response_timeout 2s
         
     | 
| 
      
 387 
     | 
    
         
            +
                ])
         
     | 
| 
      
 388 
     | 
    
         
            +
                d.instance_start
         
     | 
| 
      
 389 
     | 
    
         
            +
                assert d.instance.require_ack_response
         
     | 
| 
      
 390 
     | 
    
         
            +
                assert_equal 2, d.instance.ack_response_timeout
         
     | 
| 
      
 391 
     | 
    
         
            +
              end
         
     | 
| 
      
 392 
     | 
    
         
            +
             
     | 
| 
      
 393 
     | 
    
         
            +
              test 'suspend_flush is disable before before_shutdown' do
         
     | 
| 
      
 394 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 395 
     | 
    
         
            +
                  require_ack_response true
         
     | 
| 
      
 396 
     | 
    
         
            +
                  ack_response_timeout 2s
         
     | 
| 
      
 397 
     | 
    
         
            +
                ])
         
     | 
| 
      
 398 
     | 
    
         
            +
                d.instance_start
         
     | 
| 
      
 399 
     | 
    
         
            +
                assert_false d.instance.instance_variable_get(:@suspend_flush)
         
     | 
| 
      
 400 
     | 
    
         
            +
              end
         
     | 
| 
      
 401 
     | 
    
         
            +
             
     | 
| 
      
 402 
     | 
    
         
            +
              test 'suspend_flush should be enabled and try_flush returns nil after before_shutdown' do
         
     | 
| 
      
 403 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 404 
     | 
    
         
            +
                  require_ack_response true
         
     | 
| 
      
 405 
     | 
    
         
            +
                  ack_response_timeout 2s
         
     | 
| 
      
 406 
     | 
    
         
            +
                ])
         
     | 
| 
      
 407 
     | 
    
         
            +
                d.instance_start
         
     | 
| 
      
 408 
     | 
    
         
            +
                d.instance.before_shutdown
         
     | 
| 
      
 409 
     | 
    
         
            +
                assert_true d.instance.instance_variable_get(:@suspend_flush)
         
     | 
| 
      
 410 
     | 
    
         
            +
                assert_nil d.instance.try_flush
         
     | 
| 
      
 411 
     | 
    
         
            +
              end
         
     | 
| 
      
 412 
     | 
    
         
            +
             
     | 
| 
      
 413 
     | 
    
         
            +
              test 'verify_connection_at_startup is disabled in default' do
         
     | 
| 
      
 414 
     | 
    
         
            +
                @d = d = create_driver(config)
         
     | 
| 
      
 415 
     | 
    
         
            +
                assert_false d.instance.verify_connection_at_startup
         
     | 
| 
      
 416 
     | 
    
         
            +
              end
         
     | 
| 
      
 417 
     | 
    
         
            +
             
     | 
| 
      
 418 
     | 
    
         
            +
              test 'verify_connection_at_startup can be enabled' do
         
     | 
| 
      
 419 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 420 
     | 
    
         
            +
                  verify_connection_at_startup true
         
     | 
| 
      
 421 
     | 
    
         
            +
                ])
         
     | 
| 
      
 422 
     | 
    
         
            +
                assert_true d.instance.verify_connection_at_startup
         
     | 
| 
      
 423 
     | 
    
         
            +
              end
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
              test 'send tags in str (utf-8 strings)' do
         
     | 
| 
      
 426 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 427 
     | 
    
         
            +
             
     | 
| 
      
 428 
     | 
    
         
            +
                @d = d = create_driver(config + %[flush_interval 1s])
         
     | 
| 
      
 429 
     | 
    
         
            +
             
     | 
| 
      
 430 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 431 
     | 
    
         
            +
             
     | 
| 
      
 432 
     | 
    
         
            +
                tag_in_utf8 = "test.utf8".encode("utf-8")
         
     | 
| 
      
 433 
     | 
    
         
            +
                tag_in_ascii = "test.ascii".encode("ascii-8bit")
         
     | 
| 
      
 434 
     | 
    
         
            +
             
     | 
| 
      
 435 
     | 
    
         
            +
                emit_events = [
         
     | 
| 
      
 436 
     | 
    
         
            +
                  [tag_in_utf8, time, {"a" => 1}],
         
     | 
| 
      
 437 
     | 
    
         
            +
                  [tag_in_ascii, time, {"a" => 2}],
         
     | 
| 
      
 438 
     | 
    
         
            +
                ]
         
     | 
| 
      
 439 
     | 
    
         
            +
             
     | 
| 
      
 440 
     | 
    
         
            +
                stub(d.instance.ack_handler).read_ack_from_sock(anything).never
         
     | 
| 
      
 441 
     | 
    
         
            +
                assert_rr do
         
     | 
| 
      
 442 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 2) do
         
     | 
| 
      
 443 
     | 
    
         
            +
                    d.run do
         
     | 
| 
      
 444 
     | 
    
         
            +
                      emit_events.each do |tag, t, record|
         
     | 
| 
      
 445 
     | 
    
         
            +
                        d.feed(tag, t, record)
         
     | 
| 
      
 446 
     | 
    
         
            +
                      end
         
     | 
| 
      
 447 
     | 
    
         
            +
                    end
         
     | 
| 
      
 448 
     | 
    
         
            +
                  end
         
     | 
| 
      
 449 
     | 
    
         
            +
                end
         
     | 
| 
      
 450 
     | 
    
         
            +
             
     | 
| 
      
 451 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 452 
     | 
    
         
            +
                assert_equal_event_time(time, events[0][1])
         
     | 
| 
      
 453 
     | 
    
         
            +
                assert_equal ['test.utf8', time, emit_events[0][2]], events[0]
         
     | 
| 
      
 454 
     | 
    
         
            +
                assert_equal Encoding::UTF_8, events[0][0].encoding
         
     | 
| 
      
 455 
     | 
    
         
            +
                assert_equal_event_time(time, events[1][1])
         
     | 
| 
      
 456 
     | 
    
         
            +
                assert_equal ['test.ascii', time, emit_events[1][2]], events[1]
         
     | 
| 
      
 457 
     | 
    
         
            +
                assert_equal Encoding::UTF_8, events[1][0].encoding
         
     | 
| 
      
 458 
     | 
    
         
            +
              end
         
     | 
| 
      
 459 
     | 
    
         
            +
             
     | 
| 
      
 460 
     | 
    
         
            +
              test 'send_with_time_as_integer' do
         
     | 
| 
      
 461 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 462 
     | 
    
         
            +
             
     | 
| 
      
 463 
     | 
    
         
            +
                @d = d = create_driver(config + %[flush_interval 1s])
         
     | 
| 
      
 464 
     | 
    
         
            +
             
     | 
| 
      
 465 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 466 
     | 
    
         
            +
             
     | 
| 
      
 467 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 468 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 469 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 470 
     | 
    
         
            +
                ]
         
     | 
| 
      
 471 
     | 
    
         
            +
             
     | 
| 
      
 472 
     | 
    
         
            +
                stub(d.instance.ack_handler).read_ack_from_sock(anything).never
         
     | 
| 
      
 473 
     | 
    
         
            +
                assert_rr do
         
     | 
| 
      
 474 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 2) do
         
     | 
| 
      
 475 
     | 
    
         
            +
                    d.run(default_tag: 'test') do
         
     | 
| 
      
 476 
     | 
    
         
            +
                      records.each do |record|
         
     | 
| 
      
 477 
     | 
    
         
            +
                        d.feed(time, record)
         
     | 
| 
      
 478 
     | 
    
         
            +
                      end
         
     | 
| 
      
 479 
     | 
    
         
            +
                    end
         
     | 
| 
      
 480 
     | 
    
         
            +
                  end
         
     | 
| 
      
 481 
     | 
    
         
            +
                end
         
     | 
| 
      
 482 
     | 
    
         
            +
             
     | 
| 
      
 483 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 484 
     | 
    
         
            +
                assert_equal_event_time(time, events[0][1])
         
     | 
| 
      
 485 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 486 
     | 
    
         
            +
                assert_equal_event_time(time, events[1][1])
         
     | 
| 
      
 487 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 488 
     | 
    
         
            +
              end
         
     | 
| 
      
 489 
     | 
    
         
            +
             
     | 
| 
      
 490 
     | 
    
         
            +
              test 'send_without_time_as_integer' do
         
     | 
| 
      
 491 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 492 
     | 
    
         
            +
             
     | 
| 
      
 493 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 494 
     | 
    
         
            +
                  flush_interval 1s
         
     | 
| 
      
 495 
     | 
    
         
            +
                  time_as_integer false
         
     | 
| 
      
 496 
     | 
    
         
            +
                ])
         
     | 
| 
      
 497 
     | 
    
         
            +
             
     | 
| 
      
 498 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 499 
     | 
    
         
            +
             
     | 
| 
      
 500 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 501 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 502 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 503 
     | 
    
         
            +
                ]
         
     | 
| 
      
 504 
     | 
    
         
            +
                stub(d.instance.ack_handler).read_ack_from_sock(anything).never
         
     | 
| 
      
 505 
     | 
    
         
            +
                assert_rr do
         
     | 
| 
      
 506 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 2) do
         
     | 
| 
      
 507 
     | 
    
         
            +
                    d.run(default_tag: 'test') do
         
     | 
| 
      
 508 
     | 
    
         
            +
                      records.each do |record|
         
     | 
| 
      
 509 
     | 
    
         
            +
                        d.feed(time, record)
         
     | 
| 
      
 510 
     | 
    
         
            +
                      end
         
     | 
| 
      
 511 
     | 
    
         
            +
                    end
         
     | 
| 
      
 512 
     | 
    
         
            +
                  end
         
     | 
| 
      
 513 
     | 
    
         
            +
                end
         
     | 
| 
      
 514 
     | 
    
         
            +
             
     | 
| 
      
 515 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 516 
     | 
    
         
            +
                assert_equal_event_time(time, events[0][1])
         
     | 
| 
      
 517 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 518 
     | 
    
         
            +
                assert_equal_event_time(time, events[1][1])
         
     | 
| 
      
 519 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 520 
     | 
    
         
            +
              end
         
     | 
| 
      
 521 
     | 
    
         
            +
             
     | 
| 
      
 522 
     | 
    
         
            +
              test 'send_comprssed_message_pack_stream_if_compress_is_gzip' do
         
     | 
| 
      
 523 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 524 
     | 
    
         
            +
             
     | 
| 
      
 525 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 526 
     | 
    
         
            +
                  flush_interval 1s
         
     | 
| 
      
 527 
     | 
    
         
            +
                  compress gzip
         
     | 
| 
      
 528 
     | 
    
         
            +
                ])
         
     | 
| 
      
 529 
     | 
    
         
            +
             
     | 
| 
      
 530 
     | 
    
         
            +
                time = event_time('2011-01-02 13:14:15 UTC')
         
     | 
| 
      
 531 
     | 
    
         
            +
             
     | 
| 
      
 532 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 533 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 534 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 535 
     | 
    
         
            +
                ]
         
     | 
| 
      
 536 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2) do
         
     | 
| 
      
 537 
     | 
    
         
            +
                  d.run(default_tag: 'test') do
         
     | 
| 
      
 538 
     | 
    
         
            +
                    records.each do |record|
         
     | 
| 
      
 539 
     | 
    
         
            +
                      d.feed(time, record)
         
     | 
| 
      
 540 
     | 
    
         
            +
                    end
         
     | 
| 
      
 541 
     | 
    
         
            +
                  end
         
     | 
| 
      
 542 
     | 
    
         
            +
                end
         
     | 
| 
      
 543 
     | 
    
         
            +
             
     | 
| 
      
 544 
     | 
    
         
            +
                event_streams = target_input_driver.event_streams
         
     | 
| 
      
 545 
     | 
    
         
            +
                assert_true event_streams[0][1].is_a?(Fluent::CompressedMessagePackEventStream)
         
     | 
| 
      
 546 
     | 
    
         
            +
             
     | 
| 
      
 547 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 548 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 549 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 550 
     | 
    
         
            +
              end
         
     | 
| 
      
 551 
     | 
    
         
            +
             
     | 
| 
      
 552 
     | 
    
         
            +
              test 'send_to_a_node_supporting_responses' do
         
     | 
| 
      
 553 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 554 
     | 
    
         
            +
             
     | 
| 
      
 555 
     | 
    
         
            +
                @d = d = create_driver(config + %[flush_interval 1s])
         
     | 
| 
      
 556 
     | 
    
         
            +
             
     | 
| 
      
 557 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 558 
     | 
    
         
            +
             
     | 
| 
      
 559 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 560 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 561 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 562 
     | 
    
         
            +
                ]
         
     | 
| 
      
 563 
     | 
    
         
            +
                # not attempt to receive responses
         
     | 
| 
      
 564 
     | 
    
         
            +
                stub(d.instance.ack_handler).read_ack_from_sock(anything).never
         
     | 
| 
      
 565 
     | 
    
         
            +
                assert_rr do
         
     | 
| 
      
 566 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 2) do
         
     | 
| 
      
 567 
     | 
    
         
            +
                    d.run(default_tag: 'test') do
         
     | 
| 
      
 568 
     | 
    
         
            +
                      records.each do |record|
         
     | 
| 
      
 569 
     | 
    
         
            +
                        d.feed(time, record)
         
     | 
| 
      
 570 
     | 
    
         
            +
                      end
         
     | 
| 
      
 571 
     | 
    
         
            +
                    end
         
     | 
| 
      
 572 
     | 
    
         
            +
                  end
         
     | 
| 
      
 573 
     | 
    
         
            +
                end
         
     | 
| 
      
 574 
     | 
    
         
            +
             
     | 
| 
      
 575 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 576 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 577 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 578 
     | 
    
         
            +
              end
         
     | 
| 
      
 579 
     | 
    
         
            +
             
     | 
| 
      
 580 
     | 
    
         
            +
              test 'send_to_a_node_not_supporting_responses' do
         
     | 
| 
      
 581 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 582 
     | 
    
         
            +
             
     | 
| 
      
 583 
     | 
    
         
            +
                @d = d = create_driver(config + %[flush_interval 1s])
         
     | 
| 
      
 584 
     | 
    
         
            +
             
     | 
| 
      
 585 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 586 
     | 
    
         
            +
             
     | 
| 
      
 587 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 588 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 589 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 590 
     | 
    
         
            +
                ]
         
     | 
| 
      
 591 
     | 
    
         
            +
                # not attempt to receive responses
         
     | 
| 
      
 592 
     | 
    
         
            +
                stub(d.instance.ack_handler).read_ack_from_sock(anything).never
         
     | 
| 
      
 593 
     | 
    
         
            +
                assert_rr do
         
     | 
| 
      
 594 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 2) do
         
     | 
| 
      
 595 
     | 
    
         
            +
                    d.run(default_tag: 'test') do
         
     | 
| 
      
 596 
     | 
    
         
            +
                      records.each do |record|
         
     | 
| 
      
 597 
     | 
    
         
            +
                        d.feed(time, record)
         
     | 
| 
      
 598 
     | 
    
         
            +
                      end
         
     | 
| 
      
 599 
     | 
    
         
            +
                    end
         
     | 
| 
      
 600 
     | 
    
         
            +
                  end
         
     | 
| 
      
 601 
     | 
    
         
            +
                end
         
     | 
| 
      
 602 
     | 
    
         
            +
             
     | 
| 
      
 603 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 604 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 605 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 606 
     | 
    
         
            +
              end
         
     | 
| 
      
 607 
     | 
    
         
            +
             
     | 
| 
      
 608 
     | 
    
         
            +
              test 'a node supporting responses' do
         
     | 
| 
      
 609 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 610 
     | 
    
         
            +
             
     | 
| 
      
 611 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 612 
     | 
    
         
            +
                  require_ack_response true
         
     | 
| 
      
 613 
     | 
    
         
            +
                  ack_response_timeout 1s
         
     | 
| 
      
 614 
     | 
    
         
            +
                  <buffer tag>
         
     | 
| 
      
 615 
     | 
    
         
            +
                    flush_mode immediate
         
     | 
| 
      
 616 
     | 
    
         
            +
                    retry_type periodic
         
     | 
| 
      
 617 
     | 
    
         
            +
                    retry_wait 30s
         
     | 
| 
      
 618 
     | 
    
         
            +
                    flush_at_shutdown true
         
     | 
| 
      
 619 
     | 
    
         
            +
                  </buffer>
         
     | 
| 
      
 620 
     | 
    
         
            +
                ])
         
     | 
| 
      
 621 
     | 
    
         
            +
             
     | 
| 
      
 622 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 623 
     | 
    
         
            +
             
     | 
| 
      
 624 
     | 
    
         
            +
                acked_chunk_ids = []
         
     | 
| 
      
 625 
     | 
    
         
            +
                nacked = false
         
     | 
| 
      
 626 
     | 
    
         
            +
                mock.proxy(d.instance.ack_handler).read_ack_from_sock(anything) do |info, success|
         
     | 
| 
      
 627 
     | 
    
         
            +
                  if success
         
     | 
| 
      
 628 
     | 
    
         
            +
                    acked_chunk_ids << info.chunk_id
         
     | 
| 
      
 629 
     | 
    
         
            +
                  else
         
     | 
| 
      
 630 
     | 
    
         
            +
                    nacked = true
         
     | 
| 
      
 631 
     | 
    
         
            +
                  end
         
     | 
| 
      
 632 
     | 
    
         
            +
                  [info, success]
         
     | 
| 
      
 633 
     | 
    
         
            +
                end
         
     | 
| 
      
 634 
     | 
    
         
            +
             
     | 
| 
      
 635 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 636 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 637 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 638 
     | 
    
         
            +
                ]
         
     | 
| 
      
 639 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2, timeout: 5) do
         
     | 
| 
      
 640 
     | 
    
         
            +
                  d.end_if { acked_chunk_ids.size > 0 || nacked }
         
     | 
| 
      
 641 
     | 
    
         
            +
                  d.run(default_tag: 'test', wait_flush_completion: false, shutdown: false) do
         
     | 
| 
      
 642 
     | 
    
         
            +
                    d.feed([[time, records[0]], [time,records[1]]])
         
     | 
| 
      
 643 
     | 
    
         
            +
                  end
         
     | 
| 
      
 644 
     | 
    
         
            +
                end
         
     | 
| 
      
 645 
     | 
    
         
            +
             
     | 
| 
      
 646 
     | 
    
         
            +
                assert(!nacked, d.instance.log.logs.join)
         
     | 
| 
      
 647 
     | 
    
         
            +
             
     | 
| 
      
 648 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 649 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 650 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 651 
     | 
    
         
            +
             
     | 
| 
      
 652 
     | 
    
         
            +
                assert_equal 1, acked_chunk_ids.size
         
     | 
| 
      
 653 
     | 
    
         
            +
                assert_equal d.instance.sent_chunk_ids.first, acked_chunk_ids.first
         
     | 
| 
      
 654 
     | 
    
         
            +
              end
         
     | 
| 
      
 655 
     | 
    
         
            +
             
     | 
| 
      
 656 
     | 
    
         
            +
              test 'a node supporting responses after stop' do
         
     | 
| 
      
 657 
     | 
    
         
            +
                target_input_driver = create_target_input_driver
         
     | 
| 
      
 658 
     | 
    
         
            +
             
     | 
| 
      
 659 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 660 
     | 
    
         
            +
                  require_ack_response true
         
     | 
| 
      
 661 
     | 
    
         
            +
                  ack_response_timeout 10s
         
     | 
| 
      
 662 
     | 
    
         
            +
                  <buffer tag>
         
     | 
| 
      
 663 
     | 
    
         
            +
                    flush_mode immediate
         
     | 
| 
      
 664 
     | 
    
         
            +
                    retry_type periodic
         
     | 
| 
      
 665 
     | 
    
         
            +
                    retry_wait 30s
         
     | 
| 
      
 666 
     | 
    
         
            +
                    flush_at_shutdown true
         
     | 
| 
      
 667 
     | 
    
         
            +
                  </buffer>
         
     | 
| 
      
 668 
     | 
    
         
            +
                ])
         
     | 
| 
      
 669 
     | 
    
         
            +
             
     | 
| 
      
 670 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 671 
     | 
    
         
            +
             
     | 
| 
      
 672 
     | 
    
         
            +
                acked_chunk_ids = []
         
     | 
| 
      
 673 
     | 
    
         
            +
                nacked = false
         
     | 
| 
      
 674 
     | 
    
         
            +
                mock.proxy(d.instance.ack_handler).read_ack_from_sock(anything) do |info, success|
         
     | 
| 
      
 675 
     | 
    
         
            +
                  if success
         
     | 
| 
      
 676 
     | 
    
         
            +
                    acked_chunk_ids << info.chunk_id
         
     | 
| 
      
 677 
     | 
    
         
            +
                  else
         
     | 
| 
      
 678 
     | 
    
         
            +
                    nacked = true
         
     | 
| 
      
 679 
     | 
    
         
            +
                  end
         
     | 
| 
      
 680 
     | 
    
         
            +
                  [info, success]
         
     | 
| 
      
 681 
     | 
    
         
            +
                end
         
     | 
| 
      
 682 
     | 
    
         
            +
             
     | 
| 
      
 683 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 684 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 685 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 686 
     | 
    
         
            +
                ]
         
     | 
| 
      
 687 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2, timeout: 5) do
         
     | 
| 
      
 688 
     | 
    
         
            +
                  d.end_if { acked_chunk_ids.size > 0 || nacked }
         
     | 
| 
      
 689 
     | 
    
         
            +
                  d.run(default_tag: 'test', wait_flush_completion: false, shutdown: false) do
         
     | 
| 
      
 690 
     | 
    
         
            +
                    d.instance.stop
         
     | 
| 
      
 691 
     | 
    
         
            +
                    d.feed([[time, records[0]], [time,records[1]]])
         
     | 
| 
      
 692 
     | 
    
         
            +
                    d.instance.before_shutdown
         
     | 
| 
      
 693 
     | 
    
         
            +
                    d.instance.shutdown
         
     | 
| 
      
 694 
     | 
    
         
            +
                    d.instance.after_shutdown
         
     | 
| 
      
 695 
     | 
    
         
            +
                  end
         
     | 
| 
      
 696 
     | 
    
         
            +
                end
         
     | 
| 
      
 697 
     | 
    
         
            +
             
     | 
| 
      
 698 
     | 
    
         
            +
                assert(!nacked, d.instance.log.logs.join)
         
     | 
| 
      
 699 
     | 
    
         
            +
             
     | 
| 
      
 700 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 701 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 702 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 703 
     | 
    
         
            +
             
     | 
| 
      
 704 
     | 
    
         
            +
                assert_equal 1, acked_chunk_ids.size
         
     | 
| 
      
 705 
     | 
    
         
            +
                assert_equal d.instance.sent_chunk_ids.first, acked_chunk_ids.first
         
     | 
| 
      
 706 
     | 
    
         
            +
              end
         
     | 
| 
      
 707 
     | 
    
         
            +
             
     | 
| 
      
 708 
     | 
    
         
            +
              data('ack true' => true,
         
     | 
| 
      
 709 
     | 
    
         
            +
                   'ack false' => false)
         
     | 
| 
      
 710 
     | 
    
         
            +
              test 'TLS transport and ack parameter combination' do |ack|
         
     | 
| 
      
 711 
     | 
    
         
            +
                omit "TLS and 'ack false' always fails on AppVeyor. Need to debug" if Fluent.windows? && !ack
         
     | 
| 
      
 712 
     | 
    
         
            +
             
     | 
| 
      
 713 
     | 
    
         
            +
                input_conf = target_config + %[
         
     | 
| 
      
 714 
     | 
    
         
            +
                               <transport tls>
         
     | 
| 
      
 715 
     | 
    
         
            +
                                 insecure true
         
     | 
| 
      
 716 
     | 
    
         
            +
                               </transport>
         
     | 
| 
      
 717 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 718 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 719 
     | 
    
         
            +
             
     | 
| 
      
 720 
     | 
    
         
            +
                output_conf = %[
         
     | 
| 
      
 721 
     | 
    
         
            +
                  send_timeout 5
         
     | 
| 
      
 722 
     | 
    
         
            +
                  require_ack_response #{ack}
         
     | 
| 
      
 723 
     | 
    
         
            +
                  transport tls
         
     | 
| 
      
 724 
     | 
    
         
            +
                  tls_insecure_mode true
         
     | 
| 
      
 725 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 726 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 727 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 728 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 729 
     | 
    
         
            +
                  <buffer>
         
     | 
| 
      
 730 
     | 
    
         
            +
                    #flush_mode immediate
         
     | 
| 
      
 731 
     | 
    
         
            +
                    flush_interval 0s
         
     | 
| 
      
 732 
     | 
    
         
            +
                    flush_at_shutdown false # suppress errors in d.instance_shutdown
         
     | 
| 
      
 733 
     | 
    
         
            +
                  </buffer>
         
     | 
| 
      
 734 
     | 
    
         
            +
                ]
         
     | 
| 
      
 735 
     | 
    
         
            +
                @d = d = create_driver(output_conf)
         
     | 
| 
      
 736 
     | 
    
         
            +
             
     | 
| 
      
 737 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 738 
     | 
    
         
            +
                records = [{"a" => 1}, {"a" => 2}]
         
     | 
| 
      
 739 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2, timeout: 3) do
         
     | 
| 
      
 740 
     | 
    
         
            +
                  d.run(default_tag: 'test', wait_flush_completion: false, shutdown: false) do
         
     | 
| 
      
 741 
     | 
    
         
            +
                    records.each do |record|
         
     | 
| 
      
 742 
     | 
    
         
            +
                      d.feed(time, record)
         
     | 
| 
      
 743 
     | 
    
         
            +
                    end
         
     | 
| 
      
 744 
     | 
    
         
            +
                  end
         
     | 
| 
      
 745 
     | 
    
         
            +
                end
         
     | 
| 
      
 746 
     | 
    
         
            +
             
     | 
| 
      
 747 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 748 
     | 
    
         
            +
                assert{ events != [] }
         
     | 
| 
      
 749 
     | 
    
         
            +
                assert_equal(['test', time, records[0]], events[0])
         
     | 
| 
      
 750 
     | 
    
         
            +
                assert_equal(['test', time, records[1]], events[1])
         
     | 
| 
      
 751 
     | 
    
         
            +
              end
         
     | 
| 
      
 752 
     | 
    
         
            +
             
     | 
| 
      
 753 
     | 
    
         
            +
              test 'a destination node not supporting responses by just ignoring' do
         
     | 
| 
      
 754 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: false)
         
     | 
| 
      
 755 
     | 
    
         
            +
             
     | 
| 
      
 756 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 757 
     | 
    
         
            +
                  require_ack_response true
         
     | 
| 
      
 758 
     | 
    
         
            +
                  ack_response_timeout 1s
         
     | 
| 
      
 759 
     | 
    
         
            +
                  <buffer tag>
         
     | 
| 
      
 760 
     | 
    
         
            +
                    flush_mode immediate
         
     | 
| 
      
 761 
     | 
    
         
            +
                    retry_type periodic
         
     | 
| 
      
 762 
     | 
    
         
            +
                    retry_wait 30s
         
     | 
| 
      
 763 
     | 
    
         
            +
                    flush_at_shutdown false # suppress errors in d.instance_shutdown
         
     | 
| 
      
 764 
     | 
    
         
            +
                    flush_thread_interval 30s
         
     | 
| 
      
 765 
     | 
    
         
            +
                  </buffer>
         
     | 
| 
      
 766 
     | 
    
         
            +
                ])
         
     | 
| 
      
 767 
     | 
    
         
            +
             
     | 
| 
      
 768 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 769 
     | 
    
         
            +
                delayed_commit_timeout_value = nil
         
     | 
| 
      
 770 
     | 
    
         
            +
             
     | 
| 
      
 771 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 772 
     | 
    
         
            +
             
     | 
| 
      
 773 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 774 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 775 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 776 
     | 
    
         
            +
                ]
         
     | 
| 
      
 777 
     | 
    
         
            +
                target_input_driver.end_if{ d.instance.rollback_count > 0 }
         
     | 
| 
      
 778 
     | 
    
         
            +
                target_input_driver.end_if{ !node.available? }
         
     | 
| 
      
 779 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2, timeout: 25) do
         
     | 
| 
      
 780 
     | 
    
         
            +
                  d.run(default_tag: 'test', timeout: 20, wait_flush_completion: false, shutdown: false, flush: false) do
         
     | 
| 
      
 781 
     | 
    
         
            +
                    delayed_commit_timeout_value = d.instance.delayed_commit_timeout
         
     | 
| 
      
 782 
     | 
    
         
            +
                    d.feed([[time, records[0]], [time,records[1]]])
         
     | 
| 
      
 783 
     | 
    
         
            +
                  end
         
     | 
| 
      
 784 
     | 
    
         
            +
                end
         
     | 
| 
      
 785 
     | 
    
         
            +
             
     | 
| 
      
 786 
     | 
    
         
            +
                assert_equal (1 + 2), delayed_commit_timeout_value
         
     | 
| 
      
 787 
     | 
    
         
            +
             
     | 
| 
      
 788 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 789 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 790 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 791 
     | 
    
         
            +
             
     | 
| 
      
 792 
     | 
    
         
            +
                assert{ d.instance.rollback_count > 0 }
         
     | 
| 
      
 793 
     | 
    
         
            +
             
     | 
| 
      
 794 
     | 
    
         
            +
                logs = d.instance.log.logs
         
     | 
| 
      
 795 
     | 
    
         
            +
                assert{ logs.any?{|log| log.include?("no response from node. regard it as unavailable.") } }
         
     | 
| 
      
 796 
     | 
    
         
            +
              end
         
     | 
| 
      
 797 
     | 
    
         
            +
             
     | 
| 
      
 798 
     | 
    
         
            +
              test 'a destination node not supporting responses by disconnection' do
         
     | 
| 
      
 799 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: true)
         
     | 
| 
      
 800 
     | 
    
         
            +
             
     | 
| 
      
 801 
     | 
    
         
            +
                @d = d = create_driver(config + %[
         
     | 
| 
      
 802 
     | 
    
         
            +
                  require_ack_response true
         
     | 
| 
      
 803 
     | 
    
         
            +
                  ack_response_timeout 1s
         
     | 
| 
      
 804 
     | 
    
         
            +
                  <buffer tag>
         
     | 
| 
      
 805 
     | 
    
         
            +
                    flush_mode immediate
         
     | 
| 
      
 806 
     | 
    
         
            +
                    retry_type periodic
         
     | 
| 
      
 807 
     | 
    
         
            +
                    retry_wait 30s
         
     | 
| 
      
 808 
     | 
    
         
            +
                    flush_at_shutdown false # suppress errors in d.instance_shutdown
         
     | 
| 
      
 809 
     | 
    
         
            +
                    flush_thread_interval 30s
         
     | 
| 
      
 810 
     | 
    
         
            +
                  </buffer>
         
     | 
| 
      
 811 
     | 
    
         
            +
                ])
         
     | 
| 
      
 812 
     | 
    
         
            +
             
     | 
| 
      
 813 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 814 
     | 
    
         
            +
                delayed_commit_timeout_value = nil
         
     | 
| 
      
 815 
     | 
    
         
            +
             
     | 
| 
      
 816 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 817 
     | 
    
         
            +
             
     | 
| 
      
 818 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 819 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 820 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 821 
     | 
    
         
            +
                ]
         
     | 
| 
      
 822 
     | 
    
         
            +
                target_input_driver.end_if{ d.instance.rollback_count > 0 }
         
     | 
| 
      
 823 
     | 
    
         
            +
                target_input_driver.end_if{ !node.available? }
         
     | 
| 
      
 824 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2, timeout: 25) do
         
     | 
| 
      
 825 
     | 
    
         
            +
                  d.run(default_tag: 'test', timeout: 20, wait_flush_completion: false, shutdown: false, flush: false) do
         
     | 
| 
      
 826 
     | 
    
         
            +
                    delayed_commit_timeout_value = d.instance.delayed_commit_timeout
         
     | 
| 
      
 827 
     | 
    
         
            +
                    d.feed([[time, records[0]], [time,records[1]]])
         
     | 
| 
      
 828 
     | 
    
         
            +
                  end
         
     | 
| 
      
 829 
     | 
    
         
            +
                end
         
     | 
| 
      
 830 
     | 
    
         
            +
             
     | 
| 
      
 831 
     | 
    
         
            +
                assert_equal (1 + 2), delayed_commit_timeout_value
         
     | 
| 
      
 832 
     | 
    
         
            +
             
     | 
| 
      
 833 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 834 
     | 
    
         
            +
                assert_equal ['test', time, records[0]], events[0]
         
     | 
| 
      
 835 
     | 
    
         
            +
                assert_equal ['test', time, records[1]], events[1]
         
     | 
| 
      
 836 
     | 
    
         
            +
             
     | 
| 
      
 837 
     | 
    
         
            +
                assert{ d.instance.rollback_count > 0 }
         
     | 
| 
      
 838 
     | 
    
         
            +
             
     | 
| 
      
 839 
     | 
    
         
            +
                logs = d.instance.log.logs
         
     | 
| 
      
 840 
     | 
    
         
            +
                assert{ logs.any?{|log| log.include?("no response from node. regard it as unavailable.") } }
         
     | 
| 
      
 841 
     | 
    
         
            +
              end
         
     | 
| 
      
 842 
     | 
    
         
            +
             
     | 
| 
      
 843 
     | 
    
         
            +
              test 'authentication_with_shared_key' do
         
     | 
| 
      
 844 
     | 
    
         
            +
                input_conf = target_config + %[
         
     | 
| 
      
 845 
     | 
    
         
            +
                               <security>
         
     | 
| 
      
 846 
     | 
    
         
            +
                                 self_hostname in.localhost
         
     | 
| 
      
 847 
     | 
    
         
            +
                                 shared_key fluentd-sharedkey
         
     | 
| 
      
 848 
     | 
    
         
            +
                                 <client>
         
     | 
| 
      
 849 
     | 
    
         
            +
                                   host 127.0.0.1
         
     | 
| 
      
 850 
     | 
    
         
            +
                                 </client>
         
     | 
| 
      
 851 
     | 
    
         
            +
                               </security>
         
     | 
| 
      
 852 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 853 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 854 
     | 
    
         
            +
             
     | 
| 
      
 855 
     | 
    
         
            +
                output_conf = %[
         
     | 
| 
      
 856 
     | 
    
         
            +
                  send_timeout 51
         
     | 
| 
      
 857 
     | 
    
         
            +
                  <security>
         
     | 
| 
      
 858 
     | 
    
         
            +
                    self_hostname localhost
         
     | 
| 
      
 859 
     | 
    
         
            +
                    shared_key fluentd-sharedkey
         
     | 
| 
      
 860 
     | 
    
         
            +
                  </security>
         
     | 
| 
      
 861 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 862 
     | 
    
         
            +
                    name test
         
     | 
| 
      
 863 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 864 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 865 
     | 
    
         
            +
                    shared_key fluentd-sharedkey
         
     | 
| 
      
 866 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 867 
     | 
    
         
            +
                ]
         
     | 
| 
      
 868 
     | 
    
         
            +
                @d = d = create_driver(output_conf)
         
     | 
| 
      
 869 
     | 
    
         
            +
             
     | 
| 
      
 870 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 871 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 872 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 873 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 874 
     | 
    
         
            +
                ]
         
     | 
| 
      
 875 
     | 
    
         
            +
             
     | 
| 
      
 876 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2, timeout: 15) do
         
     | 
| 
      
 877 
     | 
    
         
            +
                  d.run(default_tag: 'test') do
         
     | 
| 
      
 878 
     | 
    
         
            +
                    records.each do |record|
         
     | 
| 
      
 879 
     | 
    
         
            +
                      d.feed(time, record)
         
     | 
| 
      
 880 
     | 
    
         
            +
                    end
         
     | 
| 
      
 881 
     | 
    
         
            +
                  end
         
     | 
| 
      
 882 
     | 
    
         
            +
                end
         
     | 
| 
      
 883 
     | 
    
         
            +
             
     | 
| 
      
 884 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 885 
     | 
    
         
            +
                assert{ events != [] }
         
     | 
| 
      
 886 
     | 
    
         
            +
                assert_equal(['test', time, records[0]], events[0])
         
     | 
| 
      
 887 
     | 
    
         
            +
                assert_equal(['test', time, records[1]], events[1])
         
     | 
| 
      
 888 
     | 
    
         
            +
              end
         
     | 
| 
      
 889 
     | 
    
         
            +
             
     | 
| 
      
 890 
     | 
    
         
            +
              test 'keepalive + shared_key' do
         
     | 
| 
      
 891 
     | 
    
         
            +
                input_conf = target_config + %[
         
     | 
| 
      
 892 
     | 
    
         
            +
                               <security>
         
     | 
| 
      
 893 
     | 
    
         
            +
                                 self_hostname in.localhost
         
     | 
| 
      
 894 
     | 
    
         
            +
                                 shared_key fluentd-sharedkey
         
     | 
| 
      
 895 
     | 
    
         
            +
                               </security>
         
     | 
| 
      
 896 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 897 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 898 
     | 
    
         
            +
             
     | 
| 
      
 899 
     | 
    
         
            +
                output_conf = %[
         
     | 
| 
      
 900 
     | 
    
         
            +
                  send_timeout 51
         
     | 
| 
      
 901 
     | 
    
         
            +
                  keepalive true
         
     | 
| 
      
 902 
     | 
    
         
            +
                  <security>
         
     | 
| 
      
 903 
     | 
    
         
            +
                    self_hostname localhost
         
     | 
| 
      
 904 
     | 
    
         
            +
                    shared_key fluentd-sharedkey
         
     | 
| 
      
 905 
     | 
    
         
            +
                  </security>
         
     | 
| 
      
 906 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 907 
     | 
    
         
            +
                    name test
         
     | 
| 
      
 908 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 909 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 910 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 911 
     | 
    
         
            +
                ]
         
     | 
| 
      
 912 
     | 
    
         
            +
                @d = d = create_driver(output_conf)
         
     | 
| 
      
 913 
     | 
    
         
            +
             
     | 
| 
      
 914 
     | 
    
         
            +
                time = event_time('2011-01-02 13:14:15 UTC')
         
     | 
| 
      
 915 
     | 
    
         
            +
                records = [{ 'a' => 1 }, { 'a' => 2 }]
         
     | 
| 
      
 916 
     | 
    
         
            +
                records2 = [{ 'b' => 1}, { 'b' => 2}]
         
     | 
| 
      
 917 
     | 
    
         
            +
                target_input_driver.run(expect_records: 4, timeout: 15) do
         
     | 
| 
      
 918 
     | 
    
         
            +
                  d.run(default_tag: 'test') do
         
     | 
| 
      
 919 
     | 
    
         
            +
                    records.each do |record|
         
     | 
| 
      
 920 
     | 
    
         
            +
                      d.feed(time, record)
         
     | 
| 
      
 921 
     | 
    
         
            +
                    end
         
     | 
| 
      
 922 
     | 
    
         
            +
             
     | 
| 
      
 923 
     | 
    
         
            +
                    d.flush # emit buffer to reuse same socket later
         
     | 
| 
      
 924 
     | 
    
         
            +
                    records2.each do |record|
         
     | 
| 
      
 925 
     | 
    
         
            +
                      d.feed(time, record)
         
     | 
| 
      
 926 
     | 
    
         
            +
                    end
         
     | 
| 
      
 927 
     | 
    
         
            +
                  end
         
     | 
| 
      
 928 
     | 
    
         
            +
                end
         
     | 
| 
      
 929 
     | 
    
         
            +
             
     | 
| 
      
 930 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 931 
     | 
    
         
            +
                assert{ events != [] }
         
     | 
| 
      
 932 
     | 
    
         
            +
                assert_equal(['test', time, records[0]], events[0])
         
     | 
| 
      
 933 
     | 
    
         
            +
                assert_equal(['test', time, records[1]], events[1])
         
     | 
| 
      
 934 
     | 
    
         
            +
                assert_equal(['test', time, records2[0]], events[2])
         
     | 
| 
      
 935 
     | 
    
         
            +
                assert_equal(['test', time, records2[1]], events[3])
         
     | 
| 
      
 936 
     | 
    
         
            +
              end
         
     | 
| 
      
 937 
     | 
    
         
            +
             
     | 
| 
      
 938 
     | 
    
         
            +
               test 'authentication_with_user_auth' do
         
     | 
| 
      
 939 
     | 
    
         
            +
                input_conf = target_config + %[
         
     | 
| 
      
 940 
     | 
    
         
            +
                               <security>
         
     | 
| 
      
 941 
     | 
    
         
            +
                                 self_hostname in.localhost
         
     | 
| 
      
 942 
     | 
    
         
            +
                                 shared_key fluentd-sharedkey
         
     | 
| 
      
 943 
     | 
    
         
            +
                                 user_auth true
         
     | 
| 
      
 944 
     | 
    
         
            +
                                 <user>
         
     | 
| 
      
 945 
     | 
    
         
            +
                                   username fluentd
         
     | 
| 
      
 946 
     | 
    
         
            +
                                   password fluentd
         
     | 
| 
      
 947 
     | 
    
         
            +
                                 </user>
         
     | 
| 
      
 948 
     | 
    
         
            +
                                 <client>
         
     | 
| 
      
 949 
     | 
    
         
            +
                                   host 127.0.0.1
         
     | 
| 
      
 950 
     | 
    
         
            +
                                 </client>
         
     | 
| 
      
 951 
     | 
    
         
            +
                               </security>
         
     | 
| 
      
 952 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 953 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 954 
     | 
    
         
            +
             
     | 
| 
      
 955 
     | 
    
         
            +
                output_conf = %[
         
     | 
| 
      
 956 
     | 
    
         
            +
                  send_timeout 51
         
     | 
| 
      
 957 
     | 
    
         
            +
                  <security>
         
     | 
| 
      
 958 
     | 
    
         
            +
                    self_hostname localhost
         
     | 
| 
      
 959 
     | 
    
         
            +
                    shared_key fluentd-sharedkey
         
     | 
| 
      
 960 
     | 
    
         
            +
                  </security>
         
     | 
| 
      
 961 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 962 
     | 
    
         
            +
                    name test
         
     | 
| 
      
 963 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 964 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 965 
     | 
    
         
            +
                    shared_key fluentd-sharedkey
         
     | 
| 
      
 966 
     | 
    
         
            +
                    username fluentd
         
     | 
| 
      
 967 
     | 
    
         
            +
                    password fluentd
         
     | 
| 
      
 968 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 969 
     | 
    
         
            +
                ]
         
     | 
| 
      
 970 
     | 
    
         
            +
                @d = d = create_driver(output_conf)
         
     | 
| 
      
 971 
     | 
    
         
            +
             
     | 
| 
      
 972 
     | 
    
         
            +
                time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 973 
     | 
    
         
            +
                records = [
         
     | 
| 
      
 974 
     | 
    
         
            +
                  {"a" => 1},
         
     | 
| 
      
 975 
     | 
    
         
            +
                  {"a" => 2}
         
     | 
| 
      
 976 
     | 
    
         
            +
                ]
         
     | 
| 
      
 977 
     | 
    
         
            +
             
     | 
| 
      
 978 
     | 
    
         
            +
                target_input_driver.run(expect_records: 2, timeout: 15) do
         
     | 
| 
      
 979 
     | 
    
         
            +
                  d.run(default_tag: 'test') do
         
     | 
| 
      
 980 
     | 
    
         
            +
                    records.each do |record|
         
     | 
| 
      
 981 
     | 
    
         
            +
                      d.feed(time, record)
         
     | 
| 
      
 982 
     | 
    
         
            +
                    end
         
     | 
| 
      
 983 
     | 
    
         
            +
                  end
         
     | 
| 
      
 984 
     | 
    
         
            +
                end
         
     | 
| 
      
 985 
     | 
    
         
            +
             
     | 
| 
      
 986 
     | 
    
         
            +
                events = target_input_driver.events
         
     | 
| 
      
 987 
     | 
    
         
            +
                assert{ events != [] }
         
     | 
| 
      
 988 
     | 
    
         
            +
                assert_equal(['test', time, records[0]], events[0])
         
     | 
| 
      
 989 
     | 
    
         
            +
                assert_equal(['test', time, records[1]], events[1])
         
     | 
| 
      
 990 
     | 
    
         
            +
              end
         
     | 
| 
      
 991 
     | 
    
         
            +
             
     | 
| 
      
 992 
     | 
    
         
            +
              # This test is not 100% but test failed with previous Node implementation which has race condition
         
     | 
| 
      
 993 
     | 
    
         
            +
              test 'Node with security is thread-safe on multi threads' do
         
     | 
| 
      
 994 
     | 
    
         
            +
                input_conf = target_config + %[
         
     | 
| 
      
 995 
     | 
    
         
            +
                               <security>
         
     | 
| 
      
 996 
     | 
    
         
            +
                                 self_hostname in.localhost
         
     | 
| 
      
 997 
     | 
    
         
            +
                                 shared_key fluentd-sharedkey
         
     | 
| 
      
 998 
     | 
    
         
            +
                                 <client>
         
     | 
| 
      
 999 
     | 
    
         
            +
                                   host 127.0.0.1
         
     | 
| 
      
 1000 
     | 
    
         
            +
                                 </client>
         
     | 
| 
      
 1001 
     | 
    
         
            +
                               </security>
         
     | 
| 
      
 1002 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 1003 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 1004 
     | 
    
         
            +
                output_conf = %[
         
     | 
| 
      
 1005 
     | 
    
         
            +
                  send_timeout 51
         
     | 
| 
      
 1006 
     | 
    
         
            +
                  <security>
         
     | 
| 
      
 1007 
     | 
    
         
            +
                    self_hostname localhost
         
     | 
| 
      
 1008 
     | 
    
         
            +
                    shared_key fluentd-sharedkey
         
     | 
| 
      
 1009 
     | 
    
         
            +
                  </security>
         
     | 
| 
      
 1010 
     | 
    
         
            +
                  <server>
         
     | 
| 
      
 1011 
     | 
    
         
            +
                    name test
         
     | 
| 
      
 1012 
     | 
    
         
            +
                    host #{TARGET_HOST}
         
     | 
| 
      
 1013 
     | 
    
         
            +
                    port #{@target_port}
         
     | 
| 
      
 1014 
     | 
    
         
            +
                    shared_key fluentd-sharedkey
         
     | 
| 
      
 1015 
     | 
    
         
            +
                  </server>
         
     | 
| 
      
 1016 
     | 
    
         
            +
                ]
         
     | 
| 
      
 1017 
     | 
    
         
            +
                @d = d = create_driver(output_conf)
         
     | 
| 
      
 1018 
     | 
    
         
            +
             
     | 
| 
      
 1019 
     | 
    
         
            +
                chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
         
     | 
| 
      
 1020 
     | 
    
         
            +
                target_input_driver.run(timeout: 15) do
         
     | 
| 
      
 1021 
     | 
    
         
            +
                  d.run(shutdown: false) do
         
     | 
| 
      
 1022 
     | 
    
         
            +
                    node = d.instance.nodes.first
         
     | 
| 
      
 1023 
     | 
    
         
            +
                    arr = []
         
     | 
| 
      
 1024 
     | 
    
         
            +
                    4.times {
         
     | 
| 
      
 1025 
     | 
    
         
            +
                      arr << Thread.new {
         
     | 
| 
      
 1026 
     | 
    
         
            +
                        node.send_data('test', chunk) rescue nil
         
     | 
| 
      
 1027 
     | 
    
         
            +
                      }
         
     | 
| 
      
 1028 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1029 
     | 
    
         
            +
                    arr.each { |a| a.join }
         
     | 
| 
      
 1030 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1031 
     | 
    
         
            +
                end
         
     | 
| 
      
 1032 
     | 
    
         
            +
             
     | 
| 
      
 1033 
     | 
    
         
            +
                logs = d.logs
         
     | 
| 
      
 1034 
     | 
    
         
            +
                assert_false(logs.any? { |log|
         
     | 
| 
      
 1035 
     | 
    
         
            +
                               log.include?("invalid format for PONG message") || log.include?("shared key mismatch")
         
     | 
| 
      
 1036 
     | 
    
         
            +
                             }, "Actual log:\n#{logs.join}")
         
     | 
| 
      
 1037 
     | 
    
         
            +
              end
         
     | 
| 
      
 1038 
     | 
    
         
            +
             
     | 
| 
      
 1039 
     | 
    
         
            +
              def create_target_input_driver(response_stub: nil, disconnect: false, conf: target_config)
         
     | 
| 
      
 1040 
     | 
    
         
            +
                require 'fluent/plugin/in_forward'
         
     | 
| 
      
 1041 
     | 
    
         
            +
             
     | 
| 
      
 1042 
     | 
    
         
            +
                # TODO: Support actual TCP heartbeat test
         
     | 
| 
      
 1043 
     | 
    
         
            +
                Fluent::Test::Driver::Input.new(Fluent::Plugin::ForwardInput) {
         
     | 
| 
      
 1044 
     | 
    
         
            +
                  if response_stub.nil?
         
     | 
| 
      
 1045 
     | 
    
         
            +
                    # do nothing because in_forward responds for ack option in default
         
     | 
| 
      
 1046 
     | 
    
         
            +
                  else
         
     | 
| 
      
 1047 
     | 
    
         
            +
                    define_method(:response) do |options|
         
     | 
| 
      
 1048 
     | 
    
         
            +
                      return response_stub.(options)
         
     | 
| 
      
 1049 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1050 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1051 
     | 
    
         
            +
                }.configure(conf)
         
     | 
| 
      
 1052 
     | 
    
         
            +
              end
         
     | 
| 
      
 1053 
     | 
    
         
            +
             
     | 
| 
      
 1054 
     | 
    
         
            +
              test 'heartbeat_type_none' do
         
     | 
| 
      
 1055 
     | 
    
         
            +
                @d = d = create_driver(config + "\nheartbeat_type none")
         
     | 
| 
      
 1056 
     | 
    
         
            +
                node = d.instance.nodes.first
         
     | 
| 
      
 1057 
     | 
    
         
            +
                assert_equal Fluent::Plugin::ForwardOutput::NoneHeartbeatNode, node.class
         
     | 
| 
      
 1058 
     | 
    
         
            +
             
     | 
| 
      
 1059 
     | 
    
         
            +
                d.instance_start
         
     | 
| 
      
 1060 
     | 
    
         
            +
                assert_nil d.instance.instance_variable_get(:@loop)   # no HeartbeatHandler, or HeartbeatRequestTimer
         
     | 
| 
      
 1061 
     | 
    
         
            +
                assert_nil d.instance.instance_variable_get(:@thread) # no HeartbeatHandler, or HeartbeatRequestTimer
         
     | 
| 
      
 1062 
     | 
    
         
            +
             
     | 
| 
      
 1063 
     | 
    
         
            +
                stub(node.failure).phi { raise 'Should not be called' }
         
     | 
| 
      
 1064 
     | 
    
         
            +
                node.tick
         
     | 
| 
      
 1065 
     | 
    
         
            +
                assert_true node.available?
         
     | 
| 
      
 1066 
     | 
    
         
            +
              end
         
     | 
| 
      
 1067 
     | 
    
         
            +
             
     | 
| 
      
 1068 
     | 
    
         
            +
              test 'heartbeat_type_udp' do
         
     | 
| 
      
 1069 
     | 
    
         
            +
                @d = d = create_driver(config + "\nheartbeat_type udp")
         
     | 
| 
      
 1070 
     | 
    
         
            +
             
     | 
| 
      
 1071 
     | 
    
         
            +
                d.instance_start
         
     | 
| 
      
 1072 
     | 
    
         
            +
                usock = d.instance.instance_variable_get(:@usock)
         
     | 
| 
      
 1073 
     | 
    
         
            +
                servers = d.instance.instance_variable_get(:@_servers)
         
     | 
| 
      
 1074 
     | 
    
         
            +
                timers = d.instance.instance_variable_get(:@_timers)
         
     | 
| 
      
 1075 
     | 
    
         
            +
                assert_equal Fluent::PluginHelper::Socket::WrappedSocket::UDP, usock.class
         
     | 
| 
      
 1076 
     | 
    
         
            +
                assert_kind_of UDPSocket, usock
         
     | 
| 
      
 1077 
     | 
    
         
            +
                assert servers.find{|s| s.title == :out_forward_heartbeat_receiver }
         
     | 
| 
      
 1078 
     | 
    
         
            +
                assert timers.include?(:out_forward_heartbeat_request)
         
     | 
| 
      
 1079 
     | 
    
         
            +
             
     | 
| 
      
 1080 
     | 
    
         
            +
                mock(usock).send("\0", 0, Socket.pack_sockaddr_in(@target_port, '127.0.0.1')).once
         
     | 
| 
      
 1081 
     | 
    
         
            +
                d.instance.send(:on_heartbeat_timer)
         
     | 
| 
      
 1082 
     | 
    
         
            +
              end
         
     | 
| 
      
 1083 
     | 
    
         
            +
             
     | 
| 
      
 1084 
     | 
    
         
            +
              test 'acts_as_secondary' do
         
     | 
| 
      
 1085 
     | 
    
         
            +
                i = Fluent::Plugin::ForwardOutput.new
         
     | 
| 
      
 1086 
     | 
    
         
            +
                conf = config_element(
         
     | 
| 
      
 1087 
     | 
    
         
            +
                  'match',
         
     | 
| 
      
 1088 
     | 
    
         
            +
                  'primary.**',
         
     | 
| 
      
 1089 
     | 
    
         
            +
                  {'@type' => 'forward'},
         
     | 
| 
      
 1090 
     | 
    
         
            +
                  [
         
     | 
| 
      
 1091 
     | 
    
         
            +
                    config_element('server', '', {'host' => '127.0.0.1'}),
         
     | 
| 
      
 1092 
     | 
    
         
            +
                    config_element('secondary', '', {}, [
         
     | 
| 
      
 1093 
     | 
    
         
            +
                        config_element('server', '', {'host' => '192.168.1.2'}),
         
     | 
| 
      
 1094 
     | 
    
         
            +
                        config_element('server', '', {'host' => '192.168.1.3'})
         
     | 
| 
      
 1095 
     | 
    
         
            +
                      ]),
         
     | 
| 
      
 1096 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 1097 
     | 
    
         
            +
                )
         
     | 
| 
      
 1098 
     | 
    
         
            +
                assert_nothing_raised do
         
     | 
| 
      
 1099 
     | 
    
         
            +
                  i.configure(conf)
         
     | 
| 
      
 1100 
     | 
    
         
            +
                end
         
     | 
| 
      
 1101 
     | 
    
         
            +
              end
         
     | 
| 
      
 1102 
     | 
    
         
            +
             
     | 
| 
      
 1103 
     | 
    
         
            +
              test 'when out_forward has @id' do
         
     | 
| 
      
 1104 
     | 
    
         
            +
                # cancel https://github.com/fluent/fluentd/blob/077508ac817b7637307434d0c978d7cdc3d1c534/lib/fluent/plugin_id.rb#L43-L53
         
     | 
| 
      
 1105 
     | 
    
         
            +
                # it always return true in test
         
     | 
| 
      
 1106 
     | 
    
         
            +
                mock.proxy(Fluent::Plugin).new_sd('static', parent: anything) { |v|
         
     | 
| 
      
 1107 
     | 
    
         
            +
                  stub(v).plugin_id_for_test? { false }
         
     | 
| 
      
 1108 
     | 
    
         
            +
                }.once
         
     | 
| 
      
 1109 
     | 
    
         
            +
             
     | 
| 
      
 1110 
     | 
    
         
            +
                output = Fluent::Test::Driver::Output.new(Fluent::Plugin::ForwardOutput) {
         
     | 
| 
      
 1111 
     | 
    
         
            +
                  def plugin_id_for_test?
         
     | 
| 
      
 1112 
     | 
    
         
            +
                    false
         
     | 
| 
      
 1113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1114 
     | 
    
         
            +
                }
         
     | 
| 
      
 1115 
     | 
    
         
            +
             
     | 
| 
      
 1116 
     | 
    
         
            +
                assert_nothing_raised do
         
     | 
| 
      
 1117 
     | 
    
         
            +
                  output.configure(config + %[
         
     | 
| 
      
 1118 
     | 
    
         
            +
                    @id unique_out_forward
         
     | 
| 
      
 1119 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 1120 
     | 
    
         
            +
                end
         
     | 
| 
      
 1121 
     | 
    
         
            +
              end
         
     | 
| 
      
 1122 
     | 
    
         
            +
             
     | 
| 
      
 1123 
     | 
    
         
            +
              sub_test_case 'verify_connection_at_startup' do
         
     | 
| 
      
 1124 
     | 
    
         
            +
                test 'nodes are not available' do
         
     | 
| 
      
 1125 
     | 
    
         
            +
                  @d = d = create_driver(config + %[
         
     | 
| 
      
 1126 
     | 
    
         
            +
                    verify_connection_at_startup true
         
     | 
| 
      
 1127 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 1128 
     | 
    
         
            +
                  e = assert_raise Fluent::UnrecoverableError do
         
     | 
| 
      
 1129 
     | 
    
         
            +
                    d.instance_start
         
     | 
| 
      
 1130 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1131 
     | 
    
         
            +
                  if Fluent.windows?
         
     | 
| 
      
 1132 
     | 
    
         
            +
                    assert_match(/No connection could be made because the target machine actively refused it/, e.message)
         
     | 
| 
      
 1133 
     | 
    
         
            +
                  else
         
     | 
| 
      
 1134 
     | 
    
         
            +
                    assert_match(/Connection refused/, e.message)
         
     | 
| 
      
 1135 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1136 
     | 
    
         
            +
             
     | 
| 
      
 1137 
     | 
    
         
            +
                  d.instance_shutdown
         
     | 
| 
      
 1138 
     | 
    
         
            +
                end
         
     | 
| 
      
 1139 
     | 
    
         
            +
             
     | 
| 
      
 1140 
     | 
    
         
            +
                test 'nodes_shared_key_miss_match' do
         
     | 
| 
      
 1141 
     | 
    
         
            +
                  input_conf = target_config + %[
         
     | 
| 
      
 1142 
     | 
    
         
            +
                               <security>
         
     | 
| 
      
 1143 
     | 
    
         
            +
                                 self_hostname in.localhost
         
     | 
| 
      
 1144 
     | 
    
         
            +
                                 shared_key fluentd-sharedkey
         
     | 
| 
      
 1145 
     | 
    
         
            +
                               </security>
         
     | 
| 
      
 1146 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 1147 
     | 
    
         
            +
                  target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 1148 
     | 
    
         
            +
                  output_conf = %[
         
     | 
| 
      
 1149 
     | 
    
         
            +
                    transport tcp
         
     | 
| 
      
 1150 
     | 
    
         
            +
                    verify_connection_at_startup true
         
     | 
| 
      
 1151 
     | 
    
         
            +
                    <security>
         
     | 
| 
      
 1152 
     | 
    
         
            +
                      self_hostname localhost
         
     | 
| 
      
 1153 
     | 
    
         
            +
                      shared_key key_miss_match
         
     | 
| 
      
 1154 
     | 
    
         
            +
                    </security>
         
     | 
| 
      
 1155 
     | 
    
         
            +
             
     | 
| 
      
 1156 
     | 
    
         
            +
                    <server>
         
     | 
| 
      
 1157 
     | 
    
         
            +
                      host #{TARGET_HOST}
         
     | 
| 
      
 1158 
     | 
    
         
            +
                      port #{@target_port}
         
     | 
| 
      
 1159 
     | 
    
         
            +
                    </server>
         
     | 
| 
      
 1160 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 1161 
     | 
    
         
            +
                  @d = d = create_driver(output_conf)
         
     | 
| 
      
 1162 
     | 
    
         
            +
             
     | 
| 
      
 1163 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 1, timeout: 1) do
         
     | 
| 
      
 1164 
     | 
    
         
            +
                    e = assert_raise Fluent::UnrecoverableError do
         
     | 
| 
      
 1165 
     | 
    
         
            +
                      d.instance_start
         
     | 
| 
      
 1166 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1167 
     | 
    
         
            +
                    assert_match(/failed to establish connection/, e.message)
         
     | 
| 
      
 1168 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1169 
     | 
    
         
            +
                end
         
     | 
| 
      
 1170 
     | 
    
         
            +
             
     | 
| 
      
 1171 
     | 
    
         
            +
                test 'nodes_shared_key_miss_match with TLS' do
         
     | 
| 
      
 1172 
     | 
    
         
            +
                  input_conf = target_config + %[
         
     | 
| 
      
 1173 
     | 
    
         
            +
                               <security>
         
     | 
| 
      
 1174 
     | 
    
         
            +
                                 self_hostname in.localhost
         
     | 
| 
      
 1175 
     | 
    
         
            +
                                 shared_key fluentd-sharedkey
         
     | 
| 
      
 1176 
     | 
    
         
            +
                               </security>
         
     | 
| 
      
 1177 
     | 
    
         
            +
                               <transport tls>
         
     | 
| 
      
 1178 
     | 
    
         
            +
                                 insecure true
         
     | 
| 
      
 1179 
     | 
    
         
            +
                               </transport>
         
     | 
| 
      
 1180 
     | 
    
         
            +
                             ]
         
     | 
| 
      
 1181 
     | 
    
         
            +
                  target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 1182 
     | 
    
         
            +
                  output_conf = %[
         
     | 
| 
      
 1183 
     | 
    
         
            +
                    transport tls
         
     | 
| 
      
 1184 
     | 
    
         
            +
                    tls_insecure_mode true
         
     | 
| 
      
 1185 
     | 
    
         
            +
                    verify_connection_at_startup true
         
     | 
| 
      
 1186 
     | 
    
         
            +
                    <security>
         
     | 
| 
      
 1187 
     | 
    
         
            +
                      self_hostname localhost
         
     | 
| 
      
 1188 
     | 
    
         
            +
                      shared_key key_miss_match
         
     | 
| 
      
 1189 
     | 
    
         
            +
                    </security>
         
     | 
| 
      
 1190 
     | 
    
         
            +
             
     | 
| 
      
 1191 
     | 
    
         
            +
                    <server>
         
     | 
| 
      
 1192 
     | 
    
         
            +
                      host #{TARGET_HOST}
         
     | 
| 
      
 1193 
     | 
    
         
            +
                      port #{@target_port}
         
     | 
| 
      
 1194 
     | 
    
         
            +
                    </server>
         
     | 
| 
      
 1195 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 1196 
     | 
    
         
            +
                  @d = d = create_driver(output_conf)
         
     | 
| 
      
 1197 
     | 
    
         
            +
             
     | 
| 
      
 1198 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 1, timeout: 1) do
         
     | 
| 
      
 1199 
     | 
    
         
            +
                    e = assert_raise Fluent::UnrecoverableError do
         
     | 
| 
      
 1200 
     | 
    
         
            +
                      d.instance_start
         
     | 
| 
      
 1201 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1202 
     | 
    
         
            +
             
     | 
| 
      
 1203 
     | 
    
         
            +
                    assert_match(/failed to establish connection/, e.message)
         
     | 
| 
      
 1204 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1205 
     | 
    
         
            +
                end
         
     | 
| 
      
 1206 
     | 
    
         
            +
             
     | 
| 
      
 1207 
     | 
    
         
            +
                test 'nodes_shared_key_match' do
         
     | 
| 
      
 1208 
     | 
    
         
            +
                  input_conf = target_config + %[
         
     | 
| 
      
 1209 
     | 
    
         
            +
                                   <security>
         
     | 
| 
      
 1210 
     | 
    
         
            +
                                     self_hostname in.localhost
         
     | 
| 
      
 1211 
     | 
    
         
            +
                                     shared_key fluentd-sharedkey
         
     | 
| 
      
 1212 
     | 
    
         
            +
                                   </security>
         
     | 
| 
      
 1213 
     | 
    
         
            +
                                 ]
         
     | 
| 
      
 1214 
     | 
    
         
            +
                  target_input_driver = create_target_input_driver(conf: input_conf)
         
     | 
| 
      
 1215 
     | 
    
         
            +
                  output_conf = %[
         
     | 
| 
      
 1216 
     | 
    
         
            +
                      verify_connection_at_startup true
         
     | 
| 
      
 1217 
     | 
    
         
            +
                      <security>
         
     | 
| 
      
 1218 
     | 
    
         
            +
                        self_hostname localhost
         
     | 
| 
      
 1219 
     | 
    
         
            +
                        shared_key fluentd-sharedkey
         
     | 
| 
      
 1220 
     | 
    
         
            +
                      </security>
         
     | 
| 
      
 1221 
     | 
    
         
            +
                      <server>
         
     | 
| 
      
 1222 
     | 
    
         
            +
                        name test
         
     | 
| 
      
 1223 
     | 
    
         
            +
                        host #{TARGET_HOST}
         
     | 
| 
      
 1224 
     | 
    
         
            +
                        port #{@target_port}
         
     | 
| 
      
 1225 
     | 
    
         
            +
                      </server>
         
     | 
| 
      
 1226 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 1227 
     | 
    
         
            +
                  @d = d = create_driver(output_conf)
         
     | 
| 
      
 1228 
     | 
    
         
            +
             
     | 
| 
      
 1229 
     | 
    
         
            +
                  time = event_time("2011-01-02 13:14:15 UTC")
         
     | 
| 
      
 1230 
     | 
    
         
            +
                  records = [{ "a" => 1 }, { "a" => 2 }]
         
     | 
| 
      
 1231 
     | 
    
         
            +
             
     | 
| 
      
 1232 
     | 
    
         
            +
                  target_input_driver.run(expect_records: 2, timeout: 3) do
         
     | 
| 
      
 1233 
     | 
    
         
            +
                    d.run(default_tag: 'test') do
         
     | 
| 
      
 1234 
     | 
    
         
            +
                      records.each do |record|
         
     | 
| 
      
 1235 
     | 
    
         
            +
                        d.feed(time, record)
         
     | 
| 
      
 1236 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1237 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1238 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1239 
     | 
    
         
            +
             
     | 
| 
      
 1240 
     | 
    
         
            +
                  events = target_input_driver.events
         
     | 
| 
      
 1241 
     | 
    
         
            +
                  assert_false events.empty?
         
     | 
| 
      
 1242 
     | 
    
         
            +
                  assert_equal(['test', time, records[0]], events[0])
         
     | 
| 
      
 1243 
     | 
    
         
            +
                  assert_equal(['test', time, records[1]], events[1])
         
     | 
| 
      
 1244 
     | 
    
         
            +
                end
         
     | 
| 
      
 1245 
     | 
    
         
            +
              end
         
     | 
| 
      
 1246 
     | 
    
         
            +
             
     | 
| 
      
 1247 
     | 
    
         
            +
              test 'Create new connection per send_data' do
         
     | 
| 
      
 1248 
     | 
    
         
            +
                target_input_driver = create_target_input_driver(conf: target_config)
         
     | 
| 
      
 1249 
     | 
    
         
            +
                output_conf = config
         
     | 
| 
      
 1250 
     | 
    
         
            +
                d = create_driver(output_conf)
         
     | 
| 
      
 1251 
     | 
    
         
            +
                d.instance_start
         
     | 
| 
      
 1252 
     | 
    
         
            +
             
     | 
| 
      
 1253 
     | 
    
         
            +
                begin
         
     | 
| 
      
 1254 
     | 
    
         
            +
                  chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
         
     | 
| 
      
 1255 
     | 
    
         
            +
                  mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
         
     | 
| 
      
 1256 
     | 
    
         
            +
                                                           linger_timeout: anything,
         
     | 
| 
      
 1257 
     | 
    
         
            +
                                                           send_timeout: anything,
         
     | 
| 
      
 1258 
     | 
    
         
            +
                                                           recv_timeout: anything,
         
     | 
| 
      
 1259 
     | 
    
         
            +
                                                           connect_timeout: anything
         
     | 
| 
      
 1260 
     | 
    
         
            +
                                                          ) { |sock| mock(sock).close.once; sock }.twice
         
     | 
| 
      
 1261 
     | 
    
         
            +
             
     | 
| 
      
 1262 
     | 
    
         
            +
                  target_input_driver.run(timeout: 15) do
         
     | 
| 
      
 1263 
     | 
    
         
            +
                    d.run(shutdown: false) do
         
     | 
| 
      
 1264 
     | 
    
         
            +
                      node = d.instance.nodes.first
         
     | 
| 
      
 1265 
     | 
    
         
            +
                      2.times do
         
     | 
| 
      
 1266 
     | 
    
         
            +
                        node.send_data('test', chunk) rescue nil
         
     | 
| 
      
 1267 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1268 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1269 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1270 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 1271 
     | 
    
         
            +
                  d.instance_shutdown
         
     | 
| 
      
 1272 
     | 
    
         
            +
                end
         
     | 
| 
      
 1273 
     | 
    
         
            +
              end
         
     | 
| 
      
 1274 
     | 
    
         
            +
             
     | 
| 
      
 1275 
     | 
    
         
            +
              test 'if no available node' do
         
     | 
| 
      
 1276 
     | 
    
         
            +
                # do not create output driver
         
     | 
| 
      
 1277 
     | 
    
         
            +
                d = create_driver(%[
         
     | 
| 
      
 1278 
     | 
    
         
            +
                <server>
         
     | 
| 
      
 1279 
     | 
    
         
            +
                  name test
         
     | 
| 
      
 1280 
     | 
    
         
            +
                  standby
         
     | 
| 
      
 1281 
     | 
    
         
            +
                  host #{TARGET_HOST}
         
     | 
| 
      
 1282 
     | 
    
         
            +
                  port #{@target_port}
         
     | 
| 
      
 1283 
     | 
    
         
            +
                </server>
         
     | 
| 
      
 1284 
     | 
    
         
            +
                ])
         
     | 
| 
      
 1285 
     | 
    
         
            +
                d.instance_start
         
     | 
| 
      
 1286 
     | 
    
         
            +
                assert_nothing_raised { d.run }
         
     | 
| 
      
 1287 
     | 
    
         
            +
              end
         
     | 
| 
      
 1288 
     | 
    
         
            +
             
     | 
| 
      
 1289 
     | 
    
         
            +
              sub_test_case 'keepalive' do
         
     | 
| 
      
 1290 
     | 
    
         
            +
                test 'Do not create connection per send_data' do
         
     | 
| 
      
 1291 
     | 
    
         
            +
                  target_input_driver = create_target_input_driver(conf: target_config)
         
     | 
| 
      
 1292 
     | 
    
         
            +
                  output_conf = config + %[
         
     | 
| 
      
 1293 
     | 
    
         
            +
                    keepalive true
         
     | 
| 
      
 1294 
     | 
    
         
            +
                    keepalive_timeout 2
         
     | 
| 
      
 1295 
     | 
    
         
            +
                  ]
         
     | 
| 
      
 1296 
     | 
    
         
            +
                  d = create_driver(output_conf)
         
     | 
| 
      
 1297 
     | 
    
         
            +
                  d.instance_start
         
     | 
| 
      
 1298 
     | 
    
         
            +
             
     | 
| 
      
 1299 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 1300 
     | 
    
         
            +
                    chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
         
     | 
| 
      
 1301 
     | 
    
         
            +
                    mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
         
     | 
| 
      
 1302 
     | 
    
         
            +
                                                             linger_timeout: anything,
         
     | 
| 
      
 1303 
     | 
    
         
            +
                                                             send_timeout: anything,
         
     | 
| 
      
 1304 
     | 
    
         
            +
                                                             recv_timeout: anything,
         
     | 
| 
      
 1305 
     | 
    
         
            +
                                                             connect_timeout: anything
         
     | 
| 
      
 1306 
     | 
    
         
            +
                                                            ) { |sock| mock(sock).close.once; sock }.once
         
     | 
| 
      
 1307 
     | 
    
         
            +
             
     | 
| 
      
 1308 
     | 
    
         
            +
                    target_input_driver.run(timeout: 15) do
         
     | 
| 
      
 1309 
     | 
    
         
            +
                      d.run(shutdown: false) do
         
     | 
| 
      
 1310 
     | 
    
         
            +
                        node = d.instance.nodes.first
         
     | 
| 
      
 1311 
     | 
    
         
            +
                        2.times do
         
     | 
| 
      
 1312 
     | 
    
         
            +
                          node.send_data('test', chunk) rescue nil
         
     | 
| 
      
 1313 
     | 
    
         
            +
                        end
         
     | 
| 
      
 1314 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1315 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1316 
     | 
    
         
            +
                  ensure
         
     | 
| 
      
 1317 
     | 
    
         
            +
                    d.instance_shutdown
         
     | 
| 
      
 1318 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1319 
     | 
    
         
            +
                end
         
     | 
| 
      
 1320 
     | 
    
         
            +
             
     | 
| 
      
 1321 
     | 
    
         
            +
                test 'create timer of purging obsolete sockets' do
         
     | 
| 
      
 1322 
     | 
    
         
            +
                  output_conf = config + %[keepalive true]
         
     | 
| 
      
 1323 
     | 
    
         
            +
                  d = create_driver(output_conf)
         
     | 
| 
      
 1324 
     | 
    
         
            +
             
     | 
| 
      
 1325 
     | 
    
         
            +
                  mock(d.instance).timer_execute(:out_forward_heartbeat_request, 1).once
         
     | 
| 
      
 1326 
     | 
    
         
            +
                  mock(d.instance).timer_execute(:out_forward_keep_alived_socket_watcher, 5).once
         
     | 
| 
      
 1327 
     | 
    
         
            +
                  d.instance_start
         
     | 
| 
      
 1328 
     | 
    
         
            +
                end
         
     | 
| 
      
 1329 
     | 
    
         
            +
             
     | 
| 
      
 1330 
     | 
    
         
            +
                sub_test_case 'with require_ack_response' do
         
     | 
| 
      
 1331 
     | 
    
         
            +
                  test 'Create connection per send_data' do
         
     | 
| 
      
 1332 
     | 
    
         
            +
                    target_input_driver = create_target_input_driver(conf: target_config)
         
     | 
| 
      
 1333 
     | 
    
         
            +
                    output_conf = config + %[
         
     | 
| 
      
 1334 
     | 
    
         
            +
                      require_ack_response true
         
     | 
| 
      
 1335 
     | 
    
         
            +
                      keepalive true
         
     | 
| 
      
 1336 
     | 
    
         
            +
                      keepalive_timeout 2
         
     | 
| 
      
 1337 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 1338 
     | 
    
         
            +
                    d = create_driver(output_conf)
         
     | 
| 
      
 1339 
     | 
    
         
            +
                    d.instance_start
         
     | 
| 
      
 1340 
     | 
    
         
            +
             
     | 
| 
      
 1341 
     | 
    
         
            +
                    chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
         
     | 
| 
      
 1342 
     | 
    
         
            +
                    mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
         
     | 
| 
      
 1343 
     | 
    
         
            +
                                                             linger_timeout: anything,
         
     | 
| 
      
 1344 
     | 
    
         
            +
                                                             send_timeout: anything,
         
     | 
| 
      
 1345 
     | 
    
         
            +
                                                             recv_timeout: anything,
         
     | 
| 
      
 1346 
     | 
    
         
            +
                                                             connect_timeout: anything) { |sock|
         
     | 
| 
      
 1347 
     | 
    
         
            +
                      mock(sock).close.once; sock
         
     | 
| 
      
 1348 
     | 
    
         
            +
                    }.twice
         
     | 
| 
      
 1349 
     | 
    
         
            +
             
     | 
| 
      
 1350 
     | 
    
         
            +
                    target_input_driver.run(timeout: 15) do
         
     | 
| 
      
 1351 
     | 
    
         
            +
                      d.run do
         
     | 
| 
      
 1352 
     | 
    
         
            +
                        node = d.instance.nodes.first
         
     | 
| 
      
 1353 
     | 
    
         
            +
                        2.times do
         
     | 
| 
      
 1354 
     | 
    
         
            +
                          node.send_data('test', chunk) rescue nil
         
     | 
| 
      
 1355 
     | 
    
         
            +
                        end
         
     | 
| 
      
 1356 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1357 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1358 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1359 
     | 
    
         
            +
                end
         
     | 
| 
      
 1360 
     | 
    
         
            +
              end
         
     | 
| 
      
 1361 
     | 
    
         
            +
            end
         
     |