fluentd 1.17.0-x86-mingw32 → 1.17.1-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 +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,195 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/configurable'
|
3
|
-
require 'fluent/config/element'
|
4
|
-
require 'fluent/config/section'
|
5
|
-
require 'fluent/system_config'
|
6
|
-
|
7
|
-
module Fluent::Config
|
8
|
-
class FakeSupervisor
|
9
|
-
attr_writer :log_level
|
10
|
-
|
11
|
-
def initialize(**opt)
|
12
|
-
@system_config = nil
|
13
|
-
@cl_opt = {
|
14
|
-
wokers: nil,
|
15
|
-
restart_worker_interval: nil,
|
16
|
-
root_dir: nil,
|
17
|
-
log_level: Fluent::Log::LEVEL_INFO,
|
18
|
-
suppress_interval: nil,
|
19
|
-
suppress_config_dump: nil,
|
20
|
-
suppress_repeated_stacktrace: nil,
|
21
|
-
log_event_label: nil,
|
22
|
-
log_event_verbose: nil,
|
23
|
-
without_source: nil,
|
24
|
-
enable_input_metrics: nil,
|
25
|
-
enable_size_metrics: nil,
|
26
|
-
emit_error_log_interval: nil,
|
27
|
-
file_permission: nil,
|
28
|
-
dir_permission: nil,
|
29
|
-
}.merge(opt)
|
30
|
-
end
|
31
|
-
|
32
|
-
def for_system_config
|
33
|
-
opt = {}
|
34
|
-
# this is copy from Supervisor#build_system_config
|
35
|
-
Fluent::SystemConfig::SYSTEM_CONFIG_PARAMETERS.each do |param|
|
36
|
-
if @cl_opt.key?(param) && !@cl_opt[param].nil?
|
37
|
-
if param == :log_level && @cl_opt[:log_level] == Fluent::Log::LEVEL_INFO
|
38
|
-
# info level can't be specified via command line option.
|
39
|
-
# log_level is info here, it is default value and <system>'s log_level should be applied if exists.
|
40
|
-
next
|
41
|
-
end
|
42
|
-
|
43
|
-
opt[param] = @cl_opt[param]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
opt
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class TestSystemConfig < ::Test::Unit::TestCase
|
52
|
-
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/system_config/#{ENV['TEST_ENV_NUMBER']}")
|
53
|
-
|
54
|
-
def parse_text(text)
|
55
|
-
basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
|
56
|
-
Fluent::Config.parse(text, '(test)', basepath, true).elements.find { |e| e.name == 'system' }
|
57
|
-
end
|
58
|
-
|
59
|
-
test 'should not override default configurations when no parameters' do
|
60
|
-
conf = parse_text(<<-EOS)
|
61
|
-
<system>
|
62
|
-
</system>
|
63
|
-
EOS
|
64
|
-
s = FakeSupervisor.new
|
65
|
-
sc = Fluent::SystemConfig.new(conf)
|
66
|
-
sc.overwrite_variables(**s.for_system_config)
|
67
|
-
assert_equal(1, sc.workers)
|
68
|
-
assert_equal(0, sc.restart_worker_interval)
|
69
|
-
assert_nil(sc.root_dir)
|
70
|
-
assert_equal(Fluent::Log::LEVEL_INFO, sc.log_level)
|
71
|
-
assert_nil(sc.suppress_repeated_stacktrace)
|
72
|
-
assert_nil(sc.ignore_repeated_log_interval)
|
73
|
-
assert_nil(sc.emit_error_log_interval)
|
74
|
-
assert_nil(sc.suppress_config_dump)
|
75
|
-
assert_nil(sc.without_source)
|
76
|
-
assert_nil(sc.enable_input_metrics)
|
77
|
-
assert_nil(sc.enable_size_metrics)
|
78
|
-
assert_nil(sc.enable_msgpack_time_support)
|
79
|
-
assert(!sc.enable_jit)
|
80
|
-
assert_equal(:text, sc.log.format)
|
81
|
-
assert_equal('%Y-%m-%d %H:%M:%S %z', sc.log.time_format)
|
82
|
-
end
|
83
|
-
|
84
|
-
data(
|
85
|
-
'workers' => ['workers', 3],
|
86
|
-
'restart_worker_interval' => ['restart_worker_interval', 60],
|
87
|
-
'root_dir' => ['root_dir', File.join(TMP_DIR, 'root')],
|
88
|
-
'log_level' => ['log_level', 'error'],
|
89
|
-
'suppress_repeated_stacktrace' => ['suppress_repeated_stacktrace', true],
|
90
|
-
'ignore_repeated_log_interval' => ['ignore_repeated_log_interval', 10],
|
91
|
-
'log_event_verbose' => ['log_event_verbose', true],
|
92
|
-
'suppress_config_dump' => ['suppress_config_dump', true],
|
93
|
-
'without_source' => ['without_source', true],
|
94
|
-
'strict_config_value' => ['strict_config_value', true],
|
95
|
-
'enable_msgpack_time_support' => ['enable_msgpack_time_support', true],
|
96
|
-
'enable_input_metrics' => ['enable_input_metrics', true],
|
97
|
-
'enable_size_metrics' => ['enable_size_metrics', true],
|
98
|
-
'enable_jit' => ['enable_jit', true],
|
99
|
-
)
|
100
|
-
test "accepts parameters" do |(k, v)|
|
101
|
-
conf = parse_text(<<-EOS)
|
102
|
-
<system>
|
103
|
-
#{k} #{v}
|
104
|
-
</system>
|
105
|
-
EOS
|
106
|
-
s = FakeSupervisor.new
|
107
|
-
sc = Fluent::SystemConfig.new(conf)
|
108
|
-
sc.overwrite_variables(**s.for_system_config)
|
109
|
-
if k == 'log_level'
|
110
|
-
assert_equal(Fluent::Log::LEVEL_ERROR, sc.__send__(k))
|
111
|
-
else
|
112
|
-
assert_equal(v, sc.__send__(k))
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
test "log parameters" do
|
117
|
-
conf = parse_text(<<-EOS)
|
118
|
-
<system>
|
119
|
-
<log>
|
120
|
-
format json
|
121
|
-
time_format %Y
|
122
|
-
</log>
|
123
|
-
</system>
|
124
|
-
EOS
|
125
|
-
s = FakeSupervisor.new
|
126
|
-
sc = Fluent::SystemConfig.new(conf)
|
127
|
-
sc.overwrite_variables(**s.for_system_config)
|
128
|
-
assert_equal(:json, sc.log.format)
|
129
|
-
assert_equal('%Y', sc.log.time_format)
|
130
|
-
end
|
131
|
-
|
132
|
-
# info is removed because info level can't be specified via command line
|
133
|
-
data('trace' => Fluent::Log::LEVEL_TRACE,
|
134
|
-
'debug' => Fluent::Log::LEVEL_DEBUG,
|
135
|
-
'warn' => Fluent::Log::LEVEL_WARN,
|
136
|
-
'error' => Fluent::Log::LEVEL_ERROR,
|
137
|
-
'fatal' => Fluent::Log::LEVEL_FATAL)
|
138
|
-
test 'log_level is ignored when log_level related command line option is passed' do |level|
|
139
|
-
conf = parse_text(<<-EOS)
|
140
|
-
<system>
|
141
|
-
log_level info
|
142
|
-
</system>
|
143
|
-
EOS
|
144
|
-
s = FakeSupervisor.new(log_level: level)
|
145
|
-
sc = Fluent::SystemConfig.new(conf)
|
146
|
-
sc.overwrite_variables(**s.for_system_config)
|
147
|
-
assert_equal(level, sc.log_level)
|
148
|
-
end
|
149
|
-
|
150
|
-
sub_test_case "log rotation" do
|
151
|
-
data('daily' => "daily",
|
152
|
-
'weekly' => 'weekly',
|
153
|
-
'monthly' => 'monthly')
|
154
|
-
test "strings for rotate_age" do |age|
|
155
|
-
conf = parse_text(<<-EOS)
|
156
|
-
<system>
|
157
|
-
<log>
|
158
|
-
rotate_age #{age}
|
159
|
-
</log>
|
160
|
-
</system>
|
161
|
-
EOS
|
162
|
-
sc = Fluent::SystemConfig.new(conf)
|
163
|
-
assert_equal(age, sc.log.rotate_age)
|
164
|
-
end
|
165
|
-
|
166
|
-
test "numeric number for rotate age" do
|
167
|
-
conf = parse_text(<<-EOS)
|
168
|
-
<system>
|
169
|
-
<log>
|
170
|
-
rotate_age 3
|
171
|
-
</log>
|
172
|
-
</system>
|
173
|
-
EOS
|
174
|
-
sc = Fluent::SystemConfig.new(conf)
|
175
|
-
assert_equal(3, sc.log.rotate_age)
|
176
|
-
end
|
177
|
-
|
178
|
-
data(h: ['100', 100],
|
179
|
-
k: ['1k', 1024],
|
180
|
-
m: ['1m', 1024 * 1024],
|
181
|
-
g: ['1g', 1024 * 1024 * 1024])
|
182
|
-
test "numeric and SI prefix for rotate_size" do |(label, size)|
|
183
|
-
conf = parse_text(<<-EOS)
|
184
|
-
<system>
|
185
|
-
<log>
|
186
|
-
rotate_size #{label}
|
187
|
-
</log>
|
188
|
-
</system>
|
189
|
-
EOS
|
190
|
-
sc = Fluent::SystemConfig.new(conf)
|
191
|
-
assert_equal(size, sc.log.rotate_size)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
data/test/config/test_types.rb
DELETED
@@ -1,408 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'fluent/config/types'
|
3
|
-
|
4
|
-
class TestConfigTypes < ::Test::Unit::TestCase
|
5
|
-
include Fluent
|
6
|
-
|
7
|
-
sub_test_case 'Config.size_value' do
|
8
|
-
data("2k" => [2048, "2k"],
|
9
|
-
"2K" => [2048, "2K"],
|
10
|
-
"3m" => [3145728, "3m"],
|
11
|
-
"3M" => [3145728, "3M"],
|
12
|
-
"4g" => [4294967296, "4g"],
|
13
|
-
"4G" => [4294967296, "4G"],
|
14
|
-
"5t" => [5497558138880, "5t"],
|
15
|
-
"5T" => [5497558138880, "5T"],
|
16
|
-
"6" => [6, "6"])
|
17
|
-
test 'normal case' do |(expected, val)|
|
18
|
-
assert_equal(expected, Config.size_value(val))
|
19
|
-
assert_equal(expected, Config.size_value(val, { strict: true }))
|
20
|
-
end
|
21
|
-
|
22
|
-
data("integer" => [6, 6],
|
23
|
-
"hoge" => [0, "hoge"],
|
24
|
-
"empty" => [0, ""])
|
25
|
-
test 'not assumed case' do |(expected, val)|
|
26
|
-
assert_equal(expected, Config.size_value(val))
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'nil' do
|
30
|
-
assert_equal(nil, Config.size_value(nil))
|
31
|
-
end
|
32
|
-
|
33
|
-
data("integer" => [6, 6],
|
34
|
-
"hoge" => [Fluent::ConfigError.new('name1: invalid value for Integer(): "hoge"'), "hoge"],
|
35
|
-
"empty" => [Fluent::ConfigError.new('name1: invalid value for Integer(): ""'), ""])
|
36
|
-
test 'not assumed case with strict' do |(expected, val)|
|
37
|
-
if expected.kind_of? Exception
|
38
|
-
assert_raise(expected) do
|
39
|
-
Config.size_value(val, { strict: true }, "name1")
|
40
|
-
end
|
41
|
-
else
|
42
|
-
assert_equal(expected, Config.size_value(val, { strict: true }, "name1"))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
test 'nil with strict' do
|
47
|
-
assert_equal(nil, Config.size_value(nil, { strict: true }))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
sub_test_case 'Config.time_value' do
|
52
|
-
data("10s" => [10, "10s"],
|
53
|
-
"10sec" => [10, "10sec"],
|
54
|
-
"2m" => [120, "2m"],
|
55
|
-
"3h" => [10800, "3h"],
|
56
|
-
"4d" => [345600, "4d"])
|
57
|
-
test 'normal case' do |(expected, val)|
|
58
|
-
assert_equal(expected, Config.time_value(val))
|
59
|
-
assert_equal(expected, Config.time_value(val, { strict: true }))
|
60
|
-
end
|
61
|
-
|
62
|
-
data("integer" => [4.0, 4],
|
63
|
-
"float" => [0.4, 0.4],
|
64
|
-
"hoge" => [0.0, "hoge"],
|
65
|
-
"empty" => [0.0, ""])
|
66
|
-
test 'not assumed case' do |(expected, val)|
|
67
|
-
assert_equal(expected, Config.time_value(val))
|
68
|
-
end
|
69
|
-
|
70
|
-
test 'nil' do
|
71
|
-
assert_equal(nil, Config.time_value(nil))
|
72
|
-
end
|
73
|
-
|
74
|
-
data("integer" => [6, 6],
|
75
|
-
"hoge" => [Fluent::ConfigError.new('name1: invalid value for Float(): "hoge"'), "hoge"],
|
76
|
-
"empty" => [Fluent::ConfigError.new('name1: invalid value for Float(): ""'), ""])
|
77
|
-
test 'not assumed case with strict' do |(expected, val)|
|
78
|
-
if expected.kind_of? Exception
|
79
|
-
assert_raise(expected) do
|
80
|
-
Config.time_value(val, { strict: true }, "name1")
|
81
|
-
end
|
82
|
-
else
|
83
|
-
assert_equal(expected, Config.time_value(val, { strict: true }, "name1"))
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
test 'nil with strict' do
|
88
|
-
assert_equal(nil, Config.time_value(nil, { strict: true }))
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
sub_test_case 'Config.bool_value' do
|
93
|
-
data("true" => [true, "true"],
|
94
|
-
"yes" => [true, "yes"],
|
95
|
-
"empty" => [true, ""],
|
96
|
-
"false" => [false, "false"],
|
97
|
-
"no" => [false, "no"])
|
98
|
-
test 'normal case' do |(expected, val)|
|
99
|
-
assert_equal(expected, Config.bool_value(val))
|
100
|
-
end
|
101
|
-
|
102
|
-
data("true" => [true, true],
|
103
|
-
"false" => [false, false],
|
104
|
-
"hoge" => [nil, "hoge"],
|
105
|
-
"nil" => [nil, nil],
|
106
|
-
"integer" => [nil, 10])
|
107
|
-
test 'not assumed case' do |(expected, val)|
|
108
|
-
assert_equal(expected, Config.bool_value(val))
|
109
|
-
end
|
110
|
-
|
111
|
-
data("true" => [true, true],
|
112
|
-
"false" => [false, false],
|
113
|
-
"hoge" => [Fluent::ConfigError.new("name1: invalid bool value: hoge"), "hoge"],
|
114
|
-
"nil" => [nil, nil],
|
115
|
-
"integer" => [Fluent::ConfigError.new("name1: invalid bool value: 10"), 10])
|
116
|
-
test 'not assumed case with strict' do |(expected, val)|
|
117
|
-
if expected.kind_of? Exception
|
118
|
-
assert_raise(expected) do
|
119
|
-
Config.bool_value(val, { strict: true }, "name1")
|
120
|
-
end
|
121
|
-
else
|
122
|
-
assert_equal(expected, Config.bool_value(val, { strict: true }, "name1"))
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
sub_test_case 'Config.regexp_value' do
|
128
|
-
data("empty" => [//, "//"],
|
129
|
-
"plain" => [/regexp/, "/regexp/"],
|
130
|
-
"zero width" => [/^$/, "/^$/"],
|
131
|
-
"character classes" => [/[a-z]/, "/[a-z]/"],
|
132
|
-
"meta charactersx" => [/.+.*?\d\w\s\S/, '/.+.*?\d\w\s\S/'])
|
133
|
-
test 'normal case' do |(expected, str)|
|
134
|
-
assert_equal(expected, Config.regexp_value(str))
|
135
|
-
end
|
136
|
-
|
137
|
-
data("empty" => [//, ""],
|
138
|
-
"plain" => [/regexp/, "regexp"],
|
139
|
-
"zero width" => [/^$/, "^$"],
|
140
|
-
"character classes" => [/[a-z]/, "[a-z]"],
|
141
|
-
"meta charactersx" => [/.+.*?\d\w\s\S/, '.+.*?\d\w\s\S'])
|
142
|
-
test 'w/o slashes' do |(expected, str)|
|
143
|
-
assert_equal(expected, Config.regexp_value(str))
|
144
|
-
end
|
145
|
-
|
146
|
-
data("missing right slash" => "/regexp",
|
147
|
-
"too many options" => "/regexp/imx",)
|
148
|
-
test 'invalid regexp' do |(str)|
|
149
|
-
assert_raise(Fluent::ConfigError.new("invalid regexp: missing right slash: #{str}")) do
|
150
|
-
Config.regexp_value(str)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
test 'nil' do
|
155
|
-
assert_equal nil, Config.regexp_value(nil)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
sub_test_case 'type converters for config_param definitions' do
|
160
|
-
data("test" => ['test', 'test'],
|
161
|
-
"1" => ['1', '1'],
|
162
|
-
"spaces" => [' ', ' '])
|
163
|
-
test 'string' do |(expected, val)|
|
164
|
-
assert_equal expected, Config::STRING_TYPE.call(val, {})
|
165
|
-
assert_equal Encoding::UTF_8, Config::STRING_TYPE.call(val, {}).encoding
|
166
|
-
end
|
167
|
-
|
168
|
-
test 'string nil' do
|
169
|
-
assert_equal nil, Config::STRING_TYPE.call(nil, {})
|
170
|
-
end
|
171
|
-
|
172
|
-
data('latin' => 'Märch',
|
173
|
-
'ascii' => 'ascii',
|
174
|
-
'space' => ' ',
|
175
|
-
'number' => '1',
|
176
|
-
'Hiragana' => 'あいうえお')
|
177
|
-
test 'string w/ binary' do |str|
|
178
|
-
actual = Config::STRING_TYPE.call(str.b, {})
|
179
|
-
assert_equal str, actual
|
180
|
-
assert_equal Encoding::UTF_8, actual.encoding
|
181
|
-
end
|
182
|
-
|
183
|
-
data('starts_with_semicolon' => [:conor, ':conor'],
|
184
|
-
'simple_string' => [:conor, 'conor'],
|
185
|
-
'empty_string' => [nil, ''])
|
186
|
-
test 'symbol' do |(expected, val)|
|
187
|
-
assert_equal Config::SYMBOL_TYPE.call(val, {}), expected
|
188
|
-
end
|
189
|
-
|
190
|
-
data("val" => [:val, 'val'],
|
191
|
-
"v" => [:v, 'v'],
|
192
|
-
"value" => [:value, 'value'])
|
193
|
-
test 'enum' do |(expected, val)|
|
194
|
-
assert_equal expected, Config::ENUM_TYPE.call(val, {list: [:val, :value, :v]})
|
195
|
-
end
|
196
|
-
|
197
|
-
test 'enum: pick unknown choice' do
|
198
|
-
assert_raises(Fluent::ConfigError.new("valid options are val,value,v but got x")) do
|
199
|
-
Config::ENUM_TYPE.call('x', {list: [:val, :value, :v]})
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
data("empty list" => {},
|
204
|
-
"string list" => {list: ["val", "value", "v"]})
|
205
|
-
test 'enum: invalid choices' do | list |
|
206
|
-
assert_raises(RuntimeError.new("Plugin BUG: config type 'enum' requires :list of symbols")) do
|
207
|
-
Config::ENUM_TYPE.call('val', list)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
test 'enum: nil' do
|
212
|
-
assert_equal nil, Config::ENUM_TYPE.call(nil)
|
213
|
-
end
|
214
|
-
|
215
|
-
data("1" => [1, '1'],
|
216
|
-
"1.0" => [1, '1.0'],
|
217
|
-
"1_000" => [1000, '1_000'],
|
218
|
-
"1x" => [1, '1x'])
|
219
|
-
test 'integer' do |(expected, val)|
|
220
|
-
assert_equal expected, Config::INTEGER_TYPE.call(val, {})
|
221
|
-
end
|
222
|
-
|
223
|
-
data("integer" => [6, 6],
|
224
|
-
"hoge" => [0, "hoge"],
|
225
|
-
"empty" => [0, ""])
|
226
|
-
test 'integer: not assumed case' do |(expected, val)|
|
227
|
-
assert_equal expected, Config::INTEGER_TYPE.call(val, {})
|
228
|
-
end
|
229
|
-
|
230
|
-
test 'integer: nil' do
|
231
|
-
assert_equal nil, Config::INTEGER_TYPE.call(nil, {})
|
232
|
-
end
|
233
|
-
|
234
|
-
data("integer" => [6, 6],
|
235
|
-
"hoge" => [Fluent::ConfigError.new('name1: invalid value for Integer(): "hoge"'), "hoge"],
|
236
|
-
"empty" => [Fluent::ConfigError.new('name1: invalid value for Integer(): ""'), ""])
|
237
|
-
test 'integer: not assumed case with strict' do |(expected, val)|
|
238
|
-
if expected.kind_of? Exception
|
239
|
-
assert_raise(expected) do
|
240
|
-
Config::INTEGER_TYPE.call(val, { strict: true }, "name1")
|
241
|
-
end
|
242
|
-
else
|
243
|
-
assert_equal expected, Config::INTEGER_TYPE.call(val, { strict: true }, "name1")
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
test 'integer: nil with strict' do
|
248
|
-
assert_equal nil, Config::INTEGER_TYPE.call(nil, { strict: true })
|
249
|
-
end
|
250
|
-
|
251
|
-
data("1" => [1.0, '1'],
|
252
|
-
"1.0" => [1.0, '1.0'],
|
253
|
-
"1.00" => [1.0, '1.00'],
|
254
|
-
"1e0" => [1.0, '1e0'])
|
255
|
-
test 'float' do |(expected, val)|
|
256
|
-
assert_equal expected, Config::FLOAT_TYPE.call(val, {})
|
257
|
-
end
|
258
|
-
|
259
|
-
data("integer" => [6, 6],
|
260
|
-
"hoge" => [0, "hoge"],
|
261
|
-
"empty" => [0, ""])
|
262
|
-
test 'float: not assumed case' do |(expected, val)|
|
263
|
-
assert_equal expected, Config::FLOAT_TYPE.call(val, {})
|
264
|
-
end
|
265
|
-
|
266
|
-
test 'float: nil' do
|
267
|
-
assert_equal nil, Config::FLOAT_TYPE.call(nil, {})
|
268
|
-
end
|
269
|
-
|
270
|
-
data("integer" => [6, 6],
|
271
|
-
"hoge" => [Fluent::ConfigError.new('name1: invalid value for Float(): "hoge"'), "hoge"],
|
272
|
-
"empty" => [Fluent::ConfigError.new('name1: invalid value for Float(): ""'), ""])
|
273
|
-
test 'float: not assumed case with strict' do |(expected, val)|
|
274
|
-
if expected.kind_of? Exception
|
275
|
-
assert_raise(expected) do
|
276
|
-
Config::FLOAT_TYPE.call(val, { strict: true }, "name1")
|
277
|
-
end
|
278
|
-
else
|
279
|
-
assert_equal expected, Config::FLOAT_TYPE.call(val, { strict: true }, "name1")
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
test 'float: nil with strict' do
|
284
|
-
assert_equal nil, Config::FLOAT_TYPE.call(nil, { strict: true })
|
285
|
-
end
|
286
|
-
|
287
|
-
data("1000" => [1000, '1000'],
|
288
|
-
"1k" => [1024, '1k'],
|
289
|
-
"1m" => [1024*1024, '1m'])
|
290
|
-
test 'size' do |(expected, val)|
|
291
|
-
assert_equal expected, Config::SIZE_TYPE.call(val, {})
|
292
|
-
end
|
293
|
-
|
294
|
-
data("true" => [true, 'true'],
|
295
|
-
"yes" => [true, 'yes'],
|
296
|
-
"no" => [false, 'no'],
|
297
|
-
"false" => [false, 'false'],
|
298
|
-
"TRUE" => [nil, 'TRUE'],
|
299
|
-
"True" => [nil, 'True'],
|
300
|
-
"Yes" => [nil, 'Yes'],
|
301
|
-
"No" => [nil, 'No'],
|
302
|
-
"empty" => [true, ''],
|
303
|
-
"unexpected_string" => [nil, 'unexpected_string'])
|
304
|
-
test 'bool' do |(expected, val)|
|
305
|
-
assert_equal expected, Config::BOOL_TYPE.call(val, {})
|
306
|
-
end
|
307
|
-
|
308
|
-
data("0" => [0, '0'],
|
309
|
-
"1" => [1.0, '1'],
|
310
|
-
"1.01" => [1.01, '1.01'],
|
311
|
-
"1s" => [1, '1s'],
|
312
|
-
"1," => [60, '1m'],
|
313
|
-
"1h" => [3600, '1h'],
|
314
|
-
"1d" => [86400, '1d'])
|
315
|
-
test 'time' do |(expected, val)|
|
316
|
-
assert_equal expected, Config::TIME_TYPE.call(val, {})
|
317
|
-
end
|
318
|
-
|
319
|
-
data("empty" => [//, "//"],
|
320
|
-
"plain" => [/regexp/, "/regexp/"],
|
321
|
-
"zero width" => [/^$/, "/^$/"],
|
322
|
-
"character classes" => [/[a-z]/, "/[a-z]/"],
|
323
|
-
"meta charactersx" => [/.+.*?\d\w\s\S/, '/.+.*?\d\w\s\S/'])
|
324
|
-
test 'regexp' do |(expected, str)|
|
325
|
-
assert_equal(expected, Config::REGEXP_TYPE.call(str, {}))
|
326
|
-
end
|
327
|
-
|
328
|
-
data("string and integer" => [{"x"=>"v","k"=>1}, '{"x":"v","k":1}', {}],
|
329
|
-
"strings" => [{"x"=>"v","k"=>"1"}, 'x:v,k:1', {}],
|
330
|
-
"w/ space" => [{"x"=>"v","k"=>"1"}, 'x:v, k:1', {}],
|
331
|
-
"heading space" => [{"x"=>"v","k"=>"1"}, ' x:v, k:1 ', {}],
|
332
|
-
"trailing space" => [{"x"=>"v","k"=>"1"}, 'x:v , k:1 ', {}],
|
333
|
-
"multiple colons" => [{"x"=>"v:v","k"=>"1"}, 'x:v:v, k:1', {}],
|
334
|
-
"symbolize keys" => [{x: "v", k: 1}, '{"x":"v","k":1}', {symbolize_keys: true}],
|
335
|
-
"value_type: :string" => [{x: "v", k: "1"}, 'x:v,k:1', {symbolize_keys: true, value_type: :string}],
|
336
|
-
"value_type: :string 2" => [{x: "v", k: "1"}, '{"x":"v","k":1}', {symbolize_keys: true, value_type: :string}],
|
337
|
-
"value_type: :integer" => [{x: 0, k: 1}, 'x:0,k:1', {symbolize_keys: true, value_type: :integer}],
|
338
|
-
"time 1" => [{"x"=>1,"y"=>60,"z"=>3600}, '{"x":"1s","y":"1m","z":"1h"}', {value_type: :time}],
|
339
|
-
"time 2" => [{"x"=>1,"y"=>60,"z"=>3600}, 'x:1s,y:1m,z:1h', {value_type: :time}])
|
340
|
-
test 'hash' do |(expected, val, opts)|
|
341
|
-
assert_equal(expected, Config::HASH_TYPE.call(val, opts))
|
342
|
-
end
|
343
|
-
|
344
|
-
test 'hash w/ unknown type' do
|
345
|
-
assert_raise(RuntimeError.new("unknown type in REFORMAT: foo")) do
|
346
|
-
Config::HASH_TYPE.call("x:1,y:2", {value_type: :foo})
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
test 'hash w/ strict option' do
|
351
|
-
assert_raise(Fluent::ConfigError.new('y: invalid value for Integer(): "hoge"')) do
|
352
|
-
Config::HASH_TYPE.call("x:1,y:hoge", {value_type: :integer, strict: true})
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
data('latin' => ['3:Märch', {"3"=>"Märch"}],
|
357
|
-
'ascii' => ['ascii:ascii', {"ascii"=>"ascii"}],
|
358
|
-
'number' => ['number:1', {"number"=>"1"}],
|
359
|
-
'Hiragana' => ['hiragana:あいうえお', {"hiragana"=>"あいうえお"}])
|
360
|
-
test 'hash w/ binary' do |(target, expected)|
|
361
|
-
assert_equal(expected, Config::HASH_TYPE.call(target.b, { value_type: :string }))
|
362
|
-
end
|
363
|
-
|
364
|
-
test 'hash w/ nil' do
|
365
|
-
assert_equal(nil, Config::HASH_TYPE.call(nil))
|
366
|
-
end
|
367
|
-
|
368
|
-
data("strings and integer" => [["1","2",1], '["1","2",1]', {}],
|
369
|
-
"number strings" => [["1","2","1"], '1,2,1', {}],
|
370
|
-
"alphabets" => [["a","b","c"], '["a","b","c"]', {}],
|
371
|
-
"alphabets w/o quote" => [["a","b","c"], 'a,b,c', {}],
|
372
|
-
"w/ spaces" => [["a","b","c"], 'a, b, c', {}],
|
373
|
-
"w/ space before comma" => [["a","b","c"], 'a , b , c', {}],
|
374
|
-
"comma or space w/ qupte" => [["a a","b,b"," c "], '["a a","b,b"," c "]', {}],
|
375
|
-
"space in a value w/o qupte" => [["a a","b","c"], 'a a,b,c', {}],
|
376
|
-
"integers" => [[1,2,1], '[1,2,1]', {}],
|
377
|
-
"value_type: :integer w/ quote" => [[1,2,1], '["1","2","1"]', {value_type: :integer}],
|
378
|
-
"value_type: :integer w/o quote" => [[1,2,1], '1,2,1', {value_type: :integer}])
|
379
|
-
test 'array' do |(expected, val, opts)|
|
380
|
-
assert_equal(expected, Config::ARRAY_TYPE.call(val, opts))
|
381
|
-
end
|
382
|
-
|
383
|
-
data('["1","2"]' => [["1","2"], '["1","2"]'],
|
384
|
-
'["3"]' => [["3"], '["3"]'])
|
385
|
-
test 'array w/ default values' do |(expected, val)|
|
386
|
-
array_options = {
|
387
|
-
default: [],
|
388
|
-
}
|
389
|
-
assert_equal(expected, Config::ARRAY_TYPE.call(val, array_options))
|
390
|
-
end
|
391
|
-
|
392
|
-
test 'array w/ unknown type' do
|
393
|
-
assert_raise(RuntimeError.new("unknown type in REFORMAT: foo")) do
|
394
|
-
Config::ARRAY_TYPE.call("1,2", {value_type: :foo})
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
test 'array w/ strict option' do
|
399
|
-
assert_raise(Fluent::ConfigError.new(': invalid value for Integer(): "hoge"')) do
|
400
|
-
Config::ARRAY_TYPE.call("1,hoge", {value_type: :integer, strict: true}, "name1")
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
test 'array w/ nil' do
|
405
|
-
assert_equal(nil, Config::ARRAY_TYPE.call(nil))
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|