fluentd 1.11.4-x64-mingw32 → 1.12.3-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.deepsource.toml +13 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  4. data/.github/ISSUE_TEMPLATE/config.yml +5 -0
  5. data/.github/workflows/linux-test.yaml +36 -0
  6. data/.github/workflows/macos-test.yaml +30 -0
  7. data/.github/workflows/stale-actions.yml +22 -0
  8. data/.github/workflows/windows-test.yaml +35 -0
  9. data/.gitlab-ci.yml +41 -19
  10. data/CHANGELOG.md +166 -0
  11. data/MAINTAINERS.md +5 -2
  12. data/README.md +7 -4
  13. data/bin/fluent-cap-ctl +7 -0
  14. data/bin/fluent-ctl +7 -0
  15. data/fluentd.gemspec +7 -5
  16. data/lib/fluent/capability.rb +87 -0
  17. data/lib/fluent/command/bundler_injection.rb +1 -1
  18. data/lib/fluent/command/ca_generate.rb +6 -3
  19. data/lib/fluent/command/cap_ctl.rb +174 -0
  20. data/lib/fluent/command/cat.rb +0 -1
  21. data/lib/fluent/command/ctl.rb +177 -0
  22. data/lib/fluent/command/fluentd.rb +4 -0
  23. data/lib/fluent/command/plugin_config_formatter.rb +18 -2
  24. data/lib/fluent/command/plugin_generator.rb +31 -1
  25. data/lib/fluent/compat/parser.rb +2 -2
  26. data/lib/fluent/config/section.rb +2 -2
  27. data/lib/fluent/config/types.rb +2 -2
  28. data/lib/fluent/env.rb +4 -0
  29. data/lib/fluent/event.rb +3 -13
  30. data/lib/fluent/load.rb +0 -1
  31. data/lib/fluent/plugin.rb +5 -0
  32. data/lib/fluent/plugin/buffer.rb +2 -21
  33. data/lib/fluent/plugin/file_wrapper.rb +39 -3
  34. data/lib/fluent/plugin/formatter.rb +24 -0
  35. data/lib/fluent/plugin/formatter_csv.rb +1 -1
  36. data/lib/fluent/plugin/formatter_hash.rb +3 -1
  37. data/lib/fluent/plugin/formatter_json.rb +3 -1
  38. data/lib/fluent/plugin/formatter_ltsv.rb +7 -5
  39. data/lib/fluent/plugin/formatter_out_file.rb +6 -4
  40. data/lib/fluent/plugin/formatter_single_value.rb +4 -2
  41. data/lib/fluent/plugin/formatter_tsv.rb +4 -2
  42. data/lib/fluent/plugin/in_http.rb +24 -3
  43. data/lib/fluent/plugin/in_monitor_agent.rb +1 -1
  44. data/lib/fluent/plugin/in_tail.rb +129 -41
  45. data/lib/fluent/plugin/in_tail/position_file.rb +39 -14
  46. data/lib/fluent/plugin/in_tcp.rb +1 -0
  47. data/lib/fluent/plugin/out_copy.rb +18 -5
  48. data/lib/fluent/plugin/out_exec_filter.rb +3 -3
  49. data/lib/fluent/plugin/out_forward.rb +61 -28
  50. data/lib/fluent/plugin/out_http.rb +28 -3
  51. data/lib/fluent/plugin/output.rb +18 -10
  52. data/lib/fluent/plugin/parser_csv.rb +2 -2
  53. data/lib/fluent/plugin/parser_syslog.rb +2 -2
  54. data/lib/fluent/plugin/storage_local.rb +4 -4
  55. data/lib/fluent/plugin_helper/http_server/compat/server.rb +1 -1
  56. data/lib/fluent/plugin_helper/inject.rb +4 -2
  57. data/lib/fluent/plugin_helper/retry_state.rb +4 -0
  58. data/lib/fluent/plugin_helper/server.rb +4 -2
  59. data/lib/fluent/plugin_helper/socket_option.rb +2 -2
  60. data/lib/fluent/supervisor.rb +153 -48
  61. data/lib/fluent/system_config.rb +2 -1
  62. data/lib/fluent/time.rb +58 -1
  63. data/lib/fluent/version.rb +1 -1
  64. data/lib/fluent/winsvc.rb +22 -4
  65. data/templates/new_gem/fluent-plugin.gemspec.erb +3 -3
  66. data/templates/plugin_config_formatter/param.md-table.erb +10 -0
  67. data/test/command/test_binlog_reader.rb +22 -6
  68. data/test/command/test_cap_ctl.rb +100 -0
  69. data/test/command/test_ctl.rb +57 -0
  70. data/test/command/test_fluentd.rb +38 -0
  71. data/test/command/test_plugin_config_formatter.rb +124 -2
  72. data/test/config/test_configurable.rb +1 -1
  73. data/test/plugin/in_tail/test_position_file.rb +46 -26
  74. data/test/plugin/test_file_wrapper.rb +105 -0
  75. data/test/plugin/test_filter_stdout.rb +6 -1
  76. data/test/plugin/test_formatter_hash.rb +6 -3
  77. data/test/plugin/test_formatter_json.rb +14 -4
  78. data/test/plugin/test_formatter_ltsv.rb +13 -5
  79. data/test/plugin/test_formatter_out_file.rb +35 -14
  80. data/test/plugin/test_formatter_single_value.rb +12 -6
  81. data/test/plugin/test_formatter_tsv.rb +12 -4
  82. data/test/plugin/test_in_exec.rb +1 -1
  83. data/test/plugin/test_in_http.rb +25 -0
  84. data/test/plugin/test_in_tail.rb +503 -42
  85. data/test/plugin/test_out_copy.rb +87 -0
  86. data/test/plugin/test_out_file.rb +23 -18
  87. data/test/plugin/test_out_forward.rb +94 -6
  88. data/test/plugin/test_out_http.rb +20 -1
  89. data/test/plugin/test_output.rb +15 -3
  90. data/test/plugin/test_output_as_buffered_backup.rb +2 -0
  91. data/test/plugin/test_parser_csv.rb +14 -0
  92. data/test/plugin/test_parser_syslog.rb +16 -2
  93. data/test/plugin/test_sd_file.rb +1 -1
  94. data/test/plugin_helper/service_discovery/test_manager.rb +1 -1
  95. data/test/plugin_helper/test_child_process.rb +5 -2
  96. data/test/plugin_helper/test_compat_parameters.rb +7 -2
  97. data/test/plugin_helper/test_http_server_helper.rb +4 -2
  98. data/test/plugin_helper/test_inject.rb +29 -0
  99. data/test/plugin_helper/test_server.rb +26 -7
  100. data/test/test_capability.rb +74 -0
  101. data/test/test_event.rb +16 -0
  102. data/test/test_formatter.rb +64 -10
  103. data/test/test_output.rb +8 -3
  104. data/test/test_supervisor.rb +150 -1
  105. data/test/test_time_parser.rb +109 -0
  106. metadata +87 -33
  107. data/.travis.yml +0 -57
  108. data/appveyor.yml +0 -28
