fluentd 1.9.3-x64-mingw32 → 1.10.0-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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue-auto-closer.yml +12 -0
  3. data/CHANGELOG.md +48 -0
  4. data/lib/fluent/msgpack_factory.rb +13 -6
  5. data/lib/fluent/plugin/buffer.rb +2 -2
  6. data/lib/fluent/plugin/in_dummy.rb +1 -1
  7. data/lib/fluent/plugin/in_tail.rb +35 -26
  8. data/lib/fluent/plugin/out_forward.rb +4 -6
  9. data/lib/fluent/plugin/out_forward/handshake_protocol.rb +4 -0
  10. data/lib/fluent/plugin/parser_syslog.rb +114 -34
  11. data/lib/fluent/plugin/sd_file.rb +1 -0
  12. data/lib/fluent/plugin/sd_srv.rb +135 -0
  13. data/lib/fluent/plugin_helper/cert_option.rb +15 -2
  14. data/lib/fluent/plugin_helper/server.rb +3 -1
  15. data/lib/fluent/plugin_helper/socket_option.rb +19 -1
  16. data/lib/fluent/version.rb +1 -1
  17. data/test/command/test_fluentd.rb +14 -2
  18. data/test/helper.rb +2 -2
  19. data/test/plugin/in_tail/test_fifo.rb +121 -0
  20. data/test/plugin/in_tail/test_io_handler.rb +132 -0
  21. data/test/plugin/in_tail/test_position_file.rb +1 -1
  22. data/test/plugin/out_forward/test_handshake_protocol.rb +10 -1
  23. data/test/plugin/test_buf_file.rb +3 -1
  24. data/test/plugin/test_buffer.rb +20 -0
  25. data/test/plugin/test_compressable.rb +7 -4
  26. data/test/plugin/test_in_dummy.rb +12 -14
  27. data/test/plugin/test_in_forward.rb +2 -2
  28. data/test/plugin/test_in_tail.rb +6 -6
  29. data/test/plugin/test_out_forward.rb +28 -1
  30. data/test/plugin/test_output_as_buffered_secondary.rb +1 -1
  31. data/test/plugin/test_parser_syslog.rb +46 -34
  32. data/test/plugin/test_sd_file.rb +17 -0
  33. data/test/plugin/test_sd_srv.rb +230 -0
  34. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +19 -0
  35. data/test/plugin_helper/test_cert_option.rb +2 -0
  36. data/test/plugin_helper/test_child_process.rb +5 -3
  37. data/test/test_msgpack_factory.rb +18 -0
  38. metadata +14 -2
@@ -6,7 +6,7 @@ require 'tempfile'
6
6
 
7
7
  class IntailPositionFileTest < Test::Unit::TestCase
8
8
  setup do
9
- @file = Tempfile.new('intail_position_file_test')
9
+ @file = Tempfile.new('intail_position_file_test').binmode
10
10
  end
11
11
 
12
12
  teardown do
@@ -81,6 +81,15 @@ class HandshakeProtocolTest < Test::Unit::TestCase
81
81
  assert_equal(ri.state, :established)
82
82
  end
83
83
 
84
+ test 'raises an error when password and username are nil if auth exists' do
85
+ handshake = Fluent::Plugin::ForwardOutput::HandshakeProtocol.new(log: $log, hostname: 'hostname', shared_key: 'shared_key', password: nil, username: nil)
86
+ ri = Fluent::Plugin::ForwardOutput::ConnectionManager::RequestInfo.new(:helo)
87
+
88
+ assert_raise(Fluent::Plugin::ForwardOutput::PingpongError.new('username and password are required')) do
89
+ handshake.invoke('', ri, ['HELO', { 'auth' => 'auth' }])
90
+ end
91
+ end
92
+
84
93
  data(
85
94
  lack_of_elem: ['PONG', true, '', 'client_hostname'],
86
95
  wrong_message: ['WRONG_PONG', true, '', 'client_hostname', '40a3c5943cc6256e0c5dcf176e97db3826b0909698c330dc8e53d15af63efb47e030d113130255dd6e7ced5176d2999cc2e02a44852d45152503af317b73b33f'],
@@ -89,7 +98,7 @@ class HandshakeProtocolTest < Test::Unit::TestCase
89
98
  wrong_key: ['PONG', true, '', 'hostname', 'wrong_key'],
90
99
  )
