fluentd 0.14.5-x64-mingw32 → 0.14.7-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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +55 -0
  3. data/bin/fluent-binlog-reader +7 -0
  4. data/example/in_dummy_with_compression.conf +23 -0
  5. data/lib/fluent/agent.rb +8 -12
  6. data/lib/fluent/command/binlog_reader.rb +234 -0
  7. data/lib/fluent/command/fluentd.rb +17 -1
  8. data/lib/fluent/compat/file_util.rb +1 -1
  9. data/lib/fluent/compat/output.rb +5 -1
  10. data/lib/fluent/config/configure_proxy.rb +18 -3
  11. data/lib/fluent/config/element.rb +1 -1
  12. data/lib/fluent/config/section.rb +1 -1
  13. data/lib/fluent/config/v1_parser.rb +1 -1
  14. data/lib/fluent/env.rb +1 -0
  15. data/lib/fluent/event.rb +49 -2
  16. data/lib/fluent/event_router.rb +6 -2
  17. data/lib/fluent/label.rb +8 -0
  18. data/lib/fluent/log.rb +30 -1
  19. data/lib/fluent/plugin.rb +1 -1
  20. data/lib/fluent/plugin/base.rb +3 -0
  21. data/lib/fluent/plugin/buf_file.rb +2 -2
  22. data/lib/fluent/plugin/buf_memory.rb +1 -1
  23. data/lib/fluent/plugin/buffer.rb +12 -2
  24. data/lib/fluent/plugin/buffer/chunk.rb +68 -7
  25. data/lib/fluent/plugin/buffer/file_chunk.rb +4 -4
  26. data/lib/fluent/plugin/buffer/memory_chunk.rb +4 -4
  27. data/lib/fluent/plugin/compressable.rb +91 -0
  28. data/lib/fluent/plugin/filter_grep.rb +4 -4
  29. data/lib/fluent/plugin/formatter.rb +2 -2
  30. data/lib/fluent/plugin/formatter_json.rb +2 -1
  31. data/lib/fluent/plugin/formatter_out_file.rb +3 -30
  32. data/lib/fluent/plugin/in_forward.rb +6 -5
  33. data/lib/fluent/plugin/in_monitor_agent.rb +7 -21
  34. data/lib/fluent/plugin/in_syslog.rb +1 -1
  35. data/lib/fluent/plugin/in_tail.rb +11 -2
  36. data/lib/fluent/plugin/multi_output.rb +63 -3
  37. data/lib/fluent/plugin/out_exec.rb +1 -1
  38. data/lib/fluent/plugin/out_file.rb +5 -1
  39. data/lib/fluent/plugin/out_forward.rb +17 -5
  40. data/lib/fluent/plugin/out_stdout.rb +2 -1
  41. data/lib/fluent/plugin/output.rb +205 -19
  42. data/lib/fluent/plugin/parser.rb +5 -49
  43. data/lib/fluent/plugin/parser_apache2.rb +1 -1
  44. data/lib/fluent/plugin/parser_json.rb +4 -4
  45. data/lib/fluent/plugin/parser_multiline.rb +5 -5
  46. data/lib/fluent/plugin/parser_regexp.rb +1 -2
  47. data/lib/fluent/plugin/parser_syslog.rb +2 -2
  48. data/lib/fluent/plugin/storage_local.rb +2 -1
  49. data/lib/fluent/plugin_helper.rb +1 -0
  50. data/lib/fluent/plugin_helper/compat_parameters.rb +39 -21
  51. data/lib/fluent/plugin_helper/extract.rb +92 -0
  52. data/lib/fluent/plugin_helper/inject.rb +10 -12
  53. data/lib/fluent/plugin_helper/thread.rb +23 -3
  54. data/lib/fluent/registry.rb +1 -1
  55. data/lib/fluent/root_agent.rb +2 -1
  56. data/lib/fluent/supervisor.rb +28 -8
  57. data/lib/fluent/test/base.rb +0 -7
  58. data/lib/fluent/test/driver/base.rb +1 -0
  59. data/lib/fluent/test/driver/output.rb +3 -0
  60. data/lib/fluent/test/helpers.rb +18 -0
  61. data/lib/fluent/test/input_test.rb +4 -2
  62. data/lib/fluent/test/log.rb +3 -1
  63. data/lib/fluent/time.rb +232 -1
  64. data/lib/fluent/timezone.rb +1 -1
  65. data/lib/fluent/version.rb +1 -1
  66. data/test/command/test_binlog_reader.rb +351 -0
  67. data/test/config/test_config_parser.rb +6 -0
  68. data/test/config/test_configurable.rb +47 -1
  69. data/test/helper.rb +0 -1
  70. data/test/plugin/test_buffer.rb +22 -2
  71. data/test/plugin/test_buffer_chunk.rb +34 -4
  72. data/test/plugin/test_buffer_file_chunk.rb +73 -0
  73. data/test/plugin/test_buffer_memory_chunk.rb +73 -0
  74. data/test/plugin/test_compressable.rb +81 -0
  75. data/test/plugin/test_formatter_json.rb +14 -1
  76. data/test/plugin/test_in_forward.rb +67 -3
  77. data/test/plugin/test_in_monitor_agent.rb +17 -1
  78. data/test/plugin/test_in_tail.rb +8 -8
  79. data/test/plugin/test_out_file.rb +0 -8
  80. data/test/plugin/test_out_forward.rb +85 -0
  81. data/test/plugin/test_out_secondary_file.rb +20 -12
  82. data/test/plugin/test_out_stdout.rb +11 -10
  83. data/test/plugin/test_output.rb +234 -0
  84. data/test/plugin/test_output_as_buffered.rb +223 -0
  85. data/test/plugin/test_output_as_buffered_compress.rb +165 -0
  86. data/test/plugin/test_parser_json.rb +8 -0
  87. data/test/plugin/test_parser_regexp.rb +1 -1
  88. data/test/plugin_helper/test_child_process.rb +2 -2
  89. data/test/plugin_helper/test_extract.rb +195 -0
  90. data/test/plugin_helper/test_inject.rb +0 -7
  91. data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +7 -0
  92. data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +7 -0
  93. data/test/test_event.rb +186 -0
  94. data/test/test_event_router.rb +1 -1
  95. data/test/test_formatter.rb +0 -7
  96. data/test/test_log.rb +121 -0
  97. data/test/test_plugin_classes.rb +62 -0
  98. data/test/test_root_agent.rb +125 -0
  99. data/test/test_supervisor.rb +25 -2
  100. data/test/test_time_formatter.rb +103 -7
  101. data/test/test_time_parser.rb +211 -0
  102. metadata +22 -4
  103. data/test/plugin/test_parser_time.rb +0 -46
