Merge "Add functional confirm_migration_error test"

This commit is contained in:
Zuul 2019-05-14 01:02:42 +00:00 committed by Gerrit Code Review
commit 3de296389a

View File

@ -2497,6 +2497,59 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase):
new_flavor=new_flavor, source_rp_uuid=source_rp_uuid, new_flavor=new_flavor, source_rp_uuid=source_rp_uuid,
dest_rp_uuid=dest_rp_uuid) dest_rp_uuid=dest_rp_uuid)
def test_migration_confirm_resize_error(self):
source_hostname = self.compute1.host
dest_hostname = self.compute2.host
source_rp_uuid = self._get_provider_uuid_by_host(source_hostname)
dest_rp_uuid = self._get_provider_uuid_by_host(dest_hostname)
server = self._boot_and_check_allocations(self.flavor1,
source_hostname)
self._move_and_check_allocations(
server, request={'migrate': None}, old_flavor=self.flavor1,
new_flavor=self.flavor1, source_rp_uuid=source_rp_uuid,
dest_rp_uuid=dest_rp_uuid)
# Mock failure
def fake_confirm_migration(context, migration, instance, network_info):
raise exception.MigrationPreCheckError(
reason='test_migration_confirm_resize_error')
with mock.patch('nova.virt.fake.FakeDriver.'
'confirm_migration',
side_effect=fake_confirm_migration):
# Confirm the migration/resize and check the usages
post = {'confirmResize': None}
self.api.post_server_action(
server['id'], post, check_response_status=[204])
server = self._wait_for_state_change(self.api, server, 'ERROR')
# After confirming and error, we should have an allocation only on the
# destination host
self.assertFlavorMatchesUsage(dest_rp_uuid, self.flavor1)
self.assertRequestMatchesUsage({'VCPU': 0,
'MEMORY_MB': 0,
'DISK_GB': 0}, source_rp_uuid)
self.assertFlavorMatchesAllocation(self.flavor1, server['id'],
dest_rp_uuid)
self._run_periodics()
# Check we're still accurate after running the periodics
self.assertFlavorMatchesUsage(dest_rp_uuid, self.flavor1)
self.assertRequestMatchesUsage({'VCPU': 0,
'MEMORY_MB': 0,
'DISK_GB': 0}, source_rp_uuid)
self.assertFlavorMatchesAllocation(self.flavor1, server['id'],
dest_rp_uuid)
self._delete_and_check_allocations(server)
def _test_resize_revert(self, dest_hostname): def _test_resize_revert(self, dest_hostname):
source_hostname = self._other_hostname(dest_hostname) source_hostname = self._other_hostname(dest_hostname)
source_rp_uuid = self._get_provider_uuid_by_host(source_hostname) source_rp_uuid = self._get_provider_uuid_by_host(source_hostname)