summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2022-06-22 16:38:02 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-22 22:46:02 +0000
commiteb8e6a0a8f090d761fc8450670c7636d976effc7 (patch)
tree382dc63c25f3613af8ffb5b1d59c8ef4612ffb86 /src/mongo/dbtests
parent3fa2961b6463ffa5a1ef1211ed2162965fa9cb19 (diff)
downloadmongo-eb8e6a0a8f090d761fc8450670c7636d976effc7.tar.gz
SERVER-62206 Remove DBClientBase::query_DEPRECATED()
Also includes related simplifications to the implementation of 'DBClientCursor'.
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/mock/mock_dbclient_connection.cpp49
-rw-r--r--src/mongo/dbtests/mock/mock_dbclient_connection.h12
-rw-r--r--src/mongo/dbtests/mock/mock_remote_db_server.cpp14
-rw-r--r--src/mongo/dbtests/mock/mock_remote_db_server.h15
-rw-r--r--src/mongo/dbtests/mock_dbclient_conn_test.cpp39
5 files changed, 0 insertions, 129 deletions
diff --git a/src/mongo/dbtests/mock/mock_dbclient_connection.cpp b/src/mongo/dbtests/mock/mock_dbclient_connection.cpp
index f66746b71c0..957888cfa35 100644
--- a/src/mongo/dbtests/mock/mock_dbclient_connection.cpp
+++ b/src/mongo/dbtests/mock/mock_dbclient_connection.cpp
@@ -160,55 +160,6 @@ std::unique_ptr<DBClientCursor> MockDBClientConnection::find(
return nullptr;
}
-std::unique_ptr<mongo::DBClientCursor> MockDBClientConnection::query_DEPRECATED(
- const NamespaceStringOrUUID& nsOrUuid,
- const BSONObj& filter,
- const client_deprecated::Query& querySettings,
- int limit,
- int nToSkip,
- const BSONObj* fieldsToReturn,
- int queryOptions,
- int batchSize,
- boost::optional<BSONObj> readConcernObj) {
- checkConnection();
-
- try {
- mongo::BSONArray result(_remoteServer->query(_remoteServerInstanceID,
- nsOrUuid,
- filter,
- querySettings,
- limit,
- nToSkip,
- fieldsToReturn,
- queryOptions,
- batchSize,
- readConcernObj));
-
- BSONArray resultsInCursor;
-
- // A simple mock implementation of a resumable query, where we skip the first 'n' fields
- // where 'n' is given by the mock resume token.
- auto nToSkip = 0;
- BSONObj querySettingsAsBSON = querySettings.getFullSettingsDeprecated();
- if (querySettingsAsBSON.hasField("$_resumeAfter")) {
- nToSkip = nToSkipFromResumeAfter(querySettingsAsBSON.getField("$_resumeAfter").Obj());
- }
-
- bool provideResumeToken = false;
- if (querySettingsAsBSON.hasField("$_requestResumeToken")) {
- provideResumeToken = true;
- }
-
-
- return bsonArrayToCursor(std::move(result), nToSkip, provideResumeToken, batchSize);
- } catch (const mongo::DBException&) {
- _failed.store(true);
- throw;
- }
-
- return nullptr;
-}
-
mongo::ConnectionString::ConnectionType MockDBClientConnection::type() const {
return mongo::ConnectionString::ConnectionType::kCustom;
}
diff --git a/src/mongo/dbtests/mock/mock_dbclient_connection.h b/src/mongo/dbtests/mock/mock_dbclient_connection.h
index 0baac0ebfba..4b60f2bec4a 100644
--- a/src/mongo/dbtests/mock/mock_dbclient_connection.h
+++ b/src/mongo/dbtests/mock/mock_dbclient_connection.h
@@ -104,7 +104,6 @@ public:
// DBClientBase methods
//
using DBClientBase::find;
- using DBClientBase::query_DEPRECATED;
bool connect(const char* hostName, StringData applicationName, std::string& errmsg);
@@ -125,17 +124,6 @@ public:
const ReadPreferenceSetting& /*unused*/,
ExhaustMode /*unused*/) override;
- std::unique_ptr<mongo::DBClientCursor> query_DEPRECATED(
- const NamespaceStringOrUUID& nsOrUuid,
- const BSONObj& filter = BSONObj{},
- const client_deprecated::Query& querySettings = client_deprecated::Query(),
- int limit = 0,
- int nToSkip = 0,
- const mongo::BSONObj* fieldsToReturn = nullptr,
- int queryOptions = 0,
- int batchSize = 0,
- boost::optional<BSONObj> readConcernObj = boost::none) override;
-
uint64_t getSockCreationMicroSec() const override;
void insert(const std::string& ns,
diff --git a/src/mongo/dbtests/mock/mock_remote_db_server.cpp b/src/mongo/dbtests/mock/mock_remote_db_server.cpp
index b25a4021beb..0b98308d1d2 100644
--- a/src/mongo/dbtests/mock/mock_remote_db_server.cpp
+++ b/src/mongo/dbtests/mock/mock_remote_db_server.cpp
@@ -228,20 +228,6 @@ mongo::BSONArray MockRemoteDBServer::find(MockRemoteDBServer::InstanceID id,
return findImpl(id, findRequest.getNamespaceOrUUID(), findRequest.getProjection());
}
-mongo::BSONArray MockRemoteDBServer::query(MockRemoteDBServer::InstanceID id,
- const NamespaceStringOrUUID& nsOrUuid,
- const BSONObj& filter,
- const client_deprecated::Query& querySettings,
- int limit,
- int nToSkip,
- const BSONObj* fieldsToReturn,
- int queryOptions,
- int batchSize,
- boost::optional<BSONObj> readConcernObj) {
- BSONObj projection = fieldsToReturn ? *fieldsToReturn : BSONObj{};
- return findImpl(id, nsOrUuid, std::move(projection));
-}
-
mongo::ConnectionString::ConnectionType MockRemoteDBServer::type() const {
return mongo::ConnectionString::ConnectionType::kCustom;
}
diff --git a/src/mongo/dbtests/mock/mock_remote_db_server.h b/src/mongo/dbtests/mock/mock_remote_db_server.h
index c20dc851580..034ad8e7ea4 100644
--- a/src/mongo/dbtests/mock/mock_remote_db_server.h
+++ b/src/mongo/dbtests/mock/mock_remote_db_server.h
@@ -32,7 +32,6 @@
#include <string>
#include <vector>
-#include "mongo/client/client_deprecated.h"
#include "mongo/client/connection_string.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/query/find_command_gen.h"
@@ -168,20 +167,6 @@ public:
*/
mongo::BSONArray find(InstanceID id, const FindCommandRequest& findRequest);
- /**
- * Legacy query API: New callers should use 'find()' rather than this method.
- */
- mongo::BSONArray query(InstanceID id,
- const NamespaceStringOrUUID& nsOrUuid,
- const BSONObj& filter,
- const client_deprecated::Query& querySettings,
- int limit = 0,
- int nToSkip = 0,
- const mongo::BSONObj* fieldsToReturn = nullptr,
- int queryOptions = 0,
- int batchSize = 0,
- boost::optional<BSONObj> readConcernObj = boost::none);
-
//
// Getters
//
diff --git a/src/mongo/dbtests/mock_dbclient_conn_test.cpp b/src/mongo/dbtests/mock_dbclient_conn_test.cpp
index 91740b4358f..b9228513cf6 100644
--- a/src/mongo/dbtests/mock_dbclient_conn_test.cpp
+++ b/src/mongo/dbtests/mock_dbclient_conn_test.cpp
@@ -77,45 +77,6 @@ TEST(MockDBClientConnTest, QueryCount) {
}
}
-// This test should be removed when the legacy query API is removed.
-TEST(MockDBClientConnTest, LegacyQueryApiBumpsQueryCount) {
- MockRemoteDBServer server("test");
- MockDBClientConnection conn(&server);
- ASSERT_EQUALS(0U, server.getQueryCount());
- conn.query_DEPRECATED(NamespaceString("foo.bar"));
- ASSERT_EQUALS(1U, server.getQueryCount());
-}
-
-// This test should be removed when the legacy query API is removed.
-TEST(MockDBClientConnTest, LegacyQueryApiReturnsInsertedDocuments) {
- MockRemoteDBServer server("test");
- const std::string ns("test.user");
-
- {
- MockDBClientConnection conn(&server);
- std::unique_ptr<mongo::DBClientCursor> cursor = conn.query_DEPRECATED(NamespaceString(ns));
- ASSERT(!cursor->more());
-
- server.insert(ns, BSON("x" << 1));
- server.insert(ns, BSON("y" << 2));
- }
-
- {
- MockDBClientConnection conn(&server);
- std::unique_ptr<mongo::DBClientCursor> cursor = conn.query_DEPRECATED(NamespaceString(ns));
-
- ASSERT(cursor->more());
- BSONObj firstDoc = cursor->next();
- ASSERT_EQUALS(1, firstDoc["x"].numberInt());
-
- ASSERT(cursor->more());
- BSONObj secondDoc = cursor->next();
- ASSERT_EQUALS(2, secondDoc["y"].numberInt());
-
- ASSERT(!cursor->more());
- }
-}
-
TEST(MockDBClientConnTest, SkipBasedOnResumeAfter) {
MockRemoteDBServer server{"test"};
const std::string ns{"test.user"};