data/lib/fluent/time.rb CHANGED
@@ -50,6 +50,7 @@ module Fluent
50
50
  def to_int
51
51
  @sec
52
52
  end
53
+ alias :to_i :to_int
53
54
 
54
55
  def to_f
55
56
  @sec + @nsec / 1_000_000_000.0
@@ -131,13 +132,14 @@ module Fluent
131
132
  end
132
133
 
133
134
  module TimeMixin
134
- TIME_TYPES = ['string', 'unixtime', 'float']
135
+ TIME_TYPES = ['string', 'unixtime', 'float', 'mixed']
135
136
 
136
137
  TIME_PARAMETERS = [
137
138
  [:time_format, :string, {default: nil}],
138
139
  [:localtime, :bool, {default: true}], # UTC if :localtime is false and :timezone is nil
139
140
  [:utc, :bool, {default: false}], # to turn :localtime false
140
141
  [:timezone, :string, {default: nil}],
142
+ [:time_format_fallbacks, :array, {default: []}], # try time_format, then try fallbacks
141
143
  ]
142
144
  TIME_FULL_PARAMETERS = [
143
145
  # To avoid to define :time_type twice (in plugin_helper/inject)
@@ -169,6 +171,12 @@ module Fluent
169
171
  raise Fluent::ConfigError, "both of utc and localtime are specified, use only one of them"
170
172
  end
171
173
 
174
+ if conf.has_key?('time_type') and @time_type == :mixed
175
+ if @time_format.nil? and @time_format_fallbacks.empty?
176
+ raise Fluent::ConfigError, "time_type is :mixed but time_format and time_format_fallbacks is empty."
177
+ end
178
+ end
179
+
172
180
  Fluent::Timezone.validate!(@timezone) if @timezone
173
181
  end
174
182
  end
@@ -179,6 +187,7 @@ module Fluent
179
187
  end
180
188
 
181
189
  def time_parser_create(type: @time_type, format: @time_format, timezone: @timezone, force_localtime: false)
190
+ return MixedTimeParser.new(type, format, @localtime, timezone, @utc, force_localtime, @time_format_fallbacks) if type == :mixed
182
191
  return NumericTimeParser.new(type) if type != :string
183
192
  return TimeParser.new(format, true, nil) if force_localtime
184
193
 
@@ -451,4 +460,52 @@ module Fluent
451
460
  end
452
461
  end
453
462
  end
463
+
464
+ # MixedTimeParser is available when time_type is set to :mixed
465
+ #
466
+ # Use Case 1: primary format is specified explicitly in time_format
467
+ # time_type mixed
468
+ # time_format %iso8601
469
+ # time_format_fallbacks unixtime
470
+ # Use Case 2: time_format is omitted
471
+ # time_type mixed
472
+ # time_format_fallbacks %iso8601, unixtime
473
+ #
474
+ class MixedTimeParser < TimeParser # to include TimeParseError
475
+ def initialize(type, format = nil, localtime = nil, timezone = nil, utc = nil, force_localtime = nil, fallbacks = [])
476
+ @parsers = []
477
+ fallbacks.unshift(format).each do |fallback|
478
+ next unless fallback
479
+ case fallback
480
+ when 'unixtime', 'float'
481
+ @parsers << NumericTimeParser.new(fallback, localtime, timezone)
482
+ else
483
+ if force_localtime
484
+ @parsers << TimeParser.new(fallback, true, nil)
485
+ else
486
+ localtime = localtime && (timezone.nil? && !utc)
487
+ @parsers << TimeParser.new(fallback, localtime, timezone)
488
+ end
489
+ end
490
+ end
491
+ end
492
+
493
+ def parse(value)
494
+ @parsers.each do |parser|
495
+ begin
496
+ Float(value) if parser.class == Fluent::NumericTimeParser
497
+ rescue
498
+ next
499
+ end
500
+ begin
501
+ return parser.parse(value)
502
+ rescue
503
+ # skip TimeParseError
504
+ end
505
+ end
506
+ fallback_class = @parsers.collect do |parser| parser.class end.join(",")
507
+ raise TimeParseError, "invalid time format: value = #{value}, even though fallbacks: #{fallback_class}"
508
+ end
509
+ end
510
+
454
511
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '1.11.4'
19
+ VERSION = '1.12.3'
20
20
 
21
21
  end
data/lib/fluent/winsvc.rb CHANGED
@@ -61,7 +61,6 @@ begin
61
61
  end
62
62
 
63
63
  def service_main
64
-
65
64
  @pid = service_main_start(@service_name)
66
65
  while running?
67
66
  sleep 10
@@ -69,13 +68,32 @@ begin
69
68
  end
70
69
 
71
70
  def service_stop
72
- ev = Win32::Event.open(@service_name)
73
- ev.set
74
- ev.close
71
+ set_event(@service_name)
75
72
  if @pid > 0
76
73
  Process.waitpid(@pid)
77
74
  end
78
75
  end
76
+
77
+ def service_paramchange
78
+ set_event("#{@service_name}_USR2")
79
+ end
80
+
81
+ def service_user_defined_control(code)
82
+ case code
83
+ when 128
84
+ set_event("#{@service_name}_HUP")
85
+ when 129
86
+ set_event("#{@service_name}_USR1")
87
+ end
88
+ end
89
+
90
+ private
91
+
92
+ def set_event(event_name)
93
+ ev = Win32::Event.open(event_name)
94
+ ev.set
95
+ ev.close
96
+ end
79
97
  end
80
98
 
81
99
  FluentdService.new(opts[:service_name]).mainloop
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = test_files
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.14"
24
- spec.add_development_dependency "rake", "~> 12.0"
25
- spec.add_development_dependency "test-unit", "~> 3.0"
23
+ spec.add_development_dependency "bundler", "~> <%= bundler_version %>"
24
+ spec.add_development_dependency "rake", "~> <%= rake_version %>"
25
+ spec.add_development_dependency "test-unit", "~> <%= test_unit_version %>"
26
26
  spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
27
27
  end
@@ -0,0 +1,10 @@
1
+ <%-
2
+ type = config[:type]
3
+ required_label = config[:required] ? "required" : "optional"
4
+ default = config[:default]
5
+ alias_name = config[:alias]
6
+ deprecated = config[:deprecated]
7
+ obsoleted = config[:obsoleted]
8
+ description = config[:desc]
9
+ -%>
10
+ |<%= name %>|<%= type %> (<%= required_label %>)|<%= description %><%- if type == :enum -%> (<%= config[:list].map{|x| "`#{x}`"}.join(", ") %>)<%- end -%><%- if alias_name -%><br>Alias: <%= alias_name %><%- end -%><%- if deprecated -%><br>Deprecated: <%= deprecated %><%- end -%><%- if obsoleted -%><br>Obsoleted: <%= :obsoleted %><%- end -%>|<%- if default -%>`<%= default %>`<%- end -%>|
@@ -82,6 +82,14 @@ class TestBaseCommand < ::Test::Unit::TestCase
82
82
  end
83
83
 
84
84
  class TestHead < TestBaseCommand
85
+ setup do
86
+ @default_newline = if Fluent.windows?
87
+ "\r\n"
88
+ else
89
+ "\n"
90
+ end
91
+ end
92
+
85
93
  sub_test_case 'initialize' do
86
94
  data(
87
95
  'file is not passed' => %w(),
@@ -138,7 +146,7 @@ class TestHead < TestBaseCommand
138
146
  create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
139
147
  head = BinlogReaderCommand::Head.new(argv)
140
148
  out = capture_stdout { head.call }
141
- assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n" * 5, out
149
+ assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}" * 5, out
142
150
  end
143
151
  end
144
152
 
@@ -149,7 +157,7 @@ class TestHead < TestBaseCommand
149
157
  create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
150
158
  head = BinlogReaderCommand::Head.new(argv)
151
159
  out = capture_stdout { head.call }
152
- assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n", out
160
+ assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}", out
153
161
  end
