Skip to content

Commit

Permalink
MB-47604: Unify single threaded test backend config
Browse files Browse the repository at this point in the history
Currently we supply "persistent" as the config for couchstore buckets
and manually handle the magma (and rocks) cases. Before adding another
type of backend, refactor the config to always include the backend in
the config string (e.g. "persistent_couchstore", "persistent_magma") so
that we can read the backend directly from the config.

Change-Id: I67d4b03271d6a26c9c823c0eb0f8861362fd326e
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/158649
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
  • Loading branch information
BenHuddleston authored and daverigby committed Aug 4, 2021
1 parent fe1a20e commit ca8ce4b
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2502,7 +2502,7 @@ TEST_F(CollectionsTest, PerCollectionDiskSizeRollback) {
*/
StatChecker::PostFunc getPrepareStatCheckerPostFuncForBackend(
std::string backend, StatChecker::PostFunc fn) {
if (backend.find("Magma") != std::string::npos) {
if (backend.find("magma") != std::string::npos) {
// Magma doesn't currently track prepares as we remove them during
// compaction and we don't know if we are removing a stale one or not,
// making it impossible to count them accurately. As such we also cannot
Expand Down
10 changes: 3 additions & 7 deletions engines/ep/tests/module_tests/dcp_reflection_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,11 +1120,7 @@ class DCPLoopbackSnapshots
}

auto bucketType = getBucketType();
if (bucketType == "persistentMagma") {
config_string += "bucket_type=persistent;backend=magma";
} else {
config_string += "bucket_type=" + bucketType;
}
config_string += generateBackendConfig(bucketType);

auto evictionPolicy = getEvictionPolicy();
config_string += ";item_eviction_policy=" + evictionPolicy;
Expand All @@ -1145,10 +1141,10 @@ class DCPLoopbackSnapshots
static auto persistentConfigValues() {
using namespace std::string_literals;
return ::testing::Combine(
::testing::Values("persistent"s
::testing::Values("persistent_couchstore"s
#ifdef EP_USE_MAGMA
,
"persistentMagma"s
"persistent_magma"s
#endif
),
::testing::Values("value_only"s, "full_eviction"s),
Expand Down
16 changes: 11 additions & 5 deletions engines/ep/tests/module_tests/dcp_stream_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ using namespace std::string_view_literals;
using ::testing::ElementsAre;

void StreamTest::SetUp() {
bucketType = GetParam();
if (bucketType == "persistentMagma") {
bucketType = "persistent;backend=magma;" + magmaConfig;
bucketType = getBucketType(GetParam());
if (bucketType == "persistent") {
config_string += generateBackendConfig(GetParam());
}

if (bucketType == "persistent_magma") {
bucketType += magmaConfig;
}
DCPTest::SetUp();
vb0 = engine->getVBucket(Vbid(0));
Expand Down Expand Up @@ -1444,15 +1448,17 @@ TEST_P(CacheCallbackTest, CacheCallback_engine_enomem) {
// Test cases which run in both Full and Value eviction
INSTANTIATE_TEST_SUITE_P(PersistentAndEphemeral,
StreamTest,
::testing::Values("persistent", "ephemeral"),
::testing::Values("persistent_couchstore",
"ephemeral"),
[](const ::testing::TestParamInfo<std::string>& info) {
return info.param;
});

// Test cases which run in both Full and Value eviction
INSTANTIATE_TEST_SUITE_P(PersistentAndEphemeral,
CacheCallbackTest,
::testing::Values("persistent", "ephemeral"),
::testing::Values("persistent_couchstore",
"ephemeral"),
[](const ::testing::TestParamInfo<std::string>& info) {
return info.param;
});
Expand Down
8 changes: 4 additions & 4 deletions engines/ep/tests/module_tests/dcp_stream_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ class StreamTest : public DCPTest,
using namespace std::string_literals;
return ::testing::Values(
#ifdef EP_USE_MAGMA
"persistentMagma",
"persistent_magma",
#endif
"persistent",
"persistent_couchstore",
"ephemeral");
}

static auto persistentConfigValues() {
using namespace std::string_literals;
return ::testing::Values(
#ifdef EP_USE_MAGMA
"persistentMagma",
"persistent_magma",
#endif
"persistent");
"persistent_couchstore");
}

protected:
Expand Down
8 changes: 2 additions & 6 deletions engines/ep/tests/module_tests/dcp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -999,13 +999,9 @@ class ConnectionTest : public DCPTest,
protected:
void SetUp() override {
bucketType = std::get<0>(GetParam());
if (bucketType == "persistentMagma") {
if (bucketType.find("persistent") != std::string::npos) {
config_string += generateBackendConfig(bucketType);
bucketType = "persistent";
if (!config_string.empty()) {
config_string += ";";
}
config_string += "backend=magma;";
config_string += magmaConfig;
}
DCPTest::SetUp();
vbid = Vbid(0);
Expand Down
6 changes: 3 additions & 3 deletions engines/ep/tests/module_tests/evp_store_durability_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void DurabilityEPBucketTest::testPersistPrepare(DocumentState docState) {
// beforehand is breaking something.
#ifdef THREAD_SANITIZER
auto bucketType = std::get<0>(GetParam());
if (bucketType == "persistentRocksdb") {
if (isRocksDB()) {
return;
}
#endif
Expand Down Expand Up @@ -1397,7 +1397,7 @@ void DurabilityEPBucketTest::verifyOnDiskItemCount(VBucket& vb,
// skip for rocksdb as it treats every mutation as an insertion
// and so we would expect a different item count compared with couchstore
auto bucketType = std::get<0>(GetParam());
if (bucketType == "persistentRocksdb") {
if (isRocksDB()) {
return;
}
EXPECT_EQ(expectedValue, vb.getNumTotalItems());
Expand All @@ -1408,7 +1408,7 @@ void DurabilityEPBucketTest::verifyCollectionItemCount(VBucket& vb,
uint64_t expectedValue) {
// skip for rocksdb as it dose not perform item counting for collections
auto bucketType = std::get<0>(GetParam());
if (bucketType == "persistentRocksdb") {
if (isRocksDB()) {
return;
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,8 @@ void STParameterizedBucketTest::SetUp() {
config_string += ";";
}
auto bucketType = std::get<0>(GetParam());
if (bucketType == "persistentRocksdb") {
config_string += "bucket_type=persistent;backend=rocksdb";
} else if (bucketType == "persistentMagma") {
config_string += "bucket_type=persistent;backend=magma";
} else {
config_string += "bucket_type=" + bucketType;
}
config_string += generateBucketTypeConfig(bucketType);

auto evictionPolicy = std::get<1>(GetParam());

if (!evictionPolicy.empty()) {
Expand Down
51 changes: 25 additions & 26 deletions engines/ep/tests/module_tests/evp_store_single_threaded_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,12 @@ class STParameterizedBucketTest
return ::testing::Values(
std::make_tuple("ephemeral"s, "auto_delete"s),
std::make_tuple("ephemeral"s, "fail_new_data"),
std::make_tuple("persistent"s, "value_only"s),
std::make_tuple("persistent"s, "full_eviction"s)
std::make_tuple("persistent_couchstore"s, "value_only"s),
std::make_tuple("persistent_couchstore"s, "full_eviction"s)
#ifdef EP_USE_MAGMA
,
std::make_tuple("persistentMagma"s, "value_only"s),
std::make_tuple("persistentMagma"s, "full_eviction"s)
std::make_tuple("persistent_magma"s, "value_only"s),
std::make_tuple("persistent_magma"s, "full_eviction"s)
#endif
);
}
Expand All @@ -407,54 +407,53 @@ class STParameterizedBucketTest
return ::testing::Values(
std::make_tuple("ephemeral"s, "auto_delete"s),
std::make_tuple("ephemeral"s, "fail_new_data"),
std::make_tuple("persistent"s, "value_only"s),
std::make_tuple("persistent"s, "full_eviction"s));
std::make_tuple("persistent_couchstore"s, "value_only"s),
std::make_tuple("persistent_couchstore"s, "full_eviction"s));
}

static auto persistentConfigValues() {
using namespace std::string_literals;
return ::testing::Values(
std::make_tuple("persistent"s, "value_only"s),
std::make_tuple("persistent"s, "full_eviction"s)
std::make_tuple("persistent_couchstore"s, "value_only"s),
std::make_tuple("persistent_couchstore"s, "full_eviction"s)
#ifdef EP_USE_MAGMA
,
std::make_tuple("persistentMagma"s, "value_only"s),
std::make_tuple("persistentMagma"s, "full_eviction"s)
std::make_tuple("persistent_magma"s, "value_only"s),
std::make_tuple("persistent_magma"s, "full_eviction"s)
#endif
);
}

static auto couchstoreConfigValues() {
using namespace std::string_literals;
return ::testing::Values(
std::make_tuple("persistent"s, "value_only"s),
std::make_tuple("persistent"s, "full_eviction"s));
std::make_tuple("persistent_couchstore"s, "value_only"s),
std::make_tuple("persistent_couchstore"s, "full_eviction"s));
}

#ifdef EP_USE_MAGMA
static auto magmaConfigValues() {
using namespace std::string_literals;
return ::testing::Values(
std::make_tuple("persistentMagma"s, "value_only"s),
std::make_tuple("persistentMagma"s, "full_eviction"s)
);
std::make_tuple("persistent_magma"s, "value_only"s),
std::make_tuple("persistent_magma"s, "full_eviction"s));
}
#endif

static auto persistentAllBackendsConfigValues() {
using namespace std::string_literals;
return ::testing::Values(
std::make_tuple("persistent"s, "value_only"s),
std::make_tuple("persistent"s, "full_eviction"s)
std::make_tuple("persistent_couchstore"s, "value_only"s),
std::make_tuple("persistent_couchstore"s, "full_eviction"s)
#ifdef EP_USE_MAGMA
,
std::make_tuple("persistentMagma"s, "value_only"s),
std::make_tuple("persistentMagma"s, "full_eviction"s)
std::make_tuple("persistent_magma"s, "value_only"s),
std::make_tuple("persistent_magma"s, "full_eviction"s)
#endif
#ifdef EP_USE_ROCKSDB
,
std::make_tuple("persistentRocksdb"s, "value_only"s),
std::make_tuple("persistentRocksdb"s, "full_eviction"s)
std::make_tuple("persistent_rocksdb"s, "value_only"s),
std::make_tuple("persistent_rocksdb"s, "full_eviction"s)
#endif
);
}
Expand All @@ -463,12 +462,12 @@ class STParameterizedBucketTest
using namespace std::string_literals;
return ::testing::Values(
#ifdef EP_USE_ROCKSDB
std::make_tuple("persistentRocksdb"s, "full_eviction"s),
std::make_tuple("persistent_rocksdb"s, "full_eviction"s),
#endif
#ifdef EP_USE_MAGMA
std::make_tuple("persistentMagma"s, "full_eviction"s),
std::make_tuple("persistent_magma"s, "full_eviction"s),
#endif
std::make_tuple("persistent"s, "full_eviction"s));
std::make_tuple("persistent_couchstore"s, "full_eviction"s));
}

bool persistent() const {
Expand All @@ -488,11 +487,11 @@ class STParameterizedBucketTest
}

bool isRocksDB() const {
return std::get<0>(GetParam()).find("Rocksdb") != std::string::npos;
return std::get<0>(GetParam()).find("rocksdb") != std::string::npos;
}

bool isMagma() const {
return std::get<0>(GetParam()).find("Magma") != std::string::npos;
return std::get<0>(GetParam()).find("magma") != std::string::npos;
}

std::string getBackend() const {
Expand Down
8 changes: 1 addition & 7 deletions engines/ep/tests/module_tests/evp_store_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ void EPBucketFullEvictionNoBloomFilterTest::SetUp() {

void EPBucketBloomFilterParameterizedTest::SetUp() {
auto bucketType = std::get<0>(GetParam());
if (bucketType == "persistentRocksdb") {
config_string += "bucket_type=persistent;backend=rocksdb";
} else if (bucketType == "persistentMagma") {
config_string += "bucket_type=persistent;backend=magma";
} else {
config_string += "bucket_type=" + bucketType;
}
config_string += generateBucketTypeConfig(bucketType);

config_string +=
std::string{";item_eviction_policy="} + std::get<1>(GetParam());
Expand Down
26 changes: 14 additions & 12 deletions engines/ep/tests/module_tests/evp_store_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,23 @@ class EPBucketBloomFilterParameterizedTest
using namespace std::string_literals;
return ::testing::Values(
#ifdef EP_USE_ROCKSDB
std::make_tuple("persistentRocksdb"s, "value_only"s, false),
std::make_tuple("persistentRocksdb"s, "value_only"s, true),
std::make_tuple("persistentRocksdb"s, "full_eviction"s, false),
std::make_tuple("persistentRocksdb"s, "full_eviction"s, true),
std::make_tuple("persistent_rocksdb"s, "value_only"s, false),
std::make_tuple("persistent_rocksdb"s, "value_only"s, true),
std::make_tuple("persistent_rocksdb"s, "full_eviction"s, false),
std::make_tuple("persistent_rocksdb"s, "full_eviction"s, true),
#endif
#ifdef EP_USE_MAGMA
std::make_tuple("persistentMagma"s, "value_only"s, false),
std::make_tuple("persistentMagma"s, "value_only"s, true),
std::make_tuple("persistentMagma"s, "full_eviction"s, false),
std::make_tuple("persistentMagma"s, "full_eviction"s, true),
std::make_tuple("persistent_magma"s, "value_only"s, false),
std::make_tuple("persistent_magma"s, "value_only"s, true),
std::make_tuple("persistent_magma"s, "full_eviction"s, false),
std::make_tuple("persistent_magma"s, "full_eviction"s, true),
#endif
std::make_tuple("persistent"s, "value_only"s, false),
std::make_tuple("persistent"s, "value_only"s, true),
std::make_tuple("persistent"s, "full_eviction"s, false),
std::make_tuple("persistent"s, "full_eviction"s, true));
std::make_tuple("persistent_couchstore"s, "value_only"s, false),
std::make_tuple("persistent_couchstore"s, "value_only"s, true),
std::make_tuple(
"persistent_couchstore"s, "full_eviction"s, false),
std::make_tuple(
"persistent_couchstore"s, "full_eviction"s, true));
}

protected:
Expand Down
6 changes: 2 additions & 4 deletions engines/ep/tests/module_tests/evp_store_warmup_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,7 @@ void DurabilityWarmupTest::testCommittedAndPendingSyncWrite(
auto vb = engine->getVBucket(vbid);
// @TODO: RocksDB currently only has an estimated item count in
// full-eviction, so it fails this check. Skip if RocksDB && full_eviction.
if ((std::get<0>(GetParam()).find("Rocksdb") == std::string::npos) ||
std::get<0>(GetParam()) == "value_only") {
if ((!isRocksDB()) || std::get<0>(GetParam()) == "value_only") {
EXPECT_EQ(1, vb->getNumTotalItems());
}
EXPECT_EQ(1, vb->ht.getNumPreparedSyncWrites());
Expand Down Expand Up @@ -1105,8 +1104,7 @@ TEST_P(DurabilityWarmupTest, AbortedSyncWritePrepareIsNotLoaded) {
auto vb = engine->getVBucket(vbid);
// @TODO: RocksDB currently only has an estimated item count in
// full-eviction, so it fails this check. Skip if RocksDB && full_eviction.
if ((std::get<0>(GetParam()).find("Rocksdb") == std::string::npos) ||
std::get<0>(GetParam()) == "value_only") {
if (!isRocksDB() || std::get<0>(GetParam()) == "value_only") {
EXPECT_EQ(1, vb->getNumItems());
}
EXPECT_EQ(0, vb->ht.getNumPreparedSyncWrites());
Expand Down
4 changes: 2 additions & 2 deletions engines/ep/tests/module_tests/item_pager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1871,9 +1871,9 @@ class STValueEvictionExpiryPagerTest : public STExpiryPagerTest {
static auto configValues() {
return ::testing::Values(
#ifdef EP_USE_MAGMA
std::make_tuple("persistentMagma"s, "value_only"s),
std::make_tuple("persistent_magma"s, "value_only"s),
#endif
std::make_tuple("persistent"s, "value_only"s));
std::make_tuple("persistent_couchstore"s, "value_only"s));
}
};

Expand Down
Loading

0 comments on commit ca8ce4b

Please sign in to comment.