Skip to content

Commit

Permalink
Merge pull request #8569 from mmaslankaprv/fix-8562
Browse files Browse the repository at this point in the history
Made add partitions operation idempotent in `AdminOpsFuzzer`
  • Loading branch information
mmaslankaprv authored Feb 3, 2023
2 parents 7a0ef9e + 9e03b54 commit c1e70f5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 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 @@ -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):
Expand Down

0 comments on commit c1e70f5

Please sign in to comment.