fluentd 1.10.4-x86-mingw32 → 1.11.0-x86-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.

@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '1.10.4'
19
+ VERSION = '1.11.0'
20
20
 
21
21
  end
@@ -22,9 +22,14 @@ class GCStatInputTest < Test::Unit::TestCase
22
22
  assert_equal("t1", d.instance.tag)
23
23
  end
24
24
 
25
- def test_emit
25
+ def setup_gc_stat
26
26
  stat = GC.stat
27
27
  stub(GC).stat { stat }
28
+ stat
29
+ end
30
+
31
+ def test_emit
32
+ stat = setup_gc_stat
28
33
 
29
34
  d = create_driver
30
35
  d.run(expect_emits: 2)
@@ -36,4 +41,22 @@ class GCStatInputTest < Test::Unit::TestCase
36
41
  assert(events[i][1].is_a?(Fluent::EventTime))
37
42
  }
38
43
  end
44
+
45
+ def test_emit_with_use_symbol_keys_false
46
+ stat = setup_gc_stat
47
+ result = {}
48
+ stat.each_pair { |k, v|
49
+ result[k.to_s] = v
50
+ }
51
+
52
+ d = create_driver(CONFIG + "use_symbol_keys false")
53
+ d.run(expect_emits: 2)
54
+
55
+ events = d.events
56
+ assert(events.length > 0)
57
+ events.each_index {|i|
58
+ assert_equal(result, events[i][2])
59
+ assert(events[i][1].is_a?(Fluent::EventTime))
60
+ }
61
+ end
39
62
  end
@@ -1,125 +1,181 @@
1
1
  require_relative '../helper'
2
- require 'fluent/test'
2
+ require 'fluent/test/driver/input'
3
3
  require 'fluent/plugin/in_unix'
4
4
 
5
- module StreamInputTest
5
+ class UnixInputTest < Test::Unit::TestCase
6
6
  def setup
7
7
  Fluent::Test.setup
8
+ @d = nil
8
9
  end
9
10
 
10
- def test_time
11
- d = create_driver
11
+ def teardown
12
+ @d.instance_shutdown if @d
13
+ end
12
14
 
13
- time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
15
+ TMP_DIR = File.dirname(__FILE__) + "/../tmp/in_unix#{ENV['TEST_ENV_NUMBER']}"
16
+ CONFIG = %[
17
+ path #{TMP_DIR}/unix
18
+ backlog 1000
19
+ ]
20
+
21
+ def create_driver(conf = CONFIG)
22
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::UnixInput).configure(conf)
23
+ end
14
24
 
15
- d.expect_emit "tag1", time, {"a"=>1}
16
- d.expect_emit "tag2", time, {"a"=>2}
25
+ def packer(*args)
26
+ Fluent::MessagePackFactory.msgpack_packer(*args)
27
+ end
17
28
 
