Skip to content

Commit

Permalink
Fix spec
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
  • Loading branch information
ganmacs committed Feb 14, 2020
1 parent 2cacb1f commit d6a9b01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
7 changes: 5 additions & 2 deletions test/plugin/test_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,10 @@ def create_chunk_es(metadata, es)
es = Fluent::ArrayEventStream.new([ [event_time('2016-04-11 16:00:02 +0000'), {"message" => "x" * (128 - 22)}] ] * 45000)
@p.write({@dm0 => es}, format: @format)

# metadata whose seq is 4 is created, but overwrite with original metadata(seq=0) for next use of this chunk https://github.com/fluent/fluentd/blob/9d113029d4550ce576d8825bfa9612aa3e55bff0/lib/fluent/plugin/buffer.rb#L357
assert_equal [@dm0], @p.stage.keys
assert_equal 5400, @p.stage[@dm0].size
assert_equal [@dm0,@dm0,@dm0,@dm0,@dm0], @p.queue.map(&:metadata)
assert_equal [@dm0, @dm0, @dm0.dup_next, @dm0.dup_next.dup_next], @p.queue.map(&:metadata)
assert_equal [5000, 9900, 9900, 9900, 9900], @p.queue.map(&:size) # splits: 45000 / 100 => 450 * ...
# 9900 * 4 + 5400 == 45000
end
Expand Down Expand Up @@ -990,7 +991,9 @@ def create_chunk_es(metadata, es)

assert_equal [@dm0], @p.stage.keys
assert_equal 900, @p.stage[@dm0].size
assert_equal [@dm0,@dm0,@dm0,@dm0,@dm0], @p.queue.map(&:metadata)
r = [@dm0]
4.times { |i| r << r[i].dup_next }
assert_equal r, @p.queue.map(&:metadata)
assert_equal [9500, 9900, 9900, 9900, 9900], @p.queue.map(&:size) # splits: 45000 / 100 => 450 * ...
##### 900 + 9500 + 9900 * 4 == 5000 + 45000
end
Expand Down
18 changes: 9 additions & 9 deletions test/plugin/test_buffer_file_chunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def gen_chunk_path(prefix, unique_id)
assert_equal content, File.open(@c.path, 'rb'){|f| f.read }

stored_meta = {
timekey: nil, tag: nil, variables: nil,
timekey: nil, tag: nil, variables: nil, seq: 0,
id: unique_id,
s: size,
c: created_at.to_i,
Expand Down Expand Up @@ -425,7 +425,7 @@ def gen_chunk_path(prefix, unique_id)
@c.commit

expected = {
timekey: nil, tag: nil, variables: nil,
timekey: nil, tag: nil, variables: nil, seq: 0,
id: @c.unique_id,
s: @c.size,
c: @c.created_at.to_i,
Expand All @@ -443,7 +443,7 @@ def gen_chunk_path(prefix, unique_id)
@c.write_metadata

expected = {
timekey: nil, tag: nil, variables: nil,
timekey: nil, tag: nil, variables: nil, seq: 0,
id: @c.unique_id,
s: @c.size,
c: @c.created_at.to_i,
Expand All @@ -454,7 +454,7 @@ def gen_chunk_path(prefix, unique_id)
@c.commit

expected = {
timekey: nil, tag: nil, variables: nil,
timekey: nil, tag: nil, variables: nil, seq: 0,
id: @c.unique_id,
s: @c.size,
c: @c.created_at.to_i,
Expand All @@ -474,7 +474,7 @@ def gen_chunk_path(prefix, unique_id)
assert_equal content, File.open(@c.path, 'rb'){|f| f.read }

stored_meta = {
timekey: nil, tag: nil, variables: nil,
timekey: nil, tag: nil, variables: nil, seq: 0,
id: unique_id,
s: size,
c: created_at.to_i,
Expand Down Expand Up @@ -519,7 +519,7 @@ def gen_chunk_path(prefix, unique_id)
end

@metadata = {
timekey: nil, tag: 'testing', variables: {k: "x"},
timekey: nil, tag: 'testing', variables: {k: "x"}, seq: 0,
id: @chunk_id,
s: 4,
c: Time.parse('2016-04-07 17:44:00 +0900').to_i,
Expand Down Expand Up @@ -592,7 +592,7 @@ def gen_chunk_path(prefix, unique_id)
@c.append([d5s])

metadata = {
timekey: nil, tag: 'testing', variables: {k: "x"},
timekey: nil, tag: 'testing', variables: {k: "x"}, seq: 0,
id: @chunk_id,
s: 4,
c: Time.parse('2016-04-07 17:44:00 +0900').to_i,
Expand All @@ -603,7 +603,7 @@ def gen_chunk_path(prefix, unique_id)
@c.write_metadata

metadata = {
timekey: nil, tag: 'testing', variables: {k: "x"},
timekey: nil, tag: 'testing', variables: {k: "x"}, seq: 0,
id: @chunk_id,
s: 5,
c: Time.parse('2016-04-07 17:44:00 +0900').to_i,
Expand Down Expand Up @@ -672,7 +672,7 @@ def gen_chunk_path(prefix, unique_id)
@dummy_timekey = Time.parse('2016-04-07 17:40:00 +0900').to_i

@metadata = {
timekey: @dummy_timekey, tag: 'testing', variables: {k: "x"},
timekey: @dummy_timekey, tag: 'testing', variables: {k: "x"}, seq: 0,
id: @chunk_id,
s: 4,
c: Time.parse('2016-04-07 17:44:00 +0900').to_i,
Expand Down

0 comments on commit d6a9b01

Please sign in to comment.