fluentd 1.17.0-x64-mingw32 → 1.18.0-x64-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/test_config.rb
DELETED
@@ -1,369 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
require 'fluent/config'
|
3
|
-
require 'fluent/config/parser'
|
4
|
-
require 'fluent/supervisor'
|
5
|
-
require 'fluent/load'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
class ConfigTest < Test::Unit::TestCase
|
9
|
-
include Fluent
|
10
|
-
|
11
|
-
TMP_DIR = File.dirname(__FILE__) + "/tmp/config#{ENV['TEST_ENV_NUMBER']}"
|
12
|
-
|
13
|
-
def read_config(path, use_yaml: false)
|
14
|
-
path = File.expand_path(path)
|
15
|
-
if use_yaml
|
16
|
-
context = Kernel.binding
|
17
|
-
|
18
|
-
s = Fluent::Config::YamlParser::Loader.new(context).load(Pathname.new(path))
|
19
|
-
Fluent::Config::YamlParser::Parser.new(s).build.to_element
|
20
|
-
else
|
21
|
-
File.open(path) { |io|
|
22
|
-
Fluent::Config::Parser.parse(io, File.basename(path), File.dirname(path))
|
23
|
-
}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def prepare_config
|
28
|
-
write_config "#{TMP_DIR}/config_test_1.conf", %[
|
29
|
-
k1 root_config
|
30
|
-
include dir/config_test_2.conf #
|
31
|
-
include #{TMP_DIR}/config_test_4.conf
|
32
|
-
include file://#{TMP_DIR}/config_test_5.conf
|
33
|
-
<include config.d/*.conf />
|
34
|
-
]
|
35
|
-
write_config "#{TMP_DIR}/dir/config_test_2.conf", %[
|
36
|
-
k2 relative_path_include
|
37
|
-
include ../config_test_3.conf
|
38
|
-
]
|
39
|
-
write_config "#{TMP_DIR}/config_test_3.conf", %[
|
40
|
-
k3 relative_include_in_included_file
|
41
|
-
]
|
42
|
-
write_config "#{TMP_DIR}/config_test_4.conf", %[
|
43
|
-
k4 absolute_path_include
|
44
|
-
]
|
45
|
-
write_config "#{TMP_DIR}/config_test_5.conf", %[
|
46
|
-
k5 uri_include
|
47
|
-
]
|
48
|
-
write_config "#{TMP_DIR}/config.d/config_test_6.conf", %[
|
49
|
-
k6 wildcard_include_1
|
50
|
-
<elem1 name>
|
51
|
-
include normal_parameter
|
52
|
-
</elem1>
|
53
|
-
]
|
54
|
-
write_config "#{TMP_DIR}/config.d/config_test_7.conf", %[
|
55
|
-
k7 wildcard_include_2
|
56
|
-
]
|
57
|
-
write_config "#{TMP_DIR}/config.d/config_test_8.conf", %[
|
58
|
-
<elem2 name>
|
59
|
-
<include ../dir/config_test_9.conf />
|
60
|
-
</elem2>
|
61
|
-
]
|
62
|
-
write_config "#{TMP_DIR}/dir/config_test_9.conf", %[
|
63
|
-
k9 embedded
|
64
|
-
<elem3 name>
|
65
|
-
nested nested_value
|
66
|
-
include hoge
|
67
|
-
</elem3>
|
68
|
-
]
|
69
|
-
write_config "#{TMP_DIR}/config.d/00_config_test_8.conf", %[
|
70
|
-
k8 wildcard_include_3
|
71
|
-
<elem4 name>
|
72
|
-
include normal_parameter
|
73
|
-
</elem4>
|
74
|
-
]
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_include
|
79
|
-
prepare_config
|
80
|
-
c = read_config("#{TMP_DIR}/config_test_1.conf")
|
81
|
-
assert_equal 'root_config', c['k1']
|
82
|
-
assert_equal 'relative_path_include', c['k2']
|
83
|
-
assert_equal 'relative_include_in_included_file', c['k3']
|
84
|
-
assert_equal 'absolute_path_include', c['k4']
|
85
|
-
assert_equal 'uri_include', c['k5']
|
86
|
-
assert_equal 'wildcard_include_1', c['k6']
|
87
|
-
assert_equal 'wildcard_include_2', c['k7']
|
88
|
-
assert_equal 'wildcard_include_3', c['k8']
|
89
|
-
assert_equal [
|
90
|
-
'k1',
|
91
|
-
'k2',
|
92
|
-
'k3',
|
93
|
-
'k4',
|
94
|
-
'k5',
|
95
|
-
'k8', # Because of the file name this comes first.
|
96
|
-
'k6',
|
97
|
-
'k7',
|
98
|
-
], c.keys
|
99
|
-
|
100
|
-
elem1 = c.elements.find { |e| e.name == 'elem1' }
|
101
|
-
assert_not_nil elem1
|
102
|
-
assert_equal 'name', elem1.arg
|
103
|
-
assert_equal 'normal_parameter', elem1['include']
|
104
|
-
|
105
|
-
elem2 = c.elements.find { |e| e.name == 'elem2' }
|
106
|
-
assert_not_nil elem2
|
107
|
-
assert_equal 'name', elem2.arg
|
108
|
-
assert_equal 'embedded', elem2['k9']
|
109
|
-
assert !elem2.has_key?('include')
|
110
|
-
|
111
|
-
elem3 = elem2.elements.find { |e| e.name == 'elem3' }
|
112
|
-
assert_not_nil elem3
|
113
|
-
assert_equal 'nested_value', elem3['nested']
|
114
|
-
assert_equal 'hoge', elem3['include']
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_check_not_fetchd
|
118
|
-
write_config "#{TMP_DIR}/config_test_not_fetched.conf", %[
|
119
|
-
<match dummy>
|
120
|
-
type rewrite
|
121
|
-
add_prefix filtered
|
122
|
-
<rule>
|
123
|
-
key path
|
124
|
-
pattern ^[A-Z]+
|
125
|
-
replace
|
126
|
-
</rule>
|
127
|
-
</match>
|
128
|
-
]
|
129
|
-
root_conf = read_config("#{TMP_DIR}/config_test_not_fetched.conf")
|
130
|
-
match_conf = root_conf.elements.first
|
131
|
-
rule_conf = match_conf.elements.first
|
132
|
-
|
133
|
-
not_fetched = []; root_conf.check_not_fetched {|key, e| not_fetched << key }
|
134
|
-
assert_equal %w[type add_prefix key pattern replace], not_fetched
|
135
|
-
|
136
|
-
not_fetched = []; match_conf.check_not_fetched {|key, e| not_fetched << key }
|
137
|
-
assert_equal %w[type add_prefix key pattern replace], not_fetched
|
138
|
-
|
139
|
-
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
140
|
-
assert_equal %w[key pattern replace], not_fetched
|
141
|
-
|
142
|
-
# accessing should delete
|
143
|
-
match_conf['type']
|
144
|
-
rule_conf['key']
|
145
|
-
|
146
|
-
not_fetched = []; root_conf.check_not_fetched {|key, e| not_fetched << key }
|
147
|
-
assert_equal %w[add_prefix pattern replace], not_fetched
|
148
|
-
|
149
|
-
not_fetched = []; match_conf.check_not_fetched {|key, e| not_fetched << key }
|
150
|
-
assert_equal %w[add_prefix pattern replace], not_fetched
|
151
|
-
|
152
|
-
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
153
|
-
assert_equal %w[pattern replace], not_fetched
|
154
|
-
|
155
|
-
# repeatedly accessing should not grow memory usage
|
156
|
-
before_size = match_conf.unused.size
|
157
|
-
10.times { match_conf['type'] }
|
158
|
-
assert_equal before_size, match_conf.unused.size
|
159
|
-
end
|
160
|
-
|
161
|
-
sub_test_case "yaml config" do
|
162
|
-
def test_included
|
163
|
-
write_config "#{TMP_DIR}/config_test_not_fetched.yaml", <<-EOS
|
164
|
-
config:
|
165
|
-
- source:
|
166
|
-
$type: dummy
|
167
|
-
tag: tag.dummy
|
168
|
-
- source:
|
169
|
-
$type: tcp
|
170
|
-
tag: tag.tcp
|
171
|
-
parse:
|
172
|
-
$arg:
|
173
|
-
- why.parse.section.doesnot.have.arg
|
174
|
-
- huh
|
175
|
-
$type: none
|
176
|
-
- match:
|
177
|
-
$tag: tag.*
|
178
|
-
$type: stdout
|
179
|
-
buffer:
|
180
|
-
$type: memory
|
181
|
-
flush_interval: 1s
|
182
|
-
- !include fluent-included.yaml
|
183
|
-
EOS
|
184
|
-
write_config "#{TMP_DIR}/fluent-included.yaml", <<-EOS
|
185
|
-
- label:
|
186
|
-
$name: '@FLUENT_LOG'
|
187
|
-
config:
|
188
|
-
- match:
|
189
|
-
$type: "null"
|
190
|
-
$tag: "**"
|
191
|
-
buffer:
|
192
|
-
$type: memory
|
193
|
-
flush_mode: interval
|
194
|
-
flush_interval: 1s
|
195
|
-
EOS
|
196
|
-
root_conf = read_config("#{TMP_DIR}/config_test_not_fetched.yaml", use_yaml: true)
|
197
|
-
dummy_source_conf = root_conf.elements.first
|
198
|
-
tcp_source_conf = root_conf.elements[1]
|
199
|
-
parse_tcp_conf = tcp_source_conf.elements.first
|
200
|
-
match_conf = root_conf.elements[2]
|
201
|
-
label_conf = root_conf.elements[3]
|
202
|
-
fluent_log_conf = label_conf.elements.first
|
203
|
-
fluent_log_buffer_conf = fluent_log_conf.elements.first
|
204
|
-
|
205
|
-
assert_equal(
|
206
|
-
[
|
207
|
-
'dummy',
|
208
|
-
'tag.dummy',
|
209
|
-
'tcp',
|
210
|
-
'tag.tcp',
|
211
|
-
'none',
|
212
|
-
'why.parse.section.doesnot.have.arg,huh',
|
213
|
-
'stdout',
|
214
|
-
'tag.*',
|
215
|
-
'null',
|
216
|
-
'**',
|
217
|
-
'@FLUENT_LOG',
|
218
|
-
'memory',
|
219
|
-
'interval',
|
220
|
-
'1s',
|
221
|
-
],
|
222
|
-
[
|
223
|
-
dummy_source_conf['@type'],
|
224
|
-
dummy_source_conf['tag'],
|
225
|
-
tcp_source_conf['@type'],
|
226
|
-
tcp_source_conf['tag'],
|
227
|
-
parse_tcp_conf['@type'],
|
228
|
-
parse_tcp_conf.arg,
|
229
|
-
match_conf['@type'],
|
230
|
-
match_conf.arg,
|
231
|
-
fluent_log_conf['@type'],
|
232
|
-
fluent_log_conf.arg,
|
233
|
-
label_conf.arg,
|
234
|
-
fluent_log_buffer_conf['@type'],
|
235
|
-
fluent_log_buffer_conf['flush_mode'],
|
236
|
-
fluent_log_buffer_conf['flush_interval'],
|
237
|
-
])
|
238
|
-
end
|
239
|
-
|
240
|
-
def test_included_glob
|
241
|
-
write_config "#{TMP_DIR}/config.yaml", <<-EOS
|
242
|
-
config:
|
243
|
-
- !include "include/*.yaml"
|
244
|
-
EOS
|
245
|
-
write_config "#{TMP_DIR}/include/02_source2.yaml", <<-EOS
|
246
|
-
- source:
|
247
|
-
$type: dummy
|
248
|
-
tag: tag.dummy
|
249
|
-
EOS
|
250
|
-
write_config "#{TMP_DIR}/include/01_source1.yaml", <<-EOS
|
251
|
-
- source:
|
252
|
-
$type: tcp
|
253
|
-
tag: tag.tcp
|
254
|
-
parse:
|
255
|
-
$arg:
|
256
|
-
- why.parse.section.doesnot.have.arg
|
257
|
-
- huh
|
258
|
-
$type: none
|
259
|
-
EOS
|
260
|
-
write_config "#{TMP_DIR}/include/03_match1.yaml", <<-EOS
|
261
|
-
- match:
|
262
|
-
$tag: tag.*
|
263
|
-
$type: stdout
|
264
|
-
buffer:
|
265
|
-
$type: memory
|
266
|
-
flush_interval: 1s
|
267
|
-
EOS
|
268
|
-
root_conf = read_config("#{TMP_DIR}/config.yaml", use_yaml: true)
|
269
|
-
tcp_source_conf = root_conf.elements.first
|
270
|
-
dummy_source_conf = root_conf.elements[1]
|
271
|
-
parse_tcp_conf = tcp_source_conf.elements.first
|
272
|
-
match_conf = root_conf.elements[2]
|
273
|
-
|
274
|
-
assert_equal(
|
275
|
-
[
|
276
|
-
'tcp',
|
277
|
-
'tag.tcp',
|
278
|
-
'none',
|
279
|
-
'why.parse.section.doesnot.have.arg,huh',
|
280
|
-
'dummy',
|
281
|
-
'tag.dummy',
|
282
|
-
'stdout',
|
283
|
-
'tag.*',
|
284
|
-
],
|
285
|
-
[
|
286
|
-
tcp_source_conf['@type'],
|
287
|
-
tcp_source_conf['tag'],
|
288
|
-
parse_tcp_conf['@type'],
|
289
|
-
parse_tcp_conf.arg,
|
290
|
-
dummy_source_conf['@type'],
|
291
|
-
dummy_source_conf['tag'],
|
292
|
-
match_conf['@type'],
|
293
|
-
match_conf.arg,
|
294
|
-
])
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_check_not_fetchd
|
298
|
-
write_config "#{TMP_DIR}/config_test_not_fetched.yaml", <<-EOS
|
299
|
-
config:
|
300
|
-
- match:
|
301
|
-
$arg: dummy
|
302
|
-
$type: rewrite
|
303
|
-
add_prefix: filtered
|
304
|
-
rule:
|
305
|
-
key: path
|
306
|
-
pattern: "^[A-Z]+"
|
307
|
-
replace: true
|
308
|
-
EOS
|
309
|
-
root_conf = read_config("#{TMP_DIR}/config_test_not_fetched.yaml", use_yaml: true)
|
310
|
-
match_conf = root_conf.elements.first
|
311
|
-
rule_conf = match_conf.elements.first
|
312
|
-
|
313
|
-
not_fetched = []; root_conf.check_not_fetched {|key, e| not_fetched << key }
|
314
|
-
assert_equal %w[@type $arg add_prefix key pattern replace], not_fetched
|
315
|
-
|
316
|
-
not_fetched = []; match_conf.check_not_fetched {|key, e| not_fetched << key }
|
317
|
-
assert_equal %w[@type $arg add_prefix key pattern replace], not_fetched
|
318
|
-
|
319
|
-
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
320
|
-
assert_equal %w[key pattern replace], not_fetched
|
321
|
-
|
322
|
-
# accessing should delete
|
323
|
-
match_conf['type']
|
324
|
-
rule_conf['key']
|
325
|
-
|
326
|
-
not_fetched = []; root_conf.check_not_fetched {|key, e| not_fetched << key }
|
327
|
-
assert_equal %w[@type $arg add_prefix pattern replace], not_fetched
|
328
|
-
|
329
|
-
not_fetched = []; match_conf.check_not_fetched {|key, e| not_fetched << key }
|
330
|
-
assert_equal %w[@type $arg add_prefix pattern replace], not_fetched
|
331
|
-
|
332
|
-
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
333
|
-
assert_equal %w[pattern replace], not_fetched
|
334
|
-
|
335
|
-
# repeatedly accessing should not grow memory usage
|
336
|
-
before_size = match_conf.unused.size
|
337
|
-
10.times { match_conf['type'] }
|
338
|
-
assert_equal before_size, match_conf.unused.size
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
def write_config(path, data, encoding: 'utf-8')
|
343
|
-
FileUtils.mkdir_p(File.dirname(path))
|
344
|
-
File.open(path, "w:#{encoding}:utf-8") {|f| f.write data }
|
345
|
-
end
|
346
|
-
|
347
|
-
sub_test_case '.build' do
|
348
|
-
test 'read config' do
|
349
|
-
write_config("#{TMP_DIR}/build/config_build.conf", 'key value')
|
350
|
-
c = Fluent::Config.build(config_path: "#{TMP_DIR}/build/config_build.conf")
|
351
|
-
assert_equal('value', c['key'])
|
352
|
-
end
|
353
|
-
|
354
|
-
test 'read config with encoding' do
|
355
|
-
write_config("#{TMP_DIR}/build/config_build2.conf", "#てすと\nkey value", encoding: 'shift_jis')
|
356
|
-
|
357
|
-
c = Fluent::Config.build(config_path: "#{TMP_DIR}/build/config_build2.conf", encoding: 'shift_jis')
|
358
|
-
assert_equal('value', c['key'])
|
359
|
-
end
|
360
|
-
|
361
|
-
test 'read config with additional_config' do
|
362
|
-
write_config("#{TMP_DIR}/build/config_build2.conf", "key value")
|
363
|
-
|
364
|
-
c = Fluent::Config.build(config_path: "#{TMP_DIR}/build/config_build2.conf", additional_config: 'key2 value2')
|
365
|
-
assert_equal('value', c['key'])
|
366
|
-
assert_equal('value2', c['key2'])
|
367
|
-
end
|
368
|
-
end
|
369
|
-
end
|
data/test/test_configdsl.rb
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
require 'fluent/config/dsl'
|
3
|
-
require 'fluent/test'
|
4
|
-
|
5
|
-
class ConfigDSLTest < Test::Unit::TestCase
|
6
|
-
# TEST_CONFIG1 = %[
|
7
|
-
# <source>
|
8
|
-
# type forward
|
9
|
-
# port 24224
|
10
|
-
# </source>
|
11
|
-
# <match test.**>
|
12
|
-
# type forward
|
13
|
-
# flush_interval 1s
|
14
|
-
# <server>
|
15
|
-
# host host0.example.com
|
16
|
-
# port 24224
|
17
|
-
# </server>
|
18
|
-
# <server>
|
19
|
-
# host host1.example.com
|
20
|
-
# port 24224
|
21
|
-
# </server>
|
22
|
-
# </match>
|
23
|
-
# ]
|
24
|
-
TEST_DSL_CONFIG1 = %q[
|
25
|
-
source {
|
26
|
-
type "forward"
|
27
|
-
port 24224
|
28
|
-
}
|
29
|
-
match('test.**') {
|
30
|
-
type "forward"
|
31
|
-
flush_interval "1s"
|
32
|
-
(0..1).each do |i|
|
33
|
-
server {
|
34
|
-
host "host#{i}.example.com"
|
35
|
-
port 24224
|
36
|
-
}
|
37
|
-
end
|
38
|
-
}
|
39
|
-
]
|
40
|
-
|
41
|
-
TEST_DSL_CONFIG2 = %q[
|
42
|
-
v = [0, 1, 2]
|
43
|
-
]
|
44
|
-
|
45
|
-
TEST_DSL_CONFIG3 = %q[
|
46
|
-
match
|
47
|
-
]
|
48
|
-
|
49
|
-
TEST_DSL_CONFIG4 = %q[
|
50
|
-
match('aa', 'bb'){
|
51
|
-
type :null
|
52
|
-
}
|
53
|
-
]
|
54
|
-
|
55
|
-
TEST_DSL_CONFIG5 = %q[
|
56
|
-
match('aa')
|
57
|
-
]
|
58
|
-
|
59
|
-
def test_parse
|
60
|
-
root = Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG1)
|
61
|
-
|
62
|
-
assert_equal 0, root.keys.size
|
63
|
-
assert_equal 2, root.elements.size
|
64
|
-
|
65
|
-
e0 = root.elements[0]
|
66
|
-
assert_equal 'source', e0.name
|
67
|
-
assert_equal '', e0.arg
|
68
|
-
assert_equal 'forward', e0['@type']
|
69
|
-
assert_equal '24224', e0['port']
|
70
|
-
|
71
|
-
e1 = root.elements[1]
|
72
|
-
assert_equal 'match', e1.name
|
73
|
-
assert_equal 'test.**', e1.arg
|
74
|
-
assert_equal 'forward', e1['@type']
|
75
|
-
assert_equal '1s', e1['flush_interval']
|
76
|
-
assert_equal 2, e1.elements.size
|
77
|
-
e1s0 = e1.elements[0]
|
78
|
-
assert_equal 'server', e1s0.name
|
79
|
-
assert_equal 'host0.example.com', e1s0['host']
|
80
|
-
assert_equal '24224', e1s0['port']
|
81
|
-
e1s1 = e1.elements[1]
|
82
|
-
assert_equal 'server', e1s1.name
|
83
|
-
assert_equal 'host1.example.com', e1s1['host']
|
84
|
-
assert_equal '24224', e1s1['port']
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_parse2
|
88
|
-
root = Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG2)
|
89
|
-
|
90
|
-
assert_equal 0, root.keys.size
|
91
|
-
assert_equal 0, root.elements.size
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_config_error
|
95
|
-
assert_raise(ArgumentError) {
|
96
|
-
Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG3)
|
97
|
-
}
|
98
|
-
|
99
|
-
assert_raise(ArgumentError) {
|
100
|
-
Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG4)
|
101
|
-
}
|
102
|
-
|
103
|
-
assert_raise(ArgumentError) {
|
104
|
-
Fluent::Config::DSL::Parser.parse(TEST_DSL_CONFIG5)
|
105
|
-
}
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_with_ruby_keyword
|
109
|
-
uname_string = `uname -a`
|
110
|
-
root1 = Fluent::Config::DSL::Parser.parse(<<DSL)
|
111
|
-
uname_str = ruby.open('|uname -a'){|out| out.read}
|
112
|
-
source {
|
113
|
-
uname uname_str
|
114
|
-
}
|
115
|
-
DSL
|
116
|
-
source1 = root1.elements.first
|
117
|
-
assert_equal 'source', source1.name
|
118
|
-
assert_equal 1, source1.keys.size
|
119
|
-
assert_equal uname_string, source1['uname']
|
120
|
-
|
121
|
-
root2 = Fluent::Config::DSL::Parser.parse(<<DSL)
|
122
|
-
ruby_version = ruby {
|
123
|
-
require 'erb'
|
124
|
-
ERB.new('<%= RUBY_VERSION %> from erb').result
|
125
|
-
}
|
126
|
-
source {
|
127
|
-
version ruby_version
|
128
|
-
}
|
129
|
-
DSL
|
130
|
-
source2 = root2.elements.first
|
131
|
-
assert_equal 'source', source2.name
|
132
|
-
assert_equal 1, source2.keys.size
|
133
|
-
assert_equal "#{RUBY_VERSION} from erb", source2['version']
|
134
|
-
|
135
|
-
# Parser#parse raises NoMethodError when configuration dsl elements are written in ruby block
|
136
|
-
conf3 = <<DSL
|
137
|
-
ruby {
|
138
|
-
source {
|
139
|
-
type "tail"
|
140
|
-
}
|
141
|
-
}
|
142
|
-
source {
|
143
|
-
uname uname_str
|
144
|
-
}
|
145
|
-
DSL
|
146
|
-
assert_raise (NoMethodError) { Fluent::Config::DSL::Parser.parse(conf3) }
|
147
|
-
end
|
148
|
-
end
|
data/test/test_daemonizer.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
require 'fluent/daemonizer'
|
3
|
-
|
4
|
-
class DaemonizerTest < ::Test::Unit::TestCase
|
5
|
-
TMP_DIR = File.join(File.dirname(__FILE__), 'tmp', 'daemonizer')
|
6
|
-
|
7
|
-
setup do
|
8
|
-
FileUtils.mkdir_p(TMP_DIR)
|
9
|
-
end
|
10
|
-
|
11
|
-
teardown do
|
12
|
-
FileUtils.rm_rf(TMP_DIR) rescue nil
|
13
|
-
end
|
14
|
-
|
15
|
-
test 'makes pid file' do
|
16
|
-
pid_path = File.join(TMP_DIR, 'file.pid')
|
17
|
-
|
18
|
-
mock(Process).daemon(anything, anything).once
|
19
|
-
r = Fluent::Daemonizer.daemonize(pid_path) { 'ret' }
|
20
|
-
assert_equal 'ret', r
|
21
|
-
assert File.exist?(pid_path)
|
22
|
-
assert Process.pid.to_s, File.read(pid_path).to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'in platforms which do not support fork' do
|
26
|
-
pid_path = File.join(TMP_DIR, 'file.pid')
|
27
|
-
|
28
|
-
mock(Process).daemon(anything, anything) { raise NotImplementedError }
|
29
|
-
args = ['-c', 'test.conf']
|
30
|
-
mock(Process).spawn(anything, *args) { Process.pid }
|
31
|
-
|
32
|
-
Fluent::Daemonizer.daemonize(pid_path, args) { 'ret' }
|
33
|
-
assert File.exist?(pid_path)
|
34
|
-
assert Process.pid.to_s, File.read(pid_path).to_s
|
35
|
-
end
|
36
|
-
|
37
|
-
sub_test_case 'when pid file already exists' do
|
38
|
-
test 'raise an error when process is running' do
|
39
|
-
omit 'chmod of file does not affetct root user' if Process.uid.zero?
|
40
|
-
pid_path = File.join(TMP_DIR, 'file.pid')
|
41
|
-
File.write(pid_path, '1')
|
42
|
-
|
43
|
-
mock(Process).daemon(anything, anything).never
|
44
|
-
mock(Process).kill(0, 1).once
|
45
|
-
|
46
|
-
assert_raise(Fluent::ConfigError.new('pid(1) is running')) do
|
47
|
-
Fluent::Daemonizer.daemonize(pid_path) { 'ret' }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
test 'raise an error when file is not redable' do
|
52
|
-
omit 'chmod of file does not affetct root user' if Process.uid.zero?
|
53
|
-
not_readable_path = File.join(TMP_DIR, 'not_readable.pid')
|
54
|
-
|
55
|
-
File.write(not_readable_path, '1')
|
56
|
-
FileUtils.chmod(0333, not_readable_path)
|
57
|
-
|
58
|
-
mock(Process).daemon(anything, anything).never
|
59
|
-
assert_raise(Fluent::ConfigError.new("Cannot access pid file: #{File.absolute_path(not_readable_path)}")) do
|
60
|
-
Fluent::Daemonizer.daemonize(not_readable_path) { 'ret' }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
test 'raise an error when file is not writable' do
|
65
|
-
omit 'chmod of file does not affetct root user' if Process.uid.zero?
|
66
|
-
not_writable_path = File.join(TMP_DIR, 'not_writable.pid')
|
67
|
-
|
68
|
-
File.write(not_writable_path, '1')
|
69
|
-
FileUtils.chmod(0555, not_writable_path)
|
70
|
-
|
71
|
-
mock(Process).daemon(anything, anything).never
|
72
|
-
assert_raise(Fluent::ConfigError.new("Cannot access pid file: #{File.absolute_path(not_writable_path)}")) do
|
73
|
-
Fluent::Daemonizer.daemonize(not_writable_path) { 'ret' }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
test 'raise an error when directory is not writable' do
|
78
|
-
omit 'chmod of file does not affetct root user' if Process.uid.zero?
|
79
|
-
not_writable_dir = File.join(TMP_DIR, 'not_writable')
|
80
|
-
pid_path = File.join(not_writable_dir, 'file.pid')
|
81
|
-
|
82
|
-
FileUtils.mkdir_p(not_writable_dir)
|
83
|
-
FileUtils.chmod(0555, not_writable_dir)
|
84
|
-
|
85
|
-
mock(Process).daemon(anything, anything).never
|
86
|
-
assert_raise(Fluent::ConfigError.new("Cannot access directory for pid file: #{File.absolute_path(not_writable_dir)}")) do
|
87
|
-
Fluent::Daemonizer.daemonize(pid_path) { 'ret' }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|