91
100
  test 'raises an error when message is' do |msg|
92
- handshake = Fluent::Plugin::ForwardOutput::HandshakeProtocol.new(log: $log, hostname: 'hostname', shared_key: 'shared_key', password: nil, username: nil)
101
+ handshake = Fluent::Plugin::ForwardOutput::HandshakeProtocol.new(log: $log, hostname: 'hostname', shared_key: 'shared_key', password: '', username: '')
93
102
  handshake.instance_variable_set(:@shared_key_salt, 'ce1897b0d3dbd76b90d7fb96010dcac3') # to fix salt
94
103
 
95
104
  ri = Fluent::Plugin::ForwardOutput::ConnectionManager::RequestInfo.new(:pingpong, '', '')
@@ -1062,7 +1062,9 @@ class FileBufferTest < Test::Unit::TestCase
1062
1062
  if @bufdir
1063
1063
  Dir.glob(File.join(@bufdir, '*')).each do |path|
1064
1064
  next if ['.', '..'].include?(File.basename(path))
1065
- File.delete(path)
1065
+ # Windows does not permit to delete files which are used in another process.
1066
+ # Just ignore for removing failure.
1067
+ File.delete(path) rescue nil
1066
1068
  end
1067
1069
  end
1068
1070
  end
@@ -1202,4 +1202,24 @@ class BufferTest < Test::Unit::TestCase
1202
1202
  assert chunk.singleton_class.ancestors.include?(Fluent::Plugin::Buffer::Chunk::Decompressable)
1203
1203
  end
1204
1204
  end
1205
+
1206
+ sub_test_case '#statistics' do
1207
+ setup do
1208
+ @p = create_buffer({ "total_limit_size" => 1024 })
1209
+ dm = create_metadata(Time.parse('2020-03-13 16:00:00 +0000').to_i, nil, nil)
1210
+
1211
+ (class << @p; self; end).module_eval do
1212
+ define_method(:resume) {
1213
+ queued = [create_chunk(dm, ["a" * (1024 - 102)]).enqueued!]
1214
+ return {}, queued
1215
+ }
1216
+ end
1217
+
1218
+ @p.start
1219
+ end
1220
+
1221
+ test 'returns available_buffer_space_ratios' do
1222
+ assert_equal 10.0, @p.statistics['buffer']['available_buffer_space_ratios']
1223
+ end
1224
+ end
1205
1225
  end
@@ -4,6 +4,12 @@ require 'fluent/plugin/compressable'
4
4
  class CompressableTest < Test::Unit::TestCase
5
5
  include Fluent::Plugin::Compressable
6
6
 
7
+ def compress_assert_equal(expected, actual)
8
+ e = Zlib::GzipReader.new(StringIO.new(expected)).read
9
+ a = Zlib::GzipReader.new(StringIO.new(actual)).read
10
+ assert_equal(e, a)
11
+ end
12
+
7
13
  sub_test_case '#compress' do
8
14
  setup do
9
15
  @src = 'text data for compressing' * 5
@@ -18,8 +24,7 @@ class CompressableTest < Test::Unit::TestCase
18
24
  test 'write compressed data to IO with output_io option' do
19
25
  io = StringIO.new
20
26
  compress(@src, output_io: io)
21
- waiting(10){ sleep 0.1 until @gzipped_src == io.string }
22
- assert_equal @gzipped_src, io.string
27
+ compress_assert_equal @gzipped_src, io.string
23
28
  end
24
29
  end
25
30
 
@@ -36,7 +41,6 @@ class CompressableTest < Test::Unit::TestCase
36
41
  test 'write decompressed data to IO with output_io option' do
