Skip to content

Commit f7b2222

Browse files
committed
EPStoreEvictionTest: Add DeletedValue test
Change-Id: Ibd84659220c4a13bf191be702dc6b9c9f0b602c7 Reviewed-on: http://review.couchbase.org/80191 Tested-by: Build Bot <[email protected]> Reviewed-by: Oliver Downard <[email protected]>
1 parent 94359a4 commit f7b2222

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

engines/ep/tests/module_tests/evp_store_test.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,49 @@ TEST_P(EPStoreEvictionTest, SetWithMeta_ReplaceNonResident) {
321321
}
322322
}
323323

324+
// Deleted-with-Value Tests ///////////////////////////////////////////////////
325+
326+
TEST_P(EPStoreEvictionTest, DeletedValue) {
327+
// Create a deleted item which has a value, then evict it.
328+
auto key = makeStoredDocKey("key");
329+
auto item = make_item(vbid, key, "deleted value");
330+
item.setDeleted();
331+
EXPECT_EQ(ENGINE_SUCCESS, store->set(item, nullptr));
332+
333+
// The act of flushing will remove the item from the HashTable.
334+
flush_vbucket_to_disk(vbid);
335+
EXPECT_EQ(0, store->getVBucket(vbid)->getNumItems());
336+
337+
// Setup a lambda for how we want to call get (saves repeating the
338+
// same arguments for each instance below).
339+
auto do_get = [this, &key]() {
340+
auto options = get_options_t(GET_DELETED_VALUE | QUEUE_BG_FETCH);
341+
return store->get(key, vbid, cookie, options);
342+
};
343+
344+
// Try to get the Deleted-with-value key. This should return EWOULDBLOCK
345+
// (as the Deleted value is not resident).
346+
EXPECT_EQ(ENGINE_EWOULDBLOCK, do_get().getStatus())
347+
<< "Expected to need to go to disk to get Deleted-with-value key";
348+
349+
// Try a second time - this should detect the already-created temp
350+
// item, and re-schedule the bgfetch.
351+
EXPECT_EQ(ENGINE_EWOULDBLOCK, do_get().getStatus())
352+
<< "Expected to need to go to disk to get Deleted-with-value key "
353+
"(try 2)";
354+
355+
// Manually run the BGFetcher task; to fetch the two outstanding
356+
// requests (for the same key).
357+
MockGlobalTask mockTask(engine->getTaskable(), TaskId::MultiBGFetcherTask);
358+
store->getVBucket(vbid)->getShard()->getBgFetcher()->run(&mockTask);
359+
360+
auto result = do_get();
361+
EXPECT_EQ(ENGINE_SUCCESS, result.getStatus())
362+
<< "Expected to get Deleted-with-value for evicted key after "
363+
"notify_IO_complete";
364+
EXPECT_EQ("deleted value", result.item->getValue()->to_s());
365+
}
366+
324367
// Test to ensure all pendingBGfetches are deleted when the
325368
// VBucketMemoryDeletionTask is run
326369
TEST_P(EPStoreEvictionTest, MB_21976) {

0 commit comments

Comments
 (0)