fluentd 1.17.0-x86-mingw32 → 1.17.1-x86-mingw32
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 +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +1 -0
- data/SECURITY.md +2 -2
- data/fluent.conf +14 -14
- data/lib/fluent/command/cap_ctl.rb +4 -4
- data/lib/fluent/compat/call_super_mixin.rb +3 -3
- data/lib/fluent/compat/propagate_default.rb +4 -4
- data/lib/fluent/config/yaml_parser/parser.rb +4 -0
- data/lib/fluent/log/console_adapter.rb +4 -2
- data/lib/fluent/plugin/in_exec.rb +14 -2
- data/lib/fluent/plugin/in_http.rb +1 -1
- data/lib/fluent/plugin/in_sample.rb +13 -7
- data/lib/fluent/plugin/in_tail.rb +65 -23
- data/lib/fluent/plugin/out_copy.rb +1 -1
- data/lib/fluent/plugin/out_file.rb +8 -0
- data/lib/fluent/plugin/out_http.rb +12 -0
- data/lib/fluent/plugin/parser_json.rb +4 -12
- data/lib/fluent/plugin_helper/http_server/server.rb +1 -1
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
- metadata +25 -472
- data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +0 -50
- data/.github/DISCUSSION_TEMPLATE/q-a.yml +0 -47
- data/.github/ISSUE_TEMPLATE/bug_report.yml +0 -71
- data/.github/ISSUE_TEMPLATE/config.yml +0 -5
- data/.github/ISSUE_TEMPLATE/feature_request.yml +0 -39
- data/.github/ISSUE_TEMPLATE.md +0 -17
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- data/.github/workflows/stale-actions.yml +0 -24
- data/.github/workflows/test-ruby-head.yml +0 -31
- data/.github/workflows/test.yml +0 -32
- data/.gitignore +0 -30
- data/Gemfile +0 -9
- data/fluentd.gemspec +0 -62
- data/test/command/test_binlog_reader.rb +0 -362
- data/test/command/test_ca_generate.rb +0 -70
- data/test/command/test_cap_ctl.rb +0 -100
- data/test/command/test_cat.rb +0 -128
- data/test/command/test_ctl.rb +0 -56
- data/test/command/test_fluentd.rb +0 -1291
- data/test/command/test_plugin_config_formatter.rb +0 -397
- data/test/command/test_plugin_generator.rb +0 -109
- data/test/compat/test_calls_super.rb +0 -166
- data/test/compat/test_parser.rb +0 -92
- data/test/config/assertions.rb +0 -42
- data/test/config/test_config_parser.rb +0 -551
- data/test/config/test_configurable.rb +0 -1784
- data/test/config/test_configure_proxy.rb +0 -604
- data/test/config/test_dsl.rb +0 -415
- data/test/config/test_element.rb +0 -518
- data/test/config/test_literal_parser.rb +0 -309
- data/test/config/test_plugin_configuration.rb +0 -56
- data/test/config/test_section.rb +0 -191
- data/test/config/test_system_config.rb +0 -195
- data/test/config/test_types.rb +0 -408
- data/test/counter/test_client.rb +0 -563
- data/test/counter/test_error.rb +0 -44
- data/test/counter/test_mutex_hash.rb +0 -179
- data/test/counter/test_server.rb +0 -589
- data/test/counter/test_store.rb +0 -258
- data/test/counter/test_validator.rb +0 -137
- data/test/helper.rb +0 -155
- data/test/helpers/fuzzy_assert.rb +0 -89
- data/test/helpers/process_extenstion.rb +0 -33
- data/test/log/test_console_adapter.rb +0 -117
- 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/log_numeric/01.log +0 -0
- data/test/plugin/data/log_numeric/02.log +0 -0
- data/test/plugin/data/log_numeric/12.log +0 -0
- data/test/plugin/data/log_numeric/14.log +0 -0
- data/test/plugin/data/sd_file/config +0 -11
- data/test/plugin/data/sd_file/config.json +0 -17
- data/test/plugin/data/sd_file/config.yaml +0 -11
- data/test/plugin/data/sd_file/config.yml +0 -11
- data/test/plugin/data/sd_file/invalid_config.yml +0 -7
- data/test/plugin/in_tail/test_fifo.rb +0 -121
- data/test/plugin/in_tail/test_io_handler.rb +0 -150
- data/test/plugin/in_tail/test_position_file.rb +0 -346
- data/test/plugin/out_forward/test_ack_handler.rb +0 -140
- data/test/plugin/out_forward/test_connection_manager.rb +0 -145
- data/test/plugin/out_forward/test_handshake_protocol.rb +0 -112
- data/test/plugin/out_forward/test_load_balancer.rb +0 -106
- data/test/plugin/out_forward/test_socket_cache.rb +0 -174
- data/test/plugin/test_bare_output.rb +0 -131
- data/test/plugin/test_base.rb +0 -247
- data/test/plugin/test_buf_file.rb +0 -1314
- data/test/plugin/test_buf_file_single.rb +0 -898
- data/test/plugin/test_buf_memory.rb +0 -42
- data/test/plugin/test_buffer.rb +0 -1493
- data/test/plugin/test_buffer_chunk.rb +0 -209
- data/test/plugin/test_buffer_file_chunk.rb +0 -871
- data/test/plugin/test_buffer_file_single_chunk.rb +0 -611
- data/test/plugin/test_buffer_memory_chunk.rb +0 -339
- data/test/plugin/test_compressable.rb +0 -87
- data/test/plugin/test_file_util.rb +0 -96
- data/test/plugin/test_filter.rb +0 -368
- data/test/plugin/test_filter_grep.rb +0 -697
- data/test/plugin/test_filter_parser.rb +0 -731
- data/test/plugin/test_filter_record_transformer.rb +0 -577
- data/test/plugin/test_filter_stdout.rb +0 -207
- data/test/plugin/test_formatter_csv.rb +0 -136
- data/test/plugin/test_formatter_hash.rb +0 -38
- data/test/plugin/test_formatter_json.rb +0 -61
- data/test/plugin/test_formatter_ltsv.rb +0 -70
- data/test/plugin/test_formatter_msgpack.rb +0 -28
- data/test/plugin/test_formatter_out_file.rb +0 -116
- data/test/plugin/test_formatter_single_value.rb +0 -44
- data/test/plugin/test_formatter_tsv.rb +0 -76
- data/test/plugin/test_in_debug_agent.rb +0 -49
- data/test/plugin/test_in_exec.rb +0 -261
- data/test/plugin/test_in_forward.rb +0 -1178
- data/test/plugin/test_in_gc_stat.rb +0 -62
- data/test/plugin/test_in_http.rb +0 -1124
- data/test/plugin/test_in_monitor_agent.rb +0 -922
- data/test/plugin/test_in_object_space.rb +0 -66
- data/test/plugin/test_in_sample.rb +0 -190
- data/test/plugin/test_in_syslog.rb +0 -505
- data/test/plugin/test_in_tail.rb +0 -3429
- data/test/plugin/test_in_tcp.rb +0 -328
- data/test/plugin/test_in_udp.rb +0 -296
- data/test/plugin/test_in_unix.rb +0 -181
- data/test/plugin/test_input.rb +0 -137
- data/test/plugin/test_metadata.rb +0 -89
- data/test/plugin/test_metrics.rb +0 -294
- data/test/plugin/test_metrics_local.rb +0 -96
- data/test/plugin/test_multi_output.rb +0 -204
- data/test/plugin/test_out_copy.rb +0 -308
- data/test/plugin/test_out_exec.rb +0 -312
- data/test/plugin/test_out_exec_filter.rb +0 -606
- data/test/plugin/test_out_file.rb +0 -1038
- data/test/plugin/test_out_forward.rb +0 -1349
- data/test/plugin/test_out_http.rb +0 -557
- data/test/plugin/test_out_null.rb +0 -105
- data/test/plugin/test_out_relabel.rb +0 -28
- data/test/plugin/test_out_roundrobin.rb +0 -146
- data/test/plugin/test_out_secondary_file.rb +0 -458
- data/test/plugin/test_out_stdout.rb +0 -205
- data/test/plugin/test_out_stream.rb +0 -103
- data/test/plugin/test_output.rb +0 -1334
- data/test/plugin/test_output_as_buffered.rb +0 -2024
- data/test/plugin/test_output_as_buffered_backup.rb +0 -363
- data/test/plugin/test_output_as_buffered_compress.rb +0 -179
- data/test/plugin/test_output_as_buffered_overflow.rb +0 -250
- data/test/plugin/test_output_as_buffered_retries.rb +0 -966
- data/test/plugin/test_output_as_buffered_secondary.rb +0 -882
- data/test/plugin/test_output_as_standard.rb +0 -374
- data/test/plugin/test_owned_by.rb +0 -34
- data/test/plugin/test_parser.rb +0 -399
- data/test/plugin/test_parser_apache.rb +0 -42
- data/test/plugin/test_parser_apache2.rb +0 -47
- data/test/plugin/test_parser_apache_error.rb +0 -45
- data/test/plugin/test_parser_csv.rb +0 -200
- data/test/plugin/test_parser_json.rb +0 -244
- data/test/plugin/test_parser_labeled_tsv.rb +0 -160
- data/test/plugin/test_parser_msgpack.rb +0 -127
- data/test/plugin/test_parser_multiline.rb +0 -111
- data/test/plugin/test_parser_nginx.rb +0 -88
- data/test/plugin/test_parser_none.rb +0 -52
- data/test/plugin/test_parser_regexp.rb +0 -284
- data/test/plugin/test_parser_syslog.rb +0 -650
- data/test/plugin/test_parser_tsv.rb +0 -122
- data/test/plugin/test_sd_file.rb +0 -228
- data/test/plugin/test_sd_srv.rb +0 -230
- data/test/plugin/test_storage.rb +0 -166
- data/test/plugin/test_storage_local.rb +0 -335
- data/test/plugin/test_string_util.rb +0 -26
- data/test/plugin_helper/data/cert/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/cert-with-CRLF.pem +0 -19
- data/test/plugin_helper/data/cert/cert-with-no-newline.pem +0 -19
- data/test/plugin_helper/data/cert/cert.pem +0 -19
- data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +0 -20
- data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/cert_chains/cert.pem +0 -40
- data/test/plugin_helper/data/cert/empty.pem +0 -0
- data/test/plugin_helper/data/cert/generate_cert.rb +0 -125
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +0 -30
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +0 -20
- data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +0 -20
- data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +0 -30
- data/test/plugin_helper/data/cert/with_ca/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +0 -21
- data/test/plugin_helper/data/cert/with_ca/cert.pem +0 -21
- data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +0 -30
- data/test/plugin_helper/data/cert/without_ca/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +0 -20
- data/test/plugin_helper/data/cert/without_ca/cert.pem +0 -20
- data/test/plugin_helper/http_server/test_app.rb +0 -65
- data/test/plugin_helper/http_server/test_route.rb +0 -32
- data/test/plugin_helper/service_discovery/test_manager.rb +0 -93
- data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +0 -21
- data/test/plugin_helper/test_cert_option.rb +0 -25
- data/test/plugin_helper/test_child_process.rb +0 -862
- data/test/plugin_helper/test_compat_parameters.rb +0 -358
- data/test/plugin_helper/test_event_emitter.rb +0 -80
- data/test/plugin_helper/test_event_loop.rb +0 -52
- data/test/plugin_helper/test_extract.rb +0 -194
- data/test/plugin_helper/test_formatter.rb +0 -255
- data/test/plugin_helper/test_http_server_helper.rb +0 -372
- data/test/plugin_helper/test_inject.rb +0 -561
- data/test/plugin_helper/test_metrics.rb +0 -137
- data/test/plugin_helper/test_parser.rb +0 -264
- data/test/plugin_helper/test_record_accessor.rb +0 -238
- data/test/plugin_helper/test_retry_state.rb +0 -1006
- data/test/plugin_helper/test_server.rb +0 -1895
- data/test/plugin_helper/test_service_discovery.rb +0 -165
- data/test/plugin_helper/test_socket.rb +0 -146
- data/test/plugin_helper/test_storage.rb +0 -542
- data/test/plugin_helper/test_thread.rb +0 -164
- data/test/plugin_helper/test_timer.rb +0 -130
- data/test/scripts/exec_script.rb +0 -32
- data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +0 -7
- data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +0 -7
- data/test/scripts/fluent/plugin/formatter_known.rb +0 -8
- data/test/scripts/fluent/plugin/out_test.rb +0 -81
- data/test/scripts/fluent/plugin/out_test2.rb +0 -80
- data/test/scripts/fluent/plugin/parser_known.rb +0 -4
- data/test/test_capability.rb +0 -74
- data/test/test_clock.rb +0 -164
- data/test/test_config.rb +0 -369
- data/test/test_configdsl.rb +0 -148
- data/test/test_daemonizer.rb +0 -91
- data/test/test_engine.rb +0 -203
- data/test/test_event.rb +0 -531
- data/test/test_event_router.rb +0 -348
- data/test/test_event_time.rb +0 -199
- data/test/test_file_wrapper.rb +0 -53
- data/test/test_filter.rb +0 -121
- data/test/test_fluent_log_event_router.rb +0 -99
- data/test/test_formatter.rb +0 -369
- data/test/test_input.rb +0 -31
- data/test/test_log.rb +0 -1076
- data/test/test_match.rb +0 -148
- data/test/test_mixin.rb +0 -351
- data/test/test_msgpack_factory.rb +0 -50
- data/test/test_oj_options.rb +0 -55
- data/test/test_output.rb +0 -278
- data/test/test_plugin.rb +0 -251
- data/test/test_plugin_classes.rb +0 -370
- data/test/test_plugin_helper.rb +0 -81
- data/test/test_plugin_id.rb +0 -119
- data/test/test_process.rb +0 -14
- data/test/test_root_agent.rb +0 -951
- data/test/test_static_config_analysis.rb +0 -177
- data/test/test_supervisor.rb +0 -821
- data/test/test_test_drivers.rb +0 -136
- data/test/test_time_formatter.rb +0 -301
- data/test/test_time_parser.rb +0 -362
- data/test/test_tls.rb +0 -65
- data/test/test_unique_id.rb +0 -47
- data/test/test_variable_store.rb +0 -65
@@ -1,1349 +0,0 @@
|
|
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
|
-
|
1252
|
-
chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
|
1253
|
-
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
|
1254
|
-
linger_timeout: anything,
|
1255
|
-
send_timeout: anything,
|
1256
|
-
recv_timeout: anything,
|
1257
|
-
connect_timeout: anything
|
1258
|
-
) { |sock| mock(sock).close.once; sock }.twice
|
1259
|
-
|
1260
|
-
target_input_driver.run(timeout: 15) do
|
1261
|
-
d.run do
|
1262
|
-
node = d.instance.nodes.first
|
1263
|
-
2.times do
|
1264
|
-
node.send_data('test', chunk) rescue nil
|
1265
|
-
end
|
1266
|
-
end
|
1267
|
-
end
|
1268
|
-
end
|
1269
|
-
|
1270
|
-
test 'if no available node' do
|
1271
|
-
# do not create output driver
|
1272
|
-
d = create_driver(%[
|
1273
|
-
<server>
|
1274
|
-
name test
|
1275
|
-
standby
|
1276
|
-
host #{TARGET_HOST}
|
1277
|
-
port #{@target_port}
|
1278
|
-
</server>
|
1279
|
-
])
|
1280
|
-
assert_nothing_raised { d.run }
|
1281
|
-
end
|
1282
|
-
|
1283
|
-
sub_test_case 'keepalive' do
|
1284
|
-
test 'Do not create connection per send_data' do
|
1285
|
-
target_input_driver = create_target_input_driver(conf: target_config)
|
1286
|
-
output_conf = config + %[
|
1287
|
-
keepalive true
|
1288
|
-
keepalive_timeout 2
|
1289
|
-
]
|
1290
|
-
d = create_driver(output_conf)
|
1291
|
-
|
1292
|
-
chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
|
1293
|
-
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
|
1294
|
-
linger_timeout: anything,
|
1295
|
-
send_timeout: anything,
|
1296
|
-
recv_timeout: anything,
|
1297
|
-
connect_timeout: anything
|
1298
|
-
) { |sock| mock(sock).close.once; sock }.once
|
1299
|
-
|
1300
|
-
target_input_driver.run(timeout: 15) do
|
1301
|
-
d.run do
|
1302
|
-
node = d.instance.nodes.first
|
1303
|
-
2.times do
|
1304
|
-
node.send_data('test', chunk) rescue nil
|
1305
|
-
end
|
1306
|
-
end
|
1307
|
-
end
|
1308
|
-
end
|
1309
|
-
|
1310
|
-
test 'create timer of purging obsolete sockets' do
|
1311
|
-
output_conf = config + %[keepalive true]
|
1312
|
-
@d = d = create_driver(output_conf)
|
1313
|
-
|
1314
|
-
mock(d.instance).timer_execute(:out_forward_heartbeat_request, 1).once
|
1315
|
-
mock(d.instance).timer_execute(:out_forward_keep_alived_socket_watcher, 5).once
|
1316
|
-
d.instance_start
|
1317
|
-
end
|
1318
|
-
|
1319
|
-
sub_test_case 'with require_ack_response' do
|
1320
|
-
test 'Create connection per send_data' do
|
1321
|
-
target_input_driver = create_target_input_driver(conf: target_config)
|
1322
|
-
output_conf = config + %[
|
1323
|
-
require_ack_response true
|
1324
|
-
keepalive true
|
1325
|
-
keepalive_timeout 2
|
1326
|
-
]
|
1327
|
-
d = create_driver(output_conf)
|
1328
|
-
|
1329
|
-
chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
|
1330
|
-
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
|
1331
|
-
linger_timeout: anything,
|
1332
|
-
send_timeout: anything,
|
1333
|
-
recv_timeout: anything,
|
1334
|
-
connect_timeout: anything) { |sock|
|
1335
|
-
mock(sock).close.once; sock
|
1336
|
-
}.twice
|
1337
|
-
|
1338
|
-
target_input_driver.run(timeout: 15) do
|
1339
|
-
d.run do
|
1340
|
-
node = d.instance.nodes.first
|
1341
|
-
2.times do
|
1342
|
-
node.send_data('test', chunk) rescue nil
|
1343
|
-
end
|
1344
|
-
end
|
1345
|
-
end
|
1346
|
-
end
|
1347
|
-
end
|
1348
|
-
end
|
1349
|
-
end
|