fluentd 0.12.20 → 0.12.21

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +23 -0
  3. data/Rakefile +2 -2
  4. data/bin/fluent-debug +0 -1
  5. data/lib/fluent/agent.rb +12 -9
  6. data/lib/fluent/buffer.rb +9 -3
  7. data/lib/fluent/command/bundler_injection.rb +2 -0
  8. data/lib/fluent/command/cat.rb +1 -1
  9. data/lib/fluent/command/debug.rb +3 -2
  10. data/lib/fluent/command/fluentd.rb +3 -1
  11. data/lib/fluent/config.rb +4 -5
  12. data/lib/fluent/config/basic_parser.rb +3 -4
  13. data/lib/fluent/config/configure_proxy.rb +2 -0
  14. data/lib/fluent/config/dsl.rb +3 -0
  15. data/lib/fluent/config/element.rb +3 -2
  16. data/lib/fluent/config/literal_parser.rb +8 -5
  17. data/lib/fluent/config/parser.rb +5 -3
  18. data/lib/fluent/config/section.rb +3 -3
  19. data/lib/fluent/config/types.rb +44 -50
  20. data/lib/fluent/config/v1_parser.rb +8 -6
  21. data/lib/fluent/configurable.rb +8 -6
  22. data/lib/fluent/engine.rb +23 -11
  23. data/lib/fluent/event.rb +2 -0
  24. data/lib/fluent/event_router.rb +4 -2
  25. data/lib/fluent/filter.rb +6 -0
  26. data/lib/fluent/formatter.rb +27 -25
  27. data/lib/fluent/input.rb +5 -0
  28. data/lib/fluent/label.rb +2 -2
  29. data/lib/fluent/log.rb +5 -2
  30. data/lib/fluent/mixin.rb +4 -2
  31. data/lib/fluent/output.rb +45 -31
  32. data/lib/fluent/parser.rb +35 -25
  33. data/lib/fluent/plugin.rb +4 -0
  34. data/lib/fluent/plugin/buf_file.rb +9 -2
  35. data/lib/fluent/plugin/buf_memory.rb +7 -1
  36. data/lib/fluent/plugin/exec_util.rb +7 -2
  37. data/lib/fluent/plugin/filter_grep.rb +6 -3
  38. data/lib/fluent/plugin/filter_record_transformer.rb +52 -51
  39. data/lib/fluent/plugin/filter_stdout.rb +4 -1
  40. data/lib/fluent/plugin/in_debug_agent.rb +7 -5
  41. data/lib/fluent/plugin/in_dummy.rb +8 -3
  42. data/lib/fluent/plugin/in_exec.rb +16 -10
  43. data/lib/fluent/plugin/in_forward.rb +18 -11
  44. data/lib/fluent/plugin/in_gc_stat.rb +6 -2
  45. data/lib/fluent/plugin/in_http.rb +23 -14
  46. data/lib/fluent/plugin/in_monitor_agent.rb +24 -17
  47. data/lib/fluent/plugin/in_object_space.rb +9 -4
  48. data/lib/fluent/plugin/in_stream.rb +15 -6
  49. data/lib/fluent/plugin/in_syslog.rb +18 -12
  50. data/lib/fluent/plugin/in_tail.rb +61 -40
  51. data/lib/fluent/plugin/in_tcp.rb +3 -1
  52. data/lib/fluent/plugin/in_udp.rb +1 -1
  53. data/lib/fluent/plugin/out_copy.rb +5 -1
  54. data/lib/fluent/plugin/out_exec.rb +9 -6
  55. data/lib/fluent/plugin/out_exec_filter.rb +32 -25
  56. data/lib/fluent/plugin/out_file.rb +11 -5
  57. data/lib/fluent/plugin/out_forward.rb +30 -24
  58. data/lib/fluent/plugin/out_null.rb +2 -0
  59. data/lib/fluent/plugin/out_relabel.rb +2 -0
  60. data/lib/fluent/plugin/out_roundrobin.rb +3 -0
  61. data/lib/fluent/plugin/out_stdout.rb +3 -1
  62. data/lib/fluent/plugin/out_stream.rb +8 -8
  63. data/lib/fluent/plugin/socket_util.rb +12 -10
  64. data/lib/fluent/process.rb +14 -8
  65. data/lib/fluent/registry.rb +2 -2
  66. data/lib/fluent/root_agent.rb +16 -12
  67. data/lib/fluent/rpc.rb +7 -7
  68. data/lib/fluent/supervisor.rb +35 -69
  69. data/lib/fluent/system_config.rb +98 -0
  70. data/lib/fluent/test.rb +1 -1
  71. data/lib/fluent/test/base.rb +6 -1
  72. data/lib/fluent/test/filter_test.rb +4 -0
  73. data/lib/fluent/test/formatter_test.rb +3 -2
  74. data/lib/fluent/test/input_test.rb +6 -0
  75. data/lib/fluent/test/output_test.rb +4 -0
  76. data/lib/fluent/test/parser_test.rb +3 -2
  77. data/lib/fluent/timezone.rb +2 -0
  78. data/lib/fluent/version.rb +1 -1
  79. data/test/config/test_configurable.rb +11 -11
  80. data/test/config/test_configure_proxy.rb +1 -1
  81. data/test/config/test_system_config.rb +5 -5
  82. data/test/config/test_types.rb +70 -0
  83. data/test/plugin/test_filter_record_transformer.rb +72 -55
  84. data/test/plugin/test_in_forward.rb +4 -0
  85. data/test/plugin/test_in_tail.rb +73 -2
  86. data/test/test_config.rb +2 -2
  87. data/test/test_event_router.rb +1 -0
  88. data/test/test_output.rb +27 -3
  89. data/test/test_plugin_classes.rb +3 -0
  90. data/test/test_process.rb +1 -0
  91. data/test/test_root_agent.rb +5 -3
  92. metadata +3 -2
