Skip to content

Commit

Permalink
MB-51328: Reduce shard / vbucket count for KVStoreBackend tests
Browse files Browse the repository at this point in the history
Running with the full 1024 vbuckets and shards slows down tests which
check the handling of the complete vBucket set. Reduce to 16 vBuckets
and 2 shards by default.

Change-Id: I2214322f82bbef3b63b02f63510e19c217725709
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/172051
Reviewed-by: Jim Walker <jim@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
  • Loading branch information
daverigby committed Mar 10, 2022
1 parent e8db0fc commit 682fa05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions engines/ep/src/kvstore/rocksdb-kvstore/rocksdb-kvstore.cc
Expand Up @@ -497,6 +497,13 @@ void RocksDBKVStore::openDB() {
}

std::shared_ptr<VBHandle> RocksDBKVStore::getVBHandle(Vbid vbid) const {
if (vbid.get() >= configuration.getMaxVBuckets()) {
throw std::invalid_argument(
fmt::format("RocksDBKVStore::getVBHandle: {} exceeds valid "
"vBucket range (0..{})",
vbid,
configuration.getMaxVBuckets() - 1));
}
std::lock_guard<std::mutex> lg(vbhMutex);
if (vbHandles[vbid.get()]) {
return vbHandles[vbid.get()];
Expand Down
9 changes: 7 additions & 2 deletions engines/ep/tests/module_tests/kvstore_test.cc
Expand Up @@ -287,9 +287,14 @@ void KVStoreBackend::setup(const std::string& dataDir,
configStr += generateBackendConfig("persistent_" + backend) + ";";

if (backend == "magma") {
configStr += magmaConfig;
configStr += magmaConfig + ';';
}

// Run with a fixed (and lower than default) number of shards and vBuckets -
// we rarely need all 1024 vBuckets or shards, and running with smaller
// numbers makes tests faster / consume less memory etc.
configStr += "max_vbuckets=16;max_num_shards=2";

config.parseConfiguration(configStr.c_str(), get_mock_server_api());
WorkLoadPolicy workload(config.getMaxNumWorkers(),
config.getMaxNumShards());
Expand Down Expand Up @@ -1189,7 +1194,7 @@ TEST_P(KVStoreParamTest, GetItemCount) {
// Verify the negative behavour of getItemCount - if the given vbucket doens't
// exist then getItemCount should throw std::system_error.
TEST_P(KVStoreParamTest, GetItemCountInvalidVBucket) {
EXPECT_THROW(kvstore->getItemCount(Vbid{123}), std::system_error);
EXPECT_THROW(kvstore->getItemCount(Vbid{12}), std::system_error);
}

TEST_P(KVStoreParamTest, DeletedItemsForNoDeletesScanMovesLastReadSeqno) {
Expand Down

0 comments on commit 682fa05

Please sign in to comment.