Skip to content

Commit

Permalink
tests: fix test_changing_topic_retention_with_restart
Browse files Browse the repository at this point in the history
This test was assuming that segment sizes apply exactly,
but they are actually subject to a +/- 5% jitter.  To reliably
remove the expected number of segments, we must set our retention
bytes to 5% less than the amount we really expect to retain.

Fixes redpanda-data#2406
  • Loading branch information
jcsp committed Jul 4, 2022
1 parent 197b12f commit a2c0ab3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/rptest/tests/retention_policy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,15 @@ def test_changing_topic_retention_with_restart(self):
# Wait for controller, alter configs doesn't have a retry loop
kafka_tools.describe_topic(self.topic)

# When predicting segment sizes, we must account for segment_size_jitter
# which adjusts segment sizes up or down by 5%
segment_size_jitter_factor = 1.05

# change retention bytes to preserve 15 segments
self.client().alter_topic_configs(
self.topic, {
TopicSpec.PROPERTY_RETENTION_BYTES: 15 * segment_size,
TopicSpec.PROPERTY_RETENTION_BYTES:
int((15 * segment_size) / segment_size_jitter_factor),
})
wait_for_segments_removal(redpanda=self.redpanda,
topic=self.topic,
Expand Down

0 comments on commit a2c0ab3

Please sign in to comment.