fluentd 0.14.1 → 0.14.2

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +110 -1
  3. data/Rakefile +5 -1
  4. data/appveyor.yml +7 -1
  5. data/example/in_forward.conf +4 -0
  6. data/lib/fluent/compat/exec_util.rb +129 -0
  7. data/lib/fluent/compat/file_util.rb +54 -0
  8. data/lib/fluent/compat/filter.rb +21 -3
  9. data/lib/fluent/compat/formatter.rb +4 -2
  10. data/lib/fluent/compat/formatter_utils.rb +85 -0
  11. data/lib/fluent/compat/handle_tag_and_time_mixin.rb +60 -0
  12. data/lib/fluent/compat/input.rb +1 -3
  13. data/lib/fluent/compat/output.rb +95 -39
  14. data/lib/fluent/compat/parser.rb +17 -0
  15. data/lib/fluent/compat/parser_utils.rb +40 -0
  16. data/lib/fluent/compat/socket_util.rb +165 -0
  17. data/lib/fluent/compat/string_util.rb +34 -0
  18. data/lib/fluent/{test/driver/owner.rb → compat/structured_format_mixin.rb} +5 -11
  19. data/lib/fluent/config/element.rb +2 -2
  20. data/lib/fluent/configurable.rb +2 -1
  21. data/lib/fluent/event.rb +61 -7
  22. data/lib/fluent/event_router.rb +1 -1
  23. data/lib/fluent/plugin.rb +7 -7
  24. data/lib/fluent/plugin/buf_file.rb +5 -2
  25. data/lib/fluent/plugin/buffer.rb +194 -64
  26. data/lib/fluent/plugin/buffer/chunk.rb +28 -3
  27. data/lib/fluent/plugin/buffer/file_chunk.rb +5 -21
  28. data/lib/fluent/plugin/buffer/memory_chunk.rb +1 -11
  29. data/lib/fluent/plugin/exec_util.rb +2 -112
  30. data/lib/fluent/plugin/file_util.rb +3 -38
  31. data/lib/fluent/plugin/file_wrapper.rb +1 -1
  32. data/lib/fluent/plugin/filter_grep.rb +3 -7
  33. data/lib/fluent/plugin/filter_record_transformer.rb +5 -5
  34. data/lib/fluent/plugin/filter_stdout.rb +18 -11
  35. data/lib/fluent/plugin/formatter.rb +0 -48
  36. data/lib/fluent/plugin/formatter_csv.rb +7 -8
  37. data/lib/fluent/plugin/formatter_hash.rb +1 -4
  38. data/lib/fluent/plugin/formatter_json.rb +1 -4
  39. data/lib/fluent/plugin/formatter_ltsv.rb +5 -6
  40. data/lib/fluent/plugin/formatter_msgpack.rb +1 -4
  41. data/lib/fluent/plugin/formatter_out_file.rb +36 -3
  42. data/lib/fluent/plugin/formatter_stdout.rb +36 -1
  43. data/lib/fluent/plugin/in_dummy.rb +9 -2
  44. data/lib/fluent/plugin/in_exec.rb +20 -57
  45. data/lib/fluent/plugin/in_forward.rb +4 -3
  46. data/lib/fluent/plugin/in_object_space.rb +8 -44
  47. data/lib/fluent/plugin/in_syslog.rb +13 -24
  48. data/lib/fluent/plugin/in_tail.rb +3 -0
  49. data/lib/fluent/plugin/out_buffered_stdout.rb +14 -4
  50. data/lib/fluent/plugin/out_exec.rb +7 -5
  51. data/lib/fluent/plugin/out_exec_filter.rb +10 -10
  52. data/lib/fluent/plugin/out_file.rb +1 -3
  53. data/lib/fluent/plugin/out_forward.rb +38 -57
  54. data/lib/fluent/plugin/out_stdout.rb +14 -5
  55. data/lib/fluent/plugin/out_stream.rb +3 -0
  56. data/lib/fluent/plugin/output.rb +31 -14
  57. data/lib/fluent/plugin/parser.rb +0 -69
  58. data/lib/fluent/plugin/parser_apache.rb +10 -6
  59. data/lib/fluent/plugin/parser_apache_error.rb +8 -3
  60. data/lib/fluent/plugin/parser_csv.rb +3 -1
  61. data/lib/fluent/plugin/parser_json.rb +1 -1
  62. data/lib/fluent/plugin/parser_multiline.rb +5 -3
  63. data/lib/fluent/plugin/parser_nginx.rb +10 -6
  64. data/lib/fluent/plugin/parser_regexp.rb +73 -0
  65. data/lib/fluent/plugin/socket_util.rb +2 -148
  66. data/lib/fluent/plugin/storage_local.rb +1 -1
  67. data/lib/fluent/plugin/string_util.rb +3 -18
  68. data/lib/fluent/plugin_helper.rb +1 -0
  69. data/lib/fluent/plugin_helper/compat_parameters.rb +166 -41
  70. data/lib/fluent/plugin_helper/formatter.rb +30 -19
  71. data/lib/fluent/plugin_helper/inject.rb +25 -12
  72. data/lib/fluent/plugin_helper/parser.rb +22 -13
  73. data/lib/fluent/plugin_helper/storage.rb +22 -13
  74. data/lib/fluent/registry.rb +19 -6
  75. data/lib/fluent/supervisor.rb +27 -1
  76. data/lib/fluent/test/driver/base.rb +16 -92
  77. data/lib/fluent/test/driver/base_owned.rb +17 -53
  78. data/lib/fluent/test/driver/base_owner.rb +125 -0
  79. data/lib/fluent/test/driver/filter.rb +24 -2
  80. data/lib/fluent/test/driver/input.rb +2 -2
  81. data/lib/fluent/test/driver/multi_output.rb +2 -2
  82. data/lib/fluent/test/driver/output.rb +3 -5
  83. data/lib/fluent/test/helpers.rb +25 -0
  84. data/lib/fluent/test/input_test.rb +4 -4
  85. data/lib/fluent/test/output_test.rb +3 -3
  86. data/lib/fluent/version.rb +1 -1
  87. data/test/config/test_element.rb +135 -6
  88. data/test/plugin/test_buf_file.rb +71 -3
  89. data/test/plugin/test_buffer.rb +305 -86
  90. data/test/plugin/test_buffer_chunk.rb +60 -2
  91. data/test/plugin/test_buffer_file_chunk.rb +4 -3
  92. data/test/plugin/test_filter_grep.rb +25 -21
  93. data/test/plugin/test_filter_record_transformer.rb +75 -67
  94. data/test/plugin/test_filter_stdout.rb +171 -74
  95. data/test/plugin/test_formatter_csv.rb +94 -0
  96. data/test/plugin/test_formatter_json.rb +30 -0
  97. data/test/plugin/test_formatter_ltsv.rb +52 -0
  98. data/test/plugin/test_formatter_msgpack.rb +28 -0
  99. data/test/plugin/test_formatter_out_file.rb +95 -0
  100. data/test/plugin/test_formatter_single_value.rb +38 -0
  101. data/test/plugin/test_in_dummy.rb +95 -0
  102. data/test/plugin/test_in_exec.rb +27 -31
  103. data/test/plugin/test_in_forward.rb +24 -0
  104. data/test/plugin/test_in_gc_stat.rb +5 -5
  105. data/test/plugin/test_in_object_space.rb +4 -4
  106. data/test/plugin/test_in_syslog.rb +60 -35
  107. data/test/plugin/test_out_buffered_stdout.rb +17 -3
  108. data/test/plugin/test_out_forward.rb +93 -5
  109. data/test/plugin/test_out_stdout.rb +14 -3
  110. data/test/plugin/test_output_as_buffered_retries.rb +20 -0
  111. data/test/plugin/test_output_as_buffered_secondary.rb +16 -0
  112. data/test/plugin/test_output_as_standard.rb +22 -22
  113. data/test/plugin/test_parser_apache.rb +13 -9
  114. data/test/plugin/test_parser_apache_error.rb +11 -6
  115. data/test/plugin/test_parser_csv.rb +35 -25
  116. data/test/plugin/test_parser_nginx.rb +11 -5
  117. data/test/plugin/test_parser_regexp.rb +235 -68
  118. data/test/plugin/test_parser_tsv.rb +54 -58
  119. data/test/plugin_helper/test_compat_parameters.rb +111 -46
  120. data/test/plugin_helper/test_formatter.rb +40 -0
  121. data/test/plugin_helper/test_inject.rb +101 -2
  122. data/test/plugin_helper/test_parser.rb +40 -0
  123. data/test/plugin_helper/test_storage.rb +43 -0
  124. data/test/test_event.rb +93 -0
  125. data/test/test_event_router.rb +13 -4
  126. data/test/test_event_time.rb +0 -3
  127. data/test/test_formatter.rb +7 -164
  128. data/test/test_plugin_classes.rb +28 -1
  129. metadata +24 -3
