Skip to content

Commit

Permalink
rptest: fix retention value in archive_retention_test
Browse files Browse the repository at this point in the history
The `retention_value` for `retention.bytes` in
`archive_retention_test.test_delete` was being set to a value of `1KiB`
by default. Sometimes, a segment smaller than `1KiB` would be produced,
and thus would not be garbage collected.

The `retention_value` is now set using the minimum segment size to ensure
all segments are properly deleted per the expectations of the test.
  • Loading branch information
WillemKauf committed May 17, 2024
1 parent 243dfe8 commit 7c8738e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/rptest/tests/archive_retention_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ def new_manifest_spilled():
# will be deleted (in case of retention.ms)
time.sleep(2)

retention_value = 1000 # 1KiB or 1s
self.logger.debug(f"Setting {retention_type} to {retention_value}")

for part_id in range(0, topic.partition_count):
ntp = NTP(ns='kafka', topic=topic.name, partition=part_id)
summaries = view.segment_summaries(ntp)
if retention_type == 'retention.bytes':
retention_value = max(
min(summaries, key=lambda s: s.size_bytes).size_bytes - 1,
0)
segments_to_delete = len(summaries)
else:
retention_value = 1000 # 1s
Expand All @@ -198,6 +198,8 @@ def new_manifest_spilled():
if s.base_timestamp < (current_time - retention_value)
])

self.logger.debug(f"Setting {retention_type} to {retention_value}")

# Note: altering the topic config will re-init the archiver and
# reset the metric tracking segment deletion. This is why we assign
# to `segments_to_delete` instead of adding.
Expand Down

0 comments on commit 7c8738e

Please sign in to comment.