fluentd 1.16.6-x64-mingw-ucrt → 1.16.8-x64-mingw-ucrt
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/workflows/test.yml +5 -0
- data/CHANGELOG.md +60 -0
- data/README.md +0 -2
- data/fluentd.gemspec +6 -0
- data/lib/fluent/compat/formatter.rb +6 -0
- data/lib/fluent/config/parser.rb +15 -3
- data/lib/fluent/config/v1_parser.rb +1 -1
- data/lib/fluent/plugin/formatter_csv.rb +18 -4
- data/lib/fluent/plugin/in_http.rb +1 -1
- data/lib/fluent/plugin/in_tail.rb +1 -1
- data/lib/fluent/supervisor.rb +3 -3
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +38 -8
- data/test/command/test_cat.rb +2 -2
- data/test/command/test_fluentd.rb +1 -1
- data/test/config/test_plugin_configuration.rb +6 -6
- data/test/helper.rb +27 -7
- 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_in_forward.rb +2 -1
- data/test/plugin/test_in_http.rb +2 -2
- data/test/plugin/test_in_monitor_agent.rb +6 -6
- data/test/plugin/test_in_syslog.rb +25 -18
- data/test/plugin/test_in_tail.rb +5 -12
- data/test/plugin/test_in_tcp.rb +1 -1
- data/test/plugin/test_in_udp.rb +16 -10
- data/test/plugin/test_out_exec_filter.rb +12 -7
- data/test/plugin/test_out_file.rb +1 -1
- data/test/plugin/test_out_forward.rb +2 -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_parser_csv.rb +1 -1
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_server.rb +64 -41
- data/test/plugin_helper/test_socket.rb +1 -1
- data/test/test_event_router.rb +2 -2
- data/test/test_supervisor.rb +30 -21
- data/test/test_tls.rb +1 -1
- metadata +33 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4afb099e933cca84ae72dbca686fb1c9e22b029f2f3ef08117148fd926bd3fe6
|
4
|
+
data.tar.gz: 365f948071b7e8da1c90e8b398c20612859def3a3eea68b095ac862565dc7940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf7f9f7034887aef88dafcc770417241f50d657ed2cdef8083502fe533607caf9449acb00b67a3d450e081bd4205432abf55599a3a443eb04f96f1787680e62
|
7
|
+
data.tar.gz: e41d5ac1095ce23bae510d9ca87804e13872ccb53bfd229a9d28668556c8aef8c1c01a4a744ea414108dcf9bd486e10be38a29339327451ffcfdae7e749aae53
|
data/.github/workflows/test.yml
CHANGED
@@ -12,6 +12,10 @@ on:
|
|
12
12
|
- '*.md'
|
13
13
|
- 'lib/fluent/version.rb'
|
14
14
|
|
15
|
+
concurrency:
|
16
|
+
group: ${{ github.head_ref || github.sha }}-${{ github.workflow }}
|
17
|
+
cancel-in-progress: true
|
18
|
+
|
15
19
|
jobs:
|
16
20
|
test:
|
17
21
|
runs-on: ${{ matrix.os }}
|
@@ -29,6 +33,7 @@ jobs:
|
|
29
33
|
uses: ruby/setup-ruby@v1
|
30
34
|
with:
|
31
35
|
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
rubygems: latest
|
32
37
|
- name: Install addons
|
33
38
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
34
39
|
run: sudo apt-get install libgmp3-dev libcap-ng-dev
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,65 @@
|
|
1
1
|
# v1.16
|
2
2
|
|
3
|
+
## Release v1.16.8 - 2025/05/01
|
4
|
+
|
5
|
+
### Bug Fix
|
6
|
+
|
7
|
+
* winsvc: Stop the service when the supervisor is dead
|
8
|
+
https://github.com/fluent/fluentd/pull/4942
|
9
|
+
* formatter_csv: Fix memory leak
|
10
|
+
https://github.com/fluent/fluentd/pull/4920
|
11
|
+
|
12
|
+
### Misc
|
13
|
+
|
14
|
+
* Add fiddle as dependency gem for Ruby 3.5 on Windows
|
15
|
+
https://github.com/fluent/fluentd/pull/4919
|
16
|
+
* Refactoring code
|
17
|
+
https://github.com/fluent/fluentd/pull/4921
|
18
|
+
https://github.com/fluent/fluentd/pull/4922
|
19
|
+
https://github.com/fluent/fluentd/pull/4926
|
20
|
+
https://github.com/fluent/fluentd/pull/4943
|
21
|
+
* CI improvemnts
|
22
|
+
https://github.com/fluent/fluentd/pull/4821
|
23
|
+
https://github.com/fluent/fluentd/pull/4850
|
24
|
+
https://github.com/fluent/fluentd/pull/4851
|
25
|
+
https://github.com/fluent/fluentd/pull/4862
|
26
|
+
https://github.com/fluent/fluentd/pull/4915
|
27
|
+
https://github.com/fluent/fluentd/pull/4923
|
28
|
+
https://github.com/fluent/fluentd/pull/4925
|
29
|
+
https://github.com/fluent/fluentd/pull/4927
|
30
|
+
|
31
|
+
## Release v1.16.7 - 2025/01/29
|
32
|
+
|
33
|
+
### Bug Fix
|
34
|
+
|
35
|
+
* Windows: Fix `NoMethodError` of `--daemon` option
|
36
|
+
https://github.com/fluent/fluentd/pull/4796
|
37
|
+
* Windows: Fixed an issue where stopping the service immediately after startup could leave the processes
|
38
|
+
https://github.com/fluent/fluentd/pull/4782
|
39
|
+
* Windows: Fixed an issue where stopping service sometimes can not be completed forever
|
40
|
+
https://github.com/fluent/fluentd/pull/4782
|
41
|
+
|
42
|
+
### Misc
|
43
|
+
|
44
|
+
* Windows: Add workaround for unexpected exception
|
45
|
+
https://github.com/fluent/fluentd/pull/4747
|
46
|
+
* README: remove deprecated google analytics beacon
|
47
|
+
https://github.com/fluent/fluentd/pull/4797
|
48
|
+
* CI improvemnts
|
49
|
+
https://github.com/fluent/fluentd/pull/4723
|
50
|
+
https://github.com/fluent/fluentd/pull/4788
|
51
|
+
https://github.com/fluent/fluentd/pull/4789
|
52
|
+
https://github.com/fluent/fluentd/pull/4790
|
53
|
+
https://github.com/fluent/fluentd/pull/4791
|
54
|
+
https://github.com/fluent/fluentd/pull/4793
|
55
|
+
https://github.com/fluent/fluentd/pull/4794
|
56
|
+
https://github.com/fluent/fluentd/pull/4795
|
57
|
+
https://github.com/fluent/fluentd/pull/4798
|
58
|
+
https://github.com/fluent/fluentd/pull/4799
|
59
|
+
https://github.com/fluent/fluentd/pull/4800
|
60
|
+
https://github.com/fluent/fluentd/pull/4801
|
61
|
+
https://github.com/fluent/fluentd/pull/4803
|
62
|
+
|
3
63
|
## Release v1.16.6 - 2024/08/16
|
4
64
|
|
5
65
|
### Bug Fix
|
data/README.md
CHANGED
@@ -71,5 +71,3 @@ See [SECURITY](SECURITY.md) to contact us about vulnerability.
|
|
71
71
|
## Contributors:
|
72
72
|
|
73
73
|
Patches contributed by [great developers](https://github.com/fluent/fluentd/contributors).
|
74
|
-
|
75
|
-
[<img src="https://ga-beacon.appspot.com/UA-24890265-6/fluent/fluentd" />](https://github.com/fluent/fluentd)
|
data/fluentd.gemspec
CHANGED
@@ -31,6 +31,9 @@ Gem::Specification.new do |gem|
|
|
31
31
|
gem.add_runtime_dependency("webrick", ["~> 1.4"])
|
32
32
|
gem.add_runtime_dependency("console", ["< 1.24"])
|
33
33
|
|
34
|
+
# gems that aren't default gems as of Ruby 3.5
|
35
|
+
gem.add_runtime_dependency("logger", ["~> 1.6"])
|
36
|
+
|
34
37
|
# build gem for a certain platform. see also Rakefile
|
35
38
|
fake_platform = ENV['GEM_BUILD_FAKE_PLATFORM'].to_s
|
36
39
|
gem.platform = fake_platform unless fake_platform.empty?
|
@@ -39,6 +42,9 @@ Gem::Specification.new do |gem|
|
|
39
42
|
gem.add_runtime_dependency("win32-ipc", ["~> 0.7.0"])
|
40
43
|
gem.add_runtime_dependency("win32-event", ["~> 0.6.3"])
|
41
44
|
gem.add_runtime_dependency("certstore_c", ["~> 0.1.7"])
|
45
|
+
|
46
|
+
# gems that aren't default gems as of Ruby 3.5
|
47
|
+
gem.add_runtime_dependency("fiddle", ["~> 1.1"])
|
42
48
|
end
|
43
49
|
|
44
50
|
gem.add_development_dependency("rake", ["~> 13.0"])
|
@@ -101,6 +101,12 @@ module Fluent
|
|
101
101
|
|
102
102
|
class CsvFormatter < Fluent::Plugin::CsvFormatter
|
103
103
|
# TODO: warn when deprecated
|
104
|
+
|
105
|
+
# Do not cache because it is hard to consider the thread key correctly.
|
106
|
+
# (We can try, but it would be low priority.)
|
107
|
+
def csv_cacheable?
|
108
|
+
false
|
109
|
+
end
|
104
110
|
end
|
105
111
|
|
106
112
|
class SingleValueFormatter < Fluent::Plugin::SingleValueFormatter
|
data/lib/fluent/config/parser.rb
CHANGED
@@ -92,10 +92,23 @@ module Fluent
|
|
92
92
|
else
|
93
93
|
basepath = '/'
|
94
94
|
fname = path
|
95
|
-
|
96
|
-
URI.open(uri) {|f|
|
95
|
+
parser_proc = ->(f) {
|
97
96
|
Parser.new(basepath, f.each_line, fname).parse!(allow_include, nil, attrs, elems)
|
98
97
|
}
|
98
|
+
|
99
|
+
case u.scheme
|
100
|
+
when 'http', 'https', 'ftp'
|
101
|
+
# URI#open can be able to handle URIs for http, https and ftp.
|
102
|
+
require 'open-uri'
|
103
|
+
u.open(&parser_proc)
|
104
|
+
else
|
105
|
+
# TODO: This case should be handled in the previous if condition. Glob is not applied to some Windows path formats.
|
106
|
+
# 'c:/path/to/file' will be passed as URI, 'uri' and 'u.path' will be:
|
107
|
+
# - uri is 'c:/path/to/file'
|
108
|
+
# - u.path is '/path/to/file' and u.scheme is 'c'
|
109
|
+
# Therefore, the condition of the if statement above is not met and it is handled here.
|
110
|
+
File.open(uri, &parser_proc)
|
111
|
+
end
|
99
112
|
end
|
100
113
|
|
101
114
|
rescue SystemCallError => e
|
@@ -104,4 +117,3 @@ module Fluent
|
|
104
117
|
end
|
105
118
|
end
|
106
119
|
end
|
107
|
-
|
@@ -172,7 +172,7 @@ module Fluent
|
|
172
172
|
require 'open-uri'
|
173
173
|
basepath = '/'
|
174
174
|
fname = path
|
175
|
-
data =
|
175
|
+
data = u.open { |f| f.read }
|
176
176
|
data.force_encoding('UTF-8')
|
177
177
|
ss = StringScanner.new(data)
|
178
178
|
V1Parser.new(ss, basepath, fname, @eval_context).parse_element(true, nil, attrs, elems)
|
@@ -35,6 +35,22 @@ module Fluent
|
|
35
35
|
config_param :fields, :array, value_type: :string
|
36
36
|
config_param :add_newline, :bool, default: true
|
37
37
|
|
38
|
+
def csv_cacheable?
|
39
|
+
!!owner
|
40
|
+
end
|
41
|
+
|
42
|
+
def csv_thread_key
|
43
|
+
csv_cacheable? ? "#{owner.plugin_id}_csv_formatter_#{@usage}_csv" : nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def csv_for_thread
|
47
|
+
if csv_cacheable?
|
48
|
+
Thread.current[csv_thread_key] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)
|
49
|
+
else
|
50
|
+
CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
38
54
|
def configure(conf)
|
39
55
|
super
|
40
56
|
|
@@ -51,12 +67,10 @@ module Fluent
|
|
51
67
|
|
52
68
|
@generate_opts = {col_sep: @delimiter, force_quotes: @force_quotes, headers: @fields,
|
53
69
|
row_sep: @add_newline ? :auto : "".force_encoding(Encoding::ASCII_8BIT)}
|
54
|
-
# Cache CSV object per thread to avoid internal state sharing
|
55
|
-
@cache = {}
|
56
70
|
end
|
57
71
|
|
58
72
|
def format(tag, time, record)
|
59
|
-
csv =
|
73
|
+
csv = csv_for_thread
|
60
74
|
line = (csv << record).string.dup
|
61
75
|
# Need manual cleanup because CSV writer doesn't provide such method.
|
62
76
|
csv.rewind
|
@@ -65,7 +79,7 @@ module Fluent
|
|
65
79
|
end
|
66
80
|
|
67
81
|
def format_with_nested_fields(tag, time, record)
|
68
|
-
csv =
|
82
|
+
csv = csv_for_thread
|
69
83
|
values = @accessors.map { |a| a.call(record) }
|
70
84
|
line = (csv << values).string.dup
|
71
85
|
# Need manual cleanup because CSV writer doesn't provide such method.
|
@@ -534,7 +534,7 @@ module Fluent::Plugin
|
|
534
534
|
if @follow_inodes && new_inode.nil?
|
535
535
|
# nil inode means the file disappeared, so we only need to stop it.
|
536
536
|
@tails.delete(tail_watcher.path)
|
537
|
-
# https://github.com/fluent/fluentd/pull/4237#issuecomment-1633358632
|
537
|
+
# https://github.com/fluent/fluentd/pull/4237#issuecomment-1633358632
|
538
538
|
# Because of this problem, log duplication can occur during `rotate_wait`.
|
539
539
|
# Need to set `rotate_wait 0` for a workaround.
|
540
540
|
# Duplication will occur if `refresh_watcher` is called during the `rotate_wait`.
|
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/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,25 +48,32 @@ begin
|
|
48
48
|
end
|
49
49
|
|
50
50
|
class FluentdService < Daemon
|
51
|
+
ERROR_WAIT_NO_CHILDREN = 128
|
52
|
+
|
51
53
|
@pid = 0
|
52
54
|
@service_name = ''
|
53
55
|
|
54
56
|
def initialize(service_name)
|
55
57
|
@service_name = service_name
|
56
58
|
end
|
57
|
-
|
59
|
+
|
58
60
|
def service_main
|
59
61
|
@pid = service_main_start(@service_name)
|
60
|
-
|
61
|
-
|
62
|
+
begin
|
63
|
+
loop do
|
64
|
+
sleep 5
|
65
|
+
break unless running?
|
66
|
+
raise Errno::ECHILD unless Process.waitpid2(@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)
|
62
72
|
end
|
63
73
|
end
|
64
74
|
|
65
75
|
def service_stop
|
66
|
-
|
67
|
-
if @pid > 0
|
68
|
-
Process.waitpid(@pid)
|
69
|
-
end
|
76
|
+
wait_supervisor_finished if @pid > 0
|
70
77
|
end
|
71
78
|
|
72
79
|
def service_paramchange
|
@@ -91,6 +98,29 @@ begin
|
|
91
98
|
ev.set
|
92
99
|
ev.close
|
93
100
|
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
|
94
124
|
end
|
95
125
|
|
96
126
|
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(protocol: :all)
|
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, File.size(path)))
|
91
91
|
stdin.close
|
92
92
|
end
|
93
93
|
end
|
@@ -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,17 +71,31 @@ 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:, bind: "0.0.0.0")
|
75
75
|
case protocol
|
76
|
-
when :tcp
|
76
|
+
when :tcp, :tls
|
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)
|
80
82
|
else
|
81
83
|
raise ArgumentError, "unknown protocol: #{protocol}"
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
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
|
+
|
85
99
|
def unused_port_tcp(num = 1)
|
86
100
|
ports = []
|
87
101
|
sockets = []
|
@@ -90,7 +104,7 @@ def unused_port_tcp(num = 1)
|
|
90
104
|
sockets << s
|
91
105
|
ports << s.addr[1]
|
92
106
|
end
|
93
|
-
sockets.each
|
107
|
+
sockets.each(&:close)
|
94
108
|
if num == 1
|
95
109
|
return ports.first
|
96
110
|
else
|
@@ -100,12 +114,15 @@ end
|
|
100
114
|
|
101
115
|
PORT_RANGE_AVAILABLE = (1024...65535)
|
102
116
|
|
103
|
-
def unused_port_udp(num = 1, bind: "0.0.0.0")
|
117
|
+
def unused_port_udp(num = 1, port_list: [], bind: "0.0.0.0")
|
104
118
|
family = IPAddr.new(IPSocket.getaddress(bind)).ipv4? ? ::Socket::AF_INET : ::Socket::AF_INET6
|
105
119
|
ports = []
|
106
120
|
sockets = []
|
107
|
-
|
108
|
-
|
121
|
+
|
122
|
+
use_random_port = port_list.empty?
|
123
|
+
i = 0
|
124
|
+
loop do
|
125
|
+
port = use_random_port ? rand(PORT_RANGE_AVAILABLE) : port_list[i]
|
109
126
|
u = UDPSocket.new(family)
|
110
127
|
if (u.bind(bind, port) rescue nil)
|
111
128
|
ports << port
|
@@ -113,8 +130,11 @@ def unused_port_udp(num = 1, bind: "0.0.0.0")
|
|
113
130
|
else
|
114
131
|
u.close
|
115
132
|
end
|
133
|
+
i += 1
|
134
|
+
break if ports.size >= num
|
135
|
+
break if !use_random_port && i >= port_list.size
|
116
136
|
end
|
117
|
-
sockets.each
|
137
|
+
sockets.each(&:close)
|
118
138
|
if num == 1
|
119
139
|
return ports.first
|
120
140
|
else
|
@@ -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
|
+
def r.recv(arg)
|
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 self.closed?
|
117
117
|
MessagePack.pack({ 'ack' => Base64.encode64('chunk_id 111') })
|
118
|
-
|
118
|
+
end
|
119
119
|
ack.enqueue(r)
|
120
120
|
|
121
121
|
threads = []
|
@@ -17,7 +17,7 @@ class SocketCacheTest < Test::Unit::TestCase
|
|
17
17
|
assert_equal(socket, c.checkout_or('key') { socket })
|
18
18
|
c.checkin(socket)
|
19
19
|
|
20
|
-
sock =
|
20
|
+
sock = mock!.open.never.subject
|
21
21
|
assert_equal(socket, c.checkout_or('key') { sock.open })
|
22
22
|
end
|
23
23
|
|
@@ -130,7 +130,7 @@ class SocketCacheTest < Test::Unit::TestCase
|
|
130
130
|
|
131
131
|
c = Fluent::Plugin::ForwardOutput::SocketCache.new(10, $log)
|
132
132
|
sock = mock!.close { 'closed' }.subject
|
133
|
-
sock2 =
|
133
|
+
sock2 = mock!.close.never.subject
|
134
134
|
stub(sock).inspect
|
135
135
|
stub(sock2).inspect
|
136
136
|
|
@@ -154,7 +154,7 @@ class SocketCacheTest < Test::Unit::TestCase
|
|
154
154
|
Timecop.freeze(Time.parse('2016-04-13 14:00:00 +0900'))
|
155
155
|
|
156
156
|
c = Fluent::Plugin::ForwardOutput::SocketCache.new(10, $log)
|
157
|
-
sock =
|
157
|
+
sock = mock!.close.never.subject
|
158
158
|
stub(sock).inspect
|
159
159
|
c.checkout_or('key') { sock }
|
160
160
|
|
data/test/plugin/test_buffer.rb
CHANGED
@@ -946,9 +946,9 @@ class BufferTest < Test::Unit::TestCase
|
|
946
946
|
# 1. `write_once`: 42 [events] * 1 [stream]
|
947
947
|
# 2. `write_step_by_step`: 4 [events]* 10 [streams] + 2 [events] * 1 [stream]
|
948
948
|
# 3. `write_step_by_step` (by `ShouldRetry`): 1 [event] * 42 [streams]
|
949
|
-
#
|
949
|
+
#
|
950
950
|
# Example of staged chunk lock behavior:
|
951
|
-
#
|
951
|
+
#
|
952
952
|
# 1. mon_enter in write_step_by_step
|
953
953
|
# 2. ShouldRetry occurs
|
954
954
|
# 3. mon_exit in write_step_by_step
|
@@ -18,7 +18,8 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
18
18
|
Fluent::Test.setup
|
19
19
|
@responses = [] # for testing responses after sending data
|
20
20
|
@d = nil
|
21
|
-
|
21
|
+
# forward plugin uses TCP and UDP sockets on the same port number
|
22
|
+
@port = unused_port(protocol: :all)
|
22
23
|
end
|
23
24
|
|
24
25
|
def teardown
|
data/test/plugin/test_in_http.rb
CHANGED
@@ -18,7 +18,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def setup
|
20
20
|
Fluent::Test.setup
|
21
|
-
@port = unused_port
|
21
|
+
@port = unused_port(protocol: :tcp)
|
22
22
|
end
|
23
23
|
|
24
24
|
def teardown
|
@@ -982,7 +982,7 @@ class HttpInputTest < Test::Unit::TestCase
|
|
982
982
|
assert_equal ["403", "403"], res_codes
|
983
983
|
end
|
984
984
|
|
985
|
-
def test_add_query_params
|
985
|
+
def test_add_query_params
|
986
986
|
d = create_driver(config + "add_query_params true")
|
987
987
|
assert_equal true, d.instance.add_query_params
|
988
988
|
|
@@ -392,7 +392,7 @@ EOC
|
|
392
392
|
end
|
393
393
|
|
394
394
|
test "emit" do
|
395
|
-
port = unused_port
|
395
|
+
port = unused_port(protocol: :tcp)
|
396
396
|
d = create_driver("
|
397
397
|
@type monitor_agent
|
398
398
|
bind '127.0.0.1'
|
@@ -451,7 +451,7 @@ EOC
|
|
451
451
|
|
452
452
|
sub_test_case "servlets" do
|
453
453
|
setup do
|
454
|
-
@port = unused_port
|
454
|
+
@port = unused_port(protocol: :tcp)
|
455
455
|
# check @type and type in one configuration
|
456
456
|
conf = <<-EOC
|
457
457
|
<source>
|
@@ -759,7 +759,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
759
759
|
end
|
760
760
|
|
761
761
|
setup do
|
762
|
-
@port = unused_port
|
762
|
+
@port = unused_port(protocol: :tcp)
|
763
763
|
# check @type and type in one configuration
|
764
764
|
conf = <<-EOC
|
765
765
|
<source>
|
@@ -840,7 +840,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
840
840
|
|
841
841
|
sub_test_case "check the port number of http server" do
|
842
842
|
test "on single worker environment" do
|
843
|
-
port = unused_port
|
843
|
+
port = unused_port(protocol: :tcp)
|
844
844
|
d = create_driver("
|
845
845
|
@type monitor_agent
|
846
846
|
bind '127.0.0.1'
|
@@ -851,7 +851,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
851
851
|
end
|
852
852
|
|
853
853
|
test "worker_id = 2 on multi worker environment" do
|
854
|
-
port = unused_port
|
854
|
+
port = unused_port(protocol: :tcp)
|
855
855
|
Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
|
856
856
|
d = Fluent::Test::Driver::Input.new(Fluent::Plugin::MonitorAgentInput)
|
857
857
|
d.instance.instance_eval{ @_fluentd_worker_id = 2 }
|
@@ -905,7 +905,7 @@ EOC
|
|
905
905
|
end
|
906
906
|
|
907
907
|
test "plugins have a variable named buffer does not throws NoMethodError" do
|
908
|
-
port = unused_port
|
908
|
+
port = unused_port(protocol: :tcp)
|
909
909
|
d = create_driver("
|
910
910
|
@type monitor_agent
|
911
911
|
bind '127.0.0.1'
|