From 66ef2e54e1dcc9d752d504253e83973fea9a8a9a Mon Sep 17 00:00:00 2001 From: Brian Rosmaita Date: Thu, 25 Jul 2024 08:48:33 -0400 Subject: [PATCH] More thorough mock on a backup message test Modify test_backup_create_scheduling_error to mock _choose_backend_filters(), which when left unmocked eventually causes a stevedore extension_manager to be loaded, which on some systems cannot find the filter classes. Since we want to test the generation of backup user messages and not the actual loading of filters, mock the function so that we can test what we're interested in. Change-Id: I98052eafc3a31ae64890084e943f8454d98c5a91 --- cinder/tests/unit/backup/test_backup_messages.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cinder/tests/unit/backup/test_backup_messages.py b/cinder/tests/unit/backup/test_backup_messages.py index 3ed0e9ad232..a243b2eb93a 100644 --- a/cinder/tests/unit/backup/test_backup_messages.py +++ b/cinder/tests/unit/backup/test_backup_messages.py @@ -244,6 +244,8 @@ class BackupUserMessagesTest(test.TestCase): fake_context, detail=message_field.Detail.BACKUP_CREATE_CLEANUP_ERROR) + @mock.patch('cinder.scheduler.host_manager.HostManager.' + '_choose_backend_filters') @mock.patch('cinder.scheduler.host_manager.HostManager.' '_get_available_backup_service_host') @mock.patch('cinder.volume.volume_utils.update_backup_error') @@ -252,7 +254,8 @@ class BackupUserMessagesTest(test.TestCase): @mock.patch('cinder.message.api.API.create') def test_backup_create_scheduling_error( self, mock_msg_create, mock_get_vol, mock_vol_update, - mock_update_error, mock_get_backup_host): + mock_update_error, mock_get_backup_host, mock_choose_filters): + mock_choose_filters.return_value = ['AvailabilityZoneFilter'] manager = sch_manager.SchedulerManager() fake_context = mock.MagicMock() fake_backup = mock.MagicMock(id=fake.BACKUP_ID,