diff options
author | Geert Bosch <geert@mongodb.com> | 2018-07-08 15:32:08 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2018-07-11 16:54:14 -0400 |
commit | c225e347b049a2aa8fc507d142056b396fe5bfb8 (patch) | |
tree | 4fe9aa0640fdf19afeb54cf0e6735eb5adb36389 /src/mongo/dbtests | |
parent | c9c340ad6e9e1f33cb001a8375c62d6b16138c74 (diff) | |
download | mongo-c225e347b049a2aa8fc507d142056b396fe5bfb8.tar.gz |
SERVER-36013 Remove isMMAPv1 predicates and resulting dead code
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/multikey_paths_test.cpp | 26 | ||||
-rw-r--r-- | src/mongo/dbtests/oplogstarttests.cpp | 284 |
2 files changed, 10 insertions, 300 deletions
diff --git a/src/mongo/dbtests/multikey_paths_test.cpp b/src/mongo/dbtests/multikey_paths_test.cpp index bc47129d279..d3ee08fcc8a 100644 --- a/src/mongo/dbtests/multikey_paths_test.cpp +++ b/src/mongo/dbtests/multikey_paths_test.cpp @@ -92,18 +92,14 @@ public: const IndexCatalogEntry* ice = indexCatalog->getEntry(desc); auto actualMultikeyPaths = ice->getMultikeyPaths(_opCtx.get()); - if (storageEngineSupportsPathLevelMultikeyTracking()) { - ASSERT_FALSE(actualMultikeyPaths.empty()); - const bool match = (expectedMultikeyPaths == actualMultikeyPaths); - if (!match) { - FAIL(str::stream() << "Expected: " << dumpMultikeyPaths(expectedMultikeyPaths) - << ", Actual: " - << dumpMultikeyPaths(actualMultikeyPaths)); - } - ASSERT_TRUE(match); - } else { - ASSERT_TRUE(actualMultikeyPaths.empty()); + ASSERT_FALSE(actualMultikeyPaths.empty()); + const bool match = (expectedMultikeyPaths == actualMultikeyPaths); + if (!match) { + FAIL(str::stream() << "Expected: " << dumpMultikeyPaths(expectedMultikeyPaths) + << ", Actual: " + << dumpMultikeyPaths(actualMultikeyPaths)); } + ASSERT_TRUE(match); } protected: @@ -111,14 +107,6 @@ protected: const NamespaceString _nss; private: - bool storageEngineSupportsPathLevelMultikeyTracking() { - // Path-level multikey tracking is supported for all storage engines that use the KVCatalog. - // MMAPv1 is the only storage engine that does not. - // - // TODO SERVER-22727: Store path-level multikey information in MMAPv1 index catalog. - return !getGlobalServiceContext()->getStorageEngine()->isMmapV1(); - } - std::string dumpMultikeyPaths(const MultikeyPaths& multikeyPaths) { std::stringstream ss; diff --git a/src/mongo/dbtests/oplogstarttests.cpp b/src/mongo/dbtests/oplogstarttests.cpp index 243ec79c89a..46843286ff5 100644 --- a/src/mongo/dbtests/oplogstarttests.cpp +++ b/src/mongo/dbtests/oplogstarttests.cpp @@ -46,11 +46,6 @@ static const NamespaceString nss("unittests.oplogstarttests"); class Base { public: Base() : _lk(&_opCtx), _context(&_opCtx, nss.ns()), _client(&_opCtx) { - // Replication is not supported by mobile SE. - if (mongo::storageGlobalParams.engine == "mobile") { - return; - } - Collection* c = _context.db()->getCollection(&_opCtx, nss); if (!c) { WriteUnitOfWork wuow(&_opCtx); @@ -61,10 +56,6 @@ public: } ~Base() { - // Replication is not supported by mobile SE. - if (mongo::storageGlobalParams.engine == "mobile") { - return; - } client()->dropCollection(nss.ns()); // The OplogStart stage is not allowed to outlive it's RecoveryUnit. @@ -125,10 +116,6 @@ private: class OplogStartIsOldest : public Base { public: void run() { - // Replication is not supported by mobile SE. - if (mongo::storageGlobalParams.engine == "mobile") { - return; - } for (int i = 0; i < 10; ++i) { client()->insert(nss.ns(), BSON("_id" << i << "ts" << Timestamp(1000, i))); } @@ -153,10 +140,6 @@ public: class OplogStartIsNewest : public Base { public: void run() { - // Replication is not supported by mobile SE. - if (mongo::storageGlobalParams.engine == "mobile") { - return; - } for (int i = 0; i < 10; ++i) { client()->insert(nss.ns(), BSON("_id" << i << "ts" << Timestamp(1000, i))); } @@ -177,278 +160,17 @@ public: } }; -/** - * Find the starting oplog record by hopping to the - * beginning of the extent. - */ -class OplogStartIsNewestExtentHop : public Base { -public: - void run() { - // Replication is not supported by mobile SE. - if (mongo::storageGlobalParams.engine == "mobile") { - return; - } - for (int i = 0; i < 10; ++i) { - client()->insert(nss.ns(), BSON("_id" << i << "ts" << Timestamp(1000, i))); - } - - setupFromQuery(BSON("ts" << BSON("$gte" << Timestamp(1000, 1)))); - - WorkingSetID id = WorkingSet::INVALID_ID; - // ensure that we go into extent hopping mode immediately - _stage->setBackwardsScanTime(0); - - // We immediately switch to extent hopping mode, and - // should find the beginning of the extent - ASSERT_EQUALS(_stage->work(&id), PlanStage::ADVANCED); - ASSERT(_stage->isExtentHopping()); - - assertWorkingSetMemberHasId(id, 0); - } -}; - -class SizedExtentHopBase : public Base { +class All : public Suite { public: - SizedExtentHopBase() { - // Replication is not supported by mobile SE. - if (mongo::storageGlobalParams.engine == "mobile") { - return; - } - client()->dropCollection(nss.ns()); - } - virtual ~SizedExtentHopBase() { - // Replication is not supported by mobile SE. - if (mongo::storageGlobalParams.engine == "mobile") { - return; - } - client()->dropCollection(nss.ns()); - } + All() : Suite("oplogstart") {} - void run() { + void setupTests() { // Replication is not supported by mobile SE. if (mongo::storageGlobalParams.engine == "mobile") { return; } - buildCollection(); - - WorkingSetID id = WorkingSet::INVALID_ID; - setupFromQuery(BSON("ts" << BSON("$gte" << Timestamp(1000, tsGte())))); - - // ensure that we go into extent hopping mode immediately - _stage->setBackwardsScanTime(0); - - // hop back extent by extent - for (int i = 0; i < numHops(); i++) { - ASSERT_EQUALS(_stage->work(&id), PlanStage::NEED_TIME); - ASSERT(_stage->isExtentHopping()); - } - // find the right loc without hopping again - ASSERT_EQUALS(_stage->work(&id), finalState()); - - int startDocId = tsGte() - 1; - if (startDocId >= 0) { - assertWorkingSetMemberHasId(id, startDocId); - } - } - -protected: - void buildCollection() { - BSONObj info; - // Create a collection with specified extent sizes - BSONObj command = - BSON("create" << nss.coll() << "capped" << true << "$nExtents" << extentSizes()); - ASSERT(client()->runCommand(nss.db().toString(), command, info)); - - // Populate documents. - for (int i = 0; i < numDocs(); ++i) { - client()->insert( - nss.ns(), - BSON("_id" << i << "ts" << Timestamp(1000, i + 1) << "payload" << payload8k())); - } - } - - static string payload8k() { - return string(8 * 1024, 'a'); - } - /** An extent of this size is too small to contain one document containing payload8k(). */ - static int tooSmall() { - return 1 * 1024; - } - /** An extent of this size fits one document. */ - static int fitsOne() { - return 10 * 1024; - } - /** An extent of this size fits many documents. */ - static int fitsMany() { - return 50 * 1024; - } - - // to be defined by subclasses - virtual BSONArray extentSizes() const = 0; - virtual int numDocs() const = 0; - virtual int numHops() const = 0; - virtual PlanStage::StageState finalState() const { - return PlanStage::ADVANCED; - } - virtual int tsGte() const { - return 1; - } -}; - -/** - * Test hopping over a single empty extent. - * - * Collection structure: - * - * [--- extent 0 --] [ ext 1 ] [--- extent 2 ---] - * [ {_id: 0} ] [<empty>] [ {_id: 1} ] - */ -class OplogStartOneEmptyExtent : public SizedExtentHopBase { - virtual int numDocs() const { - return 2; - } - virtual int numHops() const { - return 1; - } - virtual BSONArray extentSizes() const { - return BSON_ARRAY(fitsOne() << tooSmall() << fitsOne()); - } -}; - -/** - * Test hopping over two consecutive empty extents. - * - * Collection structure: - * - * [--- extent 0 --] [ ext 1 ] [ ext 2 ] [--- extent 3 ---] - * [ {_id: 0} ] [<empty>] [<empty>] [ {_id: 1} ] - */ -class OplogStartTwoEmptyExtents : public SizedExtentHopBase { - virtual int numDocs() const { - return 2; - } - virtual int numHops() const { - return 1; - } - virtual BSONArray extentSizes() const { - return BSON_ARRAY(fitsOne() << tooSmall() << tooSmall() << fitsOne()); - } -}; - -/** - * Two extents, each filled with several documents. This - * should require us to make just a single extent hop. - */ -class OplogStartTwoFullExtents : public SizedExtentHopBase { - virtual int numDocs() const { - return 10; - } - virtual int numHops() const { - return 1; - } - virtual BSONArray extentSizes() const { - return BSON_ARRAY(fitsMany() << fitsMany()); - } -}; - -/** - * Four extents in total. Three are populated with multiple - * documents, but one of the middle extents is empty. This - * should require two extent hops. - */ -class OplogStartThreeFullOneEmpty : public SizedExtentHopBase { - virtual int numDocs() const { - return 14; - } - virtual int numHops() const { - return 2; - } - virtual BSONArray extentSizes() const { - return BSON_ARRAY(fitsMany() << fitsMany() << tooSmall() << fitsMany()); - } -}; - -/** - * Test that extent hopping mode works properly in the - * special case of one extent. - */ -class OplogStartOneFullExtent : public SizedExtentHopBase { - virtual int numDocs() const { - return 4; - } - virtual int numHops() const { - return 0; - } - virtual BSONArray extentSizes() const { - return BSON_ARRAY(fitsMany()); - } -}; - -/** - * Collection structure: - * - * [ ext 0 ] [--- extent 1 --] [--- extent 2 ---] - * [<empty>] [ {_id: 0} ] [ {_id: 1} ] - */ -class OplogStartFirstExtentEmpty : public SizedExtentHopBase { - virtual int numDocs() const { - return 2; - } - virtual int numHops() const { - return 1; - } - virtual BSONArray extentSizes() const { - return BSON_ARRAY(tooSmall() << fitsOne() << fitsOne()); - } -}; - -/** - * Find that we need to start from the very beginning of - * the collection (the EOF case), after extent hopping - * to the beginning. - * - * This requires two hops: one between the two extents, - * and one to hop back to the "null extent" which precedes - * the first extent. - */ -class OplogStartEOF : public SizedExtentHopBase { - virtual int numDocs() const { - return 2; - } - virtual int numHops() const { - return 2; - } - virtual BSONArray extentSizes() const { - return BSON_ARRAY(fitsOne() << fitsOne()); - } - virtual PlanStage::StageState finalState() const { - return PlanStage::IS_EOF; - } - virtual int tsGte() const { - return 0; - } -}; - -class All : public Suite { -public: - All() : Suite("oplogstart") {} - - void setupTests() { add<OplogStartIsOldest>(); add<OplogStartIsNewest>(); - - // These tests rely on extent allocation details specific to mmapv1. - // TODO figure out a way to generically test this. - if (getGlobalServiceContext()->getStorageEngine()->isMmapV1()) { - add<OplogStartIsNewestExtentHop>(); - add<OplogStartOneEmptyExtent>(); - add<OplogStartTwoEmptyExtents>(); - add<OplogStartTwoFullExtents>(); - add<OplogStartThreeFullOneEmpty>(); - add<OplogStartOneFullExtent>(); - add<OplogStartFirstExtentEmpty>(); - add<OplogStartEOF>(); - } } }; |