@@ -0,0 +1,195 @@
1
+ require_relative '../helper'
2
+ require 'fluent/plugin_helper/extract'
3
+ require 'fluent/time'
4
+
5
+ class ExtractHelperTest < Test::Unit::TestCase
6
+ class Dummy < Fluent::Plugin::TestBase
7
+ helpers :extract
8
+ end
9
+
10
+ class Dummy2 < Fluent::Plugin::TestBase
11
+ helpers :extract
12
+ config_section :extract do
13
+ config_set_default :tag_key, 'tag2'
14
+ end
15
+ end
16
+
17
+ def config_extract_section(hash = {})
18
+ config_element('ROOT', '', {}, [config_element('extract', '', hash)])
19
+ end
20
+
21
+ setup do
22
+ Fluent::Test.setup
23
+ @d = Dummy.new
24
+ end
25
+
26
+ teardown do
27
+ if @d
28
+ @d.stop unless @d.stopped?
29
+ @d.shutdown unless @d.shutdown?
30
+ @d.close unless @d.closed?
31
+ @d.terminate unless @d.terminated?
32
+ end
33
+ end
34
+
35
+ test 'can override default parameters, but not overwrite whole definition' do
36
+ d = Dummy.new
37
+ d.configure(config_element())
38
+ assert_nil d.extract_config
39
+
40
+ d = Dummy2.new
41
+ d.configure(config_element('ROOT', '', {}, [config_element('extract')]))
42
+ assert d.extract_config
43
+ assert_equal 'tag2', d.extract_config.tag_key
44
+ end
45
+
46
+ test 'returns nil in default' do
47
+ @d.configure(config_extract_section())
48
+ @d.start
49
+ assert_nil @d.instance_eval{ @_extract_tag_key }
50
+ assert_nil @d.instance_eval{ @_extract_time_key }
51
+ assert_nil @d.instance_eval{ @_extract_time_parser }
52
+
53
+ time = event_time()
54
+ record = {"key1" => "value1", "key2" => 2, "tag" => "yay", "time" => Time.now.to_i}
55
+
56
+ assert_nil @d.extract_tag_from_record(record)
57
+ assert_nil @d.extract_time_from_record(record)
58
+ end
59
+
60
+ test 'can be configured as specified' do
61
+ @d.configure(config_extract_section(
62
+ "tag_key" => "tag",
63
+ "time_key" => "time",
64
+ "time_type" => "unixtime",
65
+ ))
66
+
67
+ assert_equal "tag", @d.instance_eval{ @_extract_tag_key }
68
+ assert_equal "time", @d.instance_eval{ @_extract_time_key }
69
+ assert_equal :unixtime, @d.instance_eval{ @extract_config.time_type }
70
+ assert_not_nil @d.instance_eval{ @_extract_time_parser }
71
+ end
72
+
73
+ sub_test_case 'extract_tag_from_record' do
74
+ test 'returns tag string from specified tag_key field' do
75
+ @d.configure(config_extract_section("tag_key" => "tag"))
76
+ @d.start
77
+ @d.after_start
78
+
79
+ tag = @d.extract_tag_from_record({"tag" => "tag.test.code", "message" => "yay!"})
80
+ assert_equal "tag.test.code", tag
81
+ end
82
+
83
+ test 'returns tag as string by stringifying values from specified key' do
84
+ @d.configure(config_extract_section("tag_key" => "tag"))
85
+ @d.start
86
+ @d.after_start
87
+
88
+ tag = @d.extract_tag_from_record({"tag" => 100, "message" => "yay!"})
89
+ assert_equal "100", tag
90
+ end
91
+ end
92
+
93
+ sub_test_case 'extract_time_from_record' do
94
+ test 'returns EventTime object from specified time_key field, parsed as float in default' do
95
+ @d.configure(config_extract_section("time_key" => "t"))
96
+ @d.start
97
+ @d.after_start
98
+
99
+ # 1473135272 => 2016-09-06 04:14:32 UTC
100
+ t = @d.extract_time_from_record({"t" => 1473135272.5, "message" => "yay!"})
101
+ assert_equal_event_time(Fluent::EventTime.new(1473135272, 500_000_000), t)
102
+
103
+ t = @d.extract_time_from_record({"t" => "1473135272.5", "message" => "yay!"})
104
+ assert_equal_event_time(Fluent::EventTime.new(1473135272, 500_000_000), t)
105
+ end
106
+
107
+ test 'returns EventTime object, parsed as unixtime when configured so' do
108
+ @d.configure(config_extract_section("time_key" => "t", "time_type" => "unixtime"))
109
+ @d.start
110
+ @d.after_start
111
+
112
+ t = @d.extract_time_from_record({"t" => 1473135272, "message" => "yay!"})
113
+ assert_equal_event_time(Fluent::EventTime.new(1473135272, 0), t)
114
+
115
+ t = @d.extract_time_from_record({"t" => "1473135272", "message" => "yay!"})
116
+ assert_equal_event_time(Fluent::EventTime.new(1473135272, 0), t)
117
+
118
+ t = @d.extract_time_from_record({"t" => 1473135272.5, "message" => "yay!"})
119
+ assert_equal_event_time(Fluent::EventTime.new(1473135272, 0), t)
120
+ end
121
+
122
+ test 'returns EventTime object, parsed by default time parser of ruby with timezone in data' do
123
+ t = with_timezone("UTC-02") do
124
+ @d.configure(config_extract_section("time_key" => "t", "time_type" => "string"))
125
+ @d.start
126
+ @d.after_start
127
+ @d.extract_time_from_record({"t" => "2016-09-06 13:27:01 +0900", "message" => "yay!"})
128
+ end
129
+ assert_equal_event_time(event_time("2016-09-06 13:27:01 +0900"), t)
130
+ end
131
+
132
+ test 'returns EventTime object, parsed by default time parser of ruby as localtime' do
133
+ t = with_timezone("UTC-02") do
134
+ @d.configure(config_extract_section("time_key" => "t", "time_type" => "string"))
135
+ @d.start
136
+ @d.after_start
137
+ @d.extract_time_from_record({"t" => "2016-09-06 13:27:01", "message" => "yay!"})
138
+ end
139
+ assert_equal_event_time(event_time("2016-09-06 13:27:01 +0200"), t)
140
+ end
141
+
142
+ test 'returns EventTime object, parsed as configured time_format with timezone' do
143
+ t = with_timezone("UTC-02") do
144
+ @d.configure(config_extract_section("time_key" => "t", "time_type" => "string", "time_format" => "%H:%M:%S, %m/%d/%Y, %z"))
145
+ @d.start
146
+ @d.after_start
147
+ @d.extract_time_from_record({"t" => "13:27:01, 09/06/2016, -0700", "message" => "yay!"})
148
+ end
149
+ assert_equal_event_time(event_time("2016-09-06 13:27:01 -0700"), t)
150
+ end
151
+
152
+ test 'returns EventTime object, parsed as configured time_format in localtime without timezone' do
153
+ t = with_timezone("UTC-02") do
154
+ @d.configure(config_extract_section("time_key" => "t", "time_type" => "string", "time_format" => "%H:%M:%S, %m/%d/%Y"))
155
+ @d.start
156
+ @d.after_start
157
+ @d.extract_time_from_record({"t" => "13:27:01, 09/06/2016", "message" => "yay!"})
158
+ end
159
+ assert_equal_event_time(event_time("2016-09-06 13:27:01 +0200"), t)
160
+ end
161
+
162
+ test 'returns EventTime object, parsed as configured time_format in utc without timezone, localtime: false' do
163
+ t = with_timezone("UTC-02") do
164
+ c = config_extract_section("time_key" => "t", "time_type" => "string", "time_format" => "%H:%M:%S, %m/%d/%Y", "localtime" => "false")
165
+ @d.configure(c)
166
+ @d.start
167
+ @d.after_start
168
+ @d.extract_time_from_record({"t" => "13:27:01, 09/06/2016", "message" => "yay!"})
169
+ end
170
+ assert_equal_event_time(event_time("2016-09-06 13:27:01 UTC"), t)
171
+ end
172
+
173
+ test 'returns EventTime object, parsed as configured time_format in utc without timezone, utc: true' do
174
+ t = with_timezone("UTC-02") do
175
+ c = config_extract_section("time_key" => "t", "time_type" => "string", "time_format" => "%H:%M:%S, %m/%d/%Y", "utc" => "true")
176
+ @d.configure(c)
177
+ @d.start
178
+ @d.after_start
179
+ @d.extract_time_from_record({"t" => "13:27:01, 09/06/2016", "message" => "yay!"})
180
+ end
181
+ assert_equal_event_time(event_time("2016-09-06 13:27:01 UTC"), t)
182
+ end
183
+
184
+ test 'returns EventTime object, parsed as configured time_format in configured timezone' do
185
+ t = with_timezone("UTC-02") do
186
+ c = config_extract_section("time_key" => "t", "time_type" => "string", "time_format" => "%H:%M:%S, %m/%d/%Y", "timezone" => "+09:00")
187
+ @d.configure(c)
188
+ @d.start
189
+ @d.after_start
190
+ @d.extract_time_from_record({"t" => "13:27:01, 09/06/2016", "message" => "yay!"})
191
+ end
192
+ assert_equal_event_time(event_time("2016-09-06 13:27:01 +0900"), t)
193
+ end
194
+ end
195
+ end
@@ -410,13 +410,6 @@ class InjectHelperTest < Test::Unit::TestCase
410
410
  @time = event_time("2014-09-27 00:00:00 +00:00").to_i