154
162
  end
155
163
 
@@ -169,7 +177,7 @@ class TestHead < TestBaseCommand
169
177
  create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
170
178
  head = BinlogReaderCommand::Head.new(argv)
171
179
  out = capture_stdout { head.call }
172
- assert_equal "#{Yajl.dump(@record)}\n", out
180
+ assert_equal "#{Yajl.dump(@record)}#{@default_newline}", out
173
181
  end
174
182
  end
175
183
 
@@ -198,6 +206,14 @@ class TestHead < TestBaseCommand
198
206
  end
199
207
 
200
208
  class TestCat < TestBaseCommand
209
+ setup do
210
+ @default_newline = if Fluent.windows?
211
+ "\r\n"
212
+ else
213
+ "\n"
214
+ end
215
+ end
216
+
201
217
  sub_test_case 'initialize' do
202
218
  data(
203
219
  'file is not passed' => [],
@@ -254,7 +270,7 @@ class TestCat < TestBaseCommand
254
270
  create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
255
271
  head = BinlogReaderCommand::Cat.new(argv)
256
272
  out = capture_stdout { head.call }
257
- assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n" * 6, out
273
+ assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}" * 6, out
258
274
  end
259
275
  end
260
276
 
@@ -265,7 +281,7 @@ class TestCat < TestBaseCommand
265
281
  create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
