Skip to content

Commit fa6a12c

Browse files
committed
MB-41804: Merge branch 'couchbase/alice' into mad-hatter
* commit 'b624230ca': MB-41804: Track correct number of vbuckets in each state Change-Id: Ide966bba2c30fc0fe91a1521c52bdb66b5a41ac5
2 parents 67cd140 + b624230 commit fa6a12c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

engines/ep/tests/module_tests/kv_bucket_test.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,31 @@ TEST_P(KVBucketParamTest, VBucketDiskStatsENOENT) {
15911591
EXPECT_EQ(expected, store->getPerVBucketDiskStats({}, mockStatFn));
15921592
}
15931593

1594+
TEST_P(KVBucketParamTest, VbucketStateCounts) {
1595+
// confirm the vbMap correctly changes the number of vbuckets in a given
1596+
// state when vbuckets change state
1597+
auto vbA = Vbid(0);
1598+
auto vbB = Vbid(1);
1599+
1600+
auto expectVbCounts = [this](uint16_t active, uint16_t replica) {
1601+
auto message = "Expected " + std::to_string(active) + " active and " +
1602+
std::to_string(replica) + " replica vbs";
1603+
EXPECT_EQ(active, store->getNumOfVBucketsInState(vbucket_state_active))
1604+
<< message;
1605+
EXPECT_EQ(replica,
1606+
store->getNumOfVBucketsInState(vbucket_state_replica))
1607+
<< message;
1608+
};
1609+
store->setVBucketState(vbA, vbucket_state_active);
1610+
expectVbCounts(1, 0);
1611+
store->setVBucketState(vbB, vbucket_state_active);
1612+
expectVbCounts(2, 0);
1613+
store->setVBucketState(vbA, vbucket_state_replica);
1614+
expectVbCounts(1, 1);
1615+
store->setVBucketState(vbB, vbucket_state_replica);
1616+
expectVbCounts(0, 2);
1617+
}
1618+
15941619
class StoreIfTest : public KVBucketTest {
15951620
public:
15961621
void SetUp() override {

0 commit comments

Comments
 (0)