From 9e03b5431d593a7912105a22587b80542fd64fb6 Mon Sep 17 00:00:00 2001 From: Michal Maslanka Date: Thu, 2 Feb 2023 11:26:34 +0100 Subject: [PATCH] tests/admin_fuzzer: made add partitions operation idempotent Previously add partition operation was executed with non idempotent `rpk add_topic_partitions`. Fixes: #8562 Signed-off-by: Michal Maslanka --- tests/rptest/services/admin_ops_fuzzer.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/rptest/services/admin_ops_fuzzer.py b/tests/rptest/services/admin_ops_fuzzer.py index f7f841d00160..4566e3eca283 100644 --- a/tests/rptest/services/admin_ops_fuzzer.py +++ b/tests/rptest/services/admin_ops_fuzzer.py @@ -15,6 +15,7 @@ import threading import time from ducktape.utils.util import wait_until +from rptest.clients.kafka_cli_tools import KafkaCliTools from rptest.clients.types import TopicSpec from time import sleep @@ -215,23 +216,21 @@ def __init__(self, prefix): self.topic = None self.total = None self.current = None - self.to_add = None def execute(self, ctx): if self.topic is None: self.topic = _choice_random_topic(ctx, prefix=self.prefix) if self.topic is None: return False - rpk = ctx.rpk() if self.total is None: self.current = len( - list(rpk.describe_topic(self.topic, tolerant=True))) - self.to_add = random.randint(1, 5) - self.total = self.current + self.to_add + list(ctx.rpk().describe_topic(self.topic, tolerant=True))) + self.total = random.randint(self.current + 1, self.current + 5) ctx.redpanda.logger.info( - f"Updating topic: {self.topic} partitions count, current: {self.current} adding: {self.to_add} partitions" + f"Updating topic: {self.topic} partitions count. Current partition count: {self.current} new partition count: {self.total}" ) - rpk.add_topic_partitions(self.topic, self.to_add) + cli = KafkaCliTools(ctx.redpanda) + cli.create_topic_partitions(self.topic, self.total) return True def validate(self, ctx):