diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-05-14 15:58:59 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-05-21 16:04:56 -0400 |
commit | 62906f2fae85fc734e52e7190799072717374cbb (patch) | |
tree | 5896394f8118f2ba7a19c16ce2ff692cbbfcffe6 /src | |
parent | 24a79d16b0f7f5a08520380eb1e934fbd530c966 (diff) | |
download | mongo-62906f2fae85fc734e52e7190799072717374cbb.tar.gz |
SERVER-40452 Attach uuid to createCollection oplog entry in idempotency tests
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/idempotency_test.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/idempotency_test_fixture.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback_test.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_tail_test.cpp | 15 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/mongo/db/repl/idempotency_test.cpp b/src/mongo/db/repl/idempotency_test.cpp index 91c5b5781d9..6ca379bfe64 100644 --- a/src/mongo/db/repl/idempotency_test.cpp +++ b/src/mongo/db/repl/idempotency_test.cpp @@ -184,8 +184,8 @@ void RandomizedIdempotencyTest::runIdempotencyTestCase() { for (auto doc : enumerator) { BSONObj docWithId = (BSONObjBuilder(doc) << "_id" << kDocId).obj(); - this->initOps = std::vector<OplogEntry>{createCollection(), insert(docWithId)}; for (size_t i = 0; i < kNumUpdateSequencesPerDoc; i++) { + this->initOps = std::vector<OplogEntry>{createCollection(), insert(docWithId)}; std::vector<OplogEntry> updateSequence = createUpdateSequence(updateGenerator, kUpdateSequenceLength); testOpsAreIdempotent(updateSequence, SequenceType::kAnyPrefixOrSuffix); @@ -194,8 +194,6 @@ void RandomizedIdempotencyTest::runIdempotencyTestCase() { } TEST_F(RandomizedIdempotencyTest, CheckUpdateSequencesAreIdempotent) { - // TODO: SERVER-40452 Fix this test - return; runIdempotencyTestCase(); } diff --git a/src/mongo/db/repl/idempotency_test_fixture.cpp b/src/mongo/db/repl/idempotency_test_fixture.cpp index b2e96855bf7..f9feb03e87c 100644 --- a/src/mongo/db/repl/idempotency_test_fixture.cpp +++ b/src/mongo/db/repl/idempotency_test_fixture.cpp @@ -254,8 +254,13 @@ OplogEntry makeCreateCollectionOplogEntry(OpTime opTime, const BSONObj& options) { BSONObjBuilder bob; bob.append("create", nss.coll()); + boost::optional<UUID> optionalUUID; + if (options.hasField("uuid")) { + StatusWith<UUID> uuid = UUID::parse(options.getField("uuid")); + optionalUUID = uuid.getValue(); + } bob.appendElements(options); - return makeCommandOplogEntry(opTime, nss, bob.obj()); + return makeCommandOplogEntry(opTime, nss, bob.obj(), optionalUUID); } /** @@ -394,7 +399,10 @@ void IdempotencyTest::testOpsAreIdempotent(std::vector<OplogEntry> ops, Sequence auto iterations = sequenceType == SequenceType::kEntireSequence ? 1 : ops.size(); for (std::size_t i = 0; i < iterations; i++) { - ASSERT_OK(resetState()); + // Since the end state after each iteration is expected to be the same as the start state, + // we don't drop and re-create the collections. Dropping and re-creating the collections + // won't work either because we don't have ways to wait until second-phase drop to + // completely finish. std::vector<OplogEntry> fullSequence; if (sequenceType == SequenceType::kEntireSequence) { diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index 23385e13f7f..10fec44b23b 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -1563,8 +1563,6 @@ OpTime getOpTimeFromOplogEntry(const BSONObj& entry) { } TEST_F(RSRollbackTest, RollbackApplyOpsCommand) { - // TODO: SERVER-40452 Fix this test - return; createOplog(_opCtx.get()); Collection* coll = nullptr; CollectionOptions options; @@ -1711,7 +1709,6 @@ TEST_F(RSRollbackTest, RollbackApplyOpsCommand) { mutable std::multiset<int> searchedIds; } rollbackSource(std::unique_ptr<OplogInterface>(new OplogInterfaceMock({commonOperation}))); - _createCollection(_opCtx.get(), "test.t", options); ASSERT_OK(syncRollback(_opCtx.get(), OplogInterfaceMock({applyOpsOperation, commonOperation}), rollbackSource, diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp index 64ee5471ed8..dca835707aa 100644 --- a/src/mongo/db/repl/sync_tail_test.cpp +++ b/src/mongo/db/repl/sync_tail_test.cpp @@ -362,7 +362,9 @@ TEST_F(SyncTailTest, SyncApplyCommand) { << "o" << BSON("create" << nss.coll()) << "ts" - << Timestamp(1, 1)); + << Timestamp(1, 1) + << "ui" + << UUID::gen()); bool applyCmdCalled = false; _opObserver->onCreateCollectionFn = [&](OperationContext* opCtx, Collection*, @@ -2148,8 +2150,6 @@ TEST_F(IdempotencyTest, TextIndexDocumentHasUnknownLanguage) { } TEST_F(IdempotencyTest, CreateCollectionWithValidation) { - // TODO: SERVER-40452 Fix this test - return; ASSERT_OK( ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_RECOVERING)); const BSONObj uuidObj = kUuid.toBSON(); @@ -2177,11 +2177,8 @@ TEST_F(IdempotencyTest, CreateCollectionWithValidation) { } TEST_F(IdempotencyTest, CreateCollectionWithCollation) { - // TODO: SERVER-40452 Fix this test - return; ASSERT_OK(ReplicationCoordinator::get(getGlobalServiceContext()) ->setFollowerMode(MemberState::RS_RECOVERING)); - ASSERT_OK(runOpInitialSync(createCollection())); CollectionUUID uuid = UUID::gen(); auto runOpsAndValidate = [this, uuid]() { @@ -2213,7 +2210,9 @@ TEST_F(IdempotencyTest, CreateCollectionWithCollation) { << uuid); auto createColl = makeCreateCollectionOplogEntry(nextOpTime(), nss, options); - auto ops = {insertOp1, insertOp2, updateOp, dropColl, createColl}; + // We don't drop and re-create the collection since we don't have ways + // to wait until second-phase drop to completely finish. + auto ops = {createColl, insertOp1, insertOp2, updateOp}; ASSERT_OK(runOpsInitialSync(ops)); auto state = validate(); @@ -2226,8 +2225,6 @@ TEST_F(IdempotencyTest, CreateCollectionWithCollation) { } TEST_F(IdempotencyTest, CreateCollectionWithIdIndex) { - // TODO: SERVER-40452 Fix this test - return; ASSERT_OK(ReplicationCoordinator::get(getGlobalServiceContext()) ->setFollowerMode(MemberState::RS_RECOVERING)); CollectionUUID uuid = kUuid; |