summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-06-16 17:32:18 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-06-17 13:56:37 -0400
commit50c495a2c22c4367b134e15701e7ce534f642fd1 (patch)
treebc76b53a73f4fb232f0e769ca1252616f124cefc /src
parent438c694cbd3ee368430ba7b95b9be6765217f514 (diff)
downloadmongo-50c495a2c22c4367b134e15701e7ce534f642fd1.tar.gz
SERVER-18436 Make OnCommand functions take RemoteCommandRequests
Diffstat (limited to 'src')
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp16
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp13
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h5
3 files changed, 17 insertions, 17 deletions
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp
index 4d35495ce51..8e4cb6debd0 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp
@@ -68,11 +68,11 @@ namespace {
return assertGet(catalogManager()->getCollection(expectedColl.getNs()));
});
- onFindCommand([&expectedColl](const std::string& dbName, const BSONObj& cmdObj) {
- const NamespaceString nss(dbName + '.' + cmdObj.firstElement().String());
+ onFindCommand([&expectedColl](const RemoteCommandRequest& request) {
+ const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String());
ASSERT_EQ(nss.toString(), CollectionType::ConfigNS);
- auto query = assertGet(LiteParsedQuery::fromFindCommand(nss, cmdObj, false));
+ auto query = assertGet(LiteParsedQuery::fromFindCommand(nss, request.cmdObj, false));
// Ensure the query is correct
ASSERT_EQ(query->ns(), CollectionType::ConfigNS);
@@ -96,7 +96,7 @@ namespace {
ASSERT_EQUALS(status.getStatus(), ErrorCodes::NamespaceNotFound);
});
- onFindCommand([](const std::string& dbName, const BSONObj& cmdObj) {
+ onFindCommand([](const RemoteCommandRequest& request) {
return vector<BSONObj>{ };
});
@@ -118,11 +118,11 @@ namespace {
return assertGet(catalogManager()->getDatabase(expectedDb.getName()));
});
- onFindCommand([&expectedDb](const std::string& dbName, const BSONObj& cmdObj) {
- const NamespaceString nss(dbName + '.' + cmdObj.firstElement().String());
+ onFindCommand([&expectedDb](const RemoteCommandRequest& request) {
+ const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String());
ASSERT_EQ(nss.toString(), DatabaseType::ConfigNS);
- auto query = assertGet(LiteParsedQuery::fromFindCommand(nss, cmdObj, false));
+ auto query = assertGet(LiteParsedQuery::fromFindCommand(nss, request.cmdObj, false));
ASSERT_EQ(query->ns(), DatabaseType::ConfigNS);
ASSERT_EQ(query->getFilter(), BSON(DatabaseType::name(expectedDb.getName())));
@@ -144,7 +144,7 @@ namespace {
ASSERT_EQ(dbResult.getStatus(), ErrorCodes::NamespaceNotFound);
});
- onFindCommand([](const std::string& dbName, const BSONObj& cmdObj) {
+ onFindCommand([](const RemoteCommandRequest& request) {
return vector<BSONObj>{ };
});
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp
index a0eebf1400c..9e8108288ba 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.cpp
@@ -135,7 +135,7 @@ namespace mongo {
network()->getNextReadyRequest();
const RemoteCommandRequest& request = noi->getRequest();
- const auto& resultStatus = func(request.dbname, request.cmdObj);
+ const auto& resultStatus = func(request);
BSONObjBuilder result;
@@ -155,10 +155,9 @@ namespace mongo {
}
void CatalogManagerReplSetTestFixture::onFindCommand(OnFindCommandFunction func) {
- onCommand([&func](const std::string& dbName,
- const BSONObj& cmdObj) -> StatusWith<BSONObj> {
+ onCommand([&func](const RemoteCommandRequest& request) -> StatusWith<BSONObj> {
- const auto& resultStatus = func(dbName, cmdObj);
+ const auto& resultStatus = func(request);
if (!resultStatus.isOK()) {
return resultStatus.getStatus();
@@ -169,10 +168,10 @@ namespace mongo {
arr.append(obj);
}
- const std::string nss = str::stream() << dbName << '.'
- << cmdObj.firstElement().String();
+ const NamespaceString nss = NamespaceString(request.dbname,
+ request.cmdObj.firstElement().String());
BSONObjBuilder result;
- appendCursorResponseObject(0LL, nss, arr.arr(), &result);
+ appendCursorResponseObject(0LL, nss.toString(), arr.arr(), &result);
return result.obj();
});
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h
index 20936117990..6ab05d0496d 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h
@@ -38,6 +38,7 @@ namespace mongo {
class BSONObj;
class CatalogManagerReplicaSet;
+ class RemoteCommandRequest;
class RemoteCommandRunnerMock;
class ShardRegistry;
template<typename T> class StatusWith;
@@ -67,10 +68,10 @@ namespace executor {
* back on the network.
*/
using OnCommandFunction =
- std::function<StatusWith<BSONObj>(const std::string&, const BSONObj&)>;
+ std::function<StatusWith<BSONObj>(const RemoteCommandRequest&)>;
using OnFindCommandFunction =
- std::function<StatusWith<std::vector<BSONObj>>(const std::string&, const BSONObj&)>;
+ std::function<StatusWith<std::vector<BSONObj>>(const RemoteCommandRequest&)>;
CatalogManagerReplicaSet* catalogManager() const;