diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-08-15 18:03:59 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2017-08-18 08:49:39 -0400 |
commit | cacf36cb6647c9f3f6e895c7face718a54725567 (patch) | |
tree | 8c177186fadf8b109e5edac6e8b9f501fbad4966 /src/mongo/dbtests/logical_sessions_tests.cpp | |
parent | 854cc3ca62115c0296e27c75ff017a11614254c6 (diff) | |
download | mongo-cacf36cb6647c9f3f6e895c7face718a54725567.tar.gz |
SERVER-29202 Remove unused fetch methods from logical session cache
Diffstat (limited to 'src/mongo/dbtests/logical_sessions_tests.cpp')
-rw-r--r-- | src/mongo/dbtests/logical_sessions_tests.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/mongo/dbtests/logical_sessions_tests.cpp b/src/mongo/dbtests/logical_sessions_tests.cpp index 93696fce152..9c8d773b6a3 100644 --- a/src/mongo/dbtests/logical_sessions_tests.cpp +++ b/src/mongo/dbtests/logical_sessions_tests.cpp @@ -65,6 +65,26 @@ Status insertRecord(OperationContext* opCtx, LogicalSessionRecord record) { return {ErrorCodes::DuplicateSession, errorString}; } +BSONObj lsidQuery(const LogicalSessionId& lsid) { + return BSON(LogicalSessionRecord::kIdFieldName << lsid.toBSON()); +} + +StatusWith<LogicalSessionRecord> fetchRecord(OperationContext* opCtx, + const LogicalSessionId& lsid) { + DBDirectClient client(opCtx); + auto cursor = client.query(kTestNS.toString(), lsidQuery(lsid), 1); + if (!cursor->more()) { + return {ErrorCodes::NoSuchSession, "No matching record in the sessions collection"}; + } + + try { + IDLParserErrorContext ctx("LogicalSessionRecord"); + return LogicalSessionRecord::parse(ctx, cursor->next()); + } catch (...) { + return exceptionToStatus(); + } +} + } // namespace class SessionsCollectionStandaloneTest { @@ -115,10 +135,10 @@ public: res = collection()->removeRecords(opCtx(), {record1.getId()}); ASSERT_OK(res); - auto swRecord = collection()->fetchRecord(opCtx(), record1.getId()); + auto swRecord = fetchRecord(opCtx(), record1.getId()); ASSERT(!swRecord.isOK()); - swRecord = collection()->fetchRecord(opCtx(), record2.getId()); + swRecord = fetchRecord(opCtx(), record2.getId()); ASSERT(swRecord.isOK()); } }; @@ -144,7 +164,7 @@ public: ASSERT(resRefresh.isOK()); // The timestamp on the refreshed record should be updated. - auto swRecord = collection()->fetchRecord(opCtx(), record1.getId()); + auto swRecord = fetchRecord(opCtx(), record1.getId()); ASSERT(swRecord.isOK()); ASSERT_EQ(swRecord.getValue().getLastUse(), now); @@ -156,7 +176,7 @@ public: resRefresh = collection()->refreshSessions(opCtx(), {record2}, now); ASSERT(resRefresh.isOK()); - swRecord = collection()->fetchRecord(opCtx(), record2.getId()); + swRecord = fetchRecord(opCtx(), record2.getId()); ASSERT(swRecord.isOK()); // Clear the collection. |