Skip to content

Commit 10e725d

Browse files
committed
Merge branch 'couchbase/mad-hatter' into master
* branch 'couchbase/mad-hatter': MB-41804: Track correct number of vbuckets in each state Change-Id: I768047d78a5de4daa33ae6ca0dc60937f3524d99
2 parents 0397231 + b624230 commit 10e725d

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
@@ -1669,6 +1669,31 @@ TEST_P(KVBucketParamTest, VBucketDiskStatsENOENT) {
16691669
EXPECT_EQ(expected, store->getPerVBucketDiskStats({}, mockStatFn));
16701670
}
16711671

1672+
TEST_P(KVBucketParamTest, VbucketStateCounts) {
1673+
// confirm the vbMap correctly changes the number of vbuckets in a given
1674+
// state when vbuckets change state
1675+
auto vbA = Vbid(0);
1676+
auto vbB = Vbid(1);
1677+
1678+
auto expectVbCounts = [this](uint16_t active, uint16_t replica) {
1679+
auto message = "Expected " + std::to_string(active) + " active and " +
1680+
std::to_string(replica) + " replica vbs";
1681+
EXPECT_EQ(active, store->getNumOfVBucketsInState(vbucket_state_active))
1682+
<< message;
1683+
EXPECT_EQ(replica,
1684+
store->getNumOfVBucketsInState(vbucket_state_replica))
1685+
<< message;
1686+
};
1687+
store->setVBucketState(vbA, vbucket_state_active);
1688+
expectVbCounts(1, 0);
1689+
store->setVBucketState(vbB, vbucket_state_active);
1690+
expectVbCounts(2, 0);
1691+
store->setVBucketState(vbA, vbucket_state_replica);
1692+
expectVbCounts(1, 1);
1693+
store->setVBucketState(vbB, vbucket_state_replica);
1694+
expectVbCounts(0, 2);
1695+
}
1696+
16721697
class StoreIfTest : public KVBucketTest {
16731698
public:
16741699
void SetUp() override {

0 commit comments

Comments
 (0)