fluentd 0.12.28 → 0.12.29

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.

@@ -172,10 +172,7 @@ class RecordTransformerFilterTest < Test::Unit::TestCase
172
172
  yield d if block_given?
173
173
  d.run {
174
174
  msgs.each do |msg|
175
- record = {
176
- 'eventType0' => 'bar',
177
- 'message' => msg,
178
- }
175
+ record = {'eventType0' => 'bar', 'message' => msg}
179
176
  record = record.merge(msg) if msg.is_a?(Hash)
180
177
  d.emit(record, @time)
181
178
  end
@@ -269,6 +266,23 @@ class RecordTransformerFilterTest < Test::Unit::TestCase
269
266
  end
270
267
  end
271
268
 
269
+ test "Prevent overwriting reserved keys such as tag with enable_ruby #{enable_ruby}" do
270
+ config = %[
271
+ enable_ruby #{enable_ruby}
272
+ <record>
273
+ new_tag ${tag}
274
+ new_record_tag ${record["tag"]}
275
+ </record>
276
+ ]
277
+ records = [{'tag' => 'tag', 'time' => 'time'}]
278
+ filtered = emit(config, records)
279
+ filtered.each_with_index do |(_t, r), i|
280
+ assert_not_equal('tag', r['new_tag'])
281
+ assert_equal(@tag, r['new_tag'])
282
+ assert_equal('tag', r['new_record_tag'])
283
+ end
284
+ end
285
+
272
286
  test "hash values with placeholders with enable_ruby #{enable_ruby}" do
273
287
  config = %[
274
288
  enable_ruby #{enable_ruby}
@@ -62,6 +62,32 @@ class TailInputTest < Test::Unit::TestCase
62
62
  end
63
63
  end
64
64
 
65
+ def test_configure_from_encoding
66
+ # If only specified from_encoding raise ConfigError
67
+ assert_raise(Fluent::ConfigError) do
68
+ d = create_driver(SINGLE_LINE_CONFIG + 'from_encoding utf-8')
69
+ end
70
+
71
+ # valid setting
72
+ d = create_driver %[
73
+ format /(?<message>.*)/
74
+ read_from_head true
75
+ from_encoding utf-8
76
+ encoding utf-8
77
+ ]
78
+ assert_equal Encoding::UTF_8, d.instance.from_encoding
79
+
80
+ # invalid from_encoding
81
+ assert_raise(Fluent::ConfigError) do
82
+ d = create_driver %[
83
+ format /(?<message>.*)/
84
+ read_from_head true
85
+ from_encoding no-such-encoding
86
+ encoding utf-8
87
+ ]
88
+ end
89
+ end
90
+
65
91
  # TODO: Should using more better approach instead of sleep wait
66
92
 
67
93
  def test_emit
@@ -332,6 +358,28 @@ class TailInputTest < Test::Unit::TestCase
332
358
  assert_equal(encoding, emits[0][2]['message'].encoding)
333
359
  end
334
360
 
361
+ def test_from_encoding
362
+ d = create_driver %[
363
+ format /(?<message>.*)/
364
+ read_from_head true
365
+ from_encoding cp932
366
+ encoding utf-8
367
+ ]
368
+
369
+ d.run do
370
+ sleep 1
371
+
372
+ File.open("#{TMP_DIR}/tail.txt", "w:cp932") {|f|
373
+ f.puts "\x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7".force_encoding(Encoding::CP932)
374
+ }
375
+ sleep 1
376
+ end
377
+
378
+ emits = d.emits
379
+ assert_equal("\x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7".force_encoding(Encoding::CP932).encode(Encoding::UTF_8), emits[0][2]['message'])
380
+ assert_equal(Encoding::UTF_8, emits[0][2]['message'].encoding)
381
+ end
382
+
335
383
  # multiline mode test
336
384
 
337
385
  def test_multiline
@@ -436,6 +484,31 @@ class TailInputTest < Test::Unit::TestCase
436
484
  end
437
485
  end
438
486
 
487
+ def test_multiline_from_encoding_of_flushed_record
488
+ d = create_driver %[
489
+ format multiline
490
+ format1 /^s (?<message1>[^\\n]+)(\\nf (?<message2>[^\\n]+))?(\\nf (?<message3>.*))?/
491
+ format_firstline /^[s]/
492
+ multiline_flush_interval 2s
493
+ read_from_head true
494
+ from_encoding cp932
495
+ encoding utf-8
496
+ ]
497
+
498
+ d.run do
499
+ sleep 1
500
+ File.open("#{TMP_DIR}/tail.txt", "w:cp932") { |f|
501
+ f.puts "s \x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7".force_encoding(Encoding::CP932)
502
+ }
503
+
504
+ sleep 4
505
+ emits = d.emits
506
+ assert_equal(1, emits.length)
507
+ assert_equal("\x82\xCD\x82\xEB\x81\x5B\x82\xED\x81\x5B\x82\xE9\x82\xC7".force_encoding(Encoding::CP932).encode(Encoding::UTF_8), emits[0][2]['message1'])
508
+ assert_equal(Encoding::UTF_8, emits[0][2]['message1'].encoding)
509
+ end
510
+ end
511
+
439
512
  def test_multiline_with_multiple_formats
440
513
  File.open("#{TMP_DIR}/tail.txt", "w") { |f| }
441
514
 
@@ -50,6 +50,48 @@ class RootAgentTest < ::Test::Unit::TestCase
50
50
  assert_nil ra.error_collector
51
51
  end
52
52
 
53
+ test 'raises configuration error for missing type of source' do
54
+ conf = <<-EOC
55
+ <source>
56
+ </source>
57
+ EOC
58
+ errmsg = "Missing '@type' parameter on <source> directive"
59
+ assert_raise Fluent::ConfigError.new(errmsg) do
60
+ configure_ra(conf)
61
+ end
62
+ end
63
+
64
+ test 'raises configuration error for missing type of match' do
65
+ conf = <<-EOC
66
+ <source>
67
+ @type test_in
68
+ </source>
69
+ <match *.**>
70
+ </match>
71
+ EOC
72
+ errmsg = "Missing '@type' parameter on <match> directive"
73
+ assert_raise Fluent::ConfigError.new(errmsg) do
74
+ configure_ra(conf)
75
+ end
76
+ end
77
+
78
+ test 'raises configuration error for missing type of filter' do
79
+ conf = <<-EOC
80
+ <source>
81
+ @type test_in
82
+ </source>
83
+ <filter *.**>
84
+ </filter>
85
+ <match *.**>
86
+ @type test_out
87
+ </match>
88
+ EOC
89
+ errmsg = "Missing '@type' parameter on <filter> directive"
90
+ assert_raise Fluent::ConfigError.new(errmsg) do
91
+ configure_ra(conf)
92
+ end
93
+ end
94
+
53
95
  test 'with plugins' do
54
96
  # check @type and type in one configuration
55
97
  conf = <<-EOC
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.28
4
+ version: 0.12.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-15 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -363,6 +363,7 @@ files:
363
363
  - lib/fluent/plugin/exec_util.rb
364
364
  - lib/fluent/plugin/file_util.rb
365
365
  - lib/fluent/plugin/filter_grep.rb
366
+ - lib/fluent/plugin/filter_parser.rb
366
367
  - lib/fluent/plugin/filter_record_transformer.rb
367
368
  - lib/fluent/plugin/filter_stdout.rb
368
369
  - lib/fluent/plugin/in_debug_agent.rb
@@ -428,6 +429,7 @@ files:
428
429
  - test/plugin/test_buf_memory.rb
429
430
  - test/plugin/test_file_util.rb
430
431
  - test/plugin/test_filter_grep.rb
432
+ - test/plugin/test_filter_parser.rb
431
433
  - test/plugin/test_filter_record_transformer.rb
432
434
  - test/plugin/test_filter_stdout.rb
433
435
  - test/plugin/test_in_debug_agent.rb
@@ -517,6 +519,7 @@ test_files:
517
519
  - test/plugin/test_buf_memory.rb
518
520
  - test/plugin/test_file_util.rb
519
521
  - test/plugin/test_filter_grep.rb
522
+ - test/plugin/test_filter_parser.rb
520
523
  - test/plugin/test_filter_record_transformer.rb
521
524
  - test/plugin/test_filter_stdout.rb
522
525
  - test/plugin/test_in_debug_agent.rb