self.assertTrue(mock_delete_volume.called)
self.assertTrue(mock_delete_snapshot.called)
+ @mock.patch('cinder.objects.backup.BackupList.get_all_by_host')
+ @mock.patch('cinder.manager.SchedulerDependentManager._add_to_threadpool')
+ def test_init_host_with_service_inithost_offload(self,
+ mock_add_threadpool,
+ mock_get_all_by_host):
+ self.override_config('backup_service_inithost_offload', True)
+ vol1_id = self._create_volume_db_entry()
+ db.volume_update(self.ctxt, vol1_id, {'status': 'available'})
+ backup1 = self._create_backup_db_entry(status='deleting',
+ volume_id=vol1_id)
+
+ vol2_id = self._create_volume_db_entry()
+ db.volume_update(self.ctxt, vol2_id, {'status': 'available'})
+ backup2 = self._create_backup_db_entry(status='deleting',
+ volume_id=vol2_id)
+ mock_get_all_by_host.return_value = [backup1, backup2]
+ self.backup_mgr.init_host()
+ calls = [mock.call(self.backup_mgr.delete_backup, mock.ANY, backup1),
+ mock.call(self.backup_mgr.delete_backup, mock.ANY, backup2)]
+ mock_add_threadpool.assert_has_calls(calls, any_order=True)
+ self.assertEqual(2, mock_add_threadpool.call_count)
+
@mock.patch.object(db, 'volume_get')
@ddt.data(KeyError, exception.VolumeNotFound)
- def test_cleanup_temp_volumes_snapshots(self,
- err,
- mock_volume_get):
+ def test_cleanup_temp_volumes_snapshots_volume_not_found(
+ self, err, mock_volume_get):
"""Ensure we handle missing volume for a backup."""
mock_volume_get.side_effect = [err]