@@ -1,5 +1,5 @@
1
1
  require_relative '../helper'
2
- require 'fluent/test'
2
+ require 'fluent/test/driver/input'
3
3
  require 'fluent/plugin/in_syslog'
4
4
 
5
5
  class SyslogInputTest < Test::Unit::TestCase
@@ -14,7 +14,7 @@ class SyslogInputTest < Test::Unit::TestCase
14
14
  @server.close
15
15
  end
16
16
  end
17
-
17
+
18
18
  def setup
19
19
  Fluent::Test.setup
20
20
  require 'fluent/plugin/socket_util'
@@ -34,7 +34,7 @@ class SyslogInputTest < Test::Unit::TestCase
34
34
  ]
35
35
 
36
36
  def create_driver(conf=CONFIG)
37
- Fluent::Test::InputTestDriver.new(Fluent::SyslogInput).configure(conf)
37
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::SyslogInput).configure(conf)
38
38
  end
39
39
 
40
40
  def test_configure
@@ -59,19 +59,18 @@ class SyslogInputTest < Test::Unit::TestCase
59
59
  {'msg' => '<6>Dec 11 00:00:00 localhost logger: foo', 'expected' => Fluent::EventTime.from_time(Time.strptime('Dec 11 00:00:00', '%b %d %H:%M:%S'))},