411
411
  end
412
412
 
413
- def with_timezone(tz)
414
- oldtz, ENV['TZ'] = ENV['TZ'], tz
415
- yield
416
- ensure
417
- ENV['TZ'] = oldtz
418
- end
419
-
420
413
  def format(conf)
421
414
  @d.configure(config_inject_section(
422
415
  "hostname_key" => "hostnamedata",
@@ -0,0 +1,7 @@
1
+ module Fluent
2
+ Plugin.register_formatter(
3
+ 'test1',
4
+ Proc.new { |tag, time, record|
5
+ "#{tag}:#{time}:#{record.size}"
6
+ })
7
+ end
@@ -0,0 +1,7 @@
1
+ module Fluent
2
+ Plugin.register_formatter(
3
+ 'test2',
4
+ Proc.new { |tag, time, record|
5
+ "#{tag}:#{time}:#{record.size}"
6
+ })
7
+ end
@@ -1,6 +1,7 @@
1
1
  require_relative 'helper'
2
2
  require 'fluent/test'
3
3
  require 'fluent/event'
4
+ require 'fluent/plugin/compressable'
4
5
 
5
6
  module EventTest
6
7
  module DeepCopyAssertion
@@ -23,6 +24,7 @@ module EventTest
23
24
  class OneEventStreamTest < ::Test::Unit::TestCase
24
25
  include Fluent
25
26
  include DeepCopyAssertion
27
+ include Fluent::Plugin::Compressable
26
28
 
27
29
  def setup
28
30
  @time = event_time()
@@ -85,11 +87,28 @@ module EventTest
85
87
  assert_equal @record, record
86
88
  }
87
89
  end
90
+
91
+ test 'to_compressed_msgpack_stream' do
92
+ stream = @es.to_compressed_msgpack_stream
93
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(decompress(stream)) { |time, record|
94
+ assert_equal @time, time
95
+ assert_equal @record, record
96
+ }
97
+ end
98
+
99
+ test 'to_compressed_msgpack_stream with time_int argument' do
100
+ stream = @es.to_compressed_msgpack_stream(time_int: true)
101
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(decompress(stream)) { |time, record|
102
+ assert_equal @time.to_i, time
103
+ assert_equal @record, record
104
+ }
105
+ end
88
106
  end
89
107
 
90
108
  class ArrayEventStreamTest < ::Test::Unit::TestCase
91
109
  include Fluent
92
110
  include DeepCopyAssertion
111
+ include Fluent::Plugin::Compressable
93
112
 
94
113
  def setup
95
114
  time = Engine.now
@@ -161,11 +180,34 @@ module EventTest
161
180
  i += 1
162
181
  }
