fluentd 1.16.8-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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +50 -0
  3. data/.github/DISCUSSION_TEMPLATE/q-a.yml +47 -0
  4. data/.github/workflows/test-ruby-head.yml +31 -0
  5. data/.github/workflows/test.yml +2 -13
  6. data/CHANGELOG.md +33 -69
  7. data/README.md +3 -1
  8. data/Rakefile +1 -1
  9. data/fluentd.gemspec +9 -10
  10. data/lib/fluent/command/binlog_reader.rb +1 -1
  11. data/lib/fluent/command/fluentd.rb +1 -1
  12. data/lib/fluent/compat/formatter.rb +0 -6
  13. data/lib/fluent/config/configure_proxy.rb +2 -2
  14. data/lib/fluent/config/parser.rb +3 -15
  15. data/lib/fluent/config/types.rb +1 -1
  16. data/lib/fluent/config/v1_parser.rb +1 -1
  17. data/lib/fluent/config/yaml_parser/parser.rb +0 -4
  18. data/lib/fluent/configurable.rb +2 -2
  19. data/lib/fluent/counter/mutex_hash.rb +1 -1
  20. data/lib/fluent/fluent_log_event_router.rb +0 -2
  21. data/lib/fluent/plugin/buf_file.rb +1 -1
  22. data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
  23. data/lib/fluent/plugin/buffer/file_single_chunk.rb +2 -3
  24. data/lib/fluent/plugin/filter_parser.rb +26 -8
  25. data/lib/fluent/plugin/formatter_csv.rb +4 -18
  26. data/lib/fluent/plugin/in_http.rb +17 -52
  27. data/lib/fluent/plugin/in_tail.rb +35 -3
  28. data/lib/fluent/plugin/out_file.rb +0 -8
  29. data/lib/fluent/plugin/out_http.rb +125 -13
  30. data/lib/fluent/plugin/owned_by_mixin.rb +0 -1
  31. data/lib/fluent/plugin/parser_json.rb +34 -9
  32. data/lib/fluent/plugin/parser_msgpack.rb +24 -3
  33. data/lib/fluent/plugin_helper/metrics.rb +2 -2
  34. data/lib/fluent/registry.rb +6 -6
  35. data/lib/fluent/supervisor.rb +3 -3
  36. data/lib/fluent/test/output_test.rb +1 -1
  37. data/lib/fluent/unique_id.rb +1 -1
  38. data/lib/fluent/version.rb +1 -1
  39. data/lib/fluent/winsvc.rb +8 -38
  40. data/test/command/test_cat.rb +2 -2
  41. data/test/command/test_fluentd.rb +10 -57
  42. data/test/config/test_plugin_configuration.rb +6 -6
  43. data/test/helper.rb +7 -27
  44. data/test/log/test_console_adapter.rb +10 -3
  45. data/test/plugin/data/log_numeric/01.log +0 -0
  46. data/test/plugin/data/log_numeric/02.log +0 -0
  47. data/test/plugin/data/log_numeric/12.log +0 -0
  48. data/test/plugin/data/log_numeric/14.log +0 -0
  49. data/test/plugin/in_tail/test_io_handler.rb +14 -13
  50. data/test/plugin/in_tail/test_position_file.rb +7 -6
  51. data/test/plugin/out_forward/test_ack_handler.rb +3 -3
  52. data/test/plugin/out_forward/test_socket_cache.rb +3 -3
  53. data/test/plugin/test_buffer.rb +2 -2
  54. data/test/plugin/test_filter_grep.rb +1 -1
  55. data/test/plugin/test_in_forward.rb +1 -2
  56. data/test/plugin/test_in_http.rb +23 -1
  57. data/test/plugin/test_in_monitor_agent.rb +6 -6
  58. data/test/plugin/test_in_syslog.rb +18 -25
  59. data/test/plugin/test_in_tail.rb +153 -5
  60. data/test/plugin/test_in_tcp.rb +1 -1
  61. data/test/plugin/test_in_udp.rb +10 -16
  62. data/test/plugin/test_out_exec_filter.rb +7 -12
  63. data/test/plugin/test_out_file.rb +2 -22
  64. data/test/plugin/test_out_forward.rb +3 -2
  65. data/test/plugin/test_out_http.rb +128 -0
  66. data/test/plugin/test_out_stream.rb +1 -1
  67. data/test/plugin/test_output.rb +1 -1
  68. data/test/plugin/test_output_as_buffered.rb +2 -2
  69. data/test/plugin/test_output_as_buffered_retries.rb +2 -2
  70. data/test/plugin/test_owned_by.rb +0 -1
  71. data/test/plugin/test_parser_csv.rb +1 -1
  72. data/test/plugin/test_parser_json.rb +106 -31
  73. data/test/plugin/test_parser_msgpack.rb +127 -0
  74. data/test/plugin/test_storage.rb +0 -1
  75. data/test/plugin_helper/test_child_process.rb +4 -4
  76. data/test/plugin_helper/test_http_server_helper.rb +1 -1
  77. data/test/plugin_helper/test_server.rb +41 -64
  78. data/test/plugin_helper/test_socket.rb +1 -1
  79. data/test/test_config.rb +0 -6
  80. data/test/test_event_router.rb +2 -2
  81. data/test/test_supervisor.rb +21 -30
  82. data/test/test_tls.rb +1 -1
  83. metadata +85 -30
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '1.16.8'
19
+ VERSION = '1.17.0'
20
20
 