37
42
  io = StringIO.new
38
43
  decompress(@gzipped_src, output_io: io)
39
- waiting(10){ sleep 0.1 until @src == io.string }
40
44
  assert_equal @src, io.string
41
45
  end
42
46
 
@@ -58,7 +62,6 @@ class CompressableTest < Test::Unit::TestCase
58
62
  output_io = StringIO.new
59
63
 
60
64
  decompress(input_io: input_io, output_io: output_io)
61
- waiting(10){ sleep 0.1 until @src == output_io.string }
62
65
  assert_equal @src, output_io.string
63
66
  end
64
67
 
@@ -95,21 +95,20 @@ class DummyTest < Test::Unit::TestCase
95
95
  TEST_PLUGIN_STORAGE_PATH = File.join( File.dirname(File.dirname(__FILE__)), 'tmp', 'in_dummy', 'store' )
96
96
  FileUtils.mkdir_p TEST_PLUGIN_STORAGE_PATH
97
97
 
98
- sub_test_case "doesn't suspend internal counters in default" do
98
+ sub_test_case 'when dummy plugin has storage which is not specified the path' do
99
99
  config1 = {
100
100
  'tag' => 'dummy',
101
- 'rate' => '2',
101
+ 'rate' => '0',
102
102
  'dummy' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
103
103
  'auto_increment_key' => 'id',
104
- 'suspend' => false,
105
104
  }
106
105
  conf1 = config_element('ROOT', '', config1, [])
107
- test "value of auto increment key is not suspended after stop-and-start" do
106
+ test "value of auto increment key is not kept after stop-and-start" do
108
107
  assert !File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-01.json'))
109
108
 
110
109
  d1 = create_driver(conf1)
111
110
  d1.run(timeout: 0.5) do
112
- d1.instance.emit(4)
111
+ d1.instance.emit(2)
113
112
  end
114
113
 
115
114
  events = d1.events.sort{|a,b| a[2]['id'] <=> b[2]['id'] }
@@ -124,7 +123,7 @@ class DummyTest < Test::Unit::TestCase
124
123
 
125
124
  d2 = create_driver(conf1)
126
125
  d2.run(timeout: 0.5) do
127
- d2.instance.emit(4)
126
+ d2.instance.emit(2)
128
127
  end
129
128
 
130
129
  events = d2.events.sort{|a,b| a[2]['id'] <=> b[2]['id'] }
@@ -136,7 +135,7 @@ class DummyTest < Test::Unit::TestCase
136
135
  end
137
136
  end
138
137
 
139
- sub_test_case "suspend internal counters if suspend is true" do
138
+ sub_test_case 'when dummy plugin has storage which is specified the path' do
140
139
  setup do
141
140
  FileUtils.rm_rf(TEST_PLUGIN_STORAGE_PATH)
142
141
  FileUtils.mkdir_p(File.join(TEST_PLUGIN_STORAGE_PATH, 'json'))
@@ -146,10 +145,9 @@ class DummyTest < Test::Unit::TestCase
146
145
  config2 = {
147
146
  '@id' => 'test-02',
148
147
  'tag' => 'dummy',
149
- 'rate' => '2',
148
+ 'rate' => '0',
150
149
  'dummy' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
151
150
  'auto_increment_key' => 'id',
152
- 'suspend' => true,
153
151
  }
154
152
  conf2 = config_element('ROOT', '', config2, [
155
153
  config_element(
@@ -161,12 +159,12 @@ class DummyTest < Test::Unit::TestCase
161
159
  'persistent' => true,
162
160
  })
163
161
  ])
164
- test "value of auto increment key is suspended after stop-and-start" do
162
+ test "value of auto increment key is kept after stop-and-start" do
165
163
  assert !File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-02.json'))
166
164
 
167
165
  d1 = create_driver(conf2)
168
- d1.run(timeout: 0.5) do
169
- d1.instance.emit(4)
166
+ d1.run(timeout: 1) do
167
+ d1.instance.emit(2)
170
168
  end