266
282
  head = BinlogReaderCommand::Cat.new(argv)
267
283
  out = capture_stdout { head.call }
268
- assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n", out
284
+ assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}", out
269
285
  end
270
286
  end
271
287
 
@@ -276,7 +292,7 @@ class TestCat < TestBaseCommand
276
292
  create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
277
293
  head = BinlogReaderCommand::Cat.new(argv)
278
294
  out = capture_stdout { head.call }
279
- assert_equal "#{Yajl.dump(@record)}\n", out
295
+ assert_equal "#{Yajl.dump(@record)}#{@default_newline}", out
280
296
  end
281
297
  end
282
298
 
@@ -0,0 +1,100 @@
1
+ require_relative '../helper'
2
+
3
+ require 'tempfile'
4
+ require 'fluent/command/cap_ctl'
5
+
6
+ class TestFluentCapCtl < Test::Unit::TestCase
7
+ setup do
8
+ omit "This environment does not handle Linux capability" unless defined?(CapNG)
9
+ end
10
+
11
+ sub_test_case "success" do
12
+ test "clear capability" do
13
+ logs = capture_stdout do
14
+ Fluent::CapCtl.new(["--clear"]).call
15
+ end
16
+ expression = /\AClear capabilities .*\n/m
17
+ assert_match expression, logs
18
+ end
19
+
20
+ test "add capability" do
21
+ logs = capture_stdout do
22
+ Fluent::CapCtl.new(["--add", "dac_override"]).call
23
+ end
24
+ expression = /\AUpdating .* done.\nAdding .*\n/m
25
+ assert_match expression, logs
26
+ end
27
+
28
+ test "drop capability" do
29
+ logs = capture_stdout do
30
+ Fluent::CapCtl.new(["--drop", "chown"]).call
31
+ end
32
+ expression = /\AUpdating .* done.\nDropping .*\n/m
33
+ assert_match expression, logs
34
+ end
35
+
36
+ test "get capability" do
37
+ logs = capture_stdout do
38
+ Fluent::CapCtl.new(["--get"]).call
39
+ end
40
+ expression = /\ACapabilities in .*,\nEffective: .*\nInheritable: .*\nPermitted: .*/m
41
+ assert_match expression, logs
42
+ end
43
+ end
44
+
45
+ sub_test_case "success with file" do
46
+ test "clear capability" do
47
+ logs = capture_stdout do
48
+ Tempfile.create("fluent-cap-") do |tempfile|
49
+ Fluent::CapCtl.new(["--clear-cap", "-f", tempfile.path]).call
50
+ end
51
+ end
52
+ expression = /\AClear capabilities .*\n/m
53
+ assert_match expression, logs
54
+ end
55
+
56
+ test "add capability" do
57
+ logs = capture_stdout do
58
+ Tempfile.create("fluent-cap-") do |tempfile|
59
+ Fluent::CapCtl.new(["--add", "dac_override", "-f", tempfile.path]).call
60
+ end
61
+ end
62
+ expression = /\AUpdating .* done.\nAdding .*\n/m
63
+ assert_match expression, logs
64
+ end
65
+
66
+ test "drop capability" do
67
+ logs = capture_stdout do
68
+ Tempfile.create("fluent-cap-") do |tempfile|
69
+ Fluent::CapCtl.new(["--drop", "chown", "-f", tempfile.path]).call
70
+ end
71
+ end
72
+ expression = /\AUpdating .* done.\nDropping .*\n/m
73
+ assert_match expression, logs
74
+ end
75
+
76
+ test "get capability" do
77
+ logs = capture_stdout do
78
+ Tempfile.create("fluent-cap-") do |tempfile|
79
+ Fluent::CapCtl.new(["--get", "-f", tempfile.path]).call
80
+ end
81
+ end
82
+ expression = /\ACapabilities in .*,\nEffective: .*\nInheritable: .*\nPermitted: .*/m
83
+ assert_match expression, logs
84
+ end
85
+ end
86
+
87
+ sub_test_case "invalid" do
88
+ test "add capability" do
89
+ assert_raise(ArgumentError) do
90
+ Fluent::CapCtl.new(["--add", "nonexitent"]).call
91
+ end
92
+ end
93
+
94
+ test "drop capability" do
95
+ assert_raise(ArgumentError) do
96
+ Fluent::CapCtl.new(["--drop", "invalid"]).call
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,57 @@
1
+ require_relative '../helper'
2
+
3
+ require 'test-unit'
4
+ require 'win32/event' if Fluent.windows?
5
+
6
+ require 'fluent/command/ctl'
7
+
8
+ class TestFluentdCtl < ::Test::Unit::TestCase
9
+ def assert_win32_event(event_name, command, pid_or_svcname)
10
+ command, event_suffix = data
11
+ event = Win32::Event.new(event_name)
12
+ ipc = Win32::Ipc.new(event.handle)
13
+ ret = Win32::Ipc::TIMEOUT
14
+
15
+ wait_thread = Thread.new do
16
+ ret = ipc.wait(1)
17
+ end
18
+ Fluent::Ctl.new([command, pid_or_svcname]).call
19
+ wait_thread.join
20
+ assert_equal(Win32::Ipc::SIGNALED, ret)
21
+ end
22
+
23
+ data("shutdown" => ["shutdown", "TERM", ""],
24
+ "restart" => ["restart", "HUP", "HUP"],
25
+ "flush" => ["flush", "USR1", "USR1"],
26
+ "reload" => ["reload", "USR2", "USR2"])
27
+ def test_commands(data)
28
+ command, signal, event_suffix = data
29
+
30
+ if Fluent.windows?
31
+ event_name = "fluentd_54321"
32
+ event_name << "_#{event_suffix}" unless event_suffix.empty?
33
+ assert_win32_event(event_name, command, "54321")
34
+ else
35
+ got_signal = false
36
+ Signal.trap(signal) do
37
+ got_signal = true
38
+ end
39
+ Fluent::Ctl.new([command, "#{$$}"]).call
40
+ assert_true(got_signal)
41
+ end
42
+ end
43
+
44
+ data("shutdown" => ["shutdown", ""],
45
+ "restart" => ["restart", "HUP"],
46
+ "flush" => ["flush", "USR1"],
47
+ "reload" => ["reload", "USR2"])
48
+ def test_commands_with_winsvcname(data)
49
+ omit "Only for Windows" unless Fluent.windows?
50
+
51
+ command, event_suffix = data
52
+ event_name = "testfluentdwinsvc"
53
+ event_name << "_#{event_suffix}" unless event_suffix.empty?
54
+
55
+ assert_win32_event(event_name, command, "testfluentdwinsvc")
56
+ end
57
+ end
@@ -878,6 +878,8 @@ CONF
878
878
  end
