summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2023-02-01 20:54:39 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-08 02:46:14 +0000
commit567bcd0e4822d726aea15f0338c89c49de2a56b5 (patch)
treefa2a6ea1d3cbd4872fba26df3fdb44548544206f /src/mongo/s
parentf7afadd90f50662b2b3b3a45595b65b37a59bdc3 (diff)
downloadmongo-567bcd0e4822d726aea15f0338c89c49de2a56b5.tar.gz
SERVER-73112 Expose function to construct NamespaceString in unit tests
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/append_raw_responses_test.cpp2
-rw-r--r--src/mongo/s/async_requests_sender_test.cpp2
-rw-r--r--src/mongo/s/catalog/sharding_catalog_client_test.cpp32
-rw-r--r--src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp2
-rw-r--r--src/mongo/s/catalog/type_collection_test.cpp6
-rw-r--r--src/mongo/s/catalog_cache_refresh_test.cpp2
-rw-r--r--src/mongo/s/catalog_cache_test.cpp3
-rw-r--r--src/mongo/s/chunk_manager_query_test.cpp2
-rw-r--r--src/mongo/s/chunk_map_test.cpp2
-rw-r--r--src/mongo/s/chunk_test.cpp2
-rw-r--r--src/mongo/s/collection_routing_info_targeter_test.cpp2
-rw-r--r--src/mongo/s/commands/cluster_aggregate_test.cpp2
-rw-r--r--src/mongo/s/commands/cluster_command_test_fixture.h2
-rw-r--r--src/mongo/s/commands/document_shard_key_update_test.cpp4
-rw-r--r--src/mongo/s/query/cluster_client_cursor_impl_test.cpp67
-rw-r--r--src/mongo/s/query/cluster_cursor_manager_test.cpp2
-rw-r--r--src/mongo/s/query/cluster_exchange_test.cpp3
-rw-r--r--src/mongo/s/query/results_merger_test_fixture.cpp3
-rw-r--r--src/mongo/s/query/sharded_agg_test_fixture.h3
-rw-r--r--src/mongo/s/query/store_possible_cursor_test.cpp2
-rw-r--r--src/mongo/s/query_analysis_sampler_test.cpp12
-rw-r--r--src/mongo/s/request_types/balance_chunk_request_test.cpp4
-rw-r--r--src/mongo/s/request_types/merge_chunks_request_test.cpp3
-rw-r--r--src/mongo/s/routing_table_history_test.cpp2
-rw-r--r--src/mongo/s/shard_key_pattern_query_util_index_bounds_test.cpp6
-rw-r--r--src/mongo/s/shard_key_pattern_test.cpp2
-rw-r--r--src/mongo/s/stale_exception_test.cpp2
-rw-r--r--src/mongo/s/stale_shard_version_helpers_test.cpp2
-rw-r--r--src/mongo/s/transaction_router_test.cpp2
-rw-r--r--src/mongo/s/write_ops/batch_write_exec_test.cpp6
-rw-r--r--src/mongo/s/write_ops/batch_write_op_test.cpp64
-rw-r--r--src/mongo/s/write_ops/batched_command_request_test.cpp3
-rw-r--r--src/mongo/s/write_ops/batched_command_response_test.cpp5
-rw-r--r--src/mongo/s/write_ops/write_op_test.cpp2
-rw-r--r--src/mongo/s/write_ops/write_without_shard_key_util_test.cpp2
35 files changed, 143 insertions, 119 deletions
diff --git a/src/mongo/s/append_raw_responses_test.cpp b/src/mongo/s/append_raw_responses_test.cpp
index ebff915739d..00d9c94d1df 100644
--- a/src/mongo/s/append_raw_responses_test.cpp
+++ b/src/mongo/s/append_raw_responses_test.cpp
@@ -196,7 +196,7 @@ protected:
[] {
OID epoch{OID::gen()};
Timestamp timestamp{1, 0};
- return StaleConfigInfo(NamespaceString("Foo.Bar"),
+ return StaleConfigInfo(NamespaceString::createNamespaceString_forTest("Foo.Bar"),
ShardVersion(ChunkVersion({epoch, timestamp}, {1, 0}),
boost::optional<CollectionIndexes>(boost::none)),
boost::none,
diff --git a/src/mongo/s/async_requests_sender_test.cpp b/src/mongo/s/async_requests_sender_test.cpp
index 39874e7e898..b27d9b5644e 100644
--- a/src/mongo/s/async_requests_sender_test.cpp
+++ b/src/mongo/s/async_requests_sender_test.cpp
@@ -41,7 +41,7 @@ namespace mongo {
namespace {
-const NamespaceString kTestNss("testdb.testcoll");
+const NamespaceString kTestNss = NamespaceString::createNamespaceString_forTest("testdb.testcoll");
const HostAndPort kTestConfigShardHost = HostAndPort("FakeConfigHost", 12345);
const std::vector<ShardId> kTestShardIds = {
ShardId("FakeShard1"), ShardId("FakeShard2"), ShardId("FakeShard3")};
diff --git a/src/mongo/s/catalog/sharding_catalog_client_test.cpp b/src/mongo/s/catalog/sharding_catalog_client_test.cpp
index 551feda38b9..3e4a0210164 100644
--- a/src/mongo/s/catalog/sharding_catalog_client_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_client_test.cpp
@@ -67,7 +67,8 @@ using std::vector;
using unittest::assertGet;
const int kMaxCommandRetry = 3;
-const NamespaceString kNamespace("TestDB", "TestColl");
+const NamespaceString kNamespace =
+ NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
BSONObj getReplSecondaryOkMetadata() {
BSONObjBuilder o;
@@ -81,7 +82,7 @@ using ShardingCatalogClientTest = ShardingTestFixture;
TEST_F(ShardingCatalogClientTest, GetCollectionExisting) {
configTargeter()->setFindHostReturnValue(HostAndPort("TestHost1"));
- CollectionType expectedColl(NamespaceString("TestDB.TestNS"),
+ CollectionType expectedColl(NamespaceString::createNamespaceString_forTest("TestDB.TestNS"),
OID::gen(),
Timestamp(1, 1),
Date_t::now(),
@@ -138,7 +139,8 @@ TEST_F(ShardingCatalogClientTest, GetCollectionNotExisting) {
auto future = launchAsync([this] {
ASSERT_THROWS_CODE(
- catalogClient()->getCollection(operationContext(), NamespaceString("NonExistent")),
+ catalogClient()->getCollection(
+ operationContext(), NamespaceString::createNamespaceString_forTest("NonExistent")),
DBException,
ErrorCodes::NamespaceNotFound);
});
@@ -773,14 +775,14 @@ TEST_F(ShardingCatalogClientTest, RunUserManagementWriteCommandNotWritablePrimar
TEST_F(ShardingCatalogClientTest, GetCollectionsValidResultsNoDb) {
configTargeter()->setFindHostReturnValue(HostAndPort("TestHost1"));
- CollectionType coll1(NamespaceString{"test.coll1"},
+ CollectionType coll1(NamespaceString::createNamespaceString_forTest("test.coll1"),
OID::gen(),
Timestamp(1, 1),
network()->now(),
UUID::gen(),
BSON("_id" << 1));
- CollectionType coll2(NamespaceString{"anotherdb.coll1"},
+ CollectionType coll2(NamespaceString::createNamespaceString_forTest("anotherdb.coll1"),
OID::gen(),
Timestamp(1, 1),
network()->now(),
@@ -831,7 +833,7 @@ TEST_F(ShardingCatalogClientTest, GetCollectionsValidResultsNoDb) {
TEST_F(ShardingCatalogClientTest, GetCollectionsValidResultsWithDb) {
configTargeter()->setFindHostReturnValue(HostAndPort("TestHost1"));
- CollectionType coll1(NamespaceString{"test.coll1"},
+ CollectionType coll1(NamespaceString::createNamespaceString_forTest("test.coll1"),
OID::gen(),
Timestamp(1, 1),
network()->now(),
@@ -839,7 +841,7 @@ TEST_F(ShardingCatalogClientTest, GetCollectionsValidResultsWithDb) {
BSON("_id" << 1));
coll1.setUnique(true);
- CollectionType coll2(NamespaceString{"test.coll2"},
+ CollectionType coll2(NamespaceString::createNamespaceString_forTest("test.coll2"),
OID::gen(),
Timestamp(1, 1),
network()->now(),
@@ -885,7 +887,7 @@ TEST_F(ShardingCatalogClientTest, GetCollectionsInvalidCollectionType) {
ASSERT_THROWS(catalogClient()->getCollections(operationContext(), "test"), DBException);
});
- CollectionType validColl(NamespaceString{"test.coll1"},
+ CollectionType validColl(NamespaceString::createNamespaceString_forTest("test.coll1"),
OID::gen(),
Timestamp(1, 1),
network()->now(),
@@ -983,20 +985,20 @@ TEST_F(ShardingCatalogClientTest, GetTagsForCollection) {
configTargeter()->setFindHostReturnValue(HostAndPort("TestHost1"));
TagsType tagA;
- tagA.setNS(NamespaceString("TestDB.TestColl"));
+ tagA.setNS(NamespaceString::createNamespaceString_forTest("TestDB.TestColl"));
tagA.setTag("TagA");
tagA.setMinKey(BSON("a" << 100));
tagA.setMaxKey(BSON("a" << 200));
TagsType tagB;
- tagB.setNS(NamespaceString("TestDB.TestColl"));
+ tagB.setNS(NamespaceString::createNamespaceString_forTest("TestDB.TestColl"));
tagB.setTag("TagB");
tagB.setMinKey(BSON("a" << 200));
tagB.setMaxKey(BSON("a" << 300));
auto future = launchAsync([this] {
const auto& tags = assertGet(catalogClient()->getTagsForCollection(
- operationContext(), NamespaceString("TestDB.TestColl")));
+ operationContext(), NamespaceString::createNamespaceString_forTest("TestDB.TestColl")));
ASSERT_EQ(2U, tags.size());
@@ -1032,7 +1034,7 @@ TEST_F(ShardingCatalogClientTest, GetTagsForCollectionNoTags) {
auto future = launchAsync([this] {
const auto& tags = assertGet(catalogClient()->getTagsForCollection(
- operationContext(), NamespaceString("TestDB.TestColl")));
+ operationContext(), NamespaceString::createNamespaceString_forTest("TestDB.TestColl")));
ASSERT_EQ(0U, tags.size());
@@ -1049,20 +1051,20 @@ TEST_F(ShardingCatalogClientTest, GetTagsForCollectionInvalidTag) {
auto future = launchAsync([this] {
const auto swTags = catalogClient()->getTagsForCollection(
- operationContext(), NamespaceString("TestDB.TestColl"));
+ operationContext(), NamespaceString::createNamespaceString_forTest("TestDB.TestColl"));
ASSERT_EQUALS(ErrorCodes::NoSuchKey, swTags.getStatus());
});
onFindCommand([](const RemoteCommandRequest& request) {
TagsType tagA;
- tagA.setNS(NamespaceString("TestDB.TestColl"));
+ tagA.setNS(NamespaceString::createNamespaceString_forTest("TestDB.TestColl"));
tagA.setTag("TagA");
tagA.setMinKey(BSON("a" << 100));
tagA.setMaxKey(BSON("a" << 200));
TagsType tagB;
- tagB.setNS(NamespaceString("TestDB.TestColl"));
+ tagB.setNS(NamespaceString::createNamespaceString_forTest("TestDB.TestColl"));
tagB.setTag("TagB");
tagB.setMinKey(BSON("a" << 200));
// Missing maxKey
diff --git a/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp b/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp
index ac6bff8cea3..1bee8df06e4 100644
--- a/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_write_retry_test.cpp
@@ -409,7 +409,7 @@ TEST_F(UpdateRetryTest, NotWritablePrimaryOnceSuccessAfterRetry) {
HostAndPort host2("TestHost2");
configTargeter()->setFindHostReturnValue(host1);
- CollectionType collection(NamespaceString("db.coll"),
+ CollectionType collection(NamespaceString::createNamespaceString_forTest("db.coll"),
OID::gen(),
Timestamp(1, 1),
network()->now(),
diff --git a/src/mongo/s/catalog/type_collection_test.cpp b/src/mongo/s/catalog/type_collection_test.cpp
index 66838362db0..2688d7106b6 100644
--- a/src/mongo/s/catalog/type_collection_test.cpp
+++ b/src/mongo/s/catalog/type_collection_test.cpp
@@ -58,7 +58,7 @@ TEST(CollectionType, Basic) {
<< "fr_CA")
<< CollectionType::kUniqueFieldName << true));
- ASSERT(coll.getNss() == NamespaceString{"db.coll"});
+ ASSERT(coll.getNss() == NamespaceString::createNamespaceString_forTest("db.coll"));
ASSERT_EQUALS(coll.getEpoch(), oid);
ASSERT_EQUALS(coll.getUuid(), uuid);
ASSERT_EQUALS(coll.getTimestamp(), timestamp);
@@ -91,7 +91,7 @@ TEST(CollectionType, AllFieldsPresent) {
<< CollectionType::kUniqueFieldName << true << CollectionType::kUuidFieldName << uuid
<< CollectionType::kReshardingFieldsFieldName << reshardingFields.toBSON()));
- ASSERT(coll.getNss() == NamespaceString{"db.coll"});
+ ASSERT(coll.getNss() == NamespaceString::createNamespaceString_forTest("db.coll"));
ASSERT_EQUALS(coll.getEpoch(), oid);
ASSERT_EQUALS(coll.getTimestamp(), timestamp);
ASSERT_EQUALS(coll.getUpdatedAt(), Date_t::fromMillisSinceEpoch(1));
@@ -146,7 +146,7 @@ TEST(CollectionType, Pre22Format) {
<< Date_t::fromMillisSinceEpoch(1) << "dropped" << false << "key"
<< BSON("a" << 1) << "unique" << false));
- ASSERT(coll.getNss() == NamespaceString{"db.coll"});
+ ASSERT(coll.getNss() == NamespaceString::createNamespaceString_forTest("db.coll"));
ASSERT(!coll.getEpoch().isSet());
ASSERT_EQUALS(coll.getUpdatedAt(), Date_t::fromMillisSinceEpoch(1));
ASSERT_BSONOBJ_EQ(coll.getKeyPattern().toBSON(), BSON("a" << 1));
diff --git a/src/mongo/s/catalog_cache_refresh_test.cpp b/src/mongo/s/catalog_cache_refresh_test.cpp
index 4d18c95827e..6f913d5bf6d 100644
--- a/src/mongo/s/catalog_cache_refresh_test.cpp
+++ b/src/mongo/s/catalog_cache_refresh_test.cpp
@@ -46,7 +46,7 @@ namespace {
using executor::RemoteCommandRequest;
using unittest::assertGet;
-const NamespaceString kNss("TestDB", "TestColl");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
class CatalogCacheRefreshTest : public CatalogCacheTestFixture {
protected:
diff --git a/src/mongo/s/catalog_cache_test.cpp b/src/mongo/s/catalog_cache_test.cpp
index 1df4e541f27..50111fd8784 100644
--- a/src/mongo/s/catalog_cache_test.cpp
+++ b/src/mongo/s/catalog_cache_test.cpp
@@ -191,7 +191,8 @@ protected:
.toBSON(CursorResponse::ResponseType::InitialResponse);
}
- const NamespaceString kNss{"catalgoCacheTestDB.foo"};
+ const NamespaceString kNss =
+ NamespaceString::createNamespaceString_forTest("catalgoCacheTestDB.foo");
const UUID kUUID = UUID::gen();
const std::string kPattern{"_id"};
const ShardKeyPattern kShardKeyPattern{BSON(kPattern << 1)};
diff --git a/src/mongo/s/chunk_manager_query_test.cpp b/src/mongo/s/chunk_manager_query_test.cpp
index a474e37691d..adef2f2e8ee 100644
--- a/src/mongo/s/chunk_manager_query_test.cpp
+++ b/src/mongo/s/chunk_manager_query_test.cpp
@@ -43,7 +43,7 @@
namespace mongo {
namespace {
-const NamespaceString kNss("TestDB", "TestColl");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
class ChunkManagerQueryTest : public CatalogCacheTestFixture {
protected:
diff --git a/src/mongo/s/chunk_map_test.cpp b/src/mongo/s/chunk_map_test.cpp
index 88378ff53e1..f0e71e7aaaa 100644
--- a/src/mongo/s/chunk_map_test.cpp
+++ b/src/mongo/s/chunk_map_test.cpp
@@ -33,7 +33,7 @@
namespace mongo {
namespace {
-const NamespaceString kNss("TestDB", "TestColl");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
const ShardId kThisShard("testShard");
class ChunkMapTest : public unittest::Test {
diff --git a/src/mongo/s/chunk_test.cpp b/src/mongo/s/chunk_test.cpp
index 8031f58e5b2..9ecdc310306 100644
--- a/src/mongo/s/chunk_test.cpp
+++ b/src/mongo/s/chunk_test.cpp
@@ -33,7 +33,7 @@
namespace mongo {
namespace {
-const NamespaceString kNss("test.foo");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("test.foo");
const ShardId kShardOne("shardOne");
const ShardId kShardTwo("shardTwo");
const KeyPattern kShardKeyPattern(BSON("a" << 1));
diff --git a/src/mongo/s/collection_routing_info_targeter_test.cpp b/src/mongo/s/collection_routing_info_targeter_test.cpp
index e81df416820..8119ce8dc42 100644
--- a/src/mongo/s/collection_routing_info_targeter_test.cpp
+++ b/src/mongo/s/collection_routing_info_targeter_test.cpp
@@ -49,7 +49,7 @@ namespace {
using unittest::assertGet;
-const NamespaceString kNss("TestDB", "TestColl");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
auto buildUpdate(const NamespaceString& nss, BSONObj query, BSONObj update, bool upsert) {
write_ops::UpdateCommandRequest updateOp(nss);
diff --git a/src/mongo/s/commands/cluster_aggregate_test.cpp b/src/mongo/s/commands/cluster_aggregate_test.cpp
index 67002da94d8..2f9c9a137b8 100644
--- a/src/mongo/s/commands/cluster_aggregate_test.cpp
+++ b/src/mongo/s/commands/cluster_aggregate_test.cpp
@@ -94,7 +94,7 @@ protected:
*/
Status testRunAggregateEarlyExit(const BSONObj& inputBson) {
BSONObjBuilder result;
- NamespaceString nss{"a.collection"};
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("a.collection");
auto client = getServiceContext()->makeClient("ClusterCmdClient");
auto opCtx = client->makeOperationContext();
auto request = aggregation_request_helper::parseFromBSONForTests(nss, inputBson);
diff --git a/src/mongo/s/commands/cluster_command_test_fixture.h b/src/mongo/s/commands/cluster_command_test_fixture.h
index b1e3a84588c..6b0fedc80fb 100644
--- a/src/mongo/s/commands/cluster_command_test_fixture.h
+++ b/src/mongo/s/commands/cluster_command_test_fixture.h
@@ -42,7 +42,7 @@ class ClusterCommandTestFixture : public CatalogCacheTestFixture {
protected:
const size_t numShards = 2;
- const NamespaceString kNss = NamespaceString("test", "coll");
+ const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("test", "coll");
const LogicalTime kInMemoryLogicalTime = LogicalTime(Timestamp(10, 1));
diff --git a/src/mongo/s/commands/document_shard_key_update_test.cpp b/src/mongo/s/commands/document_shard_key_update_test.cpp
index b8fe91f3903..56884e58923 100644
--- a/src/mongo/s/commands/document_shard_key_update_test.cpp
+++ b/src/mongo/s/commands/document_shard_key_update_test.cpp
@@ -50,7 +50,7 @@ public:
};
TEST_F(DocumentShardKeyUpdateTest, constructShardKeyDeleteCmdObj) {
- NamespaceString nss("test.foo");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("test.foo");
BSONObj updatePreImage = BSON("x" << 4 << "y" << 3 << "_id" << 20);
auto deleteCmdObj = constructShardKeyDeleteCmdObj(nss, updatePreImage);
@@ -66,7 +66,7 @@ TEST_F(DocumentShardKeyUpdateTest, constructShardKeyDeleteCmdObj) {
}
TEST_F(DocumentShardKeyUpdateTest, constructShardKeyInsertCmdObj) {
- NamespaceString nss("test.foo");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("test.foo");
BSONObj updatePostImage = BSON("x" << 4 << "y" << 3 << "_id" << 20);
auto insertCmdObj = constructShardKeyInsertCmdObj(nss, updatePostImage, false);
diff --git a/src/mongo/s/query/cluster_client_cursor_impl_test.cpp b/src/mongo/s/query/cluster_client_cursor_impl_test.cpp
index 2581aa18116..be09e027337 100644
--- a/src/mongo/s/query/cluster_client_cursor_impl_test.cpp
+++ b/src/mongo/s/query/cluster_client_cursor_impl_test.cpp
@@ -64,7 +64,8 @@ TEST_F(ClusterClientCursorImplTest, NumReturnedSoFar) {
ClusterClientCursorImpl cursor(
_opCtx.get(),
std::move(mockStage),
- ClusterClientCursorParams(NamespaceString("unused"), APIParameters(), {}),
+ ClusterClientCursorParams(
+ NamespaceString::createNamespaceString_forTest("unused"), APIParameters(), {}),
boost::none);
ASSERT_EQ(cursor.getNumReturnedSoFar(), 0);
@@ -87,10 +88,11 @@ TEST_F(ClusterClientCursorImplTest, QueueResult) {
mockStage->queueResult(BSON("a" << 1));
mockStage->queueResult(BSON("a" << 4));
- ClusterClientCursorImpl cursor(_opCtx.get(),
- std::move(mockStage),
- ClusterClientCursorParams(NamespaceString("unused"), {}),
- boost::none);
+ ClusterClientCursorImpl cursor(
+ _opCtx.get(),
+ std::move(mockStage),
+ ClusterClientCursorParams(NamespaceString::createNamespaceString_forTest("unused"), {}),
+ boost::none);
auto firstResult = cursor.next();
ASSERT_OK(firstResult.getStatus());
@@ -128,10 +130,11 @@ TEST_F(ClusterClientCursorImplTest, RemotesExhausted) {
mockStage->queueResult(BSON("a" << 2));
mockStage->markRemotesExhausted();
- ClusterClientCursorImpl cursor(_opCtx.get(),
- std::move(mockStage),
- ClusterClientCursorParams(NamespaceString("unused"), {}),
- boost::none);
+ ClusterClientCursorImpl cursor(
+ _opCtx.get(),
+ std::move(mockStage),
+ ClusterClientCursorParams(NamespaceString::createNamespaceString_forTest("unused"), {}),
+ boost::none);
ASSERT_TRUE(cursor.remotesExhausted());
auto firstResult = cursor.next();
@@ -160,10 +163,11 @@ TEST_F(ClusterClientCursorImplTest, RemoteTimeoutPartialResultsDisallowed) {
mockStage->queueError(Status(ErrorCodes::MaxTimeMSExpired, "timeout"));
mockStage->markRemotesExhausted();
- ClusterClientCursorImpl cursor(_opCtx.get(),
- std::move(mockStage),
- ClusterClientCursorParams(NamespaceString("unused"), {}),
- boost::none);
+ ClusterClientCursorImpl cursor(
+ _opCtx.get(),
+ std::move(mockStage),
+ ClusterClientCursorParams(NamespaceString::createNamespaceString_forTest("unused"), {}),
+ boost::none);
ASSERT_TRUE(cursor.remotesExhausted());
auto firstResult = cursor.next();
@@ -185,7 +189,8 @@ TEST_F(ClusterClientCursorImplTest, RemoteTimeoutPartialResultsAllowed) {
mockStage->queueError(Status(ErrorCodes::MaxTimeMSExpired, "timeout"));
mockStage->markRemotesExhausted();
- auto params = ClusterClientCursorParams(NamespaceString("unused"), {});
+ auto params =
+ ClusterClientCursorParams(NamespaceString::createNamespaceString_forTest("unused"), {});
params.isAllowPartialResults = true;
ClusterClientCursorImpl cursor(
@@ -210,10 +215,11 @@ TEST_F(ClusterClientCursorImplTest, ForwardsAwaitDataTimeout) {
auto mockStagePtr = mockStage.get();
ASSERT_NOT_OK(mockStage->getAwaitDataTimeout().getStatus());
- ClusterClientCursorImpl cursor(_opCtx.get(),
- std::move(mockStage),
- ClusterClientCursorParams(NamespaceString("unused"), {}),
- boost::none);
+ ClusterClientCursorImpl cursor(
+ _opCtx.get(),
+ std::move(mockStage),
+ ClusterClientCursorParams(NamespaceString::createNamespaceString_forTest("unused"), {}),
+ boost::none);
ASSERT_OK(cursor.setAwaitDataTimeout(Milliseconds(789)));
auto awaitDataTimeout = mockStagePtr->getAwaitDataTimeout();
@@ -227,10 +233,11 @@ TEST_F(ClusterClientCursorImplTest, ChecksForInterrupt) {
mockStage->queueResult(BSON("a" << i));
}
- ClusterClientCursorImpl cursor(_opCtx.get(),
- std::move(mockStage),
- ClusterClientCursorParams(NamespaceString("unused"), {}),
- boost::none);
+ ClusterClientCursorImpl cursor(
+ _opCtx.get(),
+ std::move(mockStage),
+ ClusterClientCursorParams(NamespaceString::createNamespaceString_forTest("unused"), {}),
+ boost::none);
// Pull one result out of the cursor.
auto result = cursor.next();
@@ -252,14 +259,14 @@ TEST_F(ClusterClientCursorImplTest, ChecksForInterrupt) {
TEST_F(ClusterClientCursorImplTest, LogicalSessionIdsOnCursors) {
// Make a cursor with no lsid
auto mockStage = std::make_unique<RouterStageMock>(_opCtx.get());
- ClusterClientCursorParams params(NamespaceString("test"), {});
+ ClusterClientCursorParams params(NamespaceString::createNamespaceString_forTest("test"), {});
ClusterClientCursorImpl cursor{
_opCtx.get(), std::move(mockStage), std::move(params), boost::none};
ASSERT(!cursor.getLsid());
// Make a cursor with an lsid
auto mockStage2 = std::make_unique<RouterStageMock>(_opCtx.get());
- ClusterClientCursorParams params2(NamespaceString("test"), {});
+ ClusterClientCursorParams params2(NamespaceString::createNamespaceString_forTest("test"), {});
auto lsid = makeLogicalSessionIdForTest();
ClusterClientCursorImpl cursor2{_opCtx.get(), std::move(mockStage2), std::move(params2), lsid};
ASSERT(*(cursor2.getLsid()) == lsid);
@@ -270,7 +277,8 @@ TEST_F(ClusterClientCursorImplTest, ShouldStoreLSIDIfSetOnOpCtx) {
{
// Make a cursor with no lsid or txnNumber.
- ClusterClientCursorParams params(NamespaceString("test"), {});
+ ClusterClientCursorParams params(NamespaceString::createNamespaceString_forTest("test"),
+ {});
params.lsid = _opCtx->getLogicalSessionId();
params.txnNumber = _opCtx->getTxnNumber();
@@ -284,7 +292,8 @@ TEST_F(ClusterClientCursorImplTest, ShouldStoreLSIDIfSetOnOpCtx) {
{
// Make a cursor with an lsid and no txnNumber.
- ClusterClientCursorParams params(NamespaceString("test"), {});
+ ClusterClientCursorParams params(NamespaceString::createNamespaceString_forTest("test"),
+ {});
params.lsid = _opCtx->getLogicalSessionId();
params.txnNumber = _opCtx->getTxnNumber();
@@ -298,7 +307,8 @@ TEST_F(ClusterClientCursorImplTest, ShouldStoreLSIDIfSetOnOpCtx) {
{
// Make a cursor with an lsid and txnNumber.
- ClusterClientCursorParams params(NamespaceString("test"), {});
+ ClusterClientCursorParams params(NamespaceString::createNamespaceString_forTest("test"),
+ {});
params.lsid = _opCtx->getLogicalSessionId();
params.txnNumber = _opCtx->getTxnNumber();
@@ -316,7 +326,8 @@ TEST_F(ClusterClientCursorImplTest, ShouldStoreAPIParameters) {
apiParams.setAPIStrict(true);
apiParams.setAPIDeprecationErrors(true);
- ClusterClientCursorParams params(NamespaceString("test"), apiParams, {});
+ ClusterClientCursorParams params(
+ NamespaceString::createNamespaceString_forTest("test"), apiParams, {});
ClusterClientCursorImpl cursor(
_opCtx.get(), std::move(mockStage), std::move(params), boost::none);
diff --git a/src/mongo/s/query/cluster_cursor_manager_test.cpp b/src/mongo/s/query/cluster_cursor_manager_test.cpp
index 36ba0d15f5c..b27ca5c2d19 100644
--- a/src/mongo/s/query/cluster_cursor_manager_test.cpp
+++ b/src/mongo/s/query/cluster_cursor_manager_test.cpp
@@ -45,7 +45,7 @@ namespace mongo {
namespace {
using unittest::assertGet;
-const NamespaceString nss("test.collection");
+const NamespaceString nss = NamespaceString::createNamespaceString_forTest("test.collection");
class ClusterCursorManagerTest : public ServiceContextTest {
protected:
diff --git a/src/mongo/s/query/cluster_exchange_test.cpp b/src/mongo/s/query/cluster_exchange_test.cpp
index 5711ea5da64..023acc46cbd 100644
--- a/src/mongo/s/query/cluster_exchange_test.cpp
+++ b/src/mongo/s/query/cluster_exchange_test.cpp
@@ -49,7 +49,8 @@ using MergeStrategyDescriptor = DocumentSourceMerge::MergeStrategyDescriptor;
using WhenMatched = MergeStrategyDescriptor::WhenMatched;
using WhenNotMatched = MergeStrategyDescriptor::WhenNotMatched;
-const NamespaceString kTestTargetNss = NamespaceString{"unittests", "out_ns"};
+const NamespaceString kTestTargetNss =
+ NamespaceString::createNamespaceString_forTest("unittests", "out_ns");
class ClusterExchangeTest : public ShardedAggTestFixture {
protected:
diff --git a/src/mongo/s/query/results_merger_test_fixture.cpp b/src/mongo/s/query/results_merger_test_fixture.cpp
index 33a1816d795..637c879e87b 100644
--- a/src/mongo/s/query/results_merger_test_fixture.cpp
+++ b/src/mongo/s/query/results_merger_test_fixture.cpp
@@ -46,7 +46,8 @@ const std::vector<HostAndPort> ResultsMergerTestFixture::kTestShardHosts = {
HostAndPort("FakeShard2Host", 12345),
HostAndPort("FakeShard3Host", 12345)};
-const NamespaceString ResultsMergerTestFixture::kTestNss = NamespaceString{"testdb.testcoll"};
+const NamespaceString ResultsMergerTestFixture::kTestNss =
+ NamespaceString::createNamespaceString_forTest("testdb.testcoll");
void ResultsMergerTestFixture::setUp() {
ShardingTestFixture::setUp();
diff --git a/src/mongo/s/query/sharded_agg_test_fixture.h b/src/mongo/s/query/sharded_agg_test_fixture.h
index c166abee481..87df3b43630 100644
--- a/src/mongo/s/query/sharded_agg_test_fixture.h
+++ b/src/mongo/s/query/sharded_agg_test_fixture.h
@@ -53,7 +53,8 @@ public:
class ShardedAggTestFixture : public CatalogCacheTestFixture {
public:
- const NamespaceString kTestAggregateNss = NamespaceString{"unittests", "sharded_agg_test"};
+ const NamespaceString kTestAggregateNss =
+ NamespaceString::createNamespaceString_forTest("unittests", "sharded_agg_test");
void setUp() {
CatalogCacheTestFixture::setUp();
diff --git a/src/mongo/s/query/store_possible_cursor_test.cpp b/src/mongo/s/query/store_possible_cursor_test.cpp
index 7bef51b82f1..ed92a642bc4 100644
--- a/src/mongo/s/query/store_possible_cursor_test.cpp
+++ b/src/mongo/s/query/store_possible_cursor_test.cpp
@@ -41,7 +41,7 @@
namespace mongo {
namespace {
-const NamespaceString nss("test.collection");
+const NamespaceString nss = NamespaceString::createNamespaceString_forTest("test.collection");
const HostAndPort hostAndPort("testhost", 27017);
const ShardId shardId("testshard");
diff --git a/src/mongo/s/query_analysis_sampler_test.cpp b/src/mongo/s/query_analysis_sampler_test.cpp
index b62ebb93c13..be85431e911 100644
--- a/src/mongo/s/query_analysis_sampler_test.cpp
+++ b/src/mongo/s/query_analysis_sampler_test.cpp
@@ -153,7 +153,8 @@ protected:
return _mockClock->now();
}
- const NamespaceString nss{"testDb", "testColl"};
+ const NamespaceString nss =
+ NamespaceString::createNamespaceString_forTest("testDb", "testColl");
const UUID collUuid = UUID::gen();
private:
@@ -531,9 +532,12 @@ protected:
const HostAndPort kTestConfigShardHost = HostAndPort("FakeConfigHost", 12345);
- const NamespaceString nss0{"testDb", "testColl0"};
- const NamespaceString nss1{"testDb", "testColl1"};
- const NamespaceString nss2{"testDb", "testColl2"};
+ const NamespaceString nss0 =
+ NamespaceString::createNamespaceString_forTest("testDb", "testColl0");
+ const NamespaceString nss1 =
+ NamespaceString::createNamespaceString_forTest("testDb", "testColl1");
+ const NamespaceString nss2 =
+ NamespaceString::createNamespaceString_forTest("testDb", "testColl2");
const UUID collUuid0 = UUID::gen();
const UUID collUuid1 = UUID::gen();
diff --git a/src/mongo/s/request_types/balance_chunk_request_test.cpp b/src/mongo/s/request_types/balance_chunk_request_test.cpp
index a1475991bd2..f02a77b9e48 100644
--- a/src/mongo/s/request_types/balance_chunk_request_test.cpp
+++ b/src/mongo/s/request_types/balance_chunk_request_test.cpp
@@ -43,14 +43,14 @@ TEST(BalanceChunkRequest, RoundTrip) {
UUID uuid{UUID::gen()};
ChunkVersion version({OID::gen(), Timestamp(2, 0)}, {30, 1});
auto obj = BalanceChunkRequest::serializeToRebalanceCommandForConfig(
- NamespaceString("DB.Test"),
+ NamespaceString::createNamespaceString_forTest("DB.Test"),
ChunkRange(BSON("A" << 100), BSON("A" << 200)),
uuid,
ShardId("TestShard"),
version);
auto request = assertGet(BalanceChunkRequest::parseFromConfigCommand(obj));
- ASSERT_EQ(NamespaceString("DB.Test"), request.getNss());
+ ASSERT_EQ(NamespaceString::createNamespaceString_forTest("DB.Test"), request.getNss());
ASSERT_BSONOBJ_EQ(ChunkRange(BSON("A" << 100), BSON("A" << 200)).toBSON(),
request.getChunk().getRange().toBSON());
ASSERT_EQ(uuid, request.getChunk().getCollectionUUID());
diff --git a/src/mongo/s/request_types/merge_chunks_request_test.cpp b/src/mongo/s/request_types/merge_chunks_request_test.cpp
index ad4db8fcd76..368fd33d127 100644
--- a/src/mongo/s/request_types/merge_chunks_request_test.cpp
+++ b/src/mongo/s/request_types/merge_chunks_request_test.cpp
@@ -52,7 +52,8 @@ TEST(ConfigSvrMergeChunks, BasicValidConfigCommand) {
<< "shard0000"
<< "$db"
<< "admin"));
- ASSERT_EQ(NamespaceString("TestDB", "TestColl"), request.getCommandParameter());
+ ASSERT_EQ(NamespaceString::createNamespaceString_forTest("TestDB", "TestColl"),
+ request.getCommandParameter());
ASSERT_TRUE(collUUID == request.getCollectionUUID());
ASSERT_TRUE(chunkRange == request.getChunkRange());
ASSERT_EQ("shard0000", request.getShard().toString());
diff --git a/src/mongo/s/routing_table_history_test.cpp b/src/mongo/s/routing_table_history_test.cpp
index 7c8973a7237..c18f38cc8d3 100644
--- a/src/mongo/s/routing_table_history_test.cpp
+++ b/src/mongo/s/routing_table_history_test.cpp
@@ -42,7 +42,7 @@ namespace mongo {
namespace {
const ShardId kThisShard("thisShard");
-const NamespaceString kNss("TestDB", "TestColl");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
/**
* Creates a new routing table from the input routing table by inserting the chunks specified by
diff --git a/src/mongo/s/shard_key_pattern_query_util_index_bounds_test.cpp b/src/mongo/s/shard_key_pattern_query_util_index_bounds_test.cpp
index 672067b9ad9..c498d7ea8e6 100644
--- a/src/mongo/s/shard_key_pattern_query_util_index_bounds_test.cpp
+++ b/src/mongo/s/shard_key_pattern_query_util_index_bounds_test.cpp
@@ -51,7 +51,7 @@ protected:
// Utility function to create a CanonicalQuery
std::unique_ptr<CanonicalQuery> canonicalize(const char* queryStr) {
BSONObj queryObj = fromjson(queryStr);
- const NamespaceString nss("test.foo");
+ const NamespaceString nss = NamespaceString::createNamespaceString_forTest("test.foo");
auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(queryObj);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(
@@ -635,7 +635,7 @@ TEST_F(CMCollapseTreeTest, GeoNearLimitationsInPlace) {
"{a: 2, b: {$near: {$geometry: {type: \"Point\", coordinates: [0, 0]}, $minDistance: "
"0, $maxDistance: 2}}, c: {$near: {$geometry: {type: \"Point\", coordinates: [0, 0]}, "
"$minDistance: 0, $maxDistance: 2}}}");
- const NamespaceString nss("test.foo");
+ const NamespaceString nss = NamespaceString::createNamespaceString_forTest("test.foo");
auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(queryObj);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(
@@ -657,7 +657,7 @@ TEST_F(CMCollapseTreeTest, GeoNearLimitationsInPlace) {
BSONObj queryObj = fromjson(
"{$or: {a: 2, b: {$near: {$geometry: {type: \"Point\", coordinates: [0, 0]}, "
"$minDistance: 0, $maxDistance: 2}}}}");
- const NamespaceString nss("test.foo");
+ const NamespaceString nss = NamespaceString::createNamespaceString_forTest("test.foo");
auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(queryObj);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(
diff --git a/src/mongo/s/shard_key_pattern_test.cpp b/src/mongo/s/shard_key_pattern_test.cpp
index a59f0494f73..f1e51a51a7b 100644
--- a/src/mongo/s/shard_key_pattern_test.cpp
+++ b/src/mongo/s/shard_key_pattern_test.cpp
@@ -48,7 +48,7 @@ protected:
}
BSONObj queryKey(const ShardKeyPattern& pattern, const BSONObj& query) {
- const NamespaceString nss("foo");
+ const NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo");
StatusWith<BSONObj> status = extractShardKeyFromBasicQuery(_opCtx, nss, pattern, query);
if (!status.isOK())
diff --git a/src/mongo/s/stale_exception_test.cpp b/src/mongo/s/stale_exception_test.cpp
index 1e92988516d..35564248140 100644
--- a/src/mongo/s/stale_exception_test.cpp
+++ b/src/mongo/s/stale_exception_test.cpp
@@ -33,7 +33,7 @@
namespace mongo {
namespace {
-const NamespaceString kNss("test.nss");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("test.nss");
TEST(StaleExceptionTest, StaleConfigInfoSerializationTest) {
const ShardId kShardId("SHARD_ID");
diff --git a/src/mongo/s/stale_shard_version_helpers_test.cpp b/src/mongo/s/stale_shard_version_helpers_test.cpp
index 20e44b5249a..8bd43224eda 100644
--- a/src/mongo/s/stale_shard_version_helpers_test.cpp
+++ b/src/mongo/s/stale_shard_version_helpers_test.cpp
@@ -41,7 +41,7 @@ namespace {
class AsyncShardVersionRetry : public ShardingTestFixture {
public:
NamespaceString nss() const {
- return NamespaceString("test", "foo");
+ return NamespaceString::createNamespaceString_forTest("test", "foo");
}
StringData desc() const {
diff --git a/src/mongo/s/transaction_router_test.cpp b/src/mongo/s/transaction_router_test.cpp
index 837099e53fd..353fc2f363c 100644
--- a/src/mongo/s/transaction_router_test.cpp
+++ b/src/mongo/s/transaction_router_test.cpp
@@ -111,7 +111,7 @@ protected:
const BSONObj kDummyResWithWriteConcernError =
BSON("ok" << 1 << "writeConcernError" << kDummyWriteConcernError);
- const NamespaceString kViewNss = NamespaceString("test.foo");
+ const NamespaceString kViewNss = NamespaceString::createNamespaceString_forTest("test.foo");
const Status kStaleConfigStatus = {
StaleConfigInfo(kViewNss, ShardVersion::UNSHARDED(), boost::none, shard1),
diff --git a/src/mongo/s/write_ops/batch_write_exec_test.cpp b/src/mongo/s/write_ops/batch_write_exec_test.cpp
index 0977244b890..bc1ffdb1ff0 100644
--- a/src/mongo/s/write_ops/batch_write_exec_test.cpp
+++ b/src/mongo/s/write_ops/batch_write_exec_test.cpp
@@ -330,7 +330,7 @@ public:
});
}
- const NamespaceString nss{"foo.bar"};
+ const NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
const CollectionGeneration gen{OID::gen(), Timestamp(1, 1)};
MockNSTargeter singleShardNSTargeter{
@@ -1950,7 +1950,7 @@ public:
}()});
}
- const NamespaceString nss{"foo.bar"};
+ const NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
};
TEST_F(BatchWriteExecTargeterErrorTest, TargetedFailedAndErrorResponse) {
@@ -2095,7 +2095,7 @@ public:
BatchWriteExecTest::tearDown();
}
- const NamespaceString nss{"foo.bar"};
+ const NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
private:
boost::optional<RouterOperationContextSession> _scopedSession;
diff --git a/src/mongo/s/write_ops/batch_write_op_test.cpp b/src/mongo/s/write_ops/batch_write_op_test.cpp
index abb7ccd4fa5..46bd5a26c79 100644
--- a/src/mongo/s/write_ops/batch_write_op_test.cpp
+++ b/src/mongo/s/write_ops/batch_write_op_test.cpp
@@ -120,7 +120,7 @@ protected:
using BatchWriteOpTest = WriteOpTestFixture;
TEST_F(BatchWriteOpTest, SingleOp) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -152,7 +152,7 @@ TEST_F(BatchWriteOpTest, SingleOp) {
}
TEST_F(BatchWriteOpTest, SingleError) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -190,7 +190,7 @@ TEST_F(BatchWriteOpTest, SingleError) {
}
TEST_F(BatchWriteOpTest, SingleTargetError) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterHalfRange(nss, endpoint);
@@ -224,7 +224,7 @@ TEST_F(BatchWriteOpTest, SingleTargetError) {
// Write concern error test - we should pass write concern to sub-batches, and pass up the write
// concern error if one occurs.
TEST_F(BatchWriteOpTest, SingleWriteConcernErrorOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -266,7 +266,7 @@ TEST_F(BatchWriteOpTest, SingleWriteConcernErrorOrdered) {
// Single-op stale version test. We should retry the same batch until we're not stale.
TEST_F(BatchWriteOpTest, SingleStaleError) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -329,7 +329,7 @@ TEST_F(BatchWriteOpTest, SingleStaleError) {
// Multi-op targeting test (ordered)
TEST_F(BatchWriteOpTest, MultiOpSameShardOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -365,7 +365,7 @@ TEST_F(BatchWriteOpTest, MultiOpSameShardOrdered) {
// Multi-op targeting test (unordered)
TEST_F(BatchWriteOpTest, MultiOpSameShardUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -407,7 +407,7 @@ TEST_F(BatchWriteOpTest, MultiOpSameShardUnordered) {
// Multi-op, multi-endpoing targeting test (ordered). There should be two sets of single batches
// (one to each shard, one-by-one)
TEST_F(BatchWriteOpTest, MultiOpTwoShardsOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -473,7 +473,7 @@ void verifyTargetedBatches(std::map<ShardId, size_t> expected,
// Multi-op, multi-endpoint targeting test (unordered). There should be one set of two batches (one
// to each shard).
TEST_F(BatchWriteOpTest, MultiOpTwoShardsUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -518,7 +518,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardsUnordered) {
// Multi-op (ordered) targeting test where each op goes to both shards. There should be two sets of
// two batches to each shard (two for each delete op).
TEST_F(BatchWriteOpTest, MultiOpTwoShardsEachOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -573,7 +573,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardsEachOrdered) {
// Multi-op (unaordered) targeting test where each op goes to both shards. There should be one set
// of two batches to each shard (containing writes for both ops).
TEST_F(BatchWriteOpTest, MultiOpTwoShardsEachUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -620,7 +620,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardsEachUnordered) {
// shards. Should batch the first two ops, then second ops should be batched separately, then last
// ops should be batched together.
TEST_F(BatchWriteOpTest, MultiOpOneOrTwoShardsOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -714,7 +714,7 @@ TEST_F(BatchWriteOpTest, MultiOpOneOrTwoShardsOrdered) {
// Multi-op (unordered) targeting test where first two ops go to one shard, second two ops go to two
// shards. Should batch all the ops together into two batches of four ops for each shard.
TEST_F(BatchWriteOpTest, MultiOpOneOrTwoShardsUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -767,7 +767,7 @@ TEST_F(BatchWriteOpTest, MultiOpOneOrTwoShardsUnordered) {
// Multi-op targeting test where two ops go to two separate shards and there's an error on one op on
// one shard. There should be one set of two batches to each shard and an error reported.
TEST_F(BatchWriteOpTest, MultiOpSingleShardErrorUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -827,7 +827,7 @@ TEST_F(BatchWriteOpTest, MultiOpSingleShardErrorUnordered) {
// Multi-op targeting test where two ops go to two separate shards and there's an error on each op
// on each shard. There should be one set of two batches to each shard and and two errors reported.
TEST_F(BatchWriteOpTest, MultiOpTwoShardErrorsUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -884,7 +884,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardErrorsUnordered) {
// Multi-op targeting test where each op goes to both shards and there's an error on one op on one
// shard. There should be one set of two batches to each shard and an error reported.
TEST_F(BatchWriteOpTest, MultiOpPartialSingleShardErrorUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -946,7 +946,7 @@ TEST_F(BatchWriteOpTest, MultiOpPartialSingleShardErrorUnordered) {
// shard. There should be one set of two batches to each shard and an error reported, the second op
// should not get run.
TEST_F(BatchWriteOpTest, MultiOpPartialSingleShardErrorOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -1007,7 +1007,7 @@ TEST_F(BatchWriteOpTest, MultiOpPartialSingleShardErrorOrdered) {
// for single-doc batches, since the error means there's no write concern applied. Don't suppress
// the error if ordered : false.
TEST_F(BatchWriteOpTest, MultiOpErrorAndWriteConcernErrorUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -1050,7 +1050,7 @@ TEST_F(BatchWriteOpTest, MultiOpErrorAndWriteConcernErrorUnordered) {
// Single-op (ordered) error and write concern error test. Suppress the write concern error if
// ordered and we also have an error
TEST_F(BatchWriteOpTest, SingleOpErrorAndWriteConcernErrorOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -1105,7 +1105,7 @@ TEST_F(BatchWriteOpTest, SingleOpErrorAndWriteConcernErrorOrdered) {
// Targeting failure on second op in batch op (ordered)
TEST_F(BatchWriteOpTest, MultiOpFailedTargetOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterHalfRange(nss, endpoint);
@@ -1159,7 +1159,7 @@ TEST_F(BatchWriteOpTest, MultiOpFailedTargetOrdered) {
// Targeting failure on second op in batch op (unordered)
TEST_F(BatchWriteOpTest, MultiOpFailedTargetUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterHalfRange(nss, endpoint);
@@ -1212,7 +1212,7 @@ TEST_F(BatchWriteOpTest, MultiOpFailedTargetUnordered) {
// Batch failure (ok : 0) reported in a multi-op batch (ordered). Expect this gets translated down
// into write errors for first affected write.
TEST_F(BatchWriteOpTest, MultiOpFailedBatchOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -1259,7 +1259,7 @@ TEST_F(BatchWriteOpTest, MultiOpFailedBatchOrdered) {
// Batch failure (ok : 0) reported in a multi-op batch (unordered). Expect this gets translated down
// into write errors for all affected writes.
TEST_F(BatchWriteOpTest, MultiOpFailedBatchUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -1315,7 +1315,7 @@ TEST_F(BatchWriteOpTest, MultiOpFailedBatchUnordered) {
// Batch aborted (ordered). Expect this gets translated down into write error for first affected
// write.
TEST_F(BatchWriteOpTest, MultiOpAbortOrdered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -1358,7 +1358,7 @@ TEST_F(BatchWriteOpTest, MultiOpAbortOrdered) {
// Batch aborted (unordered). Expect this gets translated down into write errors for all affected
// writes.
TEST_F(BatchWriteOpTest, MultiOpAbortUnordered) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -1398,7 +1398,7 @@ TEST_F(BatchWriteOpTest, MultiOpAbortUnordered) {
// Multi-op targeting test where each op goes to both shards and both return a write concern error
TEST_F(BatchWriteOpTest, MultiOpTwoWCErrors) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpointA(ShardId("shardA"), ShardVersion::IGNORED(), boost::none);
ShardEndpoint endpointB(ShardId("shardB"), ShardVersion::IGNORED(), boost::none);
@@ -1440,7 +1440,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoWCErrors) {
}
TEST_F(BatchWriteOpTest, AttachingStmtIds) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -1530,7 +1530,7 @@ using BatchWriteOpLimitTests = WriteOpTestFixture;
// Big single operation test - should go through
TEST_F(BatchWriteOpLimitTests, OneBigDoc) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -1565,7 +1565,7 @@ TEST_F(BatchWriteOpLimitTests, OneBigDoc) {
// Big doc with smaller additional doc - should go through as two batches
TEST_F(BatchWriteOpLimitTests, OneBigOneSmall) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterFullRange(nss, endpoint);
@@ -1633,7 +1633,7 @@ private:
};
TEST_F(BatchWriteOpTransactionTest, ThrowTargetingErrorsInTransaction_Delete) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterHalfRange(nss, endpoint);
@@ -1662,7 +1662,7 @@ TEST_F(BatchWriteOpTransactionTest, ThrowTargetingErrorsInTransaction_Delete) {
}
TEST_F(BatchWriteOpTransactionTest, ThrowTargetingErrorsInTransaction_Update) {
- NamespaceString nss("foo.bar");
+ NamespaceString nss = NamespaceString::createNamespaceString_forTest("foo.bar");
ShardEndpoint endpoint(ShardId("shard"), ShardVersion::IGNORED(), boost::none);
auto targeter = initTargeterHalfRange(nss, endpoint);
@@ -1690,7 +1690,7 @@ TEST_F(BatchWriteOpTransactionTest, ThrowTargetingErrorsInTransaction_Update) {
ASSERT_EQ(ErrorCodes::UnknownError, response.getErrDetailsAt(0).getStatus().code());
}
-const NamespaceString kNss("TestDB", "TestColl");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
const int splitPoint = 50;
class WriteWithoutShardKeyFixture : public CatalogCacheTestFixture {
diff --git a/src/mongo/s/write_ops/batched_command_request_test.cpp b/src/mongo/s/write_ops/batched_command_request_test.cpp
index 368d31aa4e9..6408a9c6084 100644
--- a/src/mongo/s/write_ops/batched_command_request_test.cpp
+++ b/src/mongo/s/write_ops/batched_command_request_test.cpp
@@ -81,7 +81,8 @@ TEST(BatchedCommandRequest, InsertWithShardVersion) {
TEST(BatchedCommandRequest, InsertCloneWithIds) {
BatchedCommandRequest batchedRequest([&] {
- write_ops::InsertCommandRequest insertOp(NamespaceString("xyz.abc"));
+ write_ops::InsertCommandRequest insertOp(
+ NamespaceString::createNamespaceString_forTest("xyz.abc"));
insertOp.setWriteCommandRequestBase([] {
write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(true);
diff --git a/src/mongo/s/write_ops/batched_command_response_test.cpp b/src/mongo/s/write_ops/batched_command_response_test.cpp
index d3daad2afde..e4eb5f3b447 100644
--- a/src/mongo/s/write_ops/batched_command_response_test.cpp
+++ b/src/mongo/s/write_ops/batched_command_response_test.cpp
@@ -70,7 +70,7 @@ TEST(BatchedCommandResponseTest, Basic) {
TEST(BatchedCommandResponseTest, StaleConfigInfo) {
OID epoch = OID::gen();
- StaleConfigInfo staleInfo(NamespaceString("TestDB.TestColl"),
+ StaleConfigInfo staleInfo(NamespaceString::createNamespaceString_forTest("TestDB.TestColl"),
ShardVersion(ChunkVersion({epoch, Timestamp(100, 0)}, {1, 0}),
boost::optional<CollectionIndexes>(boost::none)),
ShardVersion(ChunkVersion({epoch, Timestamp(100, 0)}, {2, 0}),
@@ -166,7 +166,8 @@ TEST(BatchedCommandResponseTest, CompatibilityFromWriteErrorToBatchCommandRespon
reply.getWriteCommandReplyBase().setN(1);
reply.getWriteCommandReplyBase().setWriteErrors(std::vector<write_ops::WriteError>{
write_ops::WriteError(1,
- Status(StaleConfigInfo(NamespaceString("TestDB", "TestColl"),
+ Status(StaleConfigInfo(NamespaceString::createNamespaceString_forTest(
+ "TestDB", "TestColl"),
versionReceived,
boost::none,
ShardId("TestShard")),
diff --git a/src/mongo/s/write_ops/write_op_test.cpp b/src/mongo/s/write_ops/write_op_test.cpp
index a318c56cf2d..ef067bdb55e 100644
--- a/src/mongo/s/write_ops/write_op_test.cpp
+++ b/src/mongo/s/write_ops/write_op_test.cpp
@@ -40,7 +40,7 @@
namespace mongo {
namespace {
-const NamespaceString kNss("foo.bar");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("foo.bar");
write_ops::DeleteOpEntry buildDelete(const BSONObj& query, bool multi) {
write_ops::DeleteOpEntry entry;
diff --git a/src/mongo/s/write_ops/write_without_shard_key_util_test.cpp b/src/mongo/s/write_ops/write_without_shard_key_util_test.cpp
index 6a4ffdb5092..1d5f4561d18 100644
--- a/src/mongo/s/write_ops/write_without_shard_key_util_test.cpp
+++ b/src/mongo/s/write_ops/write_without_shard_key_util_test.cpp
@@ -40,7 +40,7 @@ namespace mongo {
namespace write_without_shard_key {
namespace {
-const NamespaceString kNss("TestDB", "TestColl");
+const NamespaceString kNss = NamespaceString::createNamespaceString_forTest("TestDB", "TestColl");
const int splitPoint = 50;
class WriteWithoutShardKeyUtilTest : public CatalogCacheTestFixture {