@@ -1,7 +1,11 @@
1
1
  require_relative '../helper'
2
+
2
3
  require 'fluent/test'
3
4
  require 'base64'
4
5
 
6
+ require 'fluent/env'
7
+ require 'fluent/plugin/in_forward'
8
+
5
9
  class ForwardInputTest < Test::Unit::TestCase
6
10
  def setup
7
11
  Fluent::Test.setup
@@ -30,6 +30,9 @@ class TailInputTest < Test::Unit::TestCase
30
30
  CONFIG_READ_FROM_HEAD = %[
31
31
  read_from_head true
32
32
  ]
33
+ CONFIG_ENABLE_WATCH_TIMER = %[
34
+ enable_watch_timer false
35
+ ]
33
36
  SINGLE_LINE_CONFIG = %[
34
37
  format /(?<message>.*)/
35
38
  ]
@@ -124,6 +127,32 @@ class TailInputTest < Test::Unit::TestCase
124
127
  assert_equal({"message" => "test4"}, emits[3][2])
125
128
  end
126
129
 
130
+ def test_emit_with_enable_watch_timer
131
+ File.open("#{TMP_DIR}/tail.txt", "wb") {|f|
132
+ f.puts "test1"
133
+ f.puts "test2"
134
+ }
135
+
136
+ d = create_driver(CONFIG_ENABLE_WATCH_TIMER + SINGLE_LINE_CONFIG)
137
+
138
+ d.run do
139
+ sleep 1
140
+
141
+ File.open("#{TMP_DIR}/tail.txt", "ab") {|f|
142
+ f.puts "test3"
143
+ f.puts "test4"
144
+ }
145
+ # according to cool.io's stat_watcher.c, systems without inotify will use
146
+ # an "automatic" value, typically around 5 seconds
147
+ sleep 10
148
+ end
149
+
150
+ emits = d.emits
151
+ assert(emits.length > 0)
152
+ assert_equal({"message" => "test3"}, emits[0][2])
153
+ assert_equal({"message" => "test4"}, emits[1][2])
154
+ end
155
+
127
156
  def test_rotate_file
128
157
  emits = sub_test_rotate_file(SINGLE_LINE_CONFIG)
129
158
  assert_equal(4, emits.length)
@@ -484,7 +513,7 @@ class TailInputTest < Test::Unit::TestCase
484
513
 
485
514
  flexstub(Fluent::NewTailInput::TailWatcher) do |watcherclass|
486
515
  EX_PATHS.each do |path|