21
21
  end
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
- 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)
60
+ while running?
61
+ sleep 10
72
62
  end
73
63
  end
74
64
 
75
65
  def service_stop
76
- wait_supervisor_finished if @pid > 0
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
@@ -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(protocol: :all)
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, File.size(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
- error_msg_match = ""
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
- error_msg_match = "execution timeout"
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
- error_msg_match = "unexpected error in launching fluentd: #{e.inspect}"
182
+ assert_error_msg = "unexpected error in launching fluentd: #{e.inspect}"
193
183
  else
194
- error_msg_match = "log doesn't match" unless matched
184
+ assert_error_msg = "log doesn't match" unless matched
195
185
  end
196
186
 
197
187
  if patterns_not_match.empty?
198
- error_msg_match = build_message(error_msg_match,
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
- error_msg_match << "\n" unless error_msg_match.empty?
211
- error_msg_match << "pattern exists in logs wrongly: #{ptn}"
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
- error_msg_match = build_message(error_msg_match,
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, error_msg_match
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)
@@ -1175,7 +1164,7 @@ CONF
1175
1164
  end
1176
1165
  end
1177
1166
 
1178
- sub_test_case 'shared socket options' do
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
@@ -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:, bind: "0.0.0.0")
74
+ def unused_port(num = 1, protocol: :tcp, bind: "0.0.0.0")
75
75
  case protocol
76
- when :tcp, :tls
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(&:close)
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, port_list: [], bind: "0.0.0.0")
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
- use_random_port = port_list.empty?
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(&:close)
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
- "#{@timestamp_str} [#{level}]: 0.0s: subject\n" +
77
- " | {\"kwarg1\":\"opt1\",\"kwarg2\":\"opt2\"}\n"
78
+ 1,
79
+ "#{@timestamp_str} [#{level}]: 0.0s: subject",
80
+ { "kwarg1" => "opt1", "kwarg2" => "opt2" }
78
81
  ],