171
169
 
172
170
  first_id1 = d1.events.first[2]['id']
@@ -178,8 +176,8 @@ class DummyTest < Test::Unit::TestCase
178
176
  assert File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-02.json'))
179
177
 
180
178
  d2 = create_driver(conf2)
181
- d2.run(timeout: 0.5) do
182
- d2.instance.emit(4)
179
+ d2.run(timeout: 1) do
180
+ d2.instance.emit(2)
183
181
  end
184
182
  d2.events
185
183
 
@@ -218,7 +218,7 @@ class ForwardInputTest < Test::Unit::TestCase
218
218
  }
219
219
  end
220
220
 
221
- assert_equal(records, d.events.sort_by {|a| a[1] })
221
+ assert_equal(records, d.events.sort_by {|a| a[0] })
222
222
  end
223
223
 
224
224
  test 'json_with_newline' do
@@ -237,7 +237,7 @@ class ForwardInputTest < Test::Unit::TestCase
237
237
  }
238
238
  end
239
239
 
240
- assert_equal(records, d.events.sort_by {|a| a[1] })
240
+ assert_equal(records, d.events.sort_by {|a| a[0] })
241
241
  end
242
242
  end
243
243
 
@@ -226,7 +226,7 @@ class TailInputTest < Test::Unit::TestCase
226
226
  d = create_driver(config)
227
227
  msg = 'test' * 2000 # in_tail reads 8192 bytes at once.
228
228
 
229
- d.run(expect_emits: 1) do
229
+ d.run(expect_emits: num_events, timeout: 1) do
230
230
  File.open("#{TMP_DIR}/tail.txt", "ab") {|f|
231
231
  f.puts msg
232
232
  f.puts msg
@@ -237,7 +237,7 @@ class TailInputTest < Test::Unit::TestCase
237
237
  assert_equal(true, events.length > 0)
238
238
  assert_equal({"message" => msg}, events[0][2])
239
239
  assert_equal({"message" => msg}, events[1][2])
240
- assert_equal(num_events, d.emit_count)
240
+ assert num_events <= d.emit_count
241
241
  end
242
242
 
243
243
  data(flat: CONFIG_READ_FROM_HEAD + SINGLE_LINE_CONFIG,
@@ -1078,11 +1078,11 @@ class TailInputTest < Test::Unit::TestCase
1078
1078
  "refresh_interval" => 1,
1079
1079
  })
1080
1080
  d = create_driver(config, false)
1081
- d.run(expect_emits: 1, shutdown: false) do
1081
+ d.end_if { d.instance.instance_variable_get(:@tails).keys.size >= 1 }
1082
+ d.run(expect_emits: 1, shutdown: false, timeout: 1) do
1082
1083
  File.open("#{TMP_DIR}/tail.txt", "ab") { |f| f.puts "test3\n" }
1083
1084
  end
1084
1085
 
1085
- assert_equal 1, d.instance.instance_variable_get(:@tails).keys.size
1086
1086
  cleanup_directory(TMP_DIR)
1087
1087
  waiting(20) { sleep 0.1 until Dir.glob("#{TMP_DIR}/*.txt").size == 0 } # Ensure file is deleted on Windows
1088
1088
  waiting(5) { sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size == 0 }
@@ -1164,7 +1164,7 @@ class TailInputTest < Test::Unit::TestCase
1164
1164
 
1165
1165
  Timecop.freeze(2010, 1, 2, 3, 4, 5) do
1166
1166
  EX_PATHS.each do |path|
1167
- mock.proxy(Fluent::Plugin::TailInput::TailWatcher).new(path, anything, anything, true, 1000, anything, anything, anything, anything, false).once
1167
+ mock.proxy(Fluent::Plugin::TailInput::TailWatcher).new(path, anything, anything, true, anything, nil, anything).once
1168
1168
  end
1169
1169
 
1170
1170
  plugin.refresh_watchers