163
182
  end
183
+
184
+ test 'to_compressed_msgpack_stream' do
185
+ i = 0
186
+ compressed_stream = @es.to_compressed_msgpack_stream
187
+ stream = decompress(compressed_stream)
188
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
189
+ assert_equal @times[i], time
190
+ assert_equal @records[i], record
191
+ i += 1
192
+ }
193
+ end
194
+
195
+ test 'to_compressed_msgpack_stream with time_int argument' do
196
+ i = 0
197
+ compressed_stream = @es.to_compressed_msgpack_stream(time_int: true)
198
+ stream = decompress(compressed_stream)
199
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
200
+ assert_equal @times[i].to_i, time
201
+ assert_equal @records[i], record
202
+ i += 1
203
+ }
204
+ end
164
205
  end
165
206
 
166
207
  class MultiEventStreamTest < ::Test::Unit::TestCase
167
208
  include Fluent
168
209
  include DeepCopyAssertion
210
+ include Fluent::Plugin::Compressable
169
211
 
170
212
  def setup
171
213
  time = Engine.now
@@ -240,11 +282,34 @@ module EventTest
240
282
  i += 1
241
283
  }
242
284
  end
285
+
286
+ test 'to_compressed_msgpack_stream' do
287
+ i = 0
288
+ compressed_stream = @es.to_compressed_msgpack_stream
289
+ stream = decompress(compressed_stream)
290
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
291
+ assert_equal @times[i], time
292
+ assert_equal @records[i], record
293
+ i += 1
294
+ }
295
+ end
296
+
297
+ test 'to_compressed_msgpack_stream with time_int argument' do
298
+ i = 0
299
+ compressed_stream = @es.to_compressed_msgpack_stream(time_int: true)
300
+ stream = decompress(compressed_stream)
301
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
302
+ assert_equal @times[i].to_i, time
303
+ assert_equal @records[i], record
304
+ i += 1
305
+ }
306
+ end
243
307
  end
