summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/auth/validated_tenancy_scope_test.cpp15
-rw-r--r--src/mongo/db/namespace_string_test.cpp3
-rw-r--r--src/mongo/db/op_observer/op_observer_impl_test.cpp12
-rw-r--r--src/mongo/db/pipeline/change_stream_event_transform_test.cpp10
-rw-r--r--src/mongo/db/repl/oplog_entry_test.cpp1
5 files changed, 27 insertions, 14 deletions
diff --git a/src/mongo/db/auth/validated_tenancy_scope_test.cpp b/src/mongo/db/auth/validated_tenancy_scope_test.cpp
index f1942f757a6..037faba6538 100644
--- a/src/mongo/db/auth/validated_tenancy_scope_test.cpp
+++ b/src/mongo/db/auth/validated_tenancy_scope_test.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/auth/validated_tenancy_scope.h"
#include "mongo/db/multitenancy_gen.h"
#include "mongo/db/service_context_test_fixture.h"
+#include "mongo/idl/server_parameter_test_util.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -89,7 +90,7 @@ protected:
};
TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportOffWithoutTenantOK) {
- gMultitenancySupport = false;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", false);
auto body = BSON("$db"
<< "foo");
@@ -98,7 +99,7 @@ TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportOffWithoutTenantOK)
}
TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithTenantOK) {
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
auto kOid = OID::gen();
auto body = BSON("ping" << 1 << "$tenant" << kOid);
@@ -110,7 +111,7 @@ TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithTenantOK) {
}
TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithSecurityTokenOK) {
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
const TenantId kTenantId(OID::gen());
auto body = BSON("ping" << 1);
@@ -125,7 +126,7 @@ TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithSecurityTokenOK)
}
TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportOffWithTenantNOK) {
- gMultitenancySupport = false;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", false);
auto kOid = OID::gen();
auto body = BSON("ping" << 1 << "$tenant" << kOid);
@@ -138,7 +139,7 @@ TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportOffWithTenantNOK) {
}
TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithTenantNOK) {
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
auto kOid = OID::gen();
auto body = BSON("ping" << 1 << "$tenant" << kOid);
@@ -152,7 +153,7 @@ TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithTenantNOK) {
// TODO SERVER-66822: Re-enable this test case.
// TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithoutTenantAndSecurityTokenNOK) {
-// gMultitenancySupport = true;
+// RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
// auto body = BSON("ping" << 1);
// AuthorizationSessionImplTestHelper::grantUseTenant(*(client.get()));
// ASSERT_THROWS_CODE(ValidatedTenancyScope::create(client.get(), body, {}), DBException,
@@ -160,7 +161,7 @@ TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithTenantNOK) {
// }
TEST_F(ValidatedTenancyScopeTestFixture, MultitenancySupportWithTenantAndSecurityTokenNOK) {
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
auto kOid = OID::gen();
auto body = BSON("ping" << 1 << "$tenant" << kOid);
diff --git a/src/mongo/db/namespace_string_test.cpp b/src/mongo/db/namespace_string_test.cpp
index 18eec1c1ce0..72e3ee770a6 100644
--- a/src/mongo/db/namespace_string_test.cpp
+++ b/src/mongo/db/namespace_string_test.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/multitenancy_gen.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/optime.h"
+#include "mongo/idl/server_parameter_test_util.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -357,7 +358,7 @@ TEST(NamespaceStringTest, NSSNoCollectionWithTenantId) {
}
TEST(NamespaceStringTest, ParseNSSWithTenantId) {
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
TenantId tenantId(OID::gen());
std::string tenantNsStr = str::stream() << tenantId.toString() << "_foo.bar";
diff --git a/src/mongo/db/op_observer/op_observer_impl_test.cpp b/src/mongo/db/op_observer/op_observer_impl_test.cpp
index 6d356530cc8..d6622de3b13 100644
--- a/src/mongo/db/op_observer/op_observer_impl_test.cpp
+++ b/src/mongo/db/op_observer/op_observer_impl_test.cpp
@@ -602,6 +602,7 @@ TEST_F(OpObserverTest, OnDropCollectionReturnsDropOpTime) {
}
TEST_F(OpObserverTest, OnDropCollectionInlcudesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
OpObserverImpl opObserver(std::make_unique<OplogWriterImpl>());
auto opCtx = cc().makeOperationContext();
@@ -663,6 +664,7 @@ TEST_F(OpObserverTest, OnRenameCollectionReturnsRenameOpTime) {
}
TEST_F(OpObserverTest, OnRenameCollectionIncludesTenantIdFeatureFlagOff) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", false);
OpObserverImpl opObserver(std::make_unique<OplogWriterImpl>());
auto opCtx = cc().makeOperationContext();
@@ -699,6 +701,7 @@ TEST_F(OpObserverTest, OnRenameCollectionIncludesTenantIdFeatureFlagOff) {
}
TEST_F(OpObserverTest, OnRenameCollectionIncludesTenantIdFeatureFlagOn) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
OpObserverImpl opObserver(std::make_unique<OplogWriterImpl>());
auto opCtx = cc().makeOperationContext();
@@ -818,6 +821,7 @@ TEST_F(OpObserverTest, ImportCollectionOplogEntry) {
}
TEST_F(OpObserverTest, ImportCollectionOplogEntryIncludesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
OpObserverImpl opObserver(std::make_unique<OplogWriterImpl>());
auto opCtx = cc().makeOperationContext();
@@ -862,6 +866,7 @@ TEST_F(OpObserverTest, ImportCollectionOplogEntryIncludesTenantId) {
}
TEST_F(OpObserverTest, SingleStatementInsertTestIncludesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
auto opCtx = cc().makeOperationContext();
const NamespaceString nss(TenantId(OID::gen()), "testDB", "testColl");
@@ -893,6 +898,7 @@ TEST_F(OpObserverTest, SingleStatementInsertTestIncludesTenantId) {
}
TEST_F(OpObserverTest, SingleStatementUpdateTestIncludesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
auto opCtx = cc().makeOperationContext();
const NamespaceString nss(TenantId(OID::gen()), "testDB", "testColl");
@@ -926,6 +932,7 @@ TEST_F(OpObserverTest, SingleStatementUpdateTestIncludesTenantId) {
}
TEST_F(OpObserverTest, SingleStatementDeleteTestIncludesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
auto opCtx = cc().makeOperationContext();
const NamespaceString nss(TenantId(OID::gen()), "testDB", "testColl");
@@ -1716,6 +1723,7 @@ TEST_F(OpObserverTransactionTest, TransactionalInsertTest) {
}
TEST_F(OpObserverTransactionTest, TransactionalInsertTestIncludesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
const NamespaceString nss1(TenantId(OID::gen()), "testDB", "testColl");
const NamespaceString nss2(TenantId(OID::gen()), "testDB2", "testColl2");
@@ -1838,6 +1846,7 @@ TEST_F(OpObserverTransactionTest, TransactionalUpdateTest) {
}
TEST_F(OpObserverTransactionTest, TransactionalUpdateTestIncludesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
const NamespaceString nss1(TenantId(OID::gen()), "testDB", "testColl");
const NamespaceString nss2(TenantId(OID::gen()), "testDB2", "testColl2");
@@ -1937,6 +1946,7 @@ TEST_F(OpObserverTransactionTest, TransactionalDeleteTest) {
}
TEST_F(OpObserverTransactionTest, TransactionalDeleteTestIncludesTenantId) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
const NamespaceString nss1(TenantId(OID::gen()), "testDB", "testColl");
const NamespaceString nss2(TenantId(OID::gen()), "testDB2", "testColl2");
@@ -3045,7 +3055,7 @@ TEST_F(BatchedWriteOutputsTest, TestApplyOpsInsertDeleteUpdate) {
// Repeat the same test as above, but assert tenantId is included when available
TEST_F(BatchedWriteOutputsTest, TestApplyOpsInsertDeleteUpdateIncludesTenantId) {
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
// Setup.
auto opCtxRaii = cc().makeOperationContext();
diff --git a/src/mongo/db/pipeline/change_stream_event_transform_test.cpp b/src/mongo/db/pipeline/change_stream_event_transform_test.cpp
index e0060b7d7c7..d5724544de3 100644
--- a/src/mongo/db/pipeline/change_stream_event_transform_test.cpp
+++ b/src/mongo/db/pipeline/change_stream_event_transform_test.cpp
@@ -169,7 +169,7 @@ TEST(ChangeStreamEventTransformTest, TestUpdateTransformWithTenantId) {
// Turn on multitenancySupport, but not featureFlagRequireTenantId. We expect the tenantId to be
// part of the 'ns' field in the oplog entry, but it should not be a part of the db name in the
// change event.
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
const auto documentKey = Document{{"x", 1}, {"y", 1}};
const auto tenantId = TenantId(OID::gen());
@@ -214,7 +214,7 @@ TEST(ChangeStreamEventTransformTest, TestRenameTransformWithTenantId) {
// Turn on multitenancySupport, but not featureFlagRequireTenantId. We expect the tenantId to be
// part of the 'ns' field in the oplog entry, but it should not be a part of the db name in the
// change event.
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
const auto tenantId = TenantId(OID::gen());
NamespaceString renameFrom(tenantId, "unittests.serverless_change_stream");
@@ -273,7 +273,7 @@ TEST(ChangeStreamEventTransformTest, TestDropDatabaseTransformWithTenantId) {
// Turn on multitenancySupport, but not featureFlagRequireTenantId. We expect the tenantId to be
// part of the 'ns' field in the oplog entry, but it should not be a part of the db name in the
// change event.
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
const auto tenantId = TenantId(OID::gen());
NamespaceString dbToDrop(tenantId, "unittests");
@@ -311,7 +311,7 @@ TEST(ChangeStreamEventTransformTest, TestCreateTransformWithTenantId) {
// Turn on multitenancySupport, but not featureFlagRequireTenantId. We expect the tenantId to be
// part of the 'ns' field in the oplog entry, but it should not be a part of the db name in the
// change event.
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
const auto tenantId = TenantId(OID::gen());
NamespaceString nssWithTenant(tenantId, "unittests.serverless_change_stream");
@@ -350,7 +350,7 @@ TEST(ChangeStreamEventTransformTest, TestCreateViewTransformWithTenantId) {
// Turn on multitenancySupport, but not featureFlagRequireTenantId. We expect the tenantId to be
// part of the 'ns' field in the oplog entry, but it should not be a part of the db name in the
// change event.
- gMultitenancySupport = true;
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
const auto tenantId = TenantId(OID::gen());
diff --git a/src/mongo/db/repl/oplog_entry_test.cpp b/src/mongo/db/repl/oplog_entry_test.cpp
index ca9e20e33b5..97794e04e7e 100644
--- a/src/mongo/db/repl/oplog_entry_test.cpp
+++ b/src/mongo/db/repl/oplog_entry_test.cpp
@@ -141,6 +141,7 @@ TEST(OplogEntryTest, OpTimeBaseNonStrictParsing) {
}
TEST(OplogEntryTest, InsertIncludesTidField) {
+ RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
const BSONObj doc = BSON("_id" << docId << "a" << 5);
TenantId tid(OID::gen());