'Validate the behavior for a failure during snapshot creation'

@ddt.data(False, True)
def test_create_snapshot_failure(self, cleanup_failure):

    vol = copy.deepcopy(eseries_fake.VOLUME)
    snapshot_group = copy.deepcopy(eseries_fake.SNAPSHOT_GROUP)
    snap_vol = copy.deepcopy(eseries_fake.SNAPSHOT_VOLUME)
    fake_label = 'fakeName'
    create_fail_exc = exception.NetAppDriverException('fail_create')
    cleanup_fail_exc = exception.NetAppDriverException('volume_deletion')
    if cleanup_failure:
        exc_msg = cleanup_fail_exc.msg
        delete_snap_grp = self.mock_object(self.library, '_delete_snapshot_group', side_effect=cleanup_fail_exc)
    else:
        exc_msg = create_fail_exc.msg
        delete_snap_grp = self.mock_object(self.library, '_delete_snapshot_group')
    self.mock_object(self.library, '_get_volume', return_value=vol)
    self.mock_object(self.library._client, 'create_snapshot_image', side_effect=create_fail_exc)
    self.mock_object(self.library._client, 'create_snapshot_volume', return_value=snap_vol)
    self.mock_object(self.library, '_get_available_snapshot_group', return_value=snapshot_group)
    self.mock_object(utils, 'convert_uuid_to_es_fmt', return_value=fake_label)
    fake_snapshot = copy.deepcopy(eseries_fake.FAKE_CINDER_SNAPSHOT)
    self.assertRaisesRegexp(exception.NetAppDriverException, exc_msg, self.library.create_snapshot, fake_snapshot)
    self.assertTrue(delete_snap_grp.called)