244
308
 
245
309
  class MessagePackEventStreamTest < ::Test::Unit::TestCase
246
310
  include Fluent
247
311
  include DeepCopyAssertion
312
+ include Fluent::Plugin::Compressable
248
313
 
249
314
  def setup
250
315
  pk = Fluent::Engine.msgpack_factory.packer
@@ -325,5 +390,126 @@ module EventTest
325
390
  i += 1
326
391
  }
327
392
  end
393
+
394
+ test 'to_compressed_msgpack_stream' do
395
+ i = 0
396
+ compressed_stream = @es.to_compressed_msgpack_stream
397
+ stream = decompress(compressed_stream)
398
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
399
+ assert_equal @times[i], time
400
+ assert_equal @records[i], record
401
+ i += 1
402
+ }
403
+ end
404
+ end
405
+
406
+ class CompressedMessagePackEventStreamTest < ::Test::Unit::TestCase
407
+ include Fluent
408
+ include DeepCopyAssertion
409
+ include Fluent::Plugin::Compressable
410
+
411
+ def setup
412
+ time = Engine.now
413
+ @times = [Fluent::EventTime.new(time.sec), Fluent::EventTime.new(time.sec + 1)]
414
+ @records = [{ 'k' => 'v1', 'n' => 1 }, { 'k' => 'v2', 'n' => 2 }]
415
+ @packed_record = ''
416
+ @entries = ''
417
+ @times.zip(@records).each do |_time, record|
418
+ v = [_time, record].to_msgpack
419
+ @packed_record += v
420
+ @entries += compress(v)
421
+ end
422
+ @es = CompressedMessagePackEventStream.new(@entries)
423
+ end
424
+
425
+ def ensure_data_is_decompressed
426
+ assert_equal @entries, @es.instance_variable_get(:@data)
427
+ yield
428
+ assert_equal @packed_record, @es.instance_variable_get(:@data)
429
+ end
430
+
431
+ test 'dup' do
432
+ dupped = @es.dup
433
+ assert_kind_of CompressedMessagePackEventStream, dupped
434
+ assert_not_equal @es.object_id, dupped.object_id
435
+ assert_duplicated_records @es, dupped
436
+
437
+ # After iteration of events (done in assert_duplicated_records),
438
+ # duplicated event stream still has unpacked objects and correct size
439
+ dupped = @es.dup
440
+ assert_equal 2, dupped.instance_eval{ @size }
441
+ end
442
+
443
+ test 'repeatable?' do
444
+ assert_true @es.repeatable?
445
+ end
446
+
447
+ test 'size' do
448
+ assert_equal 0, CompressedMessagePackEventStream.new('').size
449
+ ensure_data_is_decompressed { assert_equal 2, @es.size }
450
+ end
451
+
452
+ test 'each' do
453
+ i = 0
454
+ ensure_data_is_decompressed do
455
+ @es.each do |time, record|
456
+ assert_equal @times[i], time
457
+ assert_equal @records[i], record
458
+ i += 1
459
+ end
460
+ end
461
+ end
462
+
463
+ test 'slice' do
464
+ sliced = nil
465
+ ensure_data_is_decompressed { sliced = @es.slice(1,1) }
466
+ assert_kind_of EventStream, sliced
467
+ assert_equal 1, sliced.size
468
+
469
+ sliced.each do |time, record|
470
+ assert_equal @times[1], time
471
+ assert_equal 'v2', record['k']
472
+ assert_equal 2, record['n']
473
+ end
474
+
475
+ sliced = @es.slice(0,2)
476
+ assert_kind_of EventStream, sliced
477
+ assert_equal 2, sliced.size
478
+
479
+ counter = 0
480
+ sliced.each do |time, record|
481
+ assert_equal @times[counter], time
482
+ assert_equal @records[counter]['k'], record['k']
483
+ assert_equal @records[counter]['n'], record['n']
484
+ counter += 1
485
+ end
486
+ end
487
+
488
+ test 'to_msgpack_stream' do
489
+ i = 0
490
+ stream = nil
491
+ ensure_data_is_decompressed { stream = @es.to_msgpack_stream }
492
+
493
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
494
+ assert_equal @times[i], time
495
+ assert_equal @records[i], record
496
+ i += 1
497
+ }
498
+ end
499
+
500
+ test 'to_compressed_msgpack_stream' do
501
+ i = 0
502
+ # Do not call ensure_decompressed!
503
+ assert_equal @entries, @es.instance_variable_get(:@data)
504
+ compressed_stream = @es.to_compressed_msgpack_stream
505
+ assert_equal @entries, @es.instance_variable_get(:@data)
506
+
507
+ stream = decompress(compressed_stream)
508
+ Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
509
+ assert_equal @times[i], time
510
+ assert_equal @records[i], record
511
+ i += 1
512
+ }
513
+ end
328
514
  end
329
515
  end