Merge "Set lower addr to avoid IP out of range" into stable/rocky

This commit is contained in:
Zuul 2019-04-05 21:10:48 +00:00 committed by Gerrit Code Review
commit 3a1a394762
1 changed files with 12 additions and 1 deletions

View File

@ -99,7 +99,15 @@ class PortForwardingTestCase(PortForwardingTestCaseBase):
self._set_router_gw(self.router['id'], self.ext_net['id'])
self._add_router_interface(self.router['id'], self.subnet['id'])
self.fip = self._create_floatingip(self.ext_net['id'])
self.port = self._create_port(self.fmt, self.net['id']).json['port']
# We choose an IP address in the middle of the subnet so
# tests that update the IP in the port,
# like test_concurrent_create_port_forwarding_update_port(),
# don't accidentally choose an invalid IP address in
# the subnet, like the broadcast address.
self.port = self._create_port(
self.fmt, self.net['id'],
fixed_ips=[{'subnet_id': self.subnet['id'],
'ip_address': '10.0.0.100'}]).json['port']
self.port_forwarding = {
apidef.RESOURCE_NAME:
{apidef.EXTERNAL_PORT: 2225,
@ -387,6 +395,9 @@ class PortForwardingTestCase(PortForwardingTestCaseBase):
funcs, args_list)
def test_concurrent_create_port_forwarding_update_port(self):
# The initial IP address of the port is in the middle of the
# subnet range, so adding 2 to it should also produce a
# valid IP address.
new_ip = str(
netaddr.IPAddress(self.port['fixed_ips'][0]['ip_address']) + 2)
funcs = [self.pf_plugin.create_floatingip_port_forwarding,