From 6648e344a9bfb538bac68e6f2cb5b12f9cb4a828 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Wed, 18 Sep 2019 13:46:32 +0200 Subject: [PATCH] Trigger real BuildAbortException during migrate with bandwidth The functional test test_migrate_server_with_qos_port_pci_update_fail_not_reschedule used fault injection to simulate that the _update_pci_request_spec_with_allocated_interface_name call raises BuildAbortException during migrating a instance with an SRIOV port having resource request. We can do a bit better. This patch simulates that neutron names the PF device RP in placement in an unexpected way. Therefore the test does not need to mock anything in nova to simulate the same failure. Change-Id: Ib72f15eb62fd50ea7117df577478f555a8478724 blueprint: support-move-ops-with-qos-ports --- nova/tests/functional/test_servers.py | 35 +++++++++++++++------------ 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index a7bfdaf898c3..19bbcad92107 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -6794,6 +6794,16 @@ class ServerMoveWithPortResourceRequestTest( new_flavor=self.flavor_with_group_policy_bigger) def test_migrate_server_with_qos_port_pci_update_fail_not_reschedule(self): + # Update the name of the network device RP of PF2 on host2 to something + # unexpected. This will cause + # _update_pci_request_spec_with_allocated_interface_name() to raise + # when the instance is migrated to the host2. + rsp = self.placement_api.put( + '/resource_providers/%s' + % self.sriov_dev_rp_per_host[self.compute2_rp_uuid][self.PF2], + {"name": "invalid-device-rp-name"}) + self.assertEqual(200, rsp.status) + self._start_compute('host3') compute3_rp_uuid = self._get_provider_uuid_by_host('host3') self._create_networking_rp_tree('host3', compute3_rp_uuid) @@ -6810,24 +6820,19 @@ class ServerMoveWithPortResourceRequestTest( server, self.compute1_rp_uuid, non_qos_port, qos_port, qos_sriov_port, self.flavor_with_group_policy) - # The patched compute manager on host2 will raise from + # The compute manager on host2 will raise from # _update_pci_request_spec_with_allocated_interface_name which will # intentionally not trigger a re-schedule even if there is host3 as an # alternate. - with mock.patch.object( - self.computes['host2'].manager, - '_update_pci_request_spec_with_allocated_interface_name', - side_effect=exception.BuildAbortException( - instance_uuid=server['id'], reason='Testing')): - self.api.post_server_action(server['id'], {'migrate': None}) - server = self._wait_for_server_parameter( - self.api, server, - {'OS-EXT-SRV-ATTR:host': 'host1', - # Note that we have to wait for the task_state to be reverted - # to None since that happens after the fault is recorded. - 'OS-EXT-STS:task_state': None, - 'status': 'ERROR'}) - self._wait_for_migration_status(server, ['error']) + self.api.post_server_action(server['id'], {'migrate': None}) + server = self._wait_for_server_parameter( + self.api, server, + {'OS-EXT-SRV-ATTR:host': 'host1', + # Note that we have to wait for the task_state to be reverted + # to None since that happens after the fault is recorded. + 'OS-EXT-STS:task_state': None, + 'status': 'ERROR'}) + self._wait_for_migration_status(server, ['error']) self.assertIn( 'Build of instance %s aborted' % server['id'],