@@ -2694,7 +2694,8 @@ TEST_P(EPBucketCDCTest, CollectionNonHistorical) {
26942694 const uint64_t initialHighSeqno = 1 ;
26952695 ASSERT_EQ (initialHighSeqno, vb->getHighSeqno ()); // From SetUp
26962696
2697- const auto key = makeStoredDocKey (" key" , CollectionEntry::defaultC);
2697+ const auto collection = CollectionEntry::defaultC;
2698+ const auto key = makeStoredDocKey (" key" , collection);
26982699 store_item (vbid, key, " valueA" );
26992700 store_item (vbid, key, " valueB" );
27002701 EXPECT_EQ (initialHighSeqno + 2 , vb->getHighSeqno ());
@@ -2705,23 +2706,33 @@ TEST_P(EPBucketCDCTest, CollectionNonHistorical) {
27052706 EXPECT_EQ (1 , manager.getNumOpenChkItems ());
27062707 EXPECT_EQ (initialHighSeqno + 2 , manager.getHighSeqno ());
27072708
2709+ // Preconditions before flushing
2710+ // magma
27082711 constexpr auto statName = " magma_NSets" ;
27092712 size_t nSets = 0 ;
27102713 const auto & underlying = *store->getRWUnderlying (vbid);
27112714 ASSERT_TRUE (underlying.getStat (statName, nSets));
27122715 ASSERT_EQ (1 , nSets);
2716+ // KV
2717+ const auto & manifest = vb->getManifest ();
2718+ ASSERT_EQ (0 , manifest.lock (collection).getItemCount ());
27132719
2720+ // Test + postconditions
27142721 flush_vbucket_to_disk (vbid, 1 );
2722+ // magma
27152723 ASSERT_TRUE (underlying.getStat (statName, nSets));
27162724 EXPECT_EQ (2 , nSets);
2725+ // KV
2726+ EXPECT_EQ (1 , manifest.lock (collection).getItemCount ());
27172727}
27182728
27192729TEST_P (EPBucketCDCTest, CollectionHistorical) {
27202730 auto vb = store->getVBucket (vbid);
27212731 const uint64_t initialHighSeqno = 1 ;
27222732 ASSERT_EQ (initialHighSeqno, vb->getHighSeqno ()); // From SetUp
27232733
2724- const auto key = makeStoredDocKey (" key" , CollectionEntry::historical);
2734+ const auto collection = CollectionEntry::historical;
2735+ const auto key = makeStoredDocKey (" key" , collection);
27252736 store_item (vbid, key, " valueA" );
27262737 store_item (vbid, key, " valueB" );
27272738 EXPECT_EQ (initialHighSeqno + 2 , vb->getHighSeqno ());
@@ -2732,15 +2743,24 @@ TEST_P(EPBucketCDCTest, CollectionHistorical) {
27322743 EXPECT_EQ (1 , manager.getNumOpenChkItems ());
27332744 EXPECT_EQ (initialHighSeqno + 2 , manager.getHighSeqno ());
27342745
2746+ // Preconditions before flushing
2747+ // magma
27352748 constexpr auto statName = " magma_NSets" ;
27362749 size_t nSets = 0 ;
27372750 const auto & underlying = *store->getRWUnderlying (vbid);
27382751 ASSERT_TRUE (underlying.getStat (statName, nSets));
27392752 ASSERT_EQ (1 , nSets);
2753+ // KV
2754+ const auto & manifest = vb->getManifest ();
2755+ ASSERT_EQ (0 , manifest.lock (collection).getItemCount ());
27402756
2757+ // Test + postconditions
27412758 flush_vbucket_to_disk (vbid, 2 );
2759+ // magma
27422760 ASSERT_TRUE (underlying.getStat (statName, nSets));
27432761 EXPECT_EQ (3 , nSets);
2762+ // KV - Note: item count doesn't increase for historical revisions
2763+ EXPECT_EQ (1 , manifest.lock (collection).getItemCount ());
27442764}
27452765
27462766TEST_P (EPBucketCDCTest, CollectionInterleaved) {
@@ -2795,20 +2815,32 @@ TEST_P(EPBucketCDCTest, CollectionInterleaved) {
27952815 EXPECT_EQ (initialHighSeqno + 4 , (*it)->getBySeqno ());
27962816 EXPECT_EQ (keyNonHistorical, (*it)->getDocKey ());
27972817
2818+ // Preconditions
2819+ // magma
27982820 constexpr auto statName = " magma_NSets" ;
27992821 size_t initialNSets = 0 ;
28002822 const auto & underlying = *store->getRWUnderlying (vbid);
28012823 ASSERT_TRUE (underlying.getStat (statName, initialNSets));
28022824 EXPECT_EQ (1 , initialNSets);
2825+ // KV
2826+ const auto & manifest = vb->getManifest ();
2827+ ASSERT_EQ (0 , manifest.lock (CollectionEntry::historical).getItemCount ());
2828+ ASSERT_EQ (0 , manifest.lock (CollectionEntry::defaultC).getItemCount ());
28032829
2830+ // Test + postconditions
28042831 // Note:
28052832 // . 2 historical mutations -> both persisted
28062833 // . 2 non-historical mutations -> only 1 persisted
28072834 const auto expectedNumPersisted = 3 ;
28082835 flush_vbucket_to_disk (vbid, expectedNumPersisted);
2836+ // magma
28092837 size_t nSets = 0 ;
28102838 ASSERT_TRUE (underlying.getStat (statName, nSets));
28112839 EXPECT_EQ (initialNSets + expectedNumPersisted, nSets);
2840+ // KV
2841+ // Note: item count doesn't increase for historical revisions
2842+ EXPECT_EQ (1 , manifest.lock (CollectionEntry::historical).getItemCount ());
2843+ EXPECT_EQ (1 , manifest.lock (CollectionEntry::defaultC).getItemCount ());
28122844}
28132845
28142846INSTANTIATE_TEST_SUITE_P (EPBucketCDCTest,
0 commit comments