From a84ef9ae54a7dfe6d9dee54a01b189dd40bce423 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Wed, 24 Jun 2015 03:27:16 -0700 Subject: [PATCH] Make DHCPv6 out of bounds API test deterministic The test_dhcp_stateful_fixedips_outrange API test was randomly picking an IP from last + 1 up to last + 10 in the allocation range. This made it fail randomly when there was an issue related to the subnet allocation having an off-by-one issue. This adjusts the test to just always test last +1 and +2. Related-Bug: #1468163 Change-Id: I641ab092e0ea0aae67ec717b492118a2f8a6f4fd --- neutron/tests/api/test_dhcp_ipv6.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/neutron/tests/api/test_dhcp_ipv6.py b/neutron/tests/api/test_dhcp_ipv6.py index 0adfc3f61..3e181e2d0 100644 --- a/neutron/tests/api/test_dhcp_ipv6.py +++ b/neutron/tests/api/test_dhcp_ipv6.py @@ -340,13 +340,13 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): subnet = self.create_subnet(self.network, **kwargs) ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"], subnet["allocation_pools"][0]["end"]) - ip = netaddr.IPAddress(random.randrange( - ip_range.last + 1, ip_range.last + 10)).format() - self.assertRaises(lib_exc.BadRequest, - self.create_port, - self.network, - fixed_ips=[{'subnet_id': subnet['id'], - 'ip_address': ip}]) + for i in range(1, 3): + ip = netaddr.IPAddress(ip_range.last + i).format() + self.assertRaises(lib_exc.BadRequest, + self.create_port, + self.network, + fixed_ips=[{'subnet_id': subnet['id'], + 'ip_address': ip}]) @test.idempotent_id('57b8302b-cba9-4fbb-8835-9168df029051') def test_dhcp_stateful_fixedips_duplicate(self): -- 2.45.2