'Test of when an exception occurs in an exception handler.
In backup(), after an exception occurs in
self._backup_metadata(), we want to check the process when the
second exception occurs in self.delete_backup().'

def test_backup_backup_metadata_fail2(self):

    volume_id = '2164421d-f181-4db7-b9bd-000000eeb628'
    self._create_backup_db_entry(volume_id=volume_id)
    self.flags(backup_compression_algorithm='none')
    service = swift_dr.SwiftBackupDriver(self.ctxt)
    self.volume_file.seek(0)
    backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
    def fake_backup_metadata(self, backup, object_meta):
        raise exception.BackupDriverException(message=_('fake'))
    self.mock_object(swift_dr.SwiftBackupDriver, '_backup_metadata', fake_backup_metadata)
    def fake_delete(self, backup):
        raise exception.BackupOperationError()
    self.mock_object(swift_dr.SwiftBackupDriver, 'delete_backup', fake_delete)
    self.assertRaises(exception.BackupOperationError, service.backup, backup, self.volume_file)
