tests: guarantee unique networks in get_list_of_random_networks
The function generates a list of random networks, but so far did not guarantee their uniqueness. In rare cases, it breaks test_subnetpool_prefixes unit test in gate that relies on those networks to be unique. Now, the function will regenerate the result several times if duplicates are detected. Change-Id: Ia300e36ad7a25dd156ac8b5f27dcdeeaa5339ab8 Closes-Bug: #1585941
This commit is contained in:
parent
2bfa41691d
commit
543e960eb7
@ -225,7 +225,12 @@ def get_random_dscp_mark():
|
||||
|
||||
|
||||
def get_list_of_random_networks(num=10):
|
||||
return [tools.get_random_ip_network() for i in range(num)]
|
||||
for i in range(5):
|
||||
res = [tools.get_random_ip_network() for i in range(num)]
|
||||
# make sure there are no duplicates
|
||||
if len(set(res)) == num:
|
||||
return res
|
||||
raise Exception('Failed to generate unique networks')
|
||||
|
||||
|
||||
FIELD_TYPE_VALUE_GENERATOR_MAP = {
|
||||
|
Loading…
Reference in New Issue
Block a user