@@ -1173,7 +1173,7 @@ class TailInputTest < Test::Unit::TestCase
1173
1173
  mock.proxy(plugin).detach_watcher_after_rotate_wait(plugin.instance_variable_get(:@tails)['test/plugin/data/2010/01/20100102-030405.log'])
1174
1174
 
1175
1175
  Timecop.freeze(2010, 1, 2, 3, 4, 6) do
1176
- mock.proxy(Fluent::Plugin::TailInput::TailWatcher).new('test/plugin/data/2010/01/20100102-030406.log', anything, anything, true, 1000, anything, anything, anything, anything, false).once
1176
+ mock.proxy(Fluent::Plugin::TailInput::TailWatcher).new('test/plugin/data/2010/01/20100102-030406.log', anything, anything, true, anything, nil, anything).once
1177
1177
  plugin.refresh_watchers
1178
1178
 
1179
1179
  flexstub(Fluent::Plugin::TailInput::TailWatcher) do |watcherclass|
@@ -284,6 +284,29 @@ EOL
284
284
  assert_equal 1235, d.instance.discovery_manager.services[1].port
285
285
  end
286
286
 
287
+ test 'pass username and password as empty string to HandshakeProtocol' do
288
+ config_path = File.join(TMP_DIR, "sd_file.conf")
289
+ File.open(config_path, 'w') do |file|
290
+ file.write(%[
291
+ - 'host': 127.0.0.1
292
+ 'port': 1234
293
+ 'weight': 1
294
+ ])
295
+ end
296
+
297
+ mock(Fluent::Plugin::ForwardOutput::HandshakeProtocol).new(log: anything, hostname: nil, shared_key: anything, password: '', username: '')
298
+ @d = d = create_driver(%[
299
+ <service_discovery>
300
+ @type file
301
+ path #{config_path}
302
+ </service_discovery>
303
+ ])
304
+
305
+ assert_equal 1, d.instance.discovery_manager.services.size
306
+ assert_equal '127.0.0.1', d.instance.discovery_manager.services[0].host
307
+ assert_equal 1234, d.instance.discovery_manager.services[0].port
308
+ end
309
+
287
310
  test 'compress_default_value' do
288
311
  @d = d = create_driver
289
312
  assert_equal :text, d.instance.compress
@@ -997,7 +1020,11 @@ EOL
997
1020
  e = assert_raise Fluent::UnrecoverableError do
998
1021
  d.instance_start
999
1022
  end
1000
- assert_match(/Connection refused/, e.message)
1023
+ if Fluent.windows?
1024
+ assert_match(/No connection could be made because the target machine actively refused it/, e.message)
1025
+ else
1026
+ assert_match(/Connection refused/, e.message)
1027
+ end
1001
1028
 
1002
1029
  d.instance_shutdown
1003
1030
  end
@@ -617,7 +617,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
617
617
  assert{ !chunks[1].empty? }
618
618
 
619
619
  30.times do |i| # large enough
620
- now = first_failure + 60 * 0.8 + 2 + i
620
+ now = first_failure + 60 * 0.8 + 2 + [i, 9].min # must be less than retry_timeout
621
621
  Timecop.freeze( now )
622
622
  @i.flush_thread_wakeup
623
623
 
@@ -21,7 +21,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
21
21
  assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
22
22
  assert_equal(@expected, record)
23
23
  }
24
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP, @parser.instance.patterns['format'])
24
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
25
25
  assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
26
26
  end
27
27
 
@@ -35,6 +35,24 @@ class SyslogParserTest < ::Test::Unit::TestCase
35
35
  assert_equal('%b %d %M:%S:%H', @parser.instance.patterns['time_format'])
36
36
  end
37
37
 
