1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3 * Copyright 2016 Couchbase, Inc
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "callbacks.h"
21 #include "checkpoint.h"
22 #include "configuration.h"
23 #include "hash_table.h"
24 #include "item_pager.h"
26 #include <gtest/gtest.h>
30 class VBucketBGFetchItem;
33 * Dummy callback to replace the flusher callback.
35 class DummyCB: public Callback<uint16_t> {
39 void callback(uint16_t &dummy) { }
43 * Test fixture for VBucket tests.
45 * Templated on the Item Eviction policy to use.
48 : public ::testing::Test,
49 public ::testing::WithParamInterface<item_eviction_policy_t> {
55 std::vector<StoredDocKey> generateKeys(int num, int start = 0);
57 AddStatus addOne(const StoredDocKey& k, int expiry = 0);
59 void addMany(std::vector<StoredDocKey>& keys, AddStatus expect);
61 MutationStatus setOne(const StoredDocKey& k, int expiry = 0);
63 void setMany(std::vector<StoredDocKey>& keys, MutationStatus expect);
65 void softDeleteOne(const StoredDocKey& k, MutationStatus expect);
67 void softDeleteMany(std::vector<StoredDocKey>& keys, MutationStatus expect);
69 StoredValue* findValue(StoredDocKey& key);
71 void verifyValue(StoredDocKey& key,
73 TrackReference trackReference,
74 WantsDeleted wantDeleted);
76 std::pair<HashTable::HashBucketLock, StoredValue*> lockAndFind(
77 const StoredDocKey& key);
79 MutationStatus public_processSet(Item& itm, const uint64_t cas);
81 AddStatus public_processAdd(Item& itm);
83 MutationStatus public_processSoftDelete(const DocKey& key,
87 bool public_deleteStoredValue(const DocKey& key);
89 GetValue public_getAndUpdateTtl(const DocKey& key, time_t exptime);
91 std::unique_ptr<VBucket> vbucket;
93 CheckpointConfig checkpoint_config;
97 class EPVBucketTest : public VBucketTest {
99 size_t public_queueBGFetchItem(
101 std::unique_ptr<VBucketBGFetchItem> fetchItem,
102 BgFetcher* bgFetcher);