Skip to content

Commit

Permalink
Add test for checking chunk.commit isn't called against closed one
Browse files Browse the repository at this point in the history
Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Dec 12, 2023
1 parent 92d09bd commit bd3d03e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/plugin/test_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,35 @@ def create_chunk_es(metadata, es)
test '#compress returns :text' do
assert_equal :text, @p.compress
end

# https://github.com/fluent/fluentd/issues/3089#issuecomment-1811839198
test "closed chunk should not be committed" do
assert_equal 8 * 1024 * 1024, @p.chunk_limit_size
assert_equal 0.95, @p.chunk_full_threshold

stub.proxy(@p).generate_chunk(anything) do |chunk|
stub.proxy(chunk).commit do |result|
assert_false(chunk.closed?)
result
end
stub.proxy(chunk).rollback do |result|
assert_false(chunk.closed?)
result
end
chunk
end

m = @p.metadata(timekey: Time.parse('2016-04-11 16:40:00 +0000').to_i)
row = "x" * 1024 * 1024 * 8
small_row = "x" * 1024 * 400
@p.write({m => [small_row] * 40 + [row] + [small_row] * 1})

assert_equal [@dm0, @dm1, @dm1, m, m, m], @p.queue.map(&:metadata)
assert_equal [@dm2, @dm3, m], @p.stage.keys
assert_equal 1, @p.stage[m].append_count
assert_equal 1024 * 400, @p.stage[m].bytesize
assert_equal 1, @p.queue.last.append_count
end
end

sub_test_case 'standard format with configuration for test with lower chunk limit size' do
Expand Down

0 comments on commit bd3d03e

Please sign in to comment.