38
+ def test_parse_with_time_format2
39
+ @parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ')
40
+ @parser.instance.parse('2020-03-03T10:14:29Z 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
41
+ assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
42
+ assert_equal(@expected, record)
43
+ }
44
+ assert_equal('%Y-%m-%dT%H:%M:%SZ', @parser.instance.patterns['time_format'])
45
+ end
46
+
47
+ def test_parse_with_time_format_rfc5424
48
+ @parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'message_format' => 'rfc5424')
49
+ @parser.instance.parse('2020-03-03T10:14:29Z 192.168.0.1 fluentd 11111 - - [error] Syslog test') { |time, record|
50
+ assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
51
+ assert_equal(@expected.merge('host' => '192.168.0.1', 'msgid' => '-', 'extradata' => '-'), record)
52
+ }
53
+ assert_equal('%Y-%m-%dT%H:%M:%SZ', @parser.instance.patterns['time_format'])
54
+ end
55
+
38
56
  data('regexp' => 'regexp', 'string' => 'string')
39
57
  def test_parse_with_subsecond_time(param)
40
58
  @parser.configure('time_format' => '%b %d %H:%M:%S.%N', 'parser_type' => param)
@@ -51,7 +69,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
51
69
  assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
52
70
  assert_equal(@expected.merge('pri' => 6), record)
53
71
  }
54
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_WITH_PRI, @parser.instance.patterns['format'])
72
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
55
73
  assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
56
74
  end
57
75
 
@@ -71,7 +89,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
71
89
  assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
72
90
  assert_equal(@expected, record)
73
91
  }
74
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP, @parser.instance.patterns['format'])
92
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
75
93
  assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
76
94
  end
77
95
 
@@ -184,8 +202,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
184
202
  assert_equal "-", record["extradata"]
185
203
  assert_equal "Hi, from Fluentd!", record["message"]
186
204
  end
187
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
188
- @parser.instance.patterns['format'])
205
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
189
206
  end
190
207
 
191
208
  def test_parse_with_rfc5424_message_trailing_eol
@@ -202,8 +219,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
202
219
  assert_equal "-", record["extradata"]
203
220
  assert_equal "Hi, from Fluentd!", record["message"]
204
221
  end
205
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
206
- @parser.instance.patterns['format'])
222
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
207
223
  end
208
224
 
209
225
  def test_parse_with_rfc5424_multiline_message
@@ -220,8 +236,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
220
236
  assert_equal "-", record["extradata"]
221
237
  assert_equal "Hi,\nfrom\nFluentd!", record["message"]
222
238
  end
223
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
224
- @parser.instance.patterns['format'])
239
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
225
240
  end
226
241
 
227
242
  def test_parse_with_rfc5424_message_and_without_priority
@@ -237,8 +252,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
237
252
  assert_equal "-", record["extradata"]
238
253
  assert_equal "Hi, from Fluentd!", record["message"]
239
254
  end
240
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_NO_PRI,
241
- @parser.instance.patterns['format'])
255
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
242
256
  end
243
257
 
244
258
  def test_parse_with_rfc5424_empty_message_and_without_priority
@@ -254,8 +268,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
254
268
  assert_equal "-", record["extradata"]
255
269
  assert_nil record["message"]
256
270
  end
257
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_NO_PRI,
258
- @parser.instance.patterns['format'])
271
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
259
272
  end
260
273
 
261
274
  def test_parse_with_rfc5424_message_without_time_format
@@ -408,7 +421,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
408
421
  assert_equal(event_time("Feb 28 00:00:12", format: '%b %d %M:%S:%H'), time)
409
422
  assert_equal(@expected, record)
410
423
  end
411
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP, @parser.instance.patterns['format'])
424
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
412
425
  end
413
426
 
414
427
  data('regexp' => 'regexp', 'string' => 'string')
@@ -424,7 +437,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
424
437
  assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
425
438
  assert_equal(@expected.merge('pri' => 6), record)
426
439
  end
427
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_WITH_PRI, @parser.instance.patterns['format'])
440
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
428
441
  end
429
442
 
430
443
  data('regexp' => 'regexp', 'string' => 'string')
@@ -443,8 +456,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
443
456
  assert_equal "-", record["extradata"]
444
457
  assert_equal "Hi, from Fluentd!", record["message"]