487
- watcherclass.should_receive(:new).with(path, EX_RORATE_WAIT, Fluent::NewTailInput::FilePositionEntry, any, true, 1000, any, any, any).once.and_return do
516
+ watcherclass.should_receive(:new).with(path, EX_RORATE_WAIT, Fluent::NewTailInput::FilePositionEntry, any, true, true, 1000, any, any, any).once.and_return do
488
517
  flexmock('TailWatcher') { |watcher|
489
518
  watcher.should_receive(:attach).once
490
519
  watcher.should_receive(:unwatched=).zero_or_more_times
@@ -500,7 +529,7 @@ class TailInputTest < Test::Unit::TestCase
500
529
  end
501
530
 
502
531
  flexstub(Fluent::NewTailInput::TailWatcher) do |watcherclass|
503
- watcherclass.should_receive(:new).with('test/plugin/data/2010/01/20100102-030406.log', EX_RORATE_WAIT, Fluent::NewTailInput::FilePositionEntry, any, true, 1000, any, any, any).once.and_return do
532
+ watcherclass.should_receive(:new).with('test/plugin/data/2010/01/20100102-030406.log', EX_RORATE_WAIT, Fluent::NewTailInput::FilePositionEntry, any, true, true, 1000, any, any, any).once.and_return do
504
533
  flexmock('TailWatcher') do |watcher|
505
534
  watcher.should_receive(:attach).once
506
535
  watcher.should_receive(:unwatched=).zero_or_more_times
@@ -609,4 +638,46 @@ class TailInputTest < Test::Unit::TestCase
609
638
  assert_equal({"message" => "test4"}, emits[1][2])
610
639
  end
611
640
  end
641
+
642
+ sub_test_case 'emit error cases' do
643
+ def test_emit_error_with_buffer_queue_limit_error
644
+ emits = execute_test(::Fluent::BufferQueueLimitError, "queue size exceeds limit")
645
+ assert_equal(10, emits.length)
646
+ 10.times { |i|
647
+ assert_equal({"message" => "test#{i}"}, emits[i][2])
648
+ }
649
+ end
650
+
651
+ def test_emit_error_with_non_buffer_queue_limit_error
652
+ emits = execute_test(StandardError, "non BufferQueueLimitError error")
653
+ assert_true(emits.size > 0 && emits.size != 10)
654
+ emits.size.times { |i|
655
+ assert_equal({"message" => "test#{10 - emits.size + i}"}, emits[i][2])
656
+ }
657
+ end
658
+
659
+ def execute_test(error_class, error_message)
660
+ d = create_driver(CONFIG_READ_FROM_HEAD + SINGLE_LINE_CONFIG)
661
+ # Use define_singleton_method instead of d.emit_stream to capture local variable
662
+ d.define_singleton_method(:emit_stream) do |tag, es|
663
+ @test_num_errors ||= 0
664
+ if @test_num_errors < 5
665
+ @test_num_errors += 1
666
+ raise error_class, error_message
667
+ else
668
+ @emit_streams << [tag, es.to_a]
669
+ end
670
+ end
671
+
672
+ d.run do
673
+ 10.times { |i|
674
+ File.open("#{TMP_DIR}/tail.txt", "ab") { |f| f.puts "test#{i}" }
675
+ sleep 0.5
676
+ }
677
+ sleep 1
678
+ end
679
+
680
+ d.emits
681
+ end
682
+ end
612
683
  end
@@ -159,8 +159,8 @@ class ConfigTest < Test::Unit::TestCase
159
159
  def test_inline
160
160
  prepare_config
161
161
  opts = {
162
- :config_path => "#{TMP_DIR}/config_test_1.conf",
163
- :inline_config => "<source>\n type http\n port 2222\n </source>"
162
+ config_path: "#{TMP_DIR}/config_test_1.conf",
163
+ inline_config: "<source>\n type http\n port 2222\n </source>"
164
164
  }
165
165
  assert_nothing_raised do
166
166
  Fluent::Supervisor.new(opts)
@@ -1,3 +1,4 @@
1
+ require_relative 'helper'
1
2
  require 'fluent/event_router'
2
3
  require_relative 'test_plugin_classes'
3
4
 
@@ -215,13 +215,13 @@ module FluentOutputTest
215
215
 
216
216
  TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/time_sliced_output")
217
217
 
218
- CONFIG = %[]
218
+ CONFIG = %[buffer_path #{TMP_DIR}/foo]
219
219
 
220
220
  def create_driver(conf=CONFIG)
221
221
  Fluent::Test::TimeSlicedOutputTestDriver.new(Fluent::TimeSlicedOutput).configure(conf, true)
222
222
  end
223
223
 
224
- sub_test_case "test_force_flush" do
224
+ sub_test_case "force_flush test" do
225
225
  setup do
226
226
  time = Time.parse("2011-01-02 13:14:15 UTC")
227
227
  Timecop.freeze(time)
@@ -235,7 +235,6 @@ module FluentOutputTest
235
235
  test "force_flush immediately flushes" do
236
236
  d = create_driver(CONFIG + %[
237
237
  time_format %Y%m%d%H%M%S
238
- buffer_path #{TMP_DIR}/foo
239
238
  ])
240
239
  d.instance.start
241
240
  # buffer should be popped (flushed) immediately
@@ -246,5 +245,30 @@ module FluentOutputTest
246
245
  10.times { sleep 0.05 }
247
246
  end
248
247
  end
248
+
249
+ sub_test_case "test emit" do
250
+ setup do
251
+ @time = Time.parse("2011-01-02 13:14:15 UTC")
252
+ Timecop.freeze(@time)
253
+ end
254
+
255
+ teardown do
256
+ Timecop.return
257
+ end
258
+
259
+ test "emit with valid event" do
260
+ d = create_driver
261
+ d.instance.start
262
+ d.instance.emit('test', OneEventStream.new(@time.to_i, {"message" => "foo"}), NullOutputChain.instance)
263
+ assert_equal 0, d.instance.log.logs.size
264
+ end
265
+
266
+ test "emit with invalid event" do
267
+ d = create_driver
268
+ d.instance.start
269
+ d.instance.emit('test', OneEventStream.new('string', 10), NullOutputChain.instance)
270
+ assert_equal 1, d.instance.log.logs.count { |line| line =~ /dump an error event/ }
271
+ end
272
+ end
249
273
  end
250
274
  end
@@ -1,4 +1,7 @@
1
1
  require_relative 'helper'
2
+ require 'fluent/input'
3
+ require 'fluent/output'
4
+ require 'fluent/filter'
2
5
 
3
6
  module FluentTest
4
7
  class FluentTestInput < ::Fluent::Input
@@ -1,6 +1,7 @@
1
1
  require_relative 'helper'
2
2
  require 'fluent/test'
3
3
  require 'fluent/event'
4
+ require 'fluent/process'
4
5
  require 'stringio'
5
6
  require 'msgpack'
6
7
 
@@ -1,4 +1,6 @@
1
+ require_relative 'helper'
1
2
  require 'fluent/event_router'
3
+ require 'fluent/system_config'
2
4
  require_relative 'test_plugin_classes'
3
5
 
4
6
  class RootAgentTest < ::Test::Unit::TestCase
@@ -12,12 +14,12 @@ class RootAgentTest < ::Test::Unit::TestCase
12
14
  end
13
15
 
14
16
  data(
15
- 'suppress interval' => [{:suppress_interval => 30}, {:@suppress_emit_error_log_interval => 30}],
16
- 'without source' => [{:without_source => true}, {:@without_source => true}]
17
+ 'suppress interval' => [{'emit_error_log_interval' => 30}, {:@suppress_emit_error_log_interval => 30}],
18
+ 'without source' => [{'without_source' => true}, {:@without_source => true}]
17
19
  )
18
20
  def test_initialize_with_opt(data)
19
21
  opt, expected = data
20
- ra = RootAgent.new(opt)
22
+ ra = RootAgent.new(SystemConfig.new(opt))
21
23
  expected.each { |k, v|
22
24
  assert_equal v, ra.instance_variable_get(k)
23
25
  }
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.20
4
+ version: 0.12.21
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-01-25 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -391,6 +391,7 @@ files:
391
391
  - lib/fluent/rpc.rb
392
392
  - lib/fluent/status.rb
393
393
  - lib/fluent/supervisor.rb
394
+ - lib/fluent/system_config.rb
394
395
  - lib/fluent/test.rb
395
396
  - lib/fluent/test/base.rb
396
397
  - lib/fluent/test/filter_test.rb