60
60
  {'msg' => '<6>Dec 1 00:00:00 localhost logger: foo', 'expected' => Fluent::EventTime.from_time(Time.strptime('Dec 1 00:00:00', '%b %d %H:%M:%S'))},
61
61
  ]
62
-
63
- d.run do
62
+ d.run(expect_emits: 2) do
64
63
  u = Fluent::SocketUtil.create_udp_socket(k)
65
64
  u.connect(k, PORT)
66
65
  tests.each {|test|
67
66
  u.send(test['msg'], 0)
68
67
  }
69
- sleep 1
70
68
  end
71
69
 
72
- emits = d.emits
73
- emits.each_index {|i|
74
- assert_equal_event_time(tests[i]['expected'], emits[i][1])
70
+ events = d.events
71
+ assert(events.size > 0)
72
+ events.each_index {|i|
73
+ assert_equal_event_time(tests[i]['expected'], events[i][1])
75
74
  }
76
75
  }
77
76
  end
@@ -80,48 +79,66 @@ class SyslogInputTest < Test::Unit::TestCase
80
79
  d = create_driver
81
80
  tests = create_test_case
82
81
 
83
- d.run do
82
+ d.run(expect_emits: 2) do
84
83
  u = UDPSocket.new
85
84
  u.connect('127.0.0.1', PORT)
86
85
  tests.each {|test|
87
86
  u.send(test['msg'], 0)
88
87
  }
89
- sleep 1
90
88
  end
91
89
 
92
- compare_test_result(d.emits, tests)
90
+ assert(d.events.size > 0)
91
+ compare_test_result(d.events, tests)
92
+ end
93
+
94
+ def test_msg_size_udp_for_large_msg
95
+ d = create_driver(CONFIG + %[
96
+ message_length_limit 5k
97
+ ])
98
+ tests = create_test_case(large_message: true)
99
+
100
+ d.run(expect_emits: 3) do
101
+ u = UDPSocket.new
102
+ u.connect('127.0.0.1', PORT)
103
+ tests.each {|test|
104
+ u.send(test['msg'], 0)
105
+ }
106
+ end
107
+
108
+ assert(d.events.size > 0)
109
+ compare_test_result(d.events, tests)
93
110
  end
94
111
 
95
112
  def test_msg_size_with_tcp
96
113
  d = create_driver([CONFIG, 'protocol_type tcp'].join("\n"))
97
114
  tests = create_test_case
98
115
 
99
- d.run do
116
+ d.run(expect_emits: 2) do
100
117
  tests.each {|test|
101
118
  TCPSocket.open('127.0.0.1', PORT) do |s|
102
119
  s.send(test['msg'], 0)
103
120
  end
104
121
  }
