diff options
author | jannaerin <golden.janna@gmail.com> | 2023-02-01 20:54:39 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-08 02:46:14 +0000 |
commit | 567bcd0e4822d726aea15f0338c89c49de2a56b5 (patch) | |
tree | fa2a6ea1d3cbd4872fba26df3fdb44548544206f /src/mongo/db/storage/kv | |
parent | f7afadd90f50662b2b3b3a45595b65b37a59bdc3 (diff) | |
download | mongo-567bcd0e4822d726aea15f0338c89c49de2a56b5.tar.gz |
SERVER-73112 Expose function to construct NamespaceString in unit tests
Diffstat (limited to 'src/mongo/db/storage/kv')
-rw-r--r-- | src/mongo/db/storage/kv/durable_catalog_test.cpp | 29 | ||||
-rw-r--r-- | src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/storage/kv/storage_engine_test.cpp | 32 |
3 files changed, 39 insertions, 28 deletions
diff --git a/src/mongo/db/storage/kv/durable_catalog_test.cpp b/src/mongo/db/storage/kv/durable_catalog_test.cpp index 9bf2a31e610..b079b4b965c 100644 --- a/src/mongo/db/storage/kv/durable_catalog_test.cpp +++ b/src/mongo/db/storage/kv/durable_catalog_test.cpp @@ -66,7 +66,7 @@ public: void setUp() override { CatalogTestFixture::setUp(); - _nss = NamespaceString("unittests.durable_catalog"); + _nss = NamespaceString::createNamespaceString_forTest("unittests.durable_catalog"); _collectionUUID = createCollection(_nss, CollectionOptions()).uuid; } @@ -271,7 +271,7 @@ protected: return res; } - NamespaceString nss{"unittest", "import"}; + NamespaceString nss = NamespaceString::createNamespaceString_forTest("unittest", "import"); std::string ident; std::string idxIdent; std::shared_ptr<BSONCollectionCatalogEntry::MetaData> md; @@ -806,7 +806,7 @@ TEST_F(DurableCatalogTest, IdentSuffixUsesRand) { const std::string rand = "0000000000000000000"; getCatalog()->setRand_forTest(rand); - const NamespaceString nss = NamespaceString("a.b"); + const NamespaceString nss = NamespaceString::createNamespaceString_forTest("a.b"); auto uuid = (createCollection(nss, CollectionOptions())).uuid; auto collection = CollectionCatalog::get(operationContext()) @@ -832,7 +832,7 @@ TEST_F(ImportCollectionTest, ImportCollectionRandConflict) { { // Check that a newly created collection doesn't use 'rand' as the suffix in the ident. - const NamespaceString nss = NamespaceString("a.b"); + const NamespaceString nss = NamespaceString::createNamespaceString_forTest("a.b"); auto catalogId = (createCollection(nss, CollectionOptions())).catalogId; ASSERT(!StringData(getCatalog()->getEntry(catalogId).ident).endsWith(rand)); @@ -846,7 +846,8 @@ TEST_F(DurableCatalogTest, CheckTimeseriesBucketsMayHaveMixedSchemaDataFlagFCVLa serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest); { - const NamespaceString regularNss = NamespaceString("test.regular"); + const NamespaceString regularNss = + NamespaceString::createNamespaceString_forTest("test.regular"); createCollection(regularNss, CollectionOptions()); Lock::GlobalLock globalLock{operationContext(), MODE_IS}; @@ -859,7 +860,8 @@ TEST_F(DurableCatalogTest, CheckTimeseriesBucketsMayHaveMixedSchemaDataFlagFCVLa } { - const NamespaceString bucketsNss = NamespaceString("system.buckets.ts"); + const NamespaceString bucketsNss = + NamespaceString::createNamespaceString_forTest("system.buckets.ts"); CollectionOptions options; options.timeseries = TimeseriesOptions(/*timeField=*/"t"); createCollection(bucketsNss, options); @@ -881,7 +883,8 @@ TEST_F(DurableCatalogTest, CreateCollectionCatalogEntryHasCorrectTenantNamespace gMultitenancySupport = true; auto tenantId = TenantId(OID::gen()); - const NamespaceString nss = NamespaceString(tenantId, "test.regular"); + const NamespaceString nss = + NamespaceString::createNamespaceString_forTest(tenantId, "test.regular"); createCollection(nss, CollectionOptions()); auto collection = CollectionCatalog::get(operationContext()) @@ -910,15 +913,17 @@ TEST_F(DurableCatalogTest, ScanForCatalogEntryByNssBasic) { */ auto tenantId = TenantId(OID::gen()); - const NamespaceString nssFirst = NamespaceString(tenantId, "test.first"); + const NamespaceString nssFirst = + NamespaceString::createNamespaceString_forTest(tenantId, "test.first"); auto catalogIdAndUUIDFirst = createCollection(nssFirst, CollectionOptions()); - const NamespaceString nssSecond = NamespaceString("system.buckets.ts"); + const NamespaceString nssSecond = + NamespaceString::createNamespaceString_forTest("system.buckets.ts"); CollectionOptions options; options.timeseries = TimeseriesOptions(/*timeField=*/"t"); auto catalogIdAndUUIDSecond = createCollection(nssSecond, options); - const NamespaceString nssThird = NamespaceString("test.third"); + const NamespaceString nssThird = NamespaceString::createNamespaceString_forTest("test.third"); auto catalogIdAndUUIDThird = createCollection(nssThird, CollectionOptions()); /** @@ -954,8 +959,8 @@ TEST_F(DurableCatalogTest, ScanForCatalogEntryByNssBasic) { nssFirst); ASSERT_EQ(getCatalog()->getEntry(catalogIdAndUUIDFirst.catalogId).nss, nssFirst); - auto catalogEntryDoesNotExist = - getCatalog()->scanForCatalogEntryByNss(operationContext(), NamespaceString("foo", "bar")); + auto catalogEntryDoesNotExist = getCatalog()->scanForCatalogEntryByNss( + operationContext(), NamespaceString::createNamespaceString_forTest("foo", "bar")); ASSERT(catalogEntryDoesNotExist == boost::none); } diff --git a/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp b/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp index f2e5b0b3641..21614b2446a 100644 --- a/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp +++ b/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp @@ -203,8 +203,10 @@ public: auto op = makeOperation(); WriteUnitOfWork wuow(op); std::string ns = "a.b"; - ASSERT_OK(engine->createRecordStore(op, NamespaceString(ns), ns, CollectionOptions())); - rs = engine->getRecordStore(op, NamespaceString(ns), ns, CollectionOptions()); + ASSERT_OK(engine->createRecordStore( + op, NamespaceString::createNamespaceString_forTest(ns), ns, CollectionOptions())); + rs = engine->getRecordStore( + op, NamespaceString::createNamespaceString_forTest(ns), ns, CollectionOptions()); ASSERT(rs); } diff --git a/src/mongo/db/storage/kv/storage_engine_test.cpp b/src/mongo/db/storage/kv/storage_engine_test.cpp index 0e6d85e82dd..537e4ef899f 100644 --- a/src/mongo/db/storage/kv/storage_engine_test.cpp +++ b/src/mongo/db/storage/kv/storage_engine_test.cpp @@ -66,12 +66,14 @@ TEST_F(StorageEngineTest, ReconcileIdentsTest) { // Add a collection, `db.coll1` to both the DurableCatalog and KVEngine. The returned value is // the `ident` name given to the collection. - auto swCollInfo = createCollection(opCtx.get(), NamespaceString("db.coll1")); + auto swCollInfo = + createCollection(opCtx.get(), NamespaceString::createNamespaceString_forTest("db.coll1")); ASSERT_OK(swCollInfo.getStatus()); // Create a table in the KVEngine not reflected in the DurableCatalog. This should be dropped // when reconciling. - ASSERT_OK(createCollTable(opCtx.get(), NamespaceString("db.coll2"))); + ASSERT_OK( + createCollTable(opCtx.get(), NamespaceString::createNamespaceString_forTest("db.coll2"))); auto reconcileResult = unittest::assertGet(reconcile(opCtx.get())); ASSERT_EQUALS(0UL, reconcileResult.indexesToRebuild.size()); @@ -98,7 +100,7 @@ TEST_F(StorageEngineTest, ReconcileIdentsTest) { TEST_F(StorageEngineTest, LoadCatalogDropsOrphansAfterUncleanShutdown) { auto opCtx = cc().makeOperationContext(); - const NamespaceString collNs("db.coll1"); + const NamespaceString collNs = NamespaceString::createNamespaceString_forTest("db.coll1"); auto swCollInfo = createCollection(opCtx.get(), collNs); ASSERT_OK(swCollInfo.getStatus()); @@ -248,7 +250,7 @@ TEST_F(StorageEngineTest, ReconcileUnfinishedIndex) { Lock::GlobalLock lk(&*opCtx, MODE_X); - const NamespaceString ns("db.coll1"); + const NamespaceString ns = NamespaceString::createNamespaceString_forTest("db.coll1"); const std::string indexName("a_1"); auto swCollInfo = createCollection(opCtx.get(), ns); @@ -285,7 +287,7 @@ TEST_F(StorageEngineTest, ReconcileUnfinishedIndex) { TEST_F(StorageEngineTest, ReconcileUnfinishedBackgroundSecondaryIndex) { auto opCtx = cc().makeOperationContext(); - const NamespaceString ns("db.coll1"); + const NamespaceString ns = NamespaceString::createNamespaceString_forTest("db.coll1"); const std::string indexName("a_1"); auto swCollInfo = createCollection(opCtx.get(), ns); @@ -330,7 +332,7 @@ TEST_F(StorageEngineTest, ReconcileUnfinishedBackgroundSecondaryIndex) { TEST_F(StorageEngineTest, ReconcileTwoPhaseIndexBuilds) { auto opCtx = cc().makeOperationContext(); - const NamespaceString ns("db.coll1"); + const NamespaceString ns = NamespaceString::createNamespaceString_forTest("db.coll1"); const std::string indexA("a_1"); const std::string indexB("b_1"); @@ -398,7 +400,7 @@ TEST_F(StorageEngineTest, ReconcileTwoPhaseIndexBuilds) { TEST_F(StorageEngineRepairTest, LoadCatalogRecoversOrphans) { auto opCtx = cc().makeOperationContext(); - const NamespaceString collNs("db.coll1"); + const NamespaceString collNs = NamespaceString::createNamespaceString_forTest("db.coll1"); auto swCollInfo = createCollection(opCtx.get(), collNs); ASSERT_OK(swCollInfo.getStatus()); @@ -425,7 +427,7 @@ TEST_F(StorageEngineRepairTest, LoadCatalogRecoversOrphans) { TEST_F(StorageEngineRepairTest, ReconcileSucceeds) { auto opCtx = cc().makeOperationContext(); - const NamespaceString collNs("db.coll1"); + const NamespaceString collNs = NamespaceString::createNamespaceString_forTest("db.coll1"); auto swCollInfo = createCollection(opCtx.get(), collNs); ASSERT_OK(swCollInfo.getStatus()); @@ -448,7 +450,7 @@ TEST_F(StorageEngineRepairTest, ReconcileSucceeds) { TEST_F(StorageEngineRepairTest, LoadCatalogRecoversOrphansInCatalog) { auto opCtx = cc().makeOperationContext(); - const NamespaceString collNs("db.coll1"); + const NamespaceString collNs = NamespaceString::createNamespaceString_forTest("db.coll1"); auto swCollInfo = createCollection(opCtx.get(), collNs); ASSERT_OK(swCollInfo.getStatus()); ASSERT(collectionExists(opCtx.get(), collNs)); @@ -470,7 +472,8 @@ TEST_F(StorageEngineRepairTest, LoadCatalogRecoversOrphansInCatalog) { _storageEngine->loadCatalog(opCtx.get(), boost::none, StorageEngine::LastShutdownState::kClean); auto identNs = swCollInfo.getValue().ident; std::replace(identNs.begin(), identNs.end(), '-', '_'); - NamespaceString orphanNs = NamespaceString("local.orphan." + identNs); + NamespaceString orphanNs = + NamespaceString::createNamespaceString_forTest("local.orphan." + identNs); ASSERT(identExists(opCtx.get(), swCollInfo.getValue().ident)); ASSERT(collectionExists(opCtx.get(), orphanNs)); @@ -482,7 +485,7 @@ TEST_F(StorageEngineRepairTest, LoadCatalogRecoversOrphansInCatalog) { TEST_F(StorageEngineTest, LoadCatalogDropsOrphans) { auto opCtx = cc().makeOperationContext(); - const NamespaceString collNs("db.coll1"); + const NamespaceString collNs = NamespaceString::createNamespaceString_forTest("db.coll1"); auto swCollInfo = createCollection(opCtx.get(), collNs); ASSERT_OK(swCollInfo.getStatus()); ASSERT(collectionExists(opCtx.get(), collNs)); @@ -513,7 +516,8 @@ TEST_F(StorageEngineTest, LoadCatalogDropsOrphans) { ASSERT(!identExists(opCtx.get(), swCollInfo.getValue().ident)); auto identNs = swCollInfo.getValue().ident; std::replace(identNs.begin(), identNs.end(), '-', '_'); - NamespaceString orphanNs = NamespaceString("local.orphan." + identNs); + NamespaceString orphanNs = + NamespaceString::createNamespaceString_forTest("local.orphan." + identNs); ASSERT(!collectionExists(opCtx.get(), orphanNs)); } @@ -691,8 +695,8 @@ TEST_F(TimestampKVEngineTest, TimestampAdvancesOnNotification) { TEST_F(StorageEngineTestNotEphemeral, UseAlternateStorageLocation) { auto opCtx = cc().makeOperationContext(); - const NamespaceString coll1Ns("db.coll1"); - const NamespaceString coll2Ns("db.coll2"); + const NamespaceString coll1Ns = NamespaceString::createNamespaceString_forTest("db.coll1"); + const NamespaceString coll2Ns = NamespaceString::createNamespaceString_forTest("db.coll2"); auto swCollInfo = createCollection(opCtx.get(), coll1Ns); ASSERT_OK(swCollInfo.getStatus()); ASSERT(collectionExists(opCtx.get(), coll1Ns)); |