fluentd 1.17.0-x86-mingw32 → 1.18.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +100 -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/command/fluentd.rb +7 -1
- data/lib/fluent/compat/call_super_mixin.rb +3 -3
- data/lib/fluent/compat/propagate_default.rb +4 -4
- data/lib/fluent/config/literal_parser.rb +9 -2
- data/lib/fluent/config/yaml_parser/parser.rb +4 -0
- data/lib/fluent/engine.rb +49 -33
- data/lib/fluent/env.rb +3 -0
- data/lib/fluent/event_router.rb +2 -2
- data/lib/fluent/log/console_adapter.rb +4 -2
- data/lib/fluent/plugin/filter_parser.rb +27 -51
- data/lib/fluent/plugin/in_exec.rb +14 -2
- data/lib/fluent/plugin/in_http.rb +6 -1
- data/lib/fluent/plugin/in_sample.rb +13 -7
- data/lib/fluent/plugin/in_syslog.rb +4 -0
- data/lib/fluent/plugin/in_tail.rb +65 -23
- data/lib/fluent/plugin/in_tcp.rb +4 -0
- data/lib/fluent/plugin/in_udp.rb +10 -1
- data/lib/fluent/plugin/input.rb +4 -0
- data/lib/fluent/plugin/out_buffer.rb +40 -0
- 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/output.rb +2 -0
- data/lib/fluent/plugin/parser_json.rb +4 -12
- data/lib/fluent/plugin_helper/cert_option.rb +8 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +12 -0
- data/lib/fluent/plugin_helper/http_server/server.rb +24 -8
- data/lib/fluent/plugin_helper/server.rb +9 -0
- data/lib/fluent/root_agent.rb +114 -19
- data/lib/fluent/source_only_buffer_agent.rb +102 -0
- data/lib/fluent/supervisor.rb +207 -34
- data/lib/fluent/system_config.rb +15 -3
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
- metadata +24 -483
- 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
data/test/plugin/test_in_unix.rb
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/test/driver/input'
|
3
|
-
require 'fluent/plugin/in_unix'
|
4
|
-
|
5
|
-
class UnixInputTest < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
Fluent::Test.setup
|
8
|
-
@d = nil
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
@d.instance_shutdown if @d
|
13
|
-
end
|
14
|
-
|
15
|
-
TMP_DIR = File.dirname(__FILE__) + "/../tmp/in_unix#{ENV['TEST_ENV_NUMBER']}"
|
16
|
-
CONFIG = %[
|
17
|
-
path #{TMP_DIR}/unix
|
18
|
-
backlog 1000
|
19
|
-
]
|
20
|
-
|
21
|
-
def create_driver(conf = CONFIG)
|
22
|
-
Fluent::Test::Driver::Input.new(Fluent::Plugin::UnixInput).configure(conf)
|
23
|
-
end
|
24
|
-
|
25
|
-
def packer(*args)
|
26
|
-
Fluent::MessagePackFactory.msgpack_packer(*args)
|
27
|
-
end
|
28
|
-
|
29
|
-
def unpacker
|
30
|
-
Fluent::MessagePackFactory.msgpack_unpacker
|
31
|
-
end
|
32
|
-
|
33
|
-
def send_data(data)
|
34
|
-
io = UNIXSocket.new("#{TMP_DIR}/unix")
|
35
|
-
begin
|
36
|
-
io.write data
|
37
|
-
ensure
|
38
|
-
io.close
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_configure
|
43
|
-
@d = create_driver
|
44
|
-
assert_equal "#{TMP_DIR}/unix", @d.instance.path
|
45
|
-
assert_equal 1000, @d.instance.backlog
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_time
|
49
|
-
@d = create_driver
|
50
|
-
|
51
|
-
time = Fluent::EventTime.now
|
52
|
-
records = [
|
53
|
-
["tag1", 0, {"a" => 1}],
|
54
|
-
["tag2", nil, {"a" => 2}],
|
55
|
-
]
|
56
|
-
|
57
|
-
@d.run(expect_records: records.length, timeout: 5) do
|
58
|
-
records.each {|tag, _time, record|
|
59
|
-
send_data packer.write([tag, _time, record]).to_s
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
@d.events.each_with_index { |e, i|
|
64
|
-
orig = records[i]
|
65
|
-
assert_equal(orig[0], e[0])
|
66
|
-
assert_true(time <= e[1])
|
67
|
-
assert_equal(orig[2], e[2])
|
68
|
-
}
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_message
|
72
|
-
@d = create_driver
|
73
|
-
|
74
|
-
time = Fluent::EventTime.now
|
75
|
-
records = [
|
76
|
-
["tag1", time, {"a" => 1}],
|
77
|
-
["tag2", time, {"a" => 2}],
|
78
|
-
]
|
79
|
-
|
80
|
-
@d.run(expect_records: records.length, timeout: 5) do
|
81
|
-
records.each {|tag, _time, record|
|
82
|
-
send_data packer.write([tag, _time, record]).to_s
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
assert_equal(records, @d.events)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_forward
|
90
|
-
@d = create_driver
|
91
|
-
|
92
|
-
time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
|
93
|
-
records = [
|
94
|
-
["tag1", time, {"a" => 1}],
|
95
|
-
["tag1", time, {"a" => 2}]
|
96
|
-
]
|
97
|
-
|
98
|
-
@d.run(expect_records: records.length, timeout: 20) do
|
99
|
-
entries = []
|
100
|
-
records.each {|tag, _time, record|
|
101
|
-
entries << [_time, record]
|
102
|
-
}
|
103
|
-
send_data packer.write(["tag1", entries]).to_s
|
104
|
-
end
|
105
|
-
assert_equal(records, @d.events)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_packed_forward
|
109
|
-
@d = create_driver
|
110
|
-
|
111
|
-
time = Fluent::EventTime.now
|
112
|
-
records = [
|
113
|
-
["tag1", time, {"a" => 1}],
|
114
|
-
["tag1", time, {"a" => 2}],
|
115
|
-
]
|
116
|
-
|
117
|
-
@d.run(expect_records: records.length, timeout: 20) do
|
118
|
-
entries = ''
|
119
|
-
records.each {|_tag, _time, record|
|
120
|
-
packer(entries).write([_time, record]).flush
|
121
|
-
}
|
122
|
-
send_data packer.write(["tag1", entries]).to_s
|
123
|
-
end
|
124
|
-
assert_equal(records, @d.events)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_message_json
|
128
|
-
@d = create_driver
|
129
|
-
|
130
|
-
time = Fluent::EventTime.now
|
131
|
-
records = [
|
132
|
-
["tag1", time, {"a" => 1}],
|
133
|
-
["tag2", time, {"a" => 2}],
|
134
|
-
]
|
135
|
-
|
136
|
-
@d.run(expect_records: records.length, timeout: 5) do
|
137
|
-
tag, _time, record = records[0]
|
138
|
-
send_data [tag, _time.to_i, record].to_json
|
139
|
-
tag, _time, record = records[1]
|
140
|
-
send_data [tag, _time.to_f, record].to_json
|
141
|
-
end
|
142
|
-
|
143
|
-
assert_equal(records, @d.events)
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_message_with_tag
|
147
|
-
@d = create_driver(CONFIG + "tag new_tag")
|
148
|
-
|
149
|
-
time = Fluent::EventTime.now
|
150
|
-
records = [
|
151
|
-
["tag1", time, {"a" => 1}],
|
152
|
-
["tag2", time, {"a" => 2}],
|
153
|
-
]
|
154
|
-
|
155
|
-
@d.run(expect_records: records.length, timeout: 5) do
|
156
|
-
records.each {|tag, _time, record|
|
157
|
-
send_data packer.write([tag, _time, record]).to_s
|
158
|
-
}
|
159
|
-
end
|
160
|
-
|
161
|
-
@d.events.each { |event|
|
162
|
-
assert_equal("new_tag", event[0])
|
163
|
-
}
|
164
|
-
end
|
165
|
-
|
166
|
-
data('string chunk' => 'broken string',
|
167
|
-
'integer chunk' => 10)
|
168
|
-
def test_broken_message(data)
|
169
|
-
@d = create_driver
|
170
|
-
@d.run(shutdown: false, timeout: 5) do
|
171
|
-
@d.instance.__send__(:on_message, data)
|
172
|
-
end
|
173
|
-
|
174
|
-
assert_equal 0, @d.events.size
|
175
|
-
|
176
|
-
logs = @d.instance.log.logs
|
177
|
-
assert_equal 1, logs.count { |line|
|
178
|
-
line =~ / \[warn\]: incoming data is broken: msg=#{data.inspect}/
|
179
|
-
}, "should not accept broken chunk"
|
180
|
-
end
|
181
|
-
end unless Fluent.windows?
|
data/test/plugin/test_input.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/plugin/input'
|
3
|
-
require 'flexmock/test_unit'
|
4
|
-
|
5
|
-
module FluentPluginInputTest
|
6
|
-
class DummyPlugin < Fluent::Plugin::Input
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class InputTest < Test::Unit::TestCase
|
11
|
-
setup do
|
12
|
-
Fluent::Test.setup
|
13
|
-
@p = FluentPluginInputTest::DummyPlugin.new
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'has healthy lifecycle' do
|
17
|
-
assert !@p.configured?
|
18
|
-
@p.configure(config_element())
|
19
|
-
assert @p.configured?
|
20
|
-
|
21
|
-
assert !@p.started?
|
22
|
-
@p.start
|
23
|
-
assert @p.start
|
24
|
-
|
25
|
-
assert !@p.stopped?
|
26
|
-
@p.stop
|
27
|
-
assert @p.stopped?
|
28
|
-
|
29
|
-
assert !@p.before_shutdown?
|
30
|
-
@p.before_shutdown
|
31
|
-
assert @p.before_shutdown?
|
32
|
-
|
33
|
-
assert !@p.shutdown?
|
34
|
-
@p.shutdown
|
35
|
-
assert @p.shutdown?
|
36
|
-
|
37
|
-
assert !@p.after_shutdown?
|
38
|
-
@p.after_shutdown
|
39
|
-
assert @p.after_shutdown?
|
40
|
-
|
41
|
-
assert !@p.closed?
|
42
|
-
@p.close
|
43
|
-
assert @p.closed?
|
44
|
-
|
45
|
-
assert !@p.terminated?
|
46
|
-
@p.terminate
|
47
|
-
assert @p.terminated?
|
48
|
-
end
|
49
|
-
|
50
|
-
test 'has plugin_id automatically generated' do
|
51
|
-
assert @p.respond_to?(:plugin_id_configured?)
|
52
|
-
assert @p.respond_to?(:plugin_id)
|
53
|
-
|
54
|
-
@p.configure(config_element())
|
55
|
-
|
56
|
-
assert !@p.plugin_id_configured?
|
57
|
-
assert @p.plugin_id
|
58
|
-
assert{ @p.plugin_id != 'mytest' }
|
59
|
-
end
|
60
|
-
|
61
|
-
test 'has plugin_id manually configured' do
|
62
|
-
@p.configure(config_element('ROOT', '', {'@id' => 'mytest'}))
|
63
|
-
assert @p.plugin_id_configured?
|
64
|
-
assert_equal 'mytest', @p.plugin_id
|
65
|
-
end
|
66
|
-
|
67
|
-
test 'has plugin logger' do
|
68
|
-
assert @p.respond_to?(:log)
|
69
|
-
assert @p.log
|
70
|
-
|
71
|
-
# default logger
|
72
|
-
original_logger = @p.log
|
73
|
-
|
74
|
-
@p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
|
75
|
-
|
76
|
-
assert(@p.log.object_id != original_logger.object_id)
|
77
|
-
assert_equal Fluent::Log::LEVEL_DEBUG, @p.log.level
|
78
|
-
end
|
79
|
-
|
80
|
-
test 'can load plugin helpers' do
|
81
|
-
assert_nothing_raised do
|
82
|
-
class FluentPluginInputTest::DummyPlugin2 < Fluent::Plugin::Input
|
83
|
-
helpers :storage
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
test 'can use metrics plugins and fallback methods' do
|
89
|
-
@p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
|
90
|
-
|
91
|
-
%w[emit_size_metrics emit_records_metrics].each do |metric_name|
|
92
|
-
assert_true @p.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
|
93
|
-
end
|
94
|
-
|
95
|
-
assert_equal 0, @p.emit_size
|
96
|
-
assert_equal 0, @p.emit_records
|
97
|
-
end
|
98
|
-
|
99
|
-
test 'are not available with multi workers configuration in default' do
|
100
|
-
assert_false @p.multi_workers_ready?
|
101
|
-
end
|
102
|
-
|
103
|
-
test 'has router and can emit into it' do
|
104
|
-
assert @p.has_router?
|
105
|
-
|
106
|
-
@p.configure(config_element())
|
107
|
-
assert @p.router
|
108
|
-
|
109
|
-
DummyRouter = Struct.new(:emits) do
|
110
|
-
def emit(tag, es)
|
111
|
-
self.emits << [tag, es]
|
112
|
-
end
|
113
|
-
end
|
114
|
-
@p.router = DummyRouter.new([])
|
115
|
-
@p.router.emit('mytag', [])
|
116
|
-
@p.router.emit('mytag.testing', ['it is not es, but no problem for tests'])
|
117
|
-
|
118
|
-
assert_equal ['mytag', []], @p.router.emits[0]
|
119
|
-
assert_equal ['mytag.testing', ['it is not es, but no problem for tests']], @p.router.emits[1]
|
120
|
-
end
|
121
|
-
|
122
|
-
test 'has router for specified label if configured' do
|
123
|
-
@p.configure(config_element())
|
124
|
-
original_router = @p.router
|
125
|
-
|
126
|
-
router_mock = flexmock('mytest')
|
127
|
-
router_mock.should_receive(:emit).once.with('mytag.testing', ['for mock'])
|
128
|
-
label_mock = flexmock('mylabel')
|
129
|
-
label_mock.should_receive(:event_router).once.and_return(router_mock)
|
130
|
-
Fluent::Engine.root_agent.labels['@mytest'] = label_mock
|
131
|
-
|
132
|
-
@p.configure(config_element('ROOT', '', {'@label' => '@mytest'}))
|
133
|
-
assert{ @p.router.object_id != original_router.object_id }
|
134
|
-
|
135
|
-
@p.router.emit('mytag.testing', ['for mock'])
|
136
|
-
end
|
137
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/plugin/buffer'
|
3
|
-
|
4
|
-
class BufferMetadataTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def meta(timekey=nil, tag=nil, variables=nil)
|
7
|
-
Fluent::Plugin::Buffer::Metadata.new(timekey, tag, variables)
|
8
|
-
end
|
9
|
-
|
10
|
-
setup do
|
11
|
-
Fluent::Test.setup
|
12
|
-
end
|
13
|
-
|
14
|
-
sub_test_case 'about metadata' do
|
15
|
-
test 'comparison of variables should be stable' do
|
16
|
-
m = meta(nil, nil, nil)
|
17
|
-
# different sets of keys
|
18
|
-
assert_equal(-1, m.cmp_variables({}, {a: 1}))
|
19
|
-
assert_equal(1, m.cmp_variables({a: 1}, {}))
|
20
|
-
assert_equal(1, m.cmp_variables({c: 1}, {a: 1}))
|
21
|
-
assert_equal(-1, m.cmp_variables({a: 1}, {a: 1, b: 2}))
|
22
|
-
assert_equal(1, m.cmp_variables({a: 1, c: 1}, {a: 1, b: 2}))
|
23
|
-
assert_equal(1, m.cmp_variables({a: 1, b: 0, c: 1}, {a: 1, b: 2}))
|
24
|
-
# same set of keys
|
25
|
-
assert_equal(-1, m.cmp_variables({a: 1}, {a: 2}))
|
26
|
-
assert_equal(-1, m.cmp_variables({a: 1, b: 0}, {a: 1, b: 1}))
|
27
|
-
assert_equal(-1, m.cmp_variables({a: 1, b: 1, c: 100}, {a: 1, b: 1, c: 200}))
|
28
|
-
assert_equal(-1, m.cmp_variables({b: 1, c: 100, a: 1}, {a: 1, b: 1, c: 200})) # comparison sorts keys
|
29
|
-
assert_equal(-1, m.cmp_variables({a: nil}, {a: 1}))
|
30
|
-
assert_equal(-1, m.cmp_variables({a: 1, b: nil}, {a: 1, b: 1}))
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'comparison of metadata should be stable' do
|
34
|
-
n = Time.now.to_i
|
35
|
-
|
36
|
-
assert_equal(0, meta(nil, nil, nil) <=> meta(nil, nil, nil))
|
37
|
-
assert_equal(0, meta(n, nil, nil) <=> meta(n, nil, nil))
|
38
|
-
assert_equal(0, meta(nil, "t1", nil) <=> meta(nil, "t1", nil))
|
39
|
-
assert_equal(0, meta(nil, nil, {}) <=> meta(nil, nil, {}))
|
40
|
-
assert_equal(0, meta(nil, nil, {a: "1"}) <=> meta(nil, nil, {a: "1"}))
|
41
|
-
assert_equal(0, meta(n, nil, {}) <=> meta(n, nil, {}))
|
42
|
-
assert_equal(0, meta(n, "t1", {}) <=> meta(n, "t1", {}))
|
43
|
-
assert_equal(0, meta(n, "t1", {a: "x", b: 10}) <=> meta(n, "t1", {a: "x", b: 10}))
|
44
|
-
|
45
|
-
# timekey is 1st comparison key
|
46
|
-
assert_equal(-1, meta(n - 300, nil, nil) <=> meta(n - 270, nil, nil))
|
47
|
-
assert_equal(1, meta(n + 1, "a", nil) <=> meta(n - 1, "b", nil))
|
48
|
-
assert_equal(-1, meta(n - 1, nil, {a: 100}) <=> meta(n + 1, nil, {}))
|
49
|
-
|
50
|
-
# tag is 2nd
|
51
|
-
assert_equal(-1, meta(nil, "a", {}) <=> meta(nil, "b", {}))
|
52
|
-
assert_equal(-1, meta(n, "a", {}) <=> meta(n, "b", {}))
|
53
|
-
assert_equal(1, meta(nil, "x", {a: 1}) <=> meta(nil, "t", {}))
|
54
|
-
assert_equal(1, meta(n, "x", {a: 1}) <=> meta(n, "t", {}))
|
55
|
-
assert_equal(1, meta(nil, "x", {a: 1}) <=> meta(nil, "t", {a: 1}))
|
56
|
-
assert_equal(1, meta(n, "x", {a: 1}) <=> meta(n, "t", {a: 2}))
|
57
|
-
assert_equal(1, meta(n, "x", {a: 1}) <=> meta(n, "t", {a: 10, b: 1}))
|
58
|
-
|
59
|
-
# variables is the last
|
60
|
-
assert_equal(-1, meta(nil, nil, {}) <=> meta(nil, nil, {a: 1}))
|
61
|
-
assert_equal(-1, meta(n, "t", {}) <=> meta(n, "t", {a: 1}))
|
62
|
-
assert_equal(1, meta(n, "t", {a: 1}) <=> meta(n, "t", {}))
|
63
|
-
assert_equal(-1, meta(n, "t", {a: 1}) <=> meta(n, "t", {a: 2}))
|
64
|
-
assert_equal(-1, meta(n, "t", {a: 1}) <=> meta(n, "t", {a: 1, b: 1}))
|
65
|
-
assert_equal(1, meta(nil, nil, {b: 1}) <=> meta(nil, nil, {a: 1}))
|
66
|
-
assert_equal(1, meta(n, "t", {b: 1}) <=> meta(n, "t", {a: 1}))
|
67
|
-
end
|
68
|
-
|
69
|
-
test 'metadata can be sorted' do
|
70
|
-
n = Time.now.to_i
|
71
|
-
m0 = meta(nil, nil, nil)
|
72
|
-
m1 = meta(n - 1, nil, nil)
|
73
|
-
m2 = meta(n - 1, "a", nil)
|
74
|
-
m3 = meta(n - 1, "a", {a: 1})
|
75
|
-
m4 = meta(n - 1, "a", {a: 100})
|
76
|
-
m5 = meta(n - 1, "a", {a: 100, b: 1})
|
77
|
-
m6 = meta(n - 1, "aa", nil)
|
78
|
-
m7 = meta(n - 1, "aa", {a: 1})
|
79
|
-
m8 = meta(n - 1, "b", nil)
|
80
|
-
m9 = meta(n, nil, nil)
|
81
|
-
m10 = meta(n + 1, nil, {a: 1})
|
82
|
-
expected = [m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10].freeze
|
83
|
-
ary = expected.dup
|
84
|
-
100.times do
|
85
|
-
assert_equal expected, ary.shuffle.sort
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
data/test/plugin/test_metrics.rb
DELETED
@@ -1,294 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/plugin/metrics'
|
3
|
-
require 'fluent/plugin/base'
|
4
|
-
require 'fluent/system_config'
|
5
|
-
|
6
|
-
class BareMetrics < Fluent::Plugin::Metrics
|
7
|
-
Fluent::Plugin.register_metrics('bare', self)
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Just override for tests.
|
12
|
-
def has_methods_for_counter?
|
13
|
-
false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class BasicCounterMetrics < Fluent::Plugin::Metrics
|
18
|
-
Fluent::Plugin.register_metrics('example', self)
|
19
|
-
|
20
|
-
attr_reader :data
|
21
|
-
|
22
|
-
def initialize
|
23
|
-
super
|
24
|
-
@data = 0
|
25
|
-
end
|
26
|
-
def get
|
27
|
-
@data
|
28
|
-
end
|
29
|
-
def inc
|
30
|
-
@data +=1
|
31
|
-
end
|
32
|
-
def add(value)
|
33
|
-
@data += value
|
34
|
-
end
|
35
|
-
def set(value)
|
36
|
-
@data = value
|
37
|
-
end
|
38
|
-
def close
|
39
|
-
@data = 0
|
40
|
-
super
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class AliasedCounterMetrics < Fluent::Plugin::Metrics
|
45
|
-
Fluent::Plugin.register_metrics('example', self)
|
46
|
-
|
47
|
-
attr_reader :data
|
48
|
-
|
49
|
-
def initialize
|
50
|
-
super
|
51
|
-
@data = 0
|
52
|
-
end
|
53
|
-
def configure(conf)
|
54
|
-
super
|
55
|
-
class << self
|
56
|
-
alias_method :set, :set_counter
|
57
|
-
end
|
58
|
-
end
|
59
|
-
def get
|
60
|
-
@data
|
61
|
-
end
|
62
|
-
def inc
|
63
|
-
@data +=1
|
64
|
-
end
|
65
|
-
def add(value)
|
66
|
-
@data += value
|
67
|
-
end
|
68
|
-
def set_counter(value)
|
69
|
-
@data = value
|
70
|
-
end
|
71
|
-
def close
|
72
|
-
@data = 0
|
73
|
-
super
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class BasicGaugeMetrics < Fluent::Plugin::Metrics
|
78
|
-
Fluent::Plugin.register_metrics('example', self)
|
79
|
-
|
80
|
-
attr_reader :data
|
81
|
-
|
82
|
-
def initialize
|
83
|
-
super
|
84
|
-
@data = 0
|
85
|
-
end
|
86
|
-
def get
|
87
|
-
@data
|
88
|
-
end
|
89
|
-
def inc
|
90
|
-
@data +=1
|
91
|
-
end
|
92
|
-
def dec
|
93
|
-
@data -=1
|
94
|
-
end
|
95
|
-
def add(value)
|
96
|
-
@data += value
|
97
|
-
end
|
98
|
-
def sub(value)
|
99
|
-
@data -= value
|
100
|
-
end
|
101
|
-
def set(value)
|
102
|
-
@data = value
|
103
|
-
end
|
104
|
-
def close
|
105
|
-
@data = 0
|
106
|
-
super
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
class AliasedGaugeMetrics < Fluent::Plugin::Metrics
|
111
|
-
Fluent::Plugin.register_metrics('example', self)
|
112
|
-
|
113
|
-
attr_reader :data
|
114
|
-
|
115
|
-
def initialize
|
116
|
-
super
|
117
|
-
@data = 0
|
118
|
-
end
|
119
|
-
def configure(conf)
|
120
|
-
super
|
121
|
-
class << self
|
122
|
-
alias_method :dec, :dec_gauge
|
123
|
-
alias_method :set, :set_gauge
|
124
|
-
alias_method :sub, :sub_gauge
|
125
|
-
end
|
126
|
-
end
|
127
|
-
def get
|
128
|
-
@data
|
129
|
-
end
|
130
|
-
def inc
|
131
|
-
@data +=1
|
132
|
-
end
|
133
|
-
def dec_gauge
|
134
|
-
@data -=1
|
135
|
-
end
|
136
|
-
def add(value)
|
137
|
-
@data += value
|
138
|
-
end
|
139
|
-
def sub_gauge(value)
|
140
|
-
@data -= value
|
141
|
-
end
|
142
|
-
def set_gauge(value)
|
143
|
-
@data = value
|
144
|
-
end
|
145
|
-
def close
|
146
|
-
@data = 0
|
147
|
-
super
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
class StorageTest < Test::Unit::TestCase
|
152
|
-
sub_test_case 'BareMetrics' do
|
153
|
-
setup do
|
154
|
-
@m = BareMetrics.new
|
155
|
-
@m.configure(config_element())
|
156
|
-
end
|
157
|
-
|
158
|
-
test 'is configured with plugin information and system config' do
|
159
|
-
m = BareMetrics.new
|
160
|
-
m.configure(config_element('metrics', '', {}))
|
161
|
-
|
162
|
-
assert_false m.use_gauge_metric
|
163
|
-
assert_false m.has_methods_for_counter
|
164
|
-
assert_false m.has_methods_for_gauge
|
165
|
-
end
|
166
|
-
|
167
|
-
test 'all bare operations are not defined yet' do
|
168
|
-
assert_raise NotImplementedError do
|
169
|
-
@m.get
|
170
|
-
end
|
171
|
-
assert_raise NotImplementedError do
|
172
|
-
@m.inc
|
173
|
-
end
|
174
|
-
assert_raise NotImplementedError do
|
175
|
-
@m.dec
|
176
|
-
end
|
177
|
-
assert_raise NotImplementedError do
|
178
|
-
@m.add(10)
|
179
|
-
end
|
180
|
-
assert_raise NotImplementedError do
|
181
|
-
@m.sub(11)
|
182
|
-
end
|
183
|
-
assert_raise NotImplementedError do
|
184
|
-
@m.set(123)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
sub_test_case 'BasicCounterMetric' do
|
190
|
-
setup do
|
191
|
-
@m = BasicCounterMetrics.new
|
192
|
-
@m.configure(config_element('metrics', '', {'@id' => '1'}))
|
193
|
-
end
|
194
|
-
|
195
|
-
test 'all basic counter operations work well' do
|
196
|
-
assert_true @m.has_methods_for_counter
|
197
|
-
assert_false @m.has_methods_for_gauge
|
198
|
-
|
199
|
-
assert_equal 0, @m.get
|
200
|
-
assert_equal 1, @m.inc
|
201
|
-
|
202
|
-
@m.add(20)
|
203
|
-
assert_equal 21, @m.get
|
204
|
-
assert_raise NotImplementedError do
|
205
|
-
@m.dec
|
206
|
-
end
|
207
|
-
|
208
|
-
@m.set(100)
|
209
|
-
assert_equal 100, @m.get
|
210
|
-
assert_raise NotImplementedError do
|
211
|
-
@m.sub(11)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
sub_test_case 'AliasedCounterMetric' do
|
217
|
-
setup do
|
218
|
-
@m = AliasedCounterMetrics.new
|
219
|
-
@m.configure(config_element('metrics', '', {}))
|
220
|
-
end
|
221
|
-
|
222
|
-
test 'all aliased counter operations work well' do
|
223
|
-
assert_true @m.has_methods_for_counter
|
224
|
-
assert_false @m.has_methods_for_gauge
|
225
|
-
|
226
|
-
assert_equal 0, @m.get
|
227
|
-
assert_equal 1, @m.inc
|
228
|
-
|
229
|
-
@m.add(20)
|
230
|
-
assert_equal 21, @m.get
|
231
|
-
assert_raise NotImplementedError do
|
232
|
-
@m.dec
|
233
|
-
end
|
234
|
-
|
235
|
-
@m.set(100)
|
236
|
-
assert_equal 100, @m.get
|
237
|
-
assert_raise NotImplementedError do
|
238
|
-
@m.sub(11)
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
sub_test_case 'BasicGaugeMetric' do
|
244
|
-
setup do
|
245
|
-
@m = BasicGaugeMetrics.new
|
246
|
-
@m.use_gauge_metric = true
|
247
|
-
@m.configure(config_element('metrics', '', {}))
|
248
|
-
end
|
249
|
-
|
250
|
-
test 'all basic gauge operations work well' do
|
251
|
-
assert_false @m.has_methods_for_counter
|
252
|
-
assert_true @m.has_methods_for_gauge
|
253
|
-
|
254
|
-
assert_equal 0, @m.get
|
255
|
-
assert_equal 1, @m.inc
|
256
|
-
|
257
|
-
@m.add(20)
|
258
|
-
assert_equal 21, @m.get
|
259
|
-
@m.dec
|
260
|
-
assert_equal 20, @m.get
|
261
|
-
|
262
|
-
@m.set(100)
|
263
|
-
assert_equal 100, @m.get
|
264
|
-
@m.sub(11)
|
265
|
-
assert_equal 89, @m.get
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
sub_test_case 'AliasedGaugeMetric' do
|
270
|
-
setup do
|
271
|
-
@m = AliasedGaugeMetrics.new
|
272
|
-
@m.use_gauge_metric = true
|
273
|
-
@m.configure(config_element('metrics', '', {}))
|
274
|
-
end
|
275
|
-
|
276
|
-
test 'all aliased gauge operations work well' do
|
277
|
-
assert_false @m.has_methods_for_counter
|
278
|
-
assert_true @m.has_methods_for_gauge
|
279
|
-
|
280
|
-
assert_equal 0, @m.get
|
281
|
-
assert_equal 1, @m.inc
|
282
|
-
|
283
|
-
@m.add(20)
|
284
|
-
assert_equal 21, @m.get
|
285
|
-
@m.dec
|
286
|
-
assert_equal 20, @m.get
|
287
|
-
|
288
|
-
@m.set(100)
|
289
|
-
assert_equal 100, @m.get
|
290
|
-
@m.sub(11)
|
291
|
-
assert_equal 89, @m.get
|
292
|
-
end
|
293
|
-
end
|
294
|
-
end
|