105
- sleep 1
106
122
  end
107
123
 
108
- compare_test_result(d.emits, tests)
124
+ assert(d.events.size > 0)
125
+ compare_test_result(d.events, tests)
109
126
  end
110
127
 
111
128
  def test_msg_size_with_same_tcp_connection
112
129
  d = create_driver([CONFIG, 'protocol_type tcp'].join("\n"))
113
130
  tests = create_test_case
114
131
 
115
- d.run do
132
+ d.run(expect_emits: 2) do
116
133
  TCPSocket.open('127.0.0.1', PORT) do |s|
117
134
  tests.each {|test|
118
135
  s.send(test['msg'], 0)
119
136
  }
120
137
  end
121
- sleep 1
122
138
  end
123
139
 
124
- compare_test_result(d.emits, tests)
140
+ assert(d.events.size > 0)
141
+ compare_test_result(d.events, tests)
125
142
  end
126
143
 
127
144
  def test_msg_size_with_json_format
@@ -132,49 +149,57 @@ class SyslogInputTest < Test::Unit::TestCase
132
149
  {'msg' => '<6>' + event.to_json + "\n", 'expected' => msg}
133
150
  }
134
151
 
135
- d.run do
152
+ d.run(expect_emits: 2) do
136
153
  u = UDPSocket.new
137
154
  u.connect('127.0.0.1', PORT)
138
155
  tests.each {|test|
139
156
  u.send(test['msg'], 0)
140
157
  }
141
- sleep 1
142
158
  end
143
159
 
144
- compare_test_result(d.emits, tests)
160
+ assert(d.events.size > 0)
161
+ compare_test_result(d.events, tests)
145
162
  end
146
163
 
147
164
  def test_msg_size_with_include_source_host
148
- d = create_driver([CONFIG, 'include_source_host'].join("\n"))
165
+ d = create_driver([CONFIG, 'include_source_host true'].join("\n"))
149
166
  tests = create_test_case
150
167
 
151
168
  host = nil
152
- d.run do
169
+ d.run(expect_emits: 2) do
153
170
  u = UDPSocket.new
154
171
  u.connect('127.0.0.1', PORT)
155
172
  host = u.peeraddr[2]
156
173
  tests.each {|test|
157
174
  u.send(test['msg'], 0)
158
175
  }
159
- sleep 1
160
176
  end
161
177
 
162
- compare_test_result(d.emits, tests, host)
178
+ assert(d.events.size > 0)
179
+ compare_test_result(d.events, tests, host)
163
180
  end
164
181
 
165
- def create_test_case
182
+ def create_test_case(large_message: false)
166
183
  # actual syslog message has "\n"
167
- [
168
- {'msg' => '<6>Sep 10 00:00:00 localhost logger: ' + 'x' * 100 + "\n", 'expected' => 'x' * 100},
169
- {'msg' => '<6>Sep 10 00:00:00 localhost logger: ' + 'x' * 1024 + "\n", 'expected' => 'x' * 1024},
170
- ]
184
+ if large_message
185
+ [
186
+ {'msg' => '<6>Sep 10 00:00:00 localhost logger: ' + 'x' * 100 + "\n", 'expected' => 'x' * 100},
187
+ {'msg' => '<6>Sep 10 00:00:00 localhost logger: ' + 'x' * 1024 + "\n", 'expected' => 'x' * 1024},
188
+ {'msg' => '<6>Sep 10 00:00:00 localhost logger: ' + 'x' * 4096 + "\n", 'expected' => 'x' * 4096},
189
+ ]
190
+ else
191
+ [
192
+ {'msg' => '<6>Sep 10 00:00:00 localhost logger: ' + 'x' * 100 + "\n", 'expected' => 'x' * 100},
193
+ {'msg' => '<6>Sep 10 00:00:00 localhost logger: ' + 'x' * 1024 + "\n", 'expected' => 'x' * 1024},
194
+ ]
195
+ end
171
196
  end
172
197
 