879
879
 
880
880
  test "without RUBYOPT" do
881
+ saved_ruby_opt = ENV["RUBYOPT"]
882
+ ENV["RUBYOPT"] = nil
881
883
  conf = <<CONF
882
884
  <source>
883
885
  @type dummy
@@ -889,6 +891,8 @@ CONF
889
891
  CONF
890
892
  conf_path = create_conf_file('rubyopt_test.conf', conf)
891
893
  assert_log_matches(create_cmdline(conf_path), '-Eascii-8bit:ascii-8bit')
894
+ ensure
895
+ ENV["RUBYOPT"] = saved_ruby_opt
892
896
  end
893
897
 
894
898
  test 'invalid values are set to RUBYOPT' do
@@ -912,6 +916,8 @@ CONF
912
916
 
913
917
  # https://github.com/fluent/fluentd/issues/2915
914
918
  test "ruby path contains spaces" do
919
+ saved_ruby_opt = ENV["RUBYOPT"]
920
+ ENV["RUBYOPT"] = nil
915
921
  conf = <<CONF
916
922
  <source>
917
923
  @type dummy
@@ -940,6 +946,8 @@ CONF
940
946
  'spawn command to main:',
941
947
  '-Eascii-8bit:ascii-8bit'
942
948
  )
949
+ ensure
950
+ ENV["RUBYOPT"] = saved_ruby_opt
943
951
  end
