Amend functional reproducer for bug 1899835

This adds mocking of ComputeManager._live_migration_cleanup_flags()
to simulate no shared storage. Otherwise the test detects shared
storage and skips a second call to _disconnect_volume() that occurs in
the bug scenario when storage is local.

Related-Bug: #1899835

Change-Id: I06b19044876aab9b4585384352f8dccc39984526
This commit is contained in:
melanie witt
2025-04-07 11:25:18 -07:00
parent 46736446ab
commit 8cafefb2bd

View File

@@ -12,6 +12,8 @@
from unittest import mock
import fixtures
from nova import context
from nova import objects
from nova import test
@@ -37,6 +39,11 @@ class TestVolumeDisconnectDuringPreLiveMigrationRollback(base.ServersTestBase):
super().setUp()
self.start_compute(hostname='src')
self.start_compute(hostname='dest')
# Flags should indicate no shared storage: (do_cleanup, destroy_disks)
self.useFixture(fixtures.MockPatch(
'nova.compute.manager.ComputeManager.'
'_live_migration_cleanup_flags',
new=mock.Mock(return_value=(True, True))))
def test_disconnect_volume_called_during_pre_live_migration_failure(self):
server = {
@@ -102,5 +109,16 @@ class TestVolumeDisconnectDuringPreLiveMigrationRollback(base.ServersTestBase):
# FIXME(lyarwood): This is bug #1899835, disconnect_volume shouldn't be
# called on the destination host without connect_volume first being
# called and especially using with the connection_info from the source
mock_dest_disconnect.assert_called_with(
self.assertEqual(2, mock_dest_disconnect.call_count)
# First call is from ComputeManager._remove_volume_connection() called
# eventually from ComputeManager._rollback_live_migration() on the
# source.
call1 = mock.call(
mock.ANY, src_connection_info, mock.ANY, encryption=mock.ANY)
# Second call is from LibvirtDriver.destroy() =>
# LibvirtDriver.cleanup() on the destination as part of
# ComputeManager.rollback_live_migration_at_destination().
call2 = mock.call(
mock.ANY, src_connection_info, mock.ANY, destroy_secrets=True,
force=True)
mock_dest_disconnect.assert_has_calls([call1, call2])