173
- def compare_test_result(emits, tests, host = nil)
174
- emits.each_index { |i|
175
- assert_equal('syslog.kern.info', emits[0][0]) # <6> means kern.info
176
- assert_equal(tests[i]['expected'], emits[i][2]['message'])
177
- assert_equal(host, emits[i][2]['source_host']) if host
198
+ def compare_test_result(events, tests, host = nil)
199
+ events.each_index { |i|
200
+ assert_equal('syslog.kern.info', events[i][0]) # <6> means kern.info
201
+ assert_equal(tests[i]['expected'], events[i][2]['message'])
202
+ assert_equal(host, events[i][2]['source_host']) if host
178
203
  }
179
204
  end
180
205
  end
@@ -16,7 +16,7 @@ class BufferedStdoutOutputTest < Test::Unit::TestCase
16
16
 
17
17
  test 'default configure' do
18
18
  d = create_driver
19
- assert_equal 'json', d.instance.output_type
19
+ assert_equal [], d.instance.formatter_configs
20
20
  assert_equal 10 * 1024, d.instance.buffer_config.chunk_limit_size
21
21
  assert d.instance.buffer_config.flush_at_shutdown
22
22
  assert_equal ['tag'], d.instance.buffer_config.chunk_keys
@@ -27,16 +27,30 @@ class BufferedStdoutOutputTest < Test::Unit::TestCase
27
27
 
28
28
  test 'configure with output_type' do
29
29
  d = create_driver(CONFIG + "\noutput_type json")
30
- assert_equal 'json', d.instance.output_type
30
+ assert_equal 'json', d.instance.formatter_configs.first[:@type]
31
31
 
32
32
  d = create_driver(CONFIG + "\noutput_type hash")
33
- assert_equal 'hash', d.instance.output_type
33
+ assert_equal 'hash', d.instance.formatter_configs.first[:@type]
34
34
 
35
35
  assert_raise(Fluent::ConfigError) do
36
36
  d = create_driver(CONFIG + "\noutput_type foo")
37
37
  end
38
38
  end
39
39
 
40
+ sub_test_case "emit with default config" do
41
+ test '#write(synchronous)' do
42
+ d = create_driver
43
+ time = event_time()
44
+
45
+ out = capture_log do
46
+ d.run(default_tag: 'test', flush: true) do
47
+ d.feed(time, {'test' => 'test'})
48
+ end
49
+ end
50
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test\"}\n", out
51
+ end
52
+ end
53
+
40
54
  sub_test_case "emit json" do
41
55
  data('oj' => 'oj', 'yajl' => 'yajl')
42
56
  test '#write(synchronous)' do |data|
@@ -107,7 +107,6 @@ class ForwardOutputTest < Test::Unit::TestCase
107
107
 
108
108
  def test_wait_response_timeout_config
109
109
  d = create_driver(CONFIG)
110
- assert_equal false, d.instance.extend_internal_protocol
111
110
  assert_equal false, d.instance.require_ack_response
112
111
  assert_equal 190, d.instance.ack_response_timeout
113
112
 
@@ -115,11 +114,74 @@ class ForwardOutputTest < Test::Unit::TestCase
115
114
  require_ack_response true
116
115
  ack_response_timeout 2s
117
116
  ])
118
- assert d.instance.extend_internal_protocol
119
117
  assert d.instance.require_ack_response
120
118
  assert_equal 2, d.instance.ack_response_timeout
121
119
  end
122
120
 
121
+ def test_sending_contains_with_ack
122
+ target_input_driver = create_target_input_driver(true)
123
+
124
+ d = create_driver(CONFIG + %[
125
+ ack_response_timeout 1s
126
+ ])
127
+
128
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
129
+
130
+ records = [
131
+ {"a" => 1},
132
+ {"a" => 2}
133
+ ]
134
+ d.register_run_post_condition do
135
+ d.instance.responses.length == 1
136
+ end
137
+
138
+ target_input_driver.run do
139
+ d.run do
140
+ records.each do |record|
141
+ d.emit record, time
142
+ end
143
+ end
144
+ end
145
+
146
+ emits = target_input_driver.emits
147
+ assert_equal ['test', time, records[0]], emits[0]
148
+ assert_equal ['test', time, records[1]], emits[1]
149
+
150
+ assert_equal target_input_driver.instance.received_options[0]['size'], 2
151
+ end
152
+
153
+ def test_sending_contains_without_ack
154
+ target_input_driver = create_target_input_driver(true)
155
+
156
+ d = create_driver(CONFIG + %[
157
+ ack_response_timeout 1s
158
+ ])
159
+
160
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
161
+
162
+ records = [
163
+ {"a" => 1},
164
+ {"a" => 2}
165
+ ]
166
+ d.register_run_post_condition do
167
+ d.instance.responses.length == 1
168
+ end
169
+
170
+ target_input_driver.run do
171
+ d.run do
172
+ records.each do |record|
173
+ d.emit record, time
174
+ end
175
+ end
176
+ end
177
+
178
+ emits = target_input_driver.emits
179
+ assert_equal ['test', time, records[0]], emits[0]
180
+ assert_equal ['test', time, records[1]], emits[1]
181
+
182
+ assert_equal target_input_driver.instance.received_options[0]['size'], 2
183
+ end
184
+
123
185
  def test_send_with_time_as_integer
