From 765691d1e28fe59f6981cd9e24d57e358163f499 Mon Sep 17 00:00:00 2001 From: Bence Romsics Date: Wed, 27 Mar 2019 16:37:51 +0100 Subject: [PATCH] Do not use subnet broadcast address in unit test neutron.tests.unit.services.revisions.test_revision_plugin.\ TestRevisionPlugin.test_port_ip_update_revises occasionally fails in the gate, because it assumes that a random IP+1 is also a valid IP. However the +1 address may be the subnet broadcast address which is then rejected by neutron. This change makes sure to use a free IP from the subnet instead of the +1 address. Change-Id: I1b27cac301cdc1acf426b0e71c037c157e93cd45 Closes-Bug: #1821948 --- .../tests/unit/services/revisions/test_revision_plugin.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/neutron/tests/unit/services/revisions/test_revision_plugin.py b/neutron/tests/unit/services/revisions/test_revision_plugin.py index cd040b64853..9184d081f8e 100644 --- a/neutron/tests/unit/services/revisions/test_revision_plugin.py +++ b/neutron/tests/unit/services/revisions/test_revision_plugin.py @@ -13,7 +13,6 @@ # under the License. # -import netaddr from neutron_lib import context as nctx from neutron_lib.db import api as db_api from neutron_lib.plugins import constants @@ -161,13 +160,12 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase): expected_code=exc.HTTPPreconditionFailed.code) def test_port_ip_update_revises(self): - with self.port() as port: + with self.subnet() as subnet, self.port() as port: rev = port['port']['revision_number'] new = {'port': {'fixed_ips': port['port']['fixed_ips']}} # ensure adding an IP allocation updates the port - next_ip = str(netaddr.IPAddress( - new['port']['fixed_ips'][0]['ip_address']) + 1) - new['port']['fixed_ips'].append({'ip_address': next_ip}) + free_ip = self._find_ip_address(subnet['subnet']) + new['port']['fixed_ips'].append({'ip_address': free_ip}) response = self._update('ports', port['port']['id'], new) self.assertEqual(2, len(response['port']['fixed_ips'])) new_rev = response['port']['revision_number']