Skip to content

Commit

Permalink
Merge pull request #11756 from andijcr/issue/11182/further_fixes
Browse files Browse the repository at this point in the history
rptest/util: wait_for_local_storage_truncate robust on empty partitions
  • Loading branch information
jcsp authored Jun 29, 2023
2 parents 43ae692 + d99b3e6 commit d14fd22
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/rptest/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,11 @@ def wait_for_local_storage_truncate(redpanda,
redpanda.logger.debug(
"Waiting for local storage to be truncated to {target_bytes} bytes")

sizes: list[int] = []

def is_truncated():
storage = redpanda.storage(sizes=True)
nonlocal sizes
sizes = []
for node_partition in storage.partitions("kafka", topic):
if partition_idx is not None and node_partition.num != partition_idx:
Expand Down Expand Up @@ -269,11 +272,18 @@ def is_truncated():
threshold = target_bytes + 4096

# We expect to have measured size on at least one node, or this isn't meaningful
assert len(sizes) > 0
if len(sizes) == 0:
return False

return all(s <= threshold for s in sizes)

wait_until(is_truncated, timeout_sec=timeout_sec, backoff_sec=1)
wait_until(
is_truncated,
timeout_sec=timeout_sec,
backoff_sec=1,
err_msg=lambda:
f"truncation couldn't be verified for {topic=} and {target_bytes=}. last run partition_sizes={sizes}"
)


@contextmanager
Expand Down

0 comments on commit d14fd22

Please sign in to comment.