From 7a204f63e92b570d0ff872e3cb47555abd6174b2 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 12 Jan 2021 17:51:39 +0000 Subject: [PATCH] [fullstack] Be able to delete port when fake VM is destroyed When a VM fixture is destroyed, the port now can be deleted instead of unbinding it. That will update the ML2 plugin cache. When the port is actually deleted from the system, the ML2 agent should detect it and trigger the deletion process. Change-Id: I0ecbaf6f6e0b5b6b538956f2b47e7f11ce21341b Closes-Bug: #1909234 --- neutron/tests/fullstack/resources/machine.py | 11 ++++++----- neutron/tests/fullstack/test_qos.py | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/neutron/tests/fullstack/resources/machine.py b/neutron/tests/fullstack/resources/machine.py index e60f31129da..3184f10362c 100644 --- a/neutron/tests/fullstack/resources/machine.py +++ b/neutron/tests/fullstack/resources/machine.py @@ -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. diff --git a/neutron/tests/fullstack/test_qos.py b/neutron/tests/fullstack/test_qos.py index 9b39173de0c..7a3b8306adb 100644 --- a/neutron/tests/fullstack/test_qos.py +++ b/neutron/tests/fullstack/test_qos.py @@ -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( [],