445
458
  end
446
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
447
- @parser.instance.patterns['format'])
459
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
448
460
  end
449
461
 
450
462
  data('regexp' => 'regexp', 'string' => 'string')
@@ -464,9 +476,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
464
476
  record["extradata"]
465
477
  assert_equal "Hi, from Fluentd!", record["message"]
466
478
  end
467
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
468
- @parser.instance.patterns['format'])
469
- end
479
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])end
470
480
 
471
481
  data('regexp' => 'regexp', 'string' => 'string')
472
482
  def test_parse_with_both_message_type(param)
@@ -482,7 +492,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
482
492
  assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
483
493
  assert_equal(@expected.merge('pri' => 1), record)
484
494
  end
485
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_WITH_PRI, @parser.instance.patterns['format'])
495
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
486
496
 
487
497
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
488
498
  @parser.instance.parse(text) do |time, record|
@@ -493,15 +503,21 @@ class SyslogParserTest < ::Test::Unit::TestCase
493
503
  record["extradata"]
494
504
  assert_equal "Hi, from Fluentd!", record["message"]
495
505
  end
496
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
497
- @parser.instance.patterns['format'])
506
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
507
+
508
+ text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test 2>1'
509
+ @parser.instance.parse(text) do |time, record|
510
+ assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
511
+ assert_equal(@expected.merge('pri' => 1, 'message'=> '[error] Syslog test 2>1'), record)
512
+ end
513
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
498
514
 
499
515
  text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
500
516
  @parser.instance.parse(text) do |time, record|
501
517
  assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
502
518
  assert_equal(@expected.merge('pri' => 1), record)
503
519
  end
504
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_WITH_PRI, @parser.instance.patterns['format'])
520
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
505
521
 
506
522
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
507
523
  @parser.instance.parse(text) do |time, record|
@@ -511,8 +527,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
511
527
  assert_equal "-", record["extradata"]
512
528
  assert_equal "Hi, from Fluentd!", record["message"]
513
529
  end
514
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
515
- @parser.instance.patterns['format'])
530
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
516
531
  end
517
532
 
518
533
  data('regexp' => 'regexp', 'string' => 'string')
@@ -529,7 +544,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
529
544
  assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
530
545
  assert_equal(@expected.merge('pri' => 6), record)
531
546
  end
532
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_WITH_PRI, @parser.instance.patterns['format'])
547
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
533
548
 
534
549
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
535
550
  @parser.instance.parse(text) do |time, record|
@@ -540,15 +555,14 @@ class SyslogParserTest < ::Test::Unit::TestCase
540
555
  record["extradata"]
541
556
  assert_equal "Hi, from Fluentd!", record["message"]
542
557
  end
543
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
544
- @parser.instance.patterns['format'])
558
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
545
559
 
546
560
  text = '<16>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
547
561
  @parser.instance.parse(text) do |time, record|
548
562
  assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
549
563
  assert_equal(@expected.merge('pri' => 16), record)
550
564
  end
551
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_WITH_PRI, @parser.instance.patterns['format'])
565
+ assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
552
566
 
553
567
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
554
568
  @parser.instance.parse(text) do |time, record|
@@ -558,8 +572,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
558
572
  assert_equal "-", record["extradata"]
559
573
  assert_equal "Hi, from Fluentd!", record["message"]
560
574
  end
561
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
562
- @parser.instance.patterns['format'])
575
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
563
576
 
564
577
  text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd without subseconds!'
565
578
  @parser.instance.parse(text) do |time, record|
@@ -569,8 +582,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
569
582
  assert_equal "-", record["extradata"]
570
583
  assert_equal "Hi, from Fluentd without subseconds!", record["message"]
571
584
  end
572
- assert_equal(Fluent::Plugin::SyslogParser::REGEXP_RFC5424_WITH_PRI,
573
- @parser.instance.patterns['format'])
585
+ assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
574
586
  end
575
587
  end
576
588
  end