@@ -491,7 +491,7 @@ TEST_P(VBucketDurabilityTest, Active_Commit_MultipleReplicas) {
491491 CheckpointManagerTestIntrospector::public_getCheckpointList (
492492 *ckptMgr);
493493
494- auto checkPending = [this , &key, &ckptList]() -> void {
494+ auto checkPending = [this , &key, &ckptList, preparedSeqno ]() -> void {
495495 EXPECT_EQ (nullptr , ht->findForRead (key).storedValue );
496496 const auto sv = ht->findForWrite (key).storedValue ;
497497 ASSERT_NE (nullptr , sv);
@@ -501,11 +501,13 @@ TEST_P(VBucketDurabilityTest, Active_Commit_MultipleReplicas) {
501501 for (const auto & qi : *ckptList.front ()) {
502502 if (!qi->isCheckPointMetaItem ()) {
503503 EXPECT_EQ (queue_op::pending_sync_write, qi->getOperation ());
504+ EXPECT_EQ (preparedSeqno, qi->getBySeqno ());
505+ EXPECT_EQ (" value" , qi->getValue ()->to_s ());
504506 }
505507 }
506508 };
507509
508- auto checkCommitted = [this , &key, &ckptList]() -> void {
510+ auto checkCommitted = [this , &key, &ckptList, preparedSeqno ]() -> void {
509511 const auto sv = ht->findForRead (key).storedValue ;
510512 ASSERT_NE (nullptr , sv);
511513 EXPECT_NE (nullptr , ht->findForWrite (key).storedValue );
@@ -515,6 +517,9 @@ TEST_P(VBucketDurabilityTest, Active_Commit_MultipleReplicas) {
515517 for (const auto & qi : *ckptList.front ()) {
516518 if (!qi->isCheckPointMetaItem ()) {
517519 EXPECT_EQ (queue_op::commit_sync_write, qi->getOperation ());
520+ EXPECT_GT (qi->getBySeqno () /* commitSeqno*/ , preparedSeqno);
521+ EXPECT_EQ (preparedSeqno, qi->getPrepareSeqno ());
522+ EXPECT_EQ (" value" , qi->getValue ()->to_s ());
518523 }
519524 }
520525 };
@@ -679,7 +684,8 @@ TEST_P(VBucketDurabilityTest, NonPendingKeyAtAbort) {
679684 * 3) the abort_sync_write is not added to the DurabilityMonitor
680685 */
681686TEST_P (VBucketDurabilityTest, Active_AbortSyncWrite) {
682- storeSyncWrites ({1 } /* seqno*/ );
687+ const int64_t preparedSeqno = 1 ;
688+ storeSyncWrites ({preparedSeqno});
683689 ASSERT_EQ (1 ,
684690 VBucketTestIntrospector::public_getActiveDM (*vbucket)
685691 .getNumTracked ());
@@ -695,9 +701,9 @@ TEST_P(VBucketDurabilityTest, Active_AbortSyncWrite) {
695701 // Visible at write
696702 auto storedItem = ht->findForWrite (key);
697703 ASSERT_TRUE (storedItem.storedValue );
698- // item pending
699704 EXPECT_EQ (CommittedState::Pending,
700705 storedItem.storedValue ->getCommitted ());
706+ EXPECT_EQ (preparedSeqno, storedItem.storedValue ->getBySeqno ());
701707 }
702708
703709 const auto & ckptList =
@@ -719,6 +725,7 @@ TEST_P(VBucketDurabilityTest, Active_AbortSyncWrite) {
719725 it++;
720726 ASSERT_EQ (1 , ckpt->getNumItems ());
721727 EXPECT_EQ (queue_op::pending_sync_write, (*it)->getOperation ());
728+ EXPECT_EQ (preparedSeqno, (*it)->getBySeqno ());
722729 EXPECT_EQ (" value" , (*it)->getValue ()->to_s ());
723730
724731 // The Pending is tracked by the DurabilityMonitor
@@ -765,6 +772,8 @@ TEST_P(VBucketDurabilityTest, Active_AbortSyncWrite) {
765772 EXPECT_EQ (queue_op::abort_sync_write, (*it)->getOperation ());
766773 EXPECT_TRUE ((*it)->isDeleted ());
767774 EXPECT_FALSE ((*it)->getValue ());
775+ EXPECT_GT ((*it)->getBySeqno (), preparedSeqno);
776+ EXPECT_EQ (preparedSeqno, (*it)->getPrepareSeqno ());
768777
769778 // The Aborted item is not added for tracking.
770779 // Note: The Pending has not been removed as we are testing at VBucket
@@ -1026,8 +1035,9 @@ void VBucketDurabilityTest::testHTSyncDeleteCommit() {
10261035 auto * writeView = ht->findForWrite (key).storedValue ;
10271036 ASSERT_TRUE (writeView);
10281037 VBQueueItemCtx ctx;
1029- ctx.durability =
1030- DurabilityItemCtx{{cb::durability::Level::Majority, {}}, cookie};
1038+ ctx.durability = DurabilityItemCtx{
1039+ cb::durability::Requirements{cb::durability::Level::Majority, {}},
1040+ cookie};
10311041 ASSERT_EQ (MutationStatus::WasDirty,
10321042 public_processSoftDelete (key, ctx).first );
10331043
@@ -1462,14 +1472,28 @@ void VBucketDurabilityTest::testCompleteSWInPassiveDM(vbucket_state_t state,
14621472 const auto & ckptList =
14631473 CheckpointManagerTestIntrospector::public_getCheckpointList (
14641474 *ckptMgr);
1475+ // 1 checkpoint
14651476 ASSERT_EQ (1 , ckptList.size ());
1466- EXPECT_EQ (writes.size (), ckptList.front ()->getNumItems ());
1477+ // empty-item
1478+ const auto & ckpt = *ckptList.front ();
1479+ auto it = ckpt.begin ();
1480+ ASSERT_EQ (queue_op::empty, (*it)->getOperation ());
1481+ // 1 metaitem (checkpoint-start)
1482+ it++;
1483+ ASSERT_EQ (1 , ckpt.getNumMetaItems ());
1484+ EXPECT_EQ (queue_op::checkpoint_start, (*it)->getOperation ());
1485+ // 3 non-metaitem are Committed or Aborted
1486+ ASSERT_EQ (writes.size (), ckpt.getNumItems ());
14671487 const auto expectedOp =
14681488 (res == Resolution::Commit ? queue_op::commit_sync_write
14691489 : queue_op::abort_sync_write);
1470- for (const auto & qi : *ckptList.front ()) {
1471- if (!qi->isCheckPointMetaItem ()) {
1472- EXPECT_EQ (expectedOp, qi->getOperation ());
1490+ for (const auto & prepare : writes) {
1491+ it++;
1492+ EXPECT_EQ (expectedOp, (*it)->getOperation ());
1493+ EXPECT_GT ((*it)->getBySeqno () /* commitSeqno*/ , prepare.seqno );
1494+ EXPECT_EQ (prepare.seqno , (*it)->getPrepareSeqno ());
1495+ if (expectedOp == queue_op::commit_sync_write) {
1496+ EXPECT_EQ (" value" , (*it)->getValue ()->to_s ());
14731497 }
14741498 }
14751499
0 commit comments