Skip to content

Commit

Permalink
tests: avoid duplicate group names in the test
Browse files Browse the repository at this point in the history
The test could create two kafka_throughput_control groups with empty
names, or other identical names. Group names are required to be unique
when present. This change guarantees unique group names provided by
the test.
  • Loading branch information
dlex committed Jun 10, 2023
1 parent 4a2b0c3 commit cf8e16b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/rptest/tests/throughput_limits_snc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,27 @@ def get_config_parameter_random_value(self, prop: ConfigProp):
if prop == self.ConfigProp.THROUGHPUT_CONTROL:
throughput_control = []
letters = string.digits + string.ascii_letters + ' '
group_names = set()
for _ in range(self.rnd.randrange(4)):
tc_item = {}

r = self.rnd.randrange(3)
if r != 0:
tc_item['name'] = ''.join(
self.rnd.choice(letters)
for _ in range(self.binexp_random(0, 512)))
while True:
new_name = ''.join(
self.rnd.choice(letters)
for _ in range(self.binexp_random(0, 512)))
if new_name not in group_names:
break
tc_item['name'] = new_name
group_names.add(new_name)

r = self.rnd.randrange(3)
if r == 0:
tc_item['client_id'] = 'client_id 1'
elif r == 2:
tc_item['client_id'] = 'client_\d+'

throughput_control.append(tc_item)
return throughput_control

Expand Down

0 comments on commit cf8e16b

Please sign in to comment.