From a2c0ab335f21b4f8ce072a87e753dd02afd67f4f Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 4 Jul 2022 11:42:20 +0100 Subject: [PATCH] tests: fix test_changing_topic_retention_with_restart 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 https://github.com/redpanda-data/redpanda/issues/2406 --- tests/rptest/tests/retention_policy_test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/rptest/tests/retention_policy_test.py b/tests/rptest/tests/retention_policy_test.py index 3bd2315440403..b07b9c7523c8a 100644 --- a/tests/rptest/tests/retention_policy_test.py +++ b/tests/rptest/tests/retention_policy_test.py @@ -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,