Skip to content

Commit

Permalink
tests/admin_fuzzer: made add partitions operation idempotent
Browse files Browse the repository at this point in the history
Previously add partition operation was executed with non idempotent `rpk
add_topic_partitions`.

Fixes: redpanda-data#8562

Signed-off-by: Michal Maslanka <[email protected]>
  • Loading branch information
mmaslankaprv committed Feb 2, 2023
1 parent f513a05 commit 33cd2af
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/rptest/services/admin_ops_fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -222,16 +223,15 @@ def execute(self, ctx):
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):
Expand Down

0 comments on commit 33cd2af

Please sign in to comment.