]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Make DHCPv6 out of bounds API test deterministic
authorKevin Benton <blak111@gmail.com>
Wed, 24 Jun 2015 10:27:16 +0000 (03:27 -0700)
committerKevin Benton <blak111@gmail.com>
Wed, 24 Jun 2015 10:31:10 +0000 (03:31 -0700)
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

index 0adfc3f6149887bfcc43ec5ac0d196c48e79f244..3e181e2d0fa4b4fdc50dfc05609e311e4e82fe5b 100644 (file)
@@ -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):