NSX|V: fix broken unit tests

Commit 1af862791ef83d2d67d71a4db6d37b919accb3d5 broke us.

A general run of thumb is that in most cases when tests rely on
IP's/MAC's we should set the enable_dhcp=False. The reason for this
is that the upstream code does not have the DHCP port automatically
allocated.

Change-Id: Ibc762b17e256faa03c00eeeab75aefaa16e08592
This commit is contained in:
Gary Kotton 2016-06-22 21:17:22 -07:00
parent b460cb5316
commit 8df4ac798e

View File

@ -674,6 +674,20 @@ class TestPortsV2(NsxVPluginV2TestCase,
VIF_TYPE = nsx_constants.VIF_TYPE_DVS
HAS_PORT_FILTER = True
def test_duplicate_mac_generation(self):
# simulate duplicate mac generation to make sure DBDuplicate is retried
responses = ['12:34:56:78:00:00', '12:34:56:78:00:00',
'12:34:56:78:00:01']
with mock.patch('neutron.common.utils.get_random_mac',
side_effect=responses) as grand_mac:
with self.subnet(enable_dhcp=False) as s:
with self.port(subnet=s) as p1, self.port(subnet=s) as p2:
self.assertEqual('12:34:56:78:00:00',
p1['port']['mac_address'])
self.assertEqual('12:34:56:78:00:01',
p2['port']['mac_address'])
self.assertEqual(3, grand_mac.call_count)
def test_get_ports_count(self):
with self.port(), self.port(), self.port(), self.port() as p:
tenid = p['port']['tenant_id']