Fix test_pool sorted list assertion failures

Some of the tests expect to be able to sort on the pool NS record priority. However, the rand_ns_records fake data generator can create NS records with equal priority which leads to undefined sort orders and ultimately invalid test failures.[2]
This patch makes sure the fake ns records created for tests never have equal priority values.

[2] https://zuul.opendev.org/t/openstack/build/69325d93f36042f390b4301cfadd3aa8/log/job-output.txt#21738

Change-Id: Ic04d1fe093dee54da64ccb238e9650ad5fc47eb8
This commit is contained in:
Michael Johnson 2022-06-21 18:47:05 +00:00 committed by Erik Olof Gunnar Andersson
parent fe6e065ccf
commit c3adc64e44

View File

@ -209,11 +209,12 @@ def wildcard_ns_recordset(zone_name):
def rand_ns_records(): def rand_ns_records():
ns_zone = rand_zone_name() ns_zone = rand_zone_name()
records = [] ns_records = []
# Make sure we don't have equal priority here which causes test failures
# when doing sorted comparisons
for i in range(0, 2): for i in range(0, 2):
records.append("ns%s.%s" % (i, ns_zone)) ns_records.append({"hostname": "ns%s.%s" % (i, ns_zone),
ns_records = [{"hostname": x, "priority": random.randint(1, 999)} "priority": (random.randint(1, 999) + i)})
for x in records]
return ns_records return ns_records