Skip to content

Commit

Permalink
tests/admin_fuzzer: query all nodes about partition count
Browse files Browse the repository at this point in the history
Since metadata are eventually consistent we query all nodes about
current partition count of a topic. Only if all values are the same we
allow to execute add partitions operation. This way operation result
will always be deterministic.

Fixes: redpanda-data#8637

Signed-off-by: Michal Maslanka <michal@redpanda.com>
  • Loading branch information
mmaslankaprv committed Feb 13, 2023
1 parent 64e4e49 commit 51e206f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/rptest/services/admin_ops_fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,32 @@ def __init__(self, prefix):
self.total = None
self.current = None

def _current_partition_count(self, ctx):

per_node_count = set()
for n in ctx.redpanda.started_nodes():
partitions = ctx.admin().get_partitions(node=n, topic=self.topic)
per_node_count.add(len(partitions))

if len(per_node_count) != 1:
ctx.redpanda.logger.info(
f"inconsistent partition count for {self.topic}: {per_node_count}"
)
return None

return next(iter(per_node_count))

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

if self.current is None:
self.current = self._current_partition_count(ctx)
if self.current is None:
return False
if self.total is None:
self.current = len(
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 partition count: {self.current} new partition count: {self.total}"
Expand Down

0 comments on commit 51e206f

Please sign in to comment.