Merge "[fullstack] Be able to delete port when fake VM is destroyed"

This commit is contained in:
Zuul 2021-01-16 12:27:50 +00:00 committed by Gerrit Code Review
commit 74aabb0eaa
2 changed files with 9 additions and 8 deletions

View File

@ -197,15 +197,16 @@ class FakeFullstackMachine(machine_fixtures.FakeMachineBase):
)
)
def destroy(self):
def destroy(self, delete_port=False):
"""Destroy this fake machine.
This should simulate deletion of a vm. It doesn't call cleanUp().
"""
self.safe_client.client.update_port(
self.neutron_port['id'],
{'port': {pbs.HOST_ID: ''}}
)
if delete_port:
self.safe_client.client.delete_port(self.neutron_port['id'])
else:
self.safe_client.client.update_port(self.neutron_port['id'],
{'port': {pbs.HOST_ID: ''}})
# All associated vlan interfaces are deleted too
# If VM is connected to Linuxbridge it hasn't got "delete_port" method
# and it is not necessary to delete tap port connected to this bridge.

View File

@ -380,7 +380,7 @@ class TestBwLimitQoSOvs(_TestBwLimitQoS, base.BaseFullStackTestCase):
vm, BANDWIDTH_LIMIT, BANDWIDTH_BURST, self.direction)
# Delete port with qos policy attached
vm.destroy()
vm.destroy(delete_port=True)
self._wait_for_bw_rule_removed(vm, self.direction)
self.assertIsNone(vm.bridge.find_qos(vm.port.name))
self.assertIsNone(vm.bridge.find_queue(vm.port.name,
@ -511,7 +511,7 @@ class _TestDscpMarkingQoS(BaseQoSRuleTestCase):
self._wait_for_dscp_marking_rule_applied(vm, DSCP_MARK)
# Delete port with qos policy attached
vm.destroy()
vm.destroy(delete_port=True)
self._wait_for_dscp_marking_rule_removed(vm)
@ -746,7 +746,7 @@ class TestMinBwQoSOvs(_TestMinBwQoS, base.BaseFullStackTestCase):
self.assertEqual(queue.uuid, queues[0]['_uuid'])
# Delete port with qos policy attached
vm_qos.destroy()
vm_qos.destroy(delete_port=True)
self._wait_for_min_bw_rule_removed(vm_qos, self.direction)
self.assertEqual(
[],