Skip to content

Commit

Permalink
rptest: Test for future offset for leader epoch
Browse files Browse the repository at this point in the history
- Ensure that the returned epoch end offset is -1 for requested epoch's
that are in the future.

- Ensure that the returned leader epoch is not the current epoch but
actually the requested epoch.

(cherry picked from commit 1d5d6de)
  • Loading branch information
graphcareful committed Jul 13, 2023
1 parent 98793ff commit 3018539
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/rptest/tests/offset_for_leader_epoch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def test_offset_for_leader_epoch(self):

for o in leader_epoch_offsets:
# check if the offset epoch matches what is expected or it is not available
# (may be the case if leader wasn't elected in term 1 but other term in this case the offset for term 1 will not be presetn)
# (may be the case if leader wasn't elected in term 1 but other term in this case the offset for term 1 will not be present)
assert initial_offsets[(o.topic,
o.partition)] == o.epoch_end_offset or (
o.epoch_end_offset == -1
and o.leader_epoch > 1)
and o.leader_epoch == 1)

# restart all the nodes to force leader election,
# increase start timeout as partition count may get large
Expand All @@ -129,7 +129,7 @@ def test_offset_for_leader_epoch(self):
assert initial_offsets[(o.topic,
o.partition)] == o.epoch_end_offset or (
o.epoch_end_offset == -1
and o.leader_epoch > 2)
and o.leader_epoch == 1)

last_offsets = self.list_offsets(topics=topics,
total_partitions=total_partitions)
Expand All @@ -152,6 +152,16 @@ def test_offset_for_leader_epoch(self):
for o in leader_epoch_offsets:
assert o.error is not None and "UNKNOWN_LEADER_EPOCH" in o.error

# test case for requested_epoch larger then leader_epoch

leader_epoch_offsets = kcl.offset_for_leader_epoch(topics=topic_names,
leader_epoch=15000)

for o in leader_epoch_offsets:
# Ensure the leader_epoch returned is not the current leader_epoch
# but the requested
assert o.error == '' and o.leader_epoch == 15000 and o.epoch_end_offset == -1

@cluster(num_nodes=6, log_allow_list=RESTART_LOG_ALLOW_LIST)
def test_offset_for_leader_epoch_transfer(self):

Expand Down

0 comments on commit 3018539

Please sign in to comment.