79
- @logdev.logs)
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
- def setup
9
- Tempfile.create('intail_io_handler') do |file|
10
- file.binmode
11
- @file = file
12
- opened_file_metrics = Fluent::Plugin::LocalMetrics.new
13
- opened_file_metrics.configure(config_element('metrics', '', {}))
14
- closed_file_metrics = Fluent::Plugin::LocalMetrics.new
15
- closed_file_metrics.configure(config_element('metrics', '', {}))
16
- rotated_file_metrics = Fluent::Plugin::LocalMetrics.new
17
- rotated_file_metrics.configure(config_element('metrics', '', {}))
18
- @metrics = Fluent::Plugin::TailInput::MetricsInfo.new(opened_file_metrics, closed_file_metrics, rotated_file_metrics)
19
- yield
20
- end
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
- def setup
10
- Tempfile.create('intail_position_file_test') do |file|
11
- file.binmode
12
- @file = file
13
- yield
14
- end
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
- def r.recv(arg)
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 self.closed?
116
+ raise IOError, 'stream closed in another thread' if r.closed?
117
117
  MessagePack.pack({ 'ack' => Base64.encode64('chunk_id 111') })
118
- end
118
+ }
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 = mock!.open.never.subject
20
+ sock = dont_allow(mock!).open
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 = mock!.close.never.subject
133
+ sock2 = dont_allow(mock!).close
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 = mock!.close.never.subject
157
+ sock = dont_allow(mock!).close
158
158
  stub(sock).inspect
159
159
  c.checkout_or('key') { sock }
160
160
 
@@ -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
@@ -328,7 +328,7 @@ class GrepFilterTest < Test::Unit::TestCase
328
328
  end
329
329
 
330
330
  test "don't raise an exception" do
331
- assert_nothing_raised {
331
+ assert_nothing_raised {
332
332
  filter(%[regexp1 message WARN], ["\xff".force_encoding('UTF-8')])
333
333
  }
334
334
  end
@@ -18,8 +18,7 @@ class ForwardInputTest < Test::Unit::TestCase
18
18
  Fluent::Test.setup
19
19
  @responses = [] # for testing responses after sending data
20
20
  @d = nil
21
- # forward plugin uses TCP and UDP sockets on the same port number
22
- @port = unused_port(protocol: :all)
21
+ @port = unused_port
23
22
  end
24
23
 
25
24
  def teardown
@@ -18,7 +18,7 @@ class HttpInputTest < Test::Unit::TestCase
18
18
 
19
19
  def setup
20
20
  Fluent::Test.setup
21
- @port = unused_port(protocol: :tcp)
21
+ @port = unused_port
22
22
  end
23
23
 
24
24
  def teardown
@@ -517,6 +517,28 @@ class HttpInputTest < Test::Unit::TestCase
517
517
  assert_equal_event_time time, d.events[1][1]
518
518
  end
519
519
 
520
+ def test_csp_report
521
+ d = create_driver
522
+ time = event_time("2011-01-02 13:14:15 UTC")
523
+ time_i = time.to_i
524
+ events = [
525
+ ["tag1", time, {"a"=>1}],
526
+ ["tag2", time, {"a"=>2}],
527
+ ]
528
+ res_codes = []
529
+
530
+ d.run(expect_records: 2) do
531
+ events.each do |tag, t, record|
532
+ res = post("/#{tag}?time=#{time_i.to_s}", record.to_json, {"Content-Type"=>"application/csp-report; charset=utf-8"})
533
+ res_codes << res.code
534
+ end
535
+ end
536
+ assert_equal ["200", "200"], res_codes
537
+ assert_equal events, d.events
538
+ assert_equal_event_time time, d.events[0][1]
539
+ assert_equal_event_time time, d.events[1][1]
540
+ end
541
+
520
542
  def test_application_msgpack
521
543
  d = create_driver
522
544
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -392,7 +392,7 @@ EOC
392
392
  end
393
393
 
394
394
  test "emit" do
395
- port = unused_port(protocol: :tcp)
395
+ port = unused_port
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(protocol: :tcp)
454
+ @port = unused_port
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(protocol: :tcp)
762
+ @port = unused_port
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(protocol: :tcp)
843
+ port = unused_port
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(protocol: :tcp)
854
+ port = unused_port
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(protocol: :tcp)
908
+ port = unused_port
909
909
  d = create_driver("
910
910
  @type monitor_agent
911
911
  bind '127.0.0.1'