From 8cafefb2bd51de7144218bc8da584def60d34f7c Mon Sep 17 00:00:00 2001 From: melanie witt Date: Mon, 7 Apr 2025 11:25:18 -0700 Subject: [PATCH] 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 --- .../regressions/test_bug_1899835.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/nova/tests/functional/regressions/test_bug_1899835.py b/nova/tests/functional/regressions/test_bug_1899835.py index c24309accd5a..96301d1de2aa 100644 --- a/nova/tests/functional/regressions/test_bug_1899835.py +++ b/nova/tests/functional/regressions/test_bug_1899835.py @@ -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])