Skip to content

Commit

Permalink
Add comments to test.
Browse files Browse the repository at this point in the history
  • Loading branch information
pikulmar committed Sep 13, 2021
1 parent 35a843a commit e418952
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ async def mock_send(node_id, request):
async def test_solitary_abort_marker(self):
# An abort marker may not be preceded by any aborted messages

# Setup: Create a record batch (control batch) containing
# a single transaction abort marker.
builder = DefaultRecordBatchBuilder(
magic=2, compression_type=0, is_transactional=True,
producer_id=3, producer_epoch=1, base_sequence=-1,
Expand All @@ -558,9 +560,14 @@ async def test_solitary_abort_marker(self):
key=b'\x00\x00\x00\x00', value=b'\x00\x00\x00\x00\x00\x00',
headers=[])
buffer = builder.build()

records = MemoryRecords(bytes(buffer))

# Test: In aiokafka>=0.7.2, the following line would result in a an
# exception, because the implementation assumed that any transaction
# abort marker would be preceded by at least one aborted message
# originating from the same producer_id. However, this appears to
# not always be the case, as reported in
# https://github.com/aio-libs/aiokafka/issues/781 .
partition_recs = PartitionRecords(
tp=TopicPartition('test-topic', 0),
records=records,
Expand All @@ -571,4 +578,6 @@ async def test_solitary_abort_marker(self):
check_crcs=True,
isolation_level=READ_COMMITTED)

# Since isolation_level is READ_COMMITTED, no consumer records are
# expected to be returned here.
self.assertEqual(len(list(partition_recs)), 0)

0 comments on commit e418952

Please sign in to comment.