124
186
  target_input_driver = create_target_input_driver
125
187
 
@@ -379,12 +441,18 @@ class ForwardOutputTest < Test::Unit::TestCase
379
441
  DummyEngineDriver.new(Fluent::ForwardInput) {
380
442
  handler_class = Class.new(Fluent::ForwardInput::Handler) { |klass|
381
443
  attr_reader :chunk_counter # for checking if received data is successfully deserialized
444
+ attr_reader :received_options
382
445
 
383
446
  def initialize(sock, log, on_message)
384
447
  @sock = sock
385
448
  @log = log
386
449
  @chunk_counter = 0
387
- @on_message = on_message
450
+ @received_options = []
451
+ @on_message = ->(msg, chunk_size, source) {
452
+ option = on_message.call(msg, chunk_size, source)
453
+ @received_options << option
454
+ option
455
+ }
388
456
  @source = nil
389
457
  end
390
458
 
@@ -409,7 +477,7 @@ class ForwardOutputTest < Test::Unit::TestCase
409
477
  end
410
478
  }
411
479
 
412
- define_method(:start) do
480
+ define_method(:_start) do
413
481
  @thread = Thread.new do
414
482
  Socket.tcp_server_loop(@bind, @port) do |sock, client_addrinfo|
415
483
  begin
@@ -431,12 +499,15 @@ class ForwardOutputTest < Test::Unit::TestCase
431
499
  sock.close_write
432
500
  sock.close
433
501
  end
502
+ @received_options = handler.received_options
434
503
  end
435
504
  end
436
505
  end
437
506
  end
438
507
 
439
- def shutdown
508
+ attr_reader :received_options
509
+
510
+ def _shutdown
440
511
  @thread.kill
441
512
  @thread.join
442
513
  end
@@ -457,9 +528,26 @@ class ForwardOutputTest < Test::Unit::TestCase
457
528
  assert_equal node.available, true
458
529
  end
459
530
 
531
+ # To suppress calling `ForwardInput#start` in `DummyEngineDriver`,
532
+ # `DummyEnigneDriver` should avoid calling CallSuperMixin.prepend at `Fluent::Compat::Input#initialize`.
533
+ module SuppressCallSuperMixin
534
+ def start
535
+ _start
536
+ end
537
+
538
+ def before_shutdown
539
+ # nothing
540
+ end
541
+
542
+ def shutdown
543
+ _shutdown
544
+ end
545
+ end
546
+
460
547
  class DummyEngineDriver < Fluent::Test::TestDriver
461
548
  def initialize(klass, &block)
462
549
  super(klass, &block)
550
+ @instance.class.prepend(SuppressCallSuperMixin)
463
551
  @engine = DummyEngineClass.new
464
552
  end
465
553
 
@@ -16,21 +16,32 @@ class StdoutOutputTest < Test::Unit::TestCase
16
16
 
17
17
  def test_configure
18
18
  d = create_driver
19
- assert_equal 'json', d.instance.output_type
19
+ assert_equal [], d.instance.formatter_configs
20
20
  end
21
21
 
22
22
  def test_configure_output_type
23
23
  d = create_driver(CONFIG + "\noutput_type json")
24
- assert_equal 'json', d.instance.output_type
24
+ assert_equal 'json', d.instance.formatter_configs.first[:@type]
25
25
 
26
26
  d = create_driver(CONFIG + "\noutput_type hash")
27
- assert_equal 'hash', d.instance.output_type
27
+ assert_equal 'hash', d.instance.formatter_configs.first[:@type]
28
28
 
29
29
  assert_raise(Fluent::ConfigError) do
30
30
  d = create_driver(CONFIG + "\noutput_type foo")
31
31
  end
32
32
  end
33
33
 
34
+ def test_emit_in_default
35
+ d = create_driver
36
+ time = event_time()
37
+ out = capture_log do
38
+ d.run(default_tag: 'test') do
39
+ d.feed(time, {'test' => 'test1'})
40
+ end
41
+ end
42
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test1\"}\n", out
43
+ end
44
+
34
45
  data('oj' => 'oj', 'yajl' => 'yajl')
35
46
  def test_emit_json(data)
36
47
  d = create_driver(CONFIG + "\noutput_type json\njson_parser #{data}")
@@ -161,6 +161,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
161
161
  @i.register(:write){|chunk| raise "yay, your #write must fail" }
162
162
  @i.start
163
163
 
164
+ @i.interrupt_flushes
165
+
164
166
  now = Time.parse('2016-04-13 18:33:30 -0700')
165
167
  Timecop.freeze( now )
166
168
 
@@ -200,6 +202,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
200
202
  @i.register(:write){|chunk| raise "yay, your #write must fail" }
201
203
  @i.start
202
204
 
205
+ @i.interrupt_flushes
206
+
203
207
  now = Time.parse('2016-04-13 18:33:30 -0700')
204
208
  Timecop.freeze( now )
205
209
 
@@ -252,6 +256,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
252
256
  @i.register(:write){|chunk| written_tags << chunk.metadata.tag; raise "yay, your #write must fail" }
253
257
  @i.start
254
258
 
259
+ @i.interrupt_flushes
260
+
255
261
  now = Time.parse('2016-04-13 18:33:30 -0700')
256
262
  Timecop.freeze( now )
257
263
 
@@ -339,6 +345,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
339
345
  @i.register(:write){|chunk| written_tags << chunk.metadata.tag; raise "yay, your #write must fail" }
340
346
  @i.start
341
347
 
348
+ @i.interrupt_flushes
349
+
342
350
  now = Time.parse('2016-04-13 18:33:30 -0700')
343
351
  Timecop.freeze( now )
344
352
 
@@ -417,6 +425,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
417
425
  @i.register(:write){|chunk| raise "yay, your #write must fail" }
418
426
  @i.start
419
427
 
428
+ @i.interrupt_flushes
429
+
420
430
  now = Time.parse('2016-04-13 18:33:30 -0700')
421
431
  Timecop.freeze( now )
422
432
 
@@ -460,6 +470,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
460
470
  @i.register(:write){|chunk| written_tags << chunk.metadata.tag; raise "yay, your #write must fail" }
461
471
  @i.start
462
472
 
473
+ @i.interrupt_flushes
474
+
463
475
  now = Time.parse('2016-04-13 18:33:30 -0700')
464
476
  Timecop.freeze( now )
465
477
 
@@ -552,6 +564,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
552
564
  @i.register(:write){|chunk| written_tags << chunk.metadata.tag; raise "yay, your #write must fail" }
553
565
  @i.start
554
566
 
567
+ @i.interrupt_flushes
568
+
555
569
  now = Time.parse('2016-04-13 18:33:30 -0700')
556
570
  Timecop.freeze( now )
557
571
 
@@ -647,6 +661,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
647
661
  @i.register(:write){|chunk| written_tags << chunk.metadata.tag; raise "yay, your #write must fail" }
648
662
  @i.start
649
663
 
664
+ @i.interrupt_flushes
665
+
650
666
  now = Time.parse('2016-04-13 18:33:30 -0700')
651
667
  Timecop.freeze( now )
652
668
 
@@ -715,6 +731,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
715
731
  @i.register(:write){|chunk| written_tags << chunk.metadata.tag; raise "yay, your #write must fail" }
716
732
  @i.start
717
733
 
734
+ @i.interrupt_flushes
735
+
718
736
  now = Time.parse('2016-04-13 18:33:30 -0700')
719
737
  Timecop.freeze( now )
720
738
 
@@ -780,6 +798,8 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
780
798
  @i.register(:try_write){|chunk| raise "yay, your #write must fail" }
781
799
  @i.start
782
800
 
801
+ @i.interrupt_flushes
802
+
783
803
  now = Time.parse('2016-04-13 18:33:30 -0700')
784
804
  Timecop.freeze( now )
785
805