1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 *     Copyright 2018 Couchbase, Inc
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 */
17
18/*
19 * Unit tests for the checkpoint remover and associated functions.
20 */
21
22#pragma once
23
24#include "checkpoint.h"
25#include "evp_store_single_threaded_test.h"
26#include "evp_store_test.h"
27
28class CheckpointManager;
29
30/*
31 * A subclass of KVBucketTest which uses a fake ExecutorPool,
32 * which will not spawn ExecutorThreads and hence not run any tasks
33 * automatically in the background. All tasks must be manually run().
34 */
35class CheckpointRemoverTest : public SingleThreadedKVBucketTest {
36public:
37    /**
38     * Get the maximum number of items allowed in a checkpoint for the given
39     * vBucket
40     */
41    size_t getMaxCheckpointItems(VBucket& vb);
42};
43
44/**
45 * Test fixture for single-threaded tests on EPBucket.
46 */
47class CheckpointRemoverEPTest : public CheckpointRemoverTest {
48protected:
49    EPBucket& getEPBucket() {
50        return dynamic_cast<EPBucket&>(*store);
51    }
52};
53
54/**
55 * Stateless class used to gain privileged access into CheckpointManager for
56 * testing purposes. This is a friend class of CheckpointManager.
57 */
58class CheckpointManagerTestIntrospector {
59public:
60    static const CheckpointList& public_getCheckpointList(
61            CheckpointManager& checkpointManager);
62};
63