diff options
author | Dana Powers <dana.powers@gmail.com> | 2018-02-26 15:03:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-26 15:03:10 -0800 |
commit | 4cadaafb24c2bdad475a68e3df5a4e19ce043ce7 (patch) | |
tree | 11382f60a18ec2a41e1f59af18a82b239e6c21d7 /test | |
parent | e66d8c42c9ebec612093b96950df81b7355e4aab (diff) | |
download | kafka-python-4cadaafb24c2bdad475a68e3df5a4e19ce043ce7.tar.gz |
Fix KafkaConsumer compacted offset handling (#1397)
Diffstat (limited to 'test')
-rw-r--r-- | test/test_fetcher.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/test_fetcher.py b/test/test_fetcher.py index 4547222..fc031f7 100644 --- a/test/test_fetcher.py +++ b/test/test_fetcher.py @@ -514,8 +514,8 @@ def test_partition_records_offset(): records = Fetcher.PartitionRecords(fetch_offset, None, messages) assert len(records) > 0 msgs = records.take(1) - assert msgs[0].offset == 123 - assert records.fetch_offset == 124 + assert msgs[0].offset == fetch_offset + assert records.fetch_offset == fetch_offset + 1 msgs = records.take(2) assert len(msgs) == 2 assert len(records) > 0 @@ -538,3 +538,20 @@ def test_partition_records_no_fetch_offset(): for i in range(batch_start, batch_end)] records = Fetcher.PartitionRecords(fetch_offset, None, messages) assert len(records) == 0 + + +def test_partition_records_compacted_offset(): + """Test that messagesets are handle correctly + when the fetch offset points to a message that has been compacted + """ + batch_start = 0 + batch_end = 100 + fetch_offset = 42 + tp = TopicPartition('foo', 0) + messages = [ConsumerRecord(tp.topic, tp.partition, i, + None, None, 'key', 'value', 'checksum', 0, 0) + for i in range(batch_start, batch_end) if i != fetch_offset] + records = Fetcher.PartitionRecords(fetch_offset, None, messages) + assert len(records) == batch_end - fetch_offset - 1 + msgs = records.take(1) + assert msgs[0].offset == fetch_offset + 1 |