|
17 | 17 |
|
18 | 18 | #include "dcp_durability_stream_test.h" |
19 | 19 |
|
| 20 | +#include "../../src/dcp/backfill-manager.h" |
20 | 21 | #include "checkpoint_utils.h" |
21 | 22 | #include "dcp/response.h" |
22 | 23 | #include "dcp_utils.h" |
@@ -205,6 +206,51 @@ TEST_P(DurabilityActiveStreamTest, SendDcpAbort) { |
205 | 206 | ASSERT_FALSE(resp); |
206 | 207 | } |
207 | 208 |
|
| 209 | +TEST_P(DurabilityActiveStreamEphemeralTest, BackfillDurabilityLevel) { |
| 210 | + auto vb = engine->getVBucket(vbid); |
| 211 | + auto& ckptMgr = *vb->checkpointManager; |
| 212 | + // Get rid of set_vb_state and any other queue_op we are not interested in |
| 213 | + ckptMgr.clear(*vb, 0 /*seqno*/); |
| 214 | + |
| 215 | + const auto key = makeStoredDocKey("key"); |
| 216 | + const auto& value = "value"; |
| 217 | + auto item = makePendingItem( |
| 218 | + key, |
| 219 | + value, |
| 220 | + cb::durability::Requirements(cb::durability::Level::Majority, |
| 221 | + 1 /*timeout*/)); |
| 222 | + VBQueueItemCtx ctx; |
| 223 | + ctx.durability = |
| 224 | + DurabilityItemCtx{item->getDurabilityReqs(), nullptr /*cookie*/}; |
| 225 | + |
| 226 | + EXPECT_EQ(MutationStatus::WasClean, public_processSet(*vb, *item, ctx)); |
| 227 | + |
| 228 | + // We don't account Prepares in VB stats |
| 229 | + EXPECT_EQ(0, vb->getNumItems()); |
| 230 | + |
| 231 | + stream->transitionStateToBackfilling(); |
| 232 | + ASSERT_TRUE(stream->isBackfilling()); |
| 233 | + |
| 234 | + // Run the backfill we scheduled when we transitioned to the backfilling |
| 235 | + // state |
| 236 | + auto& bfm = producer->getBFM(); |
| 237 | + bfm.backfill(); |
| 238 | + |
| 239 | + const auto& readyQ = stream->public_readyQ(); |
| 240 | + EXPECT_EQ(2, readyQ.size()); |
| 241 | + |
| 242 | + // First item is a snapshot marker so just skip it |
| 243 | + auto resp = stream->public_popFromReadyQ(); |
| 244 | + resp = stream->public_popFromReadyQ(); |
| 245 | + ASSERT_TRUE(resp); |
| 246 | + EXPECT_EQ(DcpResponse::Event::Prepare, resp->getEvent()); |
| 247 | + const auto& prep = static_cast<MutationResponse&>(*resp); |
| 248 | + const auto respItem = prep.getItem(); |
| 249 | + EXPECT_EQ(cb::durability::Level::Majority, |
| 250 | + respItem->getDurabilityReqs().getLevel()); |
| 251 | + EXPECT_TRUE(respItem->getDurabilityReqs().getTimeout().isInfinite()); |
| 252 | +} |
| 253 | + |
208 | 254 | TEST_P(DurabilityActiveStreamTest, RemoveUnknownSeqnoAckAtDestruction) { |
209 | 255 | auto vb = engine->getVBucket(vbid); |
210 | 256 |
|
@@ -798,3 +844,8 @@ INSTANTIATE_TEST_CASE_P( |
798 | 844 | DurabilityPassiveStreamPersistentTest, |
799 | 845 | STParameterizedBucketTest::persistentAllBackendsConfigValues(), |
800 | 846 | STParameterizedBucketTest::PrintToStringParamName); |
| 847 | + |
| 848 | +INSTANTIATE_TEST_CASE_P(AllBucketTypes, |
| 849 | + DurabilityActiveStreamEphemeralTest, |
| 850 | + STParameterizedBucketTest::ephConfigValues(), |
| 851 | + STParameterizedBucketTest::PrintToStringParamName); |
0 commit comments