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 3b35500
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/plugin/test_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,37 @@ 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

purge_count = 0

stub.proxy(@p).generate_chunk(anything) do |chunk|
stub.proxy(chunk).purge do |result|
purge_count += 1
result
end
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)
small_row = "x" * 1024 * 400
row = "x" * 1024 * 1024 * 8
@p.write({m => [small_row] * 41 + [row]})

assert_equal 2, purge_count
end
end

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

0 comments on commit 3b35500

Please sign in to comment.