944
952
 
945
953
  test 'success to start workers when file buffer is configured in non-workers way only for specific worker' do
@@ -1065,4 +1073,34 @@ CONF
1065
1073
  "secret xxxxxx", patterns_not_match: ["secret secret0", "secret secret1"])
1066
1074
  end
1067
1075
  end
1076
+
1077
+ sub_test_case 'sahred socket options' do
1078
+ test 'enable shared socket by default' do
1079
+ conf = ""
1080
+ conf_path = create_conf_file('empty.conf', conf)
1081
+ assert File.exist?(conf_path)
1082
+ assert_log_matches(create_cmdline(conf_path),
1083
+ patterns_not_match: ["shared socket for multiple workers is disabled"])
1084
+ end
1085
+
1086
+ test 'disable shared socket by command line option' do
1087
+ conf = ""
1088
+ conf_path = create_conf_file('empty.conf', conf)
1089
+ assert File.exist?(conf_path)
1090
+ assert_log_matches(create_cmdline(conf_path, "--disable-shared-socket"),
1091
+ "shared socket for multiple workers is disabled",)
1092
+ end
1093
+
1094
+ test 'disable shared socket by system config' do
1095
+ conf = <<CONF
1096
+ <system>
1097
+ disable_shared_socket
1098
+ </system>
1099
+ CONF
1100
+ conf_path = create_conf_file('empty.conf', conf)
1101
+ assert File.exist?(conf_path)
1102
+ assert_log_matches(create_cmdline(conf_path, "--disable-shared-socket"),
1103
+ "shared socket for multiple workers is disabled",)
1104
+ end
1105
+ end
1068
1106
  end