diff options
author | Lenny Verkhovsky <lennyb@mellanox.com> | 2019-08-11 12:13:05 +0000 |
---|---|---|
committer | Adrian Chiris <adrianc@mellanox.com> | 2019-10-22 11:15:28 +0300 |
commit | 23586abc610f7fbcd0d66070b9a363acd8b6e163 (patch) | |
tree | 25007b38903c758b95bb215d72a68ab86eef28f1 /nova/tests/unit/virt/libvirt/test_vif.py | |
parent | 964d7dc87989b5765fcc60d34f734963ab8e03e7 (diff) | |
download | nova-23586abc610f7fbcd0d66070b9a363acd8b6e163.tar.gz |
Revert "vif: Resolve a TODO and update another"
This reverts commit 3f56e44b843ab8c0ee017eb58a8d77679aeb7b3b.
Closes-Bug: #1839920
MacVtap CI[1] started to fail after merging commit[2]
[1] https://wiki.openstack.org/wiki/ThirdPartySystems/Mellanox_CI
[2] https://review.opendev.org/#/c/666631/
Related-Bug: #1841067
Change-Id: Ieb901b802f7e3f08e0b5a2443bd8d3f1783260eb
Diffstat (limited to 'nova/tests/unit/virt/libvirt/test_vif.py')
-rw-r--r-- | nova/tests/unit/virt/libvirt/test_vif.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_vif.py b/nova/tests/unit/virt/libvirt/test_vif.py index 841a3de3f5..90a91f49a7 100644 --- a/nova/tests/unit/virt/libvirt/test_vif.py +++ b/nova/tests/unit/virt/libvirt/test_vif.py @@ -972,11 +972,14 @@ class LibvirtVifTestCase(test.NoDBTestCase): @mock.patch.object(pci_utils, 'get_vf_num_by_pci_address', return_value=1) @mock.patch('nova.privsep.linux_net.set_device_macaddr') @mock.patch('nova.privsep.linux_net.set_device_macaddr_and_vlan') - def test_unplug_hw_veb(self, mock_set_macaddr_and_vlan, - mock_set_macaddr, mock_get_vf_num, - mock_get_ifname): - d = vif.LibvirtGenericVIFDriver() + def _test_hw_veb_op(self, op, vlan, mock_set_macaddr_and_vlan, + mock_set_macaddr, mock_get_vf_num, + mock_get_ifname): mock_get_ifname.side_effect = ['eth1', 'eth13'] + vlan_id = int(vlan) + port_state = 'up' if vlan_id > 0 else 'down' + mac = ('00:00:00:00:00:00' if op.__name__ == 'unplug' + else self.vif_hw_veb_macvtap['address']) calls = { 'get_ifname': [mock.call(self.vif_hw_veb_macvtap['profile']['pci_slot'], @@ -984,17 +987,24 @@ class LibvirtVifTestCase(test.NoDBTestCase): mock.call(self.vif_hw_veb_macvtap['profile']['pci_slot'])], 'get_vf_num': [mock.call(self.vif_hw_veb_macvtap['profile']['pci_slot'])], - 'set_macaddr': [mock.call( - 'eth13', '00:00:00:00:00:00', port_state='down')] + 'set_macaddr': [mock.call('eth13', mac, port_state=port_state)] } - - d.unplug(self.instance, self.vif_hw_veb_macvtap) - + op(self.instance, self.vif_hw_veb_macvtap) mock_get_ifname.assert_has_calls(calls['get_ifname']) mock_get_vf_num.assert_has_calls(calls['get_vf_num']) mock_set_macaddr.assert_has_calls(calls['set_macaddr']) mock_set_macaddr_and_vlan.assert_called_once_with( - 'eth1', 1, mock.ANY, 0) + 'eth1', 1, mock.ANY, vlan_id) + + def test_plug_hw_veb(self): + d = vif.LibvirtGenericVIFDriver() + details = self.vif_hw_veb_macvtap['details'] + vlan = details[network_model.VIF_DETAILS_VLAN] + self._test_hw_veb_op(d.plug, vlan) + + def test_unplug_hw_veb(self): + d = vif.LibvirtGenericVIFDriver() + self._test_hw_veb_op(d.unplug, 0) @mock.patch('nova.network.linux_net.set_vf_trusted') def test_plug_hw_veb_trusted(self, mset_vf_trusted): |