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

@common_mocks
@mock.patch('fcntl.fcntl', spec=True)
@mock.patch('subprocess.Popen', spec=True)
def test_backup_volume_from_rbd_fail2(self, mock_popen, mock_fnctl):

    backup_name = self.service._get_backup_base_name(self.backup_id, diff_format=True)
    def mock_write_data():
        self.volume_file.seek(0)
        data = self.volume_file.read(self.data_length)
        self.callstack.append('write')
        checksum.update(data)
        test_file.write(data)
    def mock_read_data():
        self.callstack.append('read')
        return self.volume_file.read(self.data_length)
    self._setup_mock_popen(mock_popen, ['out', 'err'], p1hook=mock_read_data, p2hook=mock_write_data)
    self.mock_rbd.RBD.list = mock.Mock()
    self.mock_rbd.RBD.list.return_value = [backup_name]
    with mock.patch.object(self.service, 'get_backup_snaps'):
        with mock.patch.object(self.service, '_rbd_diff_transfer'):
            with mock.patch.object(self.service, '_full_backup'):
                with mock.patch.object(self.service, '_backup_metadata') as mock_backup_metadata:
                    def mock_backup_metadata_side_effect(backup):
                        raise exception.BackupOperationError(_('mock'))
                    mock_backup_metadata.side_effect = mock_backup_metadata_side_effect
                    with mock.patch.object(self.service, 'delete_backup') as mock_delete:
                        def mock_delete_side_effect(backup):
                            raise self.service.rbd.ImageBusy()
                        mock_delete.side_effect = mock_delete_side_effect
                        with tempfile.NamedTemporaryFile() as test_file:
                            checksum = hashlib.sha256()
                            image = self.service.rbd.Image()
                            meta = linuxrbd.RBDImageMetadata(image, 'pool_foo', 'user_foo', 'conf_foo')
                            rbdio = linuxrbd.RBDVolumeIOWrapper(meta)
                            self.assertRaises(self.service.rbd.ImageBusy, self.service.backup, self.backup, rbdio)
