diff options
author | Benety Goh <benety@mongodb.com> | 2021-09-28 08:15:44 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-28 12:38:23 +0000 |
commit | 3908a54ad0569d3cbe672923d78a41e2bb3cbb37 (patch) | |
tree | 0040ca2033abaf522f09d42f8837259c1e6fa300 /src/mongo/rpc | |
parent | 56fcb26c03a537e2dba6729249baac09569e4bcd (diff) | |
download | mongo-3908a54ad0569d3cbe672923d78a41e2bb3cbb37.tar.gz |
SERVER-59618 add LockerMongos and LockerMongosClientObserver. Register in sharding unit tests
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r-- | src/mongo/rpc/metadata/client_metadata_test.cpp | 3 | ||||
-rw-r--r-- | src/mongo/rpc/metadata/security_token_metadata_test.cpp | 4 | ||||
-rw-r--r-- | src/mongo/rpc/rewrite_state_change_errors_test.cpp | 14 |
3 files changed, 16 insertions, 5 deletions
diff --git a/src/mongo/rpc/metadata/client_metadata_test.cpp b/src/mongo/rpc/metadata/client_metadata_test.cpp index e6d414c9336..becb3af5698 100644 --- a/src/mongo/rpc/metadata/client_metadata_test.cpp +++ b/src/mongo/rpc/metadata/client_metadata_test.cpp @@ -41,6 +41,7 @@ #include "mongo/bson/bsonobjbuilder.h" #include "mongo/bson/json.h" #include "mongo/db/client.h" +#include "mongo/db/concurrency/locker_noop_client_observer.h" #include "mongo/db/operation_context.h" #include "mongo/db/service_context.h" #include "mongo/s/is_mongos.h" @@ -344,6 +345,7 @@ TEST(ClientMetadataTest, TestMongoSAppend) { TEST(ClientMetadataTest, TestInvalidDocWhileSettingOpCtxMetadata) { auto svcCtx = ServiceContext::make(); + svcCtx->registerClientObserver(std::make_unique<LockerNoopClientObserver>()); auto client = svcCtx->makeClient("ClientMetadataTest"); auto opCtx = client->makeOperationContext(); // metadataElem is of BSON type int @@ -363,6 +365,7 @@ TEST(ClientMetadataTest, TestInvalidDocWhileSettingOpCtxMetadata) { TEST(ClientMetadataTest, TestEooElemAsValueToSetOpCtxMetadata) { auto svcCtx = ServiceContext::make(); + svcCtx->registerClientObserver(std::make_unique<LockerNoopClientObserver>()); auto client = svcCtx->makeClient("ClientMetadataTest"); auto opCtx = client->makeOperationContext(); // metadataElem is of BSON type eoo diff --git a/src/mongo/rpc/metadata/security_token_metadata_test.cpp b/src/mongo/rpc/metadata/security_token_metadata_test.cpp index 0b310779865..dcdd07b076a 100644 --- a/src/mongo/rpc/metadata/security_token_metadata_test.cpp +++ b/src/mongo/rpc/metadata/security_token_metadata_test.cpp @@ -33,7 +33,7 @@ #include "mongo/db/auth/security_token.h" #include "mongo/db/auth/security_token_gen.h" #include "mongo/db/client.h" -#include "mongo/db/service_context_test_fixture.h" +#include "mongo/db/concurrency/locker_noop_service_context_test_fixture.h" #include "mongo/rpc/op_msg_test.h" #include "mongo/unittest/unittest.h" @@ -45,7 +45,7 @@ namespace { constexpr auto kPingFieldName = "ping"_sd; constexpr auto kTenantFieldName = "tenant"_sd; -class SecurityTokenMetadataTest : public ServiceContextTest {}; +class SecurityTokenMetadataTest : public LockerNoopServiceContextTest {}; TEST_F(SecurityTokenMetadataTest, SecurityTokenNotAccepted) { const auto kPingBody = BSON(kPingFieldName << 1); diff --git a/src/mongo/rpc/rewrite_state_change_errors_test.cpp b/src/mongo/rpc/rewrite_state_change_errors_test.cpp index 66cda0cd0c2..c86217d7191 100644 --- a/src/mongo/rpc/rewrite_state_change_errors_test.cpp +++ b/src/mongo/rpc/rewrite_state_change_errors_test.cpp @@ -32,6 +32,7 @@ #include "mongo/base/error_codes.h" #include "mongo/bson/bsonobj.h" #include "mongo/bson/bsonobjbuilder.h" +#include "mongo/db/concurrency/locker_noop_client_observer.h" #include "mongo/db/service_context.h" #include "mongo/rpc/message.h" #include "mongo/rpc/op_msg.h" @@ -43,6 +44,13 @@ namespace { class RewriteStateChangeErrorsTest : public unittest::Test { public: + RewriteStateChangeErrorsTest() { + sc = ServiceContext::make(); + sc->registerClientObserver(std::make_unique<LockerNoopClientObserver>()); + cc = sc->makeClient("test", nullptr); + opCtx = sc->makeOperationContext(cc.get()); + } + void setUp() override { _savedIsMongos = isMongos(); setMongos(true); // whole feature only happens on mongos @@ -89,9 +97,9 @@ public: {ErrorCodes::BadValue, ErrorCodes::BadValue}, }; - ServiceContext::UniqueServiceContext sc = ServiceContext::make(); - ServiceContext::UniqueClient cc = sc->makeClient("test", nullptr); - ServiceContext::UniqueOperationContext opCtx = sc->makeOperationContext(cc.get()); + ServiceContext::UniqueServiceContext sc; + ServiceContext::UniqueClient cc; + ServiceContext::UniqueOperationContext opCtx; private: bool _savedIsMongos; |