fluentd 1.16.11-x86-mingw32 → 1.17.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +50 -0
- data/.github/DISCUSSION_TEMPLATE/q-a.yml +47 -0
- data/.github/workflows/test-ruby-head.yml +31 -0
- data/.github/workflows/test.yml +6 -38
- data/CHANGELOG.md +33 -122
- data/README.md +4 -1
- data/Rakefile +1 -1
- data/SECURITY.md +4 -6
- data/fluentd.gemspec +5 -11
- data/lib/fluent/command/binlog_reader.rb +1 -1
- data/lib/fluent/command/fluentd.rb +1 -1
- data/lib/fluent/compat/formatter.rb +0 -6
- data/lib/fluent/config/configure_proxy.rb +2 -2
- data/lib/fluent/config/parser.rb +3 -15
- data/lib/fluent/config/types.rb +1 -1
- data/lib/fluent/config/v1_parser.rb +1 -1
- data/lib/fluent/config/yaml_parser/parser.rb +0 -4
- data/lib/fluent/configurable.rb +2 -2
- data/lib/fluent/counter/mutex_hash.rb +1 -1
- data/lib/fluent/fluent_log_event_router.rb +0 -2
- data/lib/fluent/plugin/buf_file.rb +1 -1
- data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +2 -3
- data/lib/fluent/plugin/filter_parser.rb +26 -8
- data/lib/fluent/plugin/formatter_csv.rb +4 -18
- data/lib/fluent/plugin/in_http.rb +17 -52
- data/lib/fluent/plugin/in_tail.rb +35 -3
- data/lib/fluent/plugin/out_file.rb +0 -8
- data/lib/fluent/plugin/out_forward.rb +0 -10
- data/lib/fluent/plugin/out_http.rb +125 -13
- data/lib/fluent/plugin/owned_by_mixin.rb +0 -1
- data/lib/fluent/plugin/parser_json.rb +34 -9
- data/lib/fluent/plugin/parser_msgpack.rb +24 -3
- data/lib/fluent/plugin_helper/metrics.rb +2 -2
- data/lib/fluent/plugin_helper/server.rb +1 -4
- data/lib/fluent/registry.rb +6 -6
- data/lib/fluent/supervisor.rb +3 -3
- data/lib/fluent/test/output_test.rb +1 -1
- data/lib/fluent/test.rb +2 -5
- data/lib/fluent/unique_id.rb +1 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +8 -38
- data/test/command/test_cat.rb +2 -2
- data/test/command/test_fluentd.rb +11 -58
- data/test/config/test_dsl.rb +1 -8
- data/test/config/test_element.rb +2 -2
- data/test/config/test_plugin_configuration.rb +6 -6
- data/test/helper.rb +7 -27
- data/test/log/test_console_adapter.rb +10 -3
- 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/in_tail/test_io_handler.rb +14 -13
- data/test/plugin/in_tail/test_position_file.rb +7 -6
- data/test/plugin/out_forward/test_ack_handler.rb +3 -3
- data/test/plugin/out_forward/test_socket_cache.rb +3 -3
- data/test/plugin/test_buffer.rb +2 -2
- data/test/plugin/test_filter_grep.rb +1 -1
- data/test/plugin/test_filter_stdout.rb +4 -4
- data/test/plugin/test_formatter_hash.rb +2 -2
- data/test/plugin/test_in_forward.rb +1 -2
- data/test/plugin/test_in_http.rb +23 -1
- data/test/plugin/test_in_monitor_agent.rb +6 -6
- data/test/plugin/test_in_object_space.rb +0 -4
- data/test/plugin/test_in_syslog.rb +18 -25
- data/test/plugin/test_in_tail.rb +153 -5
- data/test/plugin/test_in_tcp.rb +1 -1
- data/test/plugin/test_in_udp.rb +10 -16
- data/test/plugin/test_out_exec_filter.rb +7 -12
- data/test/plugin/test_out_file.rb +2 -22
- data/test/plugin/test_out_forward.rb +37 -61
- data/test/plugin/test_out_http.rb +128 -0
- data/test/plugin/test_out_stdout.rb +3 -3
- data/test/plugin/test_out_stream.rb +1 -1
- data/test/plugin/test_output.rb +1 -1
- data/test/plugin/test_output_as_buffered.rb +2 -2
- data/test/plugin/test_output_as_buffered_retries.rb +2 -2
- data/test/plugin/test_owned_by.rb +0 -1
- data/test/plugin/test_parser_csv.rb +1 -1
- data/test/plugin/test_parser_json.rb +106 -31
- data/test/plugin/test_parser_msgpack.rb +127 -0
- data/test/plugin/test_storage.rb +0 -1
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_server.rb +41 -83
- data/test/plugin_helper/test_socket.rb +1 -1
- data/test/test_config.rb +0 -6
- data/test/test_configdsl.rb +1 -8
- data/test/test_event_router.rb +2 -2
- data/test/test_plugin_helper.rb +1 -1
- data/test/test_supervisor.rb +21 -32
- data/test/test_tls.rb +1 -1
- metadata +66 -52
- data/test/scripts/windows_service_test.ps1 +0 -73
|
@@ -31,9 +31,9 @@ module Fluent
|
|
|
31
31
|
:binary
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def parse(data)
|
|
34
|
+
def parse(data, &block)
|
|
35
35
|
@unpacker.feed_each(data) do |obj|
|
|
36
|
-
|
|
36
|
+
parse_unpacked_data(obj, &block)
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
alias parse_partial_data parse
|
|
@@ -41,8 +41,29 @@ module Fluent
|
|
|
41
41
|
def parse_io(io, &block)
|
|
42
42
|
u = Fluent::MessagePackFactory.engine_factory.unpacker(io)
|
|
43
43
|
u.each do |obj|
|
|
44
|
-
|
|
44
|
+
parse_unpacked_data(obj, &block)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def parse_unpacked_data(data)
|
|
49
|
+
if data.is_a?(Hash)
|
|
50
|
+
time, record = convert_values(parse_time(data), data)
|
|
45
51
|
yield time, record
|
|
52
|
+
return
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
unless data.is_a?(Array)
|
|
56
|
+
yield nil, nil
|
|
57
|
+
return
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
data.each do |record|
|
|
61
|
+
unless record.is_a?(Hash)
|
|
62
|
+
yield nil, nil
|
|
63
|
+
next
|
|
64
|
+
end
|
|
65
|
+
time, converted_record = convert_values(parse_time(record), record)
|
|
66
|
+
yield time, converted_record
|
|
46
67
|
end
|
|
47
68
|
end
|
|
48
69
|
end
|
|
@@ -65,9 +65,9 @@ module Fluent
|
|
|
65
65
|
metrics.configure(config)
|
|
66
66
|
# For multi workers environment, cmetrics should be distinguish with static labels.
|
|
67
67
|
if Fluent::Engine.system_config.workers > 1
|
|
68
|
-
labels
|
|
68
|
+
labels[:worker_id] = fluentd_worker_id.to_s
|
|
69
69
|
end
|
|
70
|
-
labels
|
|
70
|
+
labels[:plugin] = @plugin_type_or_id
|
|
71
71
|
metrics.create(namespace: namespace, subsystem: subsystem, name: name, help_text: help_text, labels: labels)
|
|
72
72
|
|
|
73
73
|
@_metrics["#{@plugin_type_or_id}_#{namespace}_#{subsystem}_#{name}"] = metrics
|
|
@@ -347,10 +347,7 @@ module Fluent
|
|
|
347
347
|
end
|
|
348
348
|
|
|
349
349
|
def shutdown
|
|
350
|
-
|
|
351
|
-
# and it reduces the number of loops. This prevents the connection closing.
|
|
352
|
-
# So, it requires invoking #dup to avoid the problem.
|
|
353
|
-
@_server_connections.dup.each do |conn|
|
|
350
|
+
@_server_connections.each do |conn|
|
|
354
351
|
conn.close rescue nil
|
|
355
352
|
end
|
|
356
353
|
|
data/lib/fluent/registry.rb
CHANGED
|
@@ -60,13 +60,13 @@ module Fluent
|
|
|
60
60
|
# search from additional plugin directories
|
|
61
61
|
if @dir_search_prefix
|
|
62
62
|
path = "#{@dir_search_prefix}#{type}"
|
|
63
|
-
files = @paths.
|
|
63
|
+
files = @paths.filter_map { |lp|
|
|
64
64
|
lpath = File.expand_path(File.join(lp, "#{path}.rb"))
|
|
65
65
|
File.exist?(lpath) ? lpath : nil
|
|
66
|
-
}
|
|
66
|
+
}
|
|
67
67
|
unless files.empty?
|
|
68
68
|
# prefer newer version
|
|
69
|
-
require files.
|
|
69
|
+
require files.max
|
|
70
70
|
return
|
|
71
71
|
end
|
|
72
72
|
end
|
|
@@ -74,17 +74,17 @@ module Fluent
|
|
|
74
74
|
path = "#{@search_prefix}#{type}"
|
|
75
75
|
|
|
76
76
|
# prefer LOAD_PATH than gems
|
|
77
|
-
files = $LOAD_PATH.
|
|
77
|
+
files = $LOAD_PATH.filter_map { |lp|
|
|
78
78
|
if lp == FLUENT_LIB_PATH
|
|
79
79
|
nil
|
|
80
80
|
else
|
|
81
81
|
lpath = File.expand_path(File.join(lp, "#{path}.rb"))
|
|
82
82
|
File.exist?(lpath) ? lpath : nil
|
|
83
83
|
end
|
|
84
|
-
}
|
|
84
|
+
}
|
|
85
85
|
unless files.empty?
|
|
86
86
|
# prefer newer version
|
|
87
|
-
require files.
|
|
87
|
+
require files.max
|
|
88
88
|
return
|
|
89
89
|
end
|
|
90
90
|
|
data/lib/fluent/supervisor.rb
CHANGED
|
@@ -440,7 +440,7 @@ module Fluent
|
|
|
440
440
|
stop_immediately_at_unrecoverable_exit: true,
|
|
441
441
|
root_dir: params['root_dir'],
|
|
442
442
|
logger: $log,
|
|
443
|
-
log: $log
|
|
443
|
+
log: $log.out,
|
|
444
444
|
log_level: params['log_level'],
|
|
445
445
|
chuser: params['chuser'],
|
|
446
446
|
chgroup: params['chgroup'],
|
|
@@ -742,7 +742,7 @@ module Fluent
|
|
|
742
742
|
$log.enable_debug if system_config.log_level <= Fluent::Log::LEVEL_DEBUG
|
|
743
743
|
|
|
744
744
|
$log.info "init #{process_type} logger",
|
|
745
|
-
path: actual_log_path,
|
|
745
|
+
path: actual_log_path,
|
|
746
746
|
rotate_age: @log_rotate_age,
|
|
747
747
|
rotate_size: @log_rotate_size
|
|
748
748
|
end
|
|
@@ -995,7 +995,7 @@ module Fluent
|
|
|
995
995
|
def build_system_config(conf)
|
|
996
996
|
system_config = SystemConfig.create(conf, @cl_opt[:strict_config_value])
|
|
997
997
|
# Prefer the options explicitly specified in the command line
|
|
998
|
-
#
|
|
998
|
+
#
|
|
999
999
|
# TODO: There is a bug that `system_config.log.rotate_age/rotate_size` are
|
|
1000
1000
|
# not merged with the command line options since they are not in
|
|
1001
1001
|
# `SYSTEM_CONFIG_PARAMETERS`.
|
data/lib/fluent/test.rb
CHANGED
|
@@ -40,12 +40,9 @@ module Fluent
|
|
|
40
40
|
|
|
41
41
|
$log = dummy_logger
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
# Ensure that GC can remove the objects of the old engine.
|
|
45
|
-
# Some objects can still exist after `remove_const`. See https://github.com/fluent/fluentd/issues/5054.
|
|
46
|
-
old_engine.instance_variable_set(:@root_agent, nil)
|
|
47
|
-
|
|
43
|
+
Fluent.__send__(:remove_const, :Engine)
|
|
48
44
|
engine = Fluent.const_set(:Engine, EngineClass.new).init(SystemConfig.new)
|
|
45
|
+
|
|
49
46
|
engine.define_singleton_method(:now=) {|n|
|
|
50
47
|
@now = n
|
|
51
48
|
}
|
data/lib/fluent/unique_id.rb
CHANGED
data/lib/fluent/version.rb
CHANGED
data/lib/fluent/winsvc.rb
CHANGED
|
@@ -32,7 +32,7 @@ begin
|
|
|
32
32
|
op.parse(ARGV)
|
|
33
33
|
if opts[:service_name] == nil
|
|
34
34
|
raise "Error: No Windows Service name set. Use '--service-name'"
|
|
35
|
-
end
|
|
35
|
+
end
|
|
36
36
|
|
|
37
37
|
def read_fluentdopt(service_name)
|
|
38
38
|
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\#{service_name}") do |reg|
|
|
@@ -48,32 +48,25 @@ begin
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
class FluentdService < Daemon
|
|
51
|
-
ERROR_WAIT_NO_CHILDREN = 128
|
|
52
|
-
|
|
53
51
|
@pid = 0
|
|
54
52
|
@service_name = ''
|
|
55
53
|
|
|
56
54
|
def initialize(service_name)
|
|
57
55
|
@service_name = service_name
|
|
58
56
|
end
|
|
59
|
-
|
|
57
|
+
|
|
60
58
|
def service_main
|
|
61
59
|
@pid = service_main_start(@service_name)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
sleep 5
|
|
65
|
-
break unless running?
|
|
66
|
-
raise Errno::ECHILD if Process.waitpid(@pid, Process::WNOHANG)
|
|
67
|
-
end
|
|
68
|
-
rescue Errno::ECHILD
|
|
69
|
-
@pid = 0
|
|
70
|
-
SetEvent(@@hStopEvent)
|
|
71
|
-
SetTheServiceStatus.call(SERVICE_STOPPED, ERROR_WAIT_NO_CHILDREN, 0, 0)
|
|
60
|
+
while running?
|
|
61
|
+
sleep 10
|
|
72
62
|
end
|
|
73
63
|
end
|
|
74
64
|
|
|
75
65
|
def service_stop
|
|
76
|
-
|
|
66
|
+
set_event(@service_name)
|
|
67
|
+
if @pid > 0
|
|
68
|
+
Process.waitpid(@pid)
|
|
69
|
+
end
|
|
77
70
|
end
|
|
78
71
|
|
|
79
72
|
def service_paramchange
|
|
@@ -98,29 +91,6 @@ begin
|
|
|
98
91
|
ev.set
|
|
99
92
|
ev.close
|
|
100
93
|
end
|
|
101
|
-
|
|
102
|
-
def repeat_set_event_several_times_until_success(event_name)
|
|
103
|
-
retries = 0
|
|
104
|
-
max_retries = 10
|
|
105
|
-
delay_sec = 3
|
|
106
|
-
|
|
107
|
-
begin
|
|
108
|
-
set_event(event_name)
|
|
109
|
-
rescue Errno::ENOENT
|
|
110
|
-
# This error occurs when the supervisor process has not yet created the event.
|
|
111
|
-
# If STOP is immediately executed, this state will occur.
|
|
112
|
-
# Retry `set_event' to wait for the initialization of the supervisor.
|
|
113
|
-
retries += 1
|
|
114
|
-
raise if max_retries < retries
|
|
115
|
-
sleep(delay_sec)
|
|
116
|
-
retry
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def wait_supervisor_finished
|
|
121
|
-
repeat_set_event_several_times_until_success(@service_name)
|
|
122
|
-
Process.waitpid(@pid)
|
|
123
|
-
end
|
|
124
94
|
end
|
|
125
95
|
|
|
126
96
|
FluentdService.new(opts[:service_name]).mainloop
|
data/test/command/test_cat.rb
CHANGED
|
@@ -18,7 +18,7 @@ class TestFluentCat < ::Test::Unit::TestCase
|
|
|
18
18
|
@primary = create_primary
|
|
19
19
|
metadata = @primary.buffer.new_metadata
|
|
20
20
|
@chunk = create_chunk(@primary, metadata, @es)
|
|
21
|
-
@port = unused_port
|
|
21
|
+
@port = unused_port
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def teardown
|
|
@@ -87,7 +87,7 @@ class TestFluentCat < ::Test::Unit::TestCase
|
|
|
87
87
|
d = create_driver
|
|
88
88
|
d.run(expect_records: 1) do
|
|
89
89
|
Open3.pipeline_w("#{ServerEngine.ruby_bin_path} #{FLUENT_CAT_COMMAND} --port #{@port} --format msgpack secondary") do |stdin|
|
|
90
|
-
stdin.write(File.read(path
|
|
90
|
+
stdin.write(File.read(path))
|
|
91
91
|
stdin.close
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -128,14 +128,11 @@ class TestFluentdCommand < ::Test::Unit::TestCase
|
|
|
128
128
|
|
|
129
129
|
# ATTENTION: This stops taking logs when all `pattern_list` match or timeout,
|
|
130
130
|
# so `patterns_not_match` can test only logs up to that point.
|
|
131
|
-
# You can pass a block to assert something after log matching.
|
|
132
131
|
def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 20, env: {})
|
|
133
132
|
matched = false
|
|
134
133
|
matched_wrongly = false
|
|
135
|
-
|
|
134
|
+
assert_error_msg = ""
|
|
136
135
|
stdio_buf = ""
|
|
137
|
-
succeeded_block = true
|
|
138
|
-
error_msg_block = ""
|
|
139
136
|
begin
|
|
140
137
|
execute_command(cmdline, @tmp_dir, env) do |pid, stdout|
|
|
141
138
|
begin
|
|
@@ -166,13 +163,6 @@ class TestFluentdCommand < ::Test::Unit::TestCase
|
|
|
166
163
|
end
|
|
167
164
|
end
|
|
168
165
|
end
|
|
169
|
-
|
|
170
|
-
begin
|
|
171
|
-
yield if block_given?
|
|
172
|
-
rescue => e
|
|
173
|
-
succeeded_block = false
|
|
174
|
-
error_msg_block = "failed block execution after matching: #{e}"
|
|
175
|
-
end
|
|
176
166
|
ensure
|
|
177
167
|
if SUPERVISOR_PID_PATTERN =~ stdio_buf
|
|
178
168
|
@supervisor_pid = $1.to_i
|
|
@@ -183,19 +173,19 @@ class TestFluentdCommand < ::Test::Unit::TestCase
|
|
|
183
173
|
end
|
|
184
174
|
end
|
|
185
175
|
rescue Timeout::Error
|
|
186
|
-
|
|
176
|
+
assert_error_msg = "execution timeout"
|
|
187
177
|
# https://github.com/fluent/fluentd/issues/4095
|
|
188
178
|
# On Windows, timeout without `@supervisor_pid` means that the test is invalid,
|
|
189
179
|
# since the supervisor process will survive without being killed correctly.
|
|
190
180
|
flunk("Invalid test: The pid of supervisor could not be taken, which is necessary on Windows.") if Fluent.windows? && @supervisor_pid.nil?
|
|
191
181
|
rescue => e
|
|
192
|
-
|
|
182
|
+
assert_error_msg = "unexpected error in launching fluentd: #{e.inspect}"
|
|
193
183
|
else
|
|
194
|
-
|
|
184
|
+
assert_error_msg = "log doesn't match" unless matched
|
|
195
185
|
end
|
|
196
186
|
|
|
197
187
|
if patterns_not_match.empty?
|
|
198
|
-
|
|
188
|
+
assert_error_msg = build_message(assert_error_msg,
|
|
199
189
|
"<?>\nwas expected to include:\n<?>",
|
|
200
190
|
stdio_buf, pattern_list)
|
|
201
191
|
else
|
|
@@ -207,17 +197,16 @@ class TestFluentdCommand < ::Test::Unit::TestCase
|
|
|
207
197
|
lines.any?{|line| line.include?(ptn) }
|
|
208
198
|
end
|
|
209
199
|
if matched_wrongly
|
|
210
|
-
|
|
211
|
-
|
|
200
|
+
assert_error_msg << "\n" unless assert_error_msg.empty?
|
|
201
|
+
assert_error_msg << "pattern exists in logs wrongly: #{ptn}"
|
|
212
202
|
end
|
|
213
203
|
end
|
|
214
|
-
|
|
204
|
+
assert_error_msg = build_message(assert_error_msg,
|
|
215
205
|
"<?>\nwas expected to include:\n<?>\nand not include:\n<?>",
|
|
216
206
|
stdio_buf, pattern_list, patterns_not_match)
|
|
217
207
|
end
|
|
218
208
|
|
|
219
|
-
assert matched && !matched_wrongly,
|
|
220
|
-
assert succeeded_block, error_msg_block if block_given?
|
|
209
|
+
assert matched && !matched_wrongly, assert_error_msg
|
|
221
210
|
end
|
|
222
211
|
|
|
223
212
|
def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 20)
|
|
@@ -570,7 +559,7 @@ CONF
|
|
|
570
559
|
|
|
571
560
|
assert_fluentd_fails_to_start(
|
|
572
561
|
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
|
|
573
|
-
|
|
562
|
+
"in_buggy.rb:5: syntax error, unexpected end-of-input"
|
|
574
563
|
)
|
|
575
564
|
end
|
|
576
565
|
end
|
|
@@ -1175,7 +1164,7 @@ CONF
|
|
|
1175
1164
|
end
|
|
1176
1165
|
end
|
|
1177
1166
|
|
|
1178
|
-
sub_test_case '
|
|
1167
|
+
sub_test_case 'sahred socket options' do
|
|
1179
1168
|
test 'enable shared socket by default' do
|
|
1180
1169
|
conf = ""
|
|
1181
1170
|
conf_path = create_conf_file('empty.conf', conf)
|
|
@@ -1299,40 +1288,4 @@ CONF
|
|
|
1299
1288
|
"[debug]")
|
|
1300
1289
|
end
|
|
1301
1290
|
end
|
|
1302
|
-
|
|
1303
|
-
sub_test_case "plugin option" do
|
|
1304
|
-
test "should be the default value when not specifying" do
|
|
1305
|
-
conf_path = create_conf_file('test.conf', <<~CONF)
|
|
1306
|
-
<source>
|
|
1307
|
-
@type monitor_agent
|
|
1308
|
-
</source>
|
|
1309
|
-
CONF
|
|
1310
|
-
assert File.exist?(conf_path)
|
|
1311
|
-
cmdline = create_cmdline(conf_path)
|
|
1312
|
-
|
|
1313
|
-
assert_log_matches(cmdline, "fluentd worker is now running") do
|
|
1314
|
-
response = Net::HTTP.get(URI.parse("http://localhost:24220/api/config.json"))
|
|
1315
|
-
actual_conf = JSON.parse(response)
|
|
1316
|
-
assert_equal Fluent::Supervisor.default_options[:plugin_dirs], actual_conf["plugin_dirs"]
|
|
1317
|
-
end
|
|
1318
|
-
end
|
|
1319
|
-
|
|
1320
|
-
data(short: "-p")
|
|
1321
|
-
data(long: "--plugin")
|
|
1322
|
-
test "can be added by specifying the option" do |option_name|
|
|
1323
|
-
conf_path = create_conf_file('test.conf', <<~CONF)
|
|
1324
|
-
<source>
|
|
1325
|
-
@type monitor_agent
|
|
1326
|
-
</source>
|
|
1327
|
-
CONF
|
|
1328
|
-
assert File.exist?(conf_path)
|
|
1329
|
-
cmdline = create_cmdline(conf_path, option_name, @tmp_dir, option_name, @tmp_dir)
|
|
1330
|
-
|
|
1331
|
-
assert_log_matches(cmdline, "fluentd worker is now running") do
|
|
1332
|
-
response = Net::HTTP.get(URI.parse("http://localhost:24220/api/config.json"))
|
|
1333
|
-
actual_conf = JSON.parse(response)
|
|
1334
|
-
assert_equal Fluent::Supervisor.default_options[:plugin_dirs] + [@tmp_dir, @tmp_dir], actual_conf["plugin_dirs"]
|
|
1335
|
-
end
|
|
1336
|
-
end
|
|
1337
|
-
end
|
|
1338
1291
|
end
|
data/test/config/test_dsl.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require_relative '../helper'
|
|
2
2
|
require 'fluent/config/element'
|
|
3
3
|
require "fluent/config/dsl"
|
|
4
|
-
require 'tempfile'
|
|
5
4
|
|
|
6
5
|
TMP_DIR = File.dirname(__FILE__) + "/tmp/config_dsl#{ENV['TEST_ENV_NUMBER']}"
|
|
7
6
|
def write_config(path, data)
|
|
@@ -359,13 +358,9 @@ module Fluent::Config
|
|
|
359
358
|
sub_test_case '.parse' do
|
|
360
359
|
test 'can get result of Kernel.open() by ruby.open()' do
|
|
361
360
|
uname_string = `uname -a`
|
|
362
|
-
tmpfile = Tempfile.create('fluentd-test')
|
|
363
|
-
tmpfile.write(uname_string)
|
|
364
|
-
tmpfile.close
|
|
365
|
-
|
|
366
361
|
root = Fluent::Config::DSL::Parser.parse(<<DSL)
|
|
367
362
|
worker {
|
|
368
|
-
uname_str = ruby.open(
|
|
363
|
+
uname_str = ruby.open('|uname -a'){|out| out.read}
|
|
369
364
|
source {
|
|
370
365
|
uname uname_str
|
|
371
366
|
}
|
|
@@ -377,8 +372,6 @@ DSL
|
|
|
377
372
|
assert_equal('source', source.name)
|
|
378
373
|
assert_equal(1, source.keys.size)
|
|
379
374
|
assert_equal(uname_string, source['uname'])
|
|
380
|
-
ensure
|
|
381
|
-
File.delete(tmpfile.path)
|
|
382
375
|
end
|
|
383
376
|
|
|
384
377
|
test 'accepts ruby keyword with block, which allow to use methods included from ::Kernel' do
|
data/test/config/test_element.rb
CHANGED
|
@@ -282,8 +282,8 @@ CONF
|
|
|
282
282
|
dump = <<-CONF
|
|
283
283
|
name:ROOT, arg:, {\"k1\"=>\"v1\"}, [name:test, arg:ext, {\"k2\"=>\"v2\"}, []]
|
|
284
284
|
CONF
|
|
285
|
-
assert_not_equal(e.to_s, e.inspect
|
|
286
|
-
assert_equal(dump.chomp, e.inspect
|
|
285
|
+
assert_not_equal(e.to_s, e.inspect)
|
|
286
|
+
assert_equal(dump.chomp, e.inspect)
|
|
287
287
|
end
|
|
288
288
|
end
|
|
289
289
|
|
|
@@ -19,9 +19,9 @@ module ConfigurationForPlugins
|
|
|
19
19
|
|
|
20
20
|
class BooleanParamsWithoutValue < ::Test::Unit::TestCase
|
|
21
21
|
CONFIG = <<CONFIG
|
|
22
|
-
flag1
|
|
22
|
+
flag1
|
|
23
23
|
flag2 # yaaaaaaaaaay
|
|
24
|
-
flag3
|
|
24
|
+
flag3
|
|
25
25
|
flag4 # yaaaaaaaaaay
|
|
26
26
|
<child>
|
|
27
27
|
flag1
|
|
@@ -37,10 +37,10 @@ module ConfigurationForPlugins
|
|
|
37
37
|
</child>
|
|
38
38
|
# with following whitespace
|
|
39
39
|
<child>
|
|
40
|
-
flag1
|
|
41
|
-
flag2
|
|
42
|
-
flag3
|
|
43
|
-
flag4
|
|
40
|
+
flag1
|
|
41
|
+
flag2
|
|
42
|
+
flag3
|
|
43
|
+
flag4
|
|
44
44
|
</child>
|
|
45
45
|
CONFIG
|
|
46
46
|
|
data/test/helper.rb
CHANGED
|
@@ -71,31 +71,17 @@ end
|
|
|
71
71
|
|
|
72
72
|
include Fluent::Test::Helpers
|
|
73
73
|
|
|
74
|
-
def unused_port(num = 1, protocol
|
|
74
|
+
def unused_port(num = 1, protocol: :tcp, bind: "0.0.0.0")
|
|
75
75
|
case protocol
|
|
76
|
-
when :tcp
|
|
76
|
+
when :tcp
|
|
77
77
|
unused_port_tcp(num)
|
|
78
78
|
when :udp
|
|
79
79
|
unused_port_udp(num, bind: bind)
|
|
80
|
-
when :all
|
|
81
|
-
unused_port_tcp_udp(num)
|
|
82
80
|
else
|
|
83
81
|
raise ArgumentError, "unknown protocol: #{protocol}"
|
|
84
82
|
end
|
|
85
83
|
end
|
|
86
84
|
|
|
87
|
-
def unused_port_tcp_udp(num = 1)
|
|
88
|
-
raise "not support num > 1" if num > 1
|
|
89
|
-
|
|
90
|
-
# The default maximum number of file descriptors in macOS is 256.
|
|
91
|
-
# It might need to set num to a smaller value than that.
|
|
92
|
-
tcp_ports = unused_port_tcp(200)
|
|
93
|
-
port = unused_port_udp(1, port_list: tcp_ports)
|
|
94
|
-
raise "can't find unused port" unless port
|
|
95
|
-
|
|
96
|
-
port
|
|
97
|
-
end
|
|
98
|
-
|
|
99
85
|
def unused_port_tcp(num = 1)
|
|
100
86
|
ports = []
|
|
101
87
|
sockets = []
|
|
@@ -104,7 +90,7 @@ def unused_port_tcp(num = 1)
|
|
|
104
90
|
sockets << s
|
|
105
91
|
ports << s.addr[1]
|
|
106
92
|
end
|
|
107
|
-
sockets.each
|
|
93
|
+
sockets.each{|s| s.close }
|
|
108
94
|
if num == 1
|
|
109
95
|
return ports.first
|
|
110
96
|
else
|
|
@@ -114,15 +100,12 @@ end
|
|
|
114
100
|
|
|
115
101
|
PORT_RANGE_AVAILABLE = (1024...65535)
|
|
116
102
|
|
|
117
|
-
def unused_port_udp(num = 1,
|
|
103
|
+
def unused_port_udp(num = 1, bind: "0.0.0.0")
|
|
118
104
|
family = IPAddr.new(IPSocket.getaddress(bind)).ipv4? ? ::Socket::AF_INET : ::Socket::AF_INET6
|
|
119
105
|
ports = []
|
|
120
106
|
sockets = []
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
i = 0
|
|
124
|
-
loop do
|
|
125
|
-
port = use_random_port ? rand(PORT_RANGE_AVAILABLE) : port_list[i]
|
|
107
|
+
while ports.size < num
|
|
108
|
+
port = rand(PORT_RANGE_AVAILABLE)
|
|
126
109
|
u = UDPSocket.new(family)
|
|
127
110
|
if (u.bind(bind, port) rescue nil)
|
|
128
111
|
ports << port
|
|
@@ -130,11 +113,8 @@ def unused_port_udp(num = 1, port_list: [], bind: "0.0.0.0")
|
|
|
130
113
|
else
|
|
131
114
|
u.close
|
|
132
115
|
end
|
|
133
|
-
i += 1
|
|
134
|
-
break if ports.size >= num
|
|
135
|
-
break if !use_random_port && i >= port_list.size
|
|
136
116
|
end
|
|
137
|
-
sockets.each
|
|
117
|
+
sockets.each{|s| s.close }
|
|
138
118
|
if num == 1
|
|
139
119
|
return ports.first
|
|
140
120
|
else
|
|
@@ -72,11 +72,18 @@ class ConsoleAdapterTest < Test::Unit::TestCase
|
|
|
72
72
|
fatal: :fatal)
|
|
73
73
|
def test_options(level)
|
|
74
74
|
@console_logger.send(level, "subject", kwarg1: "opt1", kwarg2: "opt2")
|
|
75
|
+
lines = @logdev.logs[0].split("\n")
|
|
76
|
+
args = JSON.load(lines[1..].collect { |str| str.sub(/\s+\|/, "") }.join("\n"));
|
|
75
77
|
assert_equal([
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
+
1,
|
|
79
|
+
"#{@timestamp_str} [#{level}]: 0.0s: subject",
|
|
80
|
+
{ "kwarg1" => "opt1", "kwarg2" => "opt2" }
|
|
78
81
|
],
|
|
79
|
-
|
|
82
|
+
[
|
|
83
|
+
@logdev.logs.size,
|
|
84
|
+
lines[0],
|
|
85
|
+
args
|
|
86
|
+
])
|
|
80
87
|
end
|
|
81
88
|
|
|
82
89
|
data(debug: :debug,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,19 +5,20 @@ require 'fluent/plugin/metrics_local'
|
|
|
5
5
|
require 'tempfile'
|
|
6
6
|
|
|
7
7
|
class IntailIOHandlerTest < Test::Unit::TestCase
|
|
8
|
-
|
|
9
|
-
Tempfile.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
setup do
|
|
9
|
+
@file = Tempfile.new('intail_io_handler').binmode
|
|
10
|
+
opened_file_metrics = Fluent::Plugin::LocalMetrics.new
|
|
11
|
+
opened_file_metrics.configure(config_element('metrics', '', {}))
|
|
12
|
+
closed_file_metrics = Fluent::Plugin::LocalMetrics.new
|
|
13
|
+
closed_file_metrics.configure(config_element('metrics', '', {}))
|
|
14
|
+
rotated_file_metrics = Fluent::Plugin::LocalMetrics.new
|
|
15
|
+
rotated_file_metrics.configure(config_element('metrics', '', {}))
|
|
16
|
+
@metrics = Fluent::Plugin::TailInput::MetricsInfo.new(opened_file_metrics, closed_file_metrics, rotated_file_metrics)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
teardown do
|
|
20
|
+
@file.close rescue nil
|
|
21
|
+
@file.unlink rescue nil
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def create_target_info
|
|
@@ -6,12 +6,13 @@ require 'fileutils'
|
|
|
6
6
|
require 'tempfile'
|
|
7
7
|
|
|
8
8
|
class IntailPositionFileTest < Test::Unit::TestCase
|
|
9
|
-
|
|
10
|
-
Tempfile.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
setup do
|
|
10
|
+
@file = Tempfile.new('intail_position_file_test').binmode
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
teardown do
|
|
14
|
+
@file.close rescue nil
|
|
15
|
+
@file.unlink rescue nil
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
UNWATCHED_STR = '%016x' % Fluent::Plugin::TailInput::PositionFile::UNWATCHED_POSITION
|
|
@@ -111,11 +111,11 @@ class AckHandlerTest < Test::Unit::TestCase
|
|
|
111
111
|
r, w = IO.pipe
|
|
112
112
|
begin
|
|
113
113
|
w.write(chunk_id)
|
|
114
|
-
|
|
114
|
+
stub(r).recv { |_|
|
|
115
115
|
sleep(1) # To ensure that multiple threads select the socket before closing.
|
|
116
|
-
raise IOError, 'stream closed in another thread' if
|
|
116
|
+
raise IOError, 'stream closed in another thread' if r.closed?
|
|
117
117
|
MessagePack.pack({ 'ack' => Base64.encode64('chunk_id 111') })
|
|
118
|
-
|
|
118
|
+
}
|
|
119
119
|
ack.enqueue(r)
|
|
120
120
|
|
|
121
121
|
threads = []
|