18
- d.run do
19
- d.expected_emits.each {|tag,_time,record|
20
- send_data Fluent::MessagePackFactory.msgpack_packer.write([tag, _time, record]).to_s
29
+ def unpacker
30
+ Fluent::MessagePackFactory.msgpack_unpacker
31
+ end
32
+
33
+ def send_data(data)
34
+ io = UNIXSocket.new("#{TMP_DIR}/unix")
35
+ begin
36
+ io.write data
37
+ ensure
38
+ io.close
39
+ end
40
+ end
41
+
42
+ def test_configure
43
+ @d = create_driver
44
+ assert_equal "#{TMP_DIR}/unix", @d.instance.path
45
+ assert_equal 1000, @d.instance.backlog
46
+ end
47
+
48
+ def test_time
49
+ @d = create_driver
50
+
51
+ time = Fluent::EventTime.now
52
+ records = [
53
+ ["tag1", 0, {"a" => 1}],
54
+ ["tag2", nil, {"a" => 2}],
55
+ ]
56
+
57
+ @d.run(expect_records: records.length, timeout: 5) do
58
+ records.each {|tag, _time, record|
59
+ send_data packer.write([tag, _time, record]).to_s
21
60
  }
22
61
  end
62
+
63
+ @d.events.each_with_index { |e, i|
64
+ orig = records[i]
65
+ assert_equal(orig[0], e[0])
66
+ assert_true(time <= e[1])
67
+ assert_equal(orig[2], e[2])
68
+ }
23
69
  end
24
70
 
25
71
  def test_message
26
- d = create_driver
72
+ @d = create_driver
27
73
 
28
- time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
29
-
30
- d.expect_emit "tag1", time, {"a"=>1}
31
- d.expect_emit "tag2", time, {"a"=>2}
74
+ time = Fluent::EventTime.now
75
+ records = [
76
+ ["tag1", time, {"a" => 1}],
77
+ ["tag2", time, {"a" => 2}],
78
+ ]
32
79
 
33
- d.run do
34
- d.expected_emits.each {|tag,_time,record|
35
- send_data Fluent::MessagePackFactory.msgpack_packer.write([tag, _time, record]).to_s
80
+ @d.run(expect_records: records.length, timeout: 5) do
81
+ records.each {|tag, _time, record|
82
+ send_data packer.write([tag, _time, record]).to_s
36
83
  }
37
84
  end
85
+
86
+ assert_equal(records, @d.events)
38
87
  end
39
88
 
40
89
  def test_forward
41
- d = create_driver
90
+ @d = create_driver
42
91
 
43
92
  time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
93
+ records = [
94
+ ["tag1", time, {"a" => 1}],
95
+ ["tag1", time, {"a" => 2}]
96
+ ]
44
97
 
45
- d.expect_emit "tag1", time, {"a"=>1}
46
- d.expect_emit "tag1", time, {"a"=>2}
47
-
48
- d.run do
98
+ @d.run(expect_records: records.length, timeout: 20) do
49
99
  entries = []
50
- d.expected_emits.each {|tag,_time,record|
100
+ records.each {|tag, _time, record|
51
101
  entries << [_time, record]
52
102
  }
53
- send_data Fluent::MessagePackFactory.msgpack_packer.write(["tag1", entries]).to_s
103
+ send_data packer.write(["tag1", entries]).to_s
54
104
  end
105
+ assert_equal(records, @d.events)
55
106
  end
56
107
 
57
108
  def test_packed_forward
58
- d = create_driver
109
+ @d = create_driver
59
110
 
60
- time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
61
-
62
- d.expect_emit "tag1", time, {"a"=>1}
63
- d.expect_emit "tag1", time, {"a"=>2}
111
+ time = Fluent::EventTime.now
112
+ records = [
113
+ ["tag1", time, {"a" => 1}],
114
+ ["tag1", time, {"a" => 2}],
115
+ ]
64
116
 
65
- d.run do
117
+ @d.run(expect_records: records.length, timeout: 20) do
66
118
  entries = ''
67
- d.expected_emits.each {|tag,_time,record|
68
- Fluent::MessagePackFactory.msgpack_packer(entries).write([_time, record]).flush
119
+ records.each {|_tag, _time, record|
120
+ packer(entries).write([_time, record]).flush
69
121
  }
70
- send_data Fluent::MessagePackFactory.msgpack_packer.write(["tag1", entries]).to_s
122
+ send_data packer.write(["tag1", entries]).to_s
71
123
  end
124
+ assert_equal(records, @d.events)
72
125
  end
73
126
 
74
127
  def test_message_json
75
- d = create_driver
128
+ @d = create_driver
129
+
130
+ time = Fluent::EventTime.now
131
+ records = [
132
+ ["tag1", time, {"a" => 1}],
133
+ ["tag2", time, {"a" => 2}],
134
+ ]
135
+
136
+ @d.run(expect_records: records.length, timeout: 5) do
137
+ tag, _time, record = records[0]
138
+ send_data [tag, _time.to_i, record].to_json
139
+ tag, _time, record = records[1]
140
+ send_data [tag, _time.to_f, record].to_json
141
+ end
76
142
 
77
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
143
+ assert_equal(records, @d.events)
144
+ end
145
+
146
+ def test_message_with_tag
147
+ @d = create_driver(CONFIG + "tag new_tag")
78
148
 
79
- d.expect_emit "tag1", time, {"a"=>1}
80
- d.expect_emit "tag2", time, {"a"=>2}
149
+ time = Fluent::EventTime.now
150
+ records = [
151
+ ["tag1", time, {"a" => 1}],
152
+ ["tag2", time, {"a" => 2}],
153
+ ]
81
154
 
82
- d.run do
83
- d.expected_emits.each {|tag,_time,record|
84
- send_data [tag, time, record].to_json
155
+ @d.run(expect_records: records.length, timeout: 5) do
156
+ records.each {|tag, _time, record|
157
+ send_data packer.write([tag, _time, record]).to_s
85
158
  }
86
159
  end
87
- end
88
160
 
89
- def create_driver(klass, conf)
90
- Fluent::Test::InputTestDriver.new(klass).configure(conf)
161
+ @d.events.each { |event|
162
+ assert_equal("new_tag", event[0])
163
+ }
91
164
  end
92
165
 
93
- def send_data(data)
94
- io = connect
95
- begin
96
- io.write data
97
- ensure
98
- io.close
166
+ data('string chunk' => 'broken string',
167
+ 'integer chunk' => 10)
168
+ def test_broken_message(data)
169
+ @d = create_driver
170
+ @d.run(shutdown: false, timeout: 5) do
171
+ @d.instance.__send__(:on_message, data)
99
172
  end
100
- end
101
- end
102
-
103
- class UnixInputTest < Test::Unit::TestCase
104
- include StreamInputTest
105
-
106
- TMP_DIR = File.dirname(__FILE__) + "/../tmp/in_unix#{ENV['TEST_ENV_NUMBER']}"
107
- CONFIG = %[
108
- path #{TMP_DIR}/unix
109
- backlog 1000
110
- ]
111
173
 
112
- def create_driver(conf=CONFIG)
113
- super(Fluent::UnixInput, conf)
114
- end
115
-
116
- def test_configure
117
- d = create_driver
118
- assert_equal "#{TMP_DIR}/unix", d.instance.path
119
- assert_equal 1000, d.instance.backlog
120
- end
174
+ assert_equal 0, @d.events.size
121
175
 
122
- def connect
123
- UNIXSocket.new("#{TMP_DIR}/unix")
176
+ logs = @d.instance.log.logs
177
+ assert_equal 1, logs.select { |line|
178
+ line =~ / \[warn\]: incoming data is broken: msg=#{data.inspect}/
179
+ }.size, "should not accept broken chunk"
124
180
  end
125
181
  end unless Fluent.windows?
@@ -35,8 +35,9 @@ 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')
38
+ data('regexp' => 'regexp', 'string' => 'string')
39
+ def test_parse_with_time_format2(param)
40
+ @parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'parser_type' => param)
40
41
  @parser.instance.parse('2020-03-03T10:14:29Z 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
41
42
  assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
42
43
  assert_equal(@expected, record)
@@ -198,11 +199,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
198
199
  end
199
200
 
200
201
  class TestRFC5424Regexp < self
201
- def test_parse_with_rfc5424_message
202
+ data('regexp' => 'regexp', 'string' => 'string')
203
+ def test_parse_with_rfc5424_message(param)
202
204
  @parser.configure(
203
205
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
204
206
  'message_format' => 'rfc5424',
205
207
  'with_priority' => true,
208
+ 'parser_type' => param
206
209
  )
207
210
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
208
211
  @parser.instance.parse(text) do |time, record|
@@ -215,11 +218,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
215
218
  assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
216
219
  end
217
220
 
218
- def test_parse_with_rfc5424_message_trailing_eol
221
+ data('regexp' => 'regexp', 'string' => 'string')
222
+ def test_parse_with_rfc5424_message_trailing_eol(param)
219
223
  @parser.configure(
220
224
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
221
225
  'message_format' => 'rfc5424',
222
226
  'with_priority' => true,
227
+ 'parser_type' => param
223
228
  )
224
229
  text = "<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!\n"
225
230
  @parser.instance.parse(text) do |time, record|
@@ -232,11 +237,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
232
237
  assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
233
238
  end
234
239
 
235
- def test_parse_with_rfc5424_multiline_message
240
+ data('regexp' => 'regexp', 'string' => 'string')
241
+ def test_parse_with_rfc5424_multiline_message(param)
236
242
  @parser.configure(
237
243
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
238
244
  'message_format' => 'rfc5424',
239
245
  'with_priority' => true,
246
+ 'parser_type' => param
240
247
  )
241
248
  text = "<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi,\nfrom\nFluentd!"
242
249
  @parser.instance.parse(text) do |time, record|
@@ -249,10 +256,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
249
256
  assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
250
257
  end
251
258
 
252
- def test_parse_with_rfc5424_message_and_without_priority
259
+ data('regexp' => 'regexp', 'string' => 'string')
260
+ def test_parse_with_rfc5424_message_and_without_priority(param)
253
261
  @parser.configure(
254
262
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
255
263
  'message_format' => 'rfc5424',
264
+ 'parser_type' => param
256
265
  )
257
266
  text = '2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
258
267
  @parser.instance.parse(text) do |time, record|
@@ -265,10 +274,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
265
274
  assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
266
275
  end
267
276
 
268
- def test_parse_with_rfc5424_empty_message_and_without_priority
277
+ data('regexp' => 'regexp', 'string' => 'string')
278
+ def test_parse_with_rfc5424_empty_message_and_without_priority(param)
269
279
  @parser.configure(
270
280
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
271
281
  'message_format' => 'rfc5424',
282
+ 'parser_type' => param
272
283
  )
273
284
  text = '2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - -'
274
285
  @parser.instance.parse(text) do |time, record|
@@ -281,10 +292,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
281
292
  assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
282
293
  end
283
294
 
284
- def test_parse_with_rfc5424_message_without_time_format
295
+ data('regexp' => 'regexp', 'string' => 'string')
296
+ def test_parse_with_rfc5424_message_without_time_format(param)
285
297
  @parser.configure(
286
298
  'message_format' => 'rfc5424',
287
299
  'with_priority' => true,
300
+ 'parser_type' => param
288
301
  )
289
302
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
290
303
  @parser.instance.parse(text) do |time, record|
@@ -296,10 +309,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
296
309
  end
297
310
  end
298
311
 
299
- def test_parse_with_rfc5424_message_with_priority_and_pid
312
+ data('regexp' => 'regexp', 'string' => 'string')
313
+ def test_parse_with_rfc5424_message_with_priority_and_pid(param)
300
314
  @parser.configure(
301
315
  'message_format' => 'rfc5424',
302
316
  'with_priority' => true,
317
+ 'parser_type' => param
303
318
  )
304
319
  text = '<28>1 2018-09-26T15:54:26.620412+09:00 machine minissdpd 1298 - - peer 192.168.0.5:50123 is not from a LAN'
305
320
  @parser.instance.parse(text) do |time, record|
@@ -311,11 +326,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
311
326
  end
312
327
  end
313
328
 
314
- def test_parse_with_rfc5424_structured_message
329
+ data('regexp' => 'regexp', 'string' => 'string')
330
+ def test_parse_with_rfc5424_structured_message(param)
315
331
  @parser.configure(
316
332
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
317
333
  'message_format' => 'rfc5424',
318
334
  'with_priority' => true,
335
+ 'parser_type' => param
319
336
  )
320
337
  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!'
321
338
  @parser.instance.parse(text) do |time, record|
@@ -328,11 +345,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
328
345
  end
329
346
  end
330
347
 
331
- def test_parse_with_rfc5424_multiple_structured_message
348
+ data('regexp' => 'regexp', 'string' => 'string')
349
+ def test_parse_with_rfc5424_multiple_structured_message(param)
332
350
  @parser.configure(
333
351
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
334
352
  'message_format' => 'rfc5424',
335
353
  'with_priority' => true,
354
+ 'parser_type' => param
336
355
  )
337
356
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"][exampleSDID@20224 class="high"] Hi, from Fluentd!'
338
357
  @parser.instance.parse(text) do |time, record|
@@ -345,11 +364,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
345
364
  end
346
365
  end
347
366
 
348
- def test_parse_with_rfc5424_message_includes_right_bracket
367
+ data('regexp' => 'regexp', 'string' => 'string')
368
+ def test_parse_with_rfc5424_message_includes_right_bracket(param)
349
369
  @parser.configure(
350
370
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
351
371
  'message_format' => 'rfc5424',
352
372
  'with_priority' => true,
373
+ 'parser_type' => param
353
374
  )
354
375
  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]!'
355
376
  @parser.instance.parse(text) do |time, record|
@@ -362,11 +383,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
362
383
  end
363
384
  end
364
385
 
365
- def test_parse_with_rfc5424_empty_message
386
+ data('regexp' => 'regexp', 'string' => 'string')
387
+ def test_parse_with_rfc5424_empty_message(param)
366
388
  @parser.configure(
367
389
  'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
368
390
  'message_format' => 'rfc5424',
369
391
  'with_priority' => true,
392
+ 'parser_type' => param
370
393
  )
371
394
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"]'
372
395
  @parser.instance.parse(text) do |time, record|
@@ -379,10 +402,35 @@ class SyslogParserTest < ::Test::Unit::TestCase
379
402
  end
380
403
  end
381
404
 
382
- def test_parse_with_rfc5424_message_without_subseconds
405
+ data('regexp' => 'regexp', 'string' => 'string')
406
+ def test_parse_with_rfc5424_space_empty_message(param)
407
+ @parser.configure(
408
+ 'message_format' => 'rfc5424',
409
+ 'with_priority' => true,
410
+ 'parser_type' => param
411
+ )
412
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] '
413
+ @parser.instance.parse(text) do |time, record|
414
+ if param == 'string'
415
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
416
+ assert_equal "11111", record["pid"]
417
+ assert_equal "ID24224", record["msgid"]
418
+ assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
419
+ record["extradata"]
420
+ assert_equal '', record["message"]
421
+ else
422
+ assert_nil time
423
+ assert_nil record
424
+ end
425
+ end
426
+ end
427
+
428
+ data('regexp' => 'regexp', 'string' => 'string')
429
+ def test_parse_with_rfc5424_message_without_subseconds(param)
383
430
  @parser.configure(
384
431
  'message_format' => 'rfc5424',
385
432
  'with_priority' => true,
433
+ 'parser_type' => param
386
434
  )
387
435
  text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
388
436
  @parser.instance.parse(text) do |time, record|
@@ -394,10 +442,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
394
442
  end
395
443
  end
396
444
 
397
- def test_parse_with_rfc5424_message_both_timestamp
445
+ data('regexp' => 'regexp', 'string' => 'string')
446
+ def test_parse_with_rfc5424_message_both_timestamp(param)
398
447
  @parser.configure(
399
448
  'message_format' => 'rfc5424',
400
449
  'with_priority' => true,
450
+ 'parser_type' => param
401
451
  )
402
452
  text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
403
453
  @parser.instance.parse(text) do |time, record|
@@ -431,7 +481,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
431
481
  assert_equal(event_time("Feb 28 00:00:12", format: '%b %d %M:%S:%H'), time)
432
482
  assert_equal(@expected, record)
433
483
  end
434
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
435
484
  end
436
485
 
437
486
  data('regexp' => 'regexp', 'string' => 'string')
@@ -447,7 +496,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
447
496
  assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
448
497
  assert_equal(@expected.merge('pri' => 6), record)
449
498
  end
450
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
451
499
  end
452
500
 
453
501
  data('regexp' => 'regexp', 'string' => 'string')
@@ -467,7 +515,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
467
515
  assert_equal 16, record["pri"]
468
516
  assert_equal "Hi, from Fluentd!", record["message"]
469
517
  end
470
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
471
518
  end
472
519
 
473
520
  data('regexp' => 'regexp', 'string' => 'string')
@@ -487,7 +534,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
487
534
  record["extradata"]
488
535
  assert_equal "Hi, from Fluentd!", record["message"]
489
536
  end
490
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])end
537
+ end
491
538
 
492
539
  data('regexp' => 'regexp', 'string' => 'string')
493
540
  def test_parse_with_both_message_type(param)
@@ -503,7 +550,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
503
550
  assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
504
551
  assert_equal(@expected.merge('pri' => 1), record)
505
552
  end
506
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
507
553
 
508
554
  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!'
509
555
  @parser.instance.parse(text) do |time, record|
@@ -514,21 +560,18 @@ class SyslogParserTest < ::Test::Unit::TestCase
514
560
  record["extradata"]
515
561
  assert_equal "Hi, from Fluentd!", record["message"]
516
562
  end
517
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
518
563
 
519
564
  text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test 2>1'
520
565
  @parser.instance.parse(text) do |time, record|
521
566
  assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
522
567
  assert_equal(@expected.merge('pri' => 1, 'message'=> '[error] Syslog test 2>1'), record)
523
568
  end
524
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
525
569
 
526
570
  text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
527
571
  @parser.instance.parse(text) do |time, record|
528
572
  assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
529
573
  assert_equal(@expected.merge('pri' => 1), record)
530
574
  end
531
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
532
575
 
533
576
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
534
577
  @parser.instance.parse(text) do |time, record|
@@ -538,7 +581,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
538
581
  assert_equal "-", record["extradata"]
539
582
  assert_equal "Hi, from Fluentd!", record["message"]
540
583
  end
541
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
542
584
  end
543
585
 
544
586
  data('regexp' => 'regexp', 'string' => 'string')
@@ -555,7 +597,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
555
597
  assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
556
598
  assert_equal(@expected.merge('pri' => 6), record)
557
599
  end
558
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
559
600
 
560
601
  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!'
561
602
  @parser.instance.parse(text) do |time, record|
@@ -566,14 +607,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
566
607
  record["extradata"]
567
608
  assert_equal "Hi, from Fluentd!", record["message"]
568
609
  end
569
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
570
610
 
571
611
  text = '<16>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
572
612
  @parser.instance.parse(text) do |time, record|
573
613
  assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
574
614
  assert_equal(@expected.merge('pri' => 16), record)
575
615
  end
576
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
577
616
 
578
617
  text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
579
618
  @parser.instance.parse(text) do |time, record|
@@ -583,7 +622,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
583
622
  assert_equal "-", record["extradata"]
584
623
  assert_equal "Hi, from Fluentd!", record["message"]
585
624
  end
586
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
587
625
 
588
626
  text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd without subseconds!'
589
627
  @parser.instance.parse(text) do |time, record|
@@ -593,7 +631,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
593
631
  assert_equal "-", record["extradata"]
594
632
  assert_equal "Hi, from Fluentd without subseconds!", record["message"]
595
633
  end
596
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
597
634
  end
598
635
  end
599
636
  end