summaryrefslogtreecommitdiff
path: root/src/mongo/s/config_server_test_fixture.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-07-18 15:41:00 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-07-19 07:43:00 -0400
commit9857da5ed789111834ec340ebf37dbbe2f03661f (patch)
tree8f854732b30281a6c4ee7450e22594837e3b710e /src/mongo/s/config_server_test_fixture.cpp
parent0fd8a76d5033287db54a825024311bd597bbd404 (diff)
downloadmongo-9857da5ed789111834ec340ebf37dbbe2f03661f.tar.gz
SERVER-28752 Get rid of usages of Batched Insert/Update/Delete Request in sharding tests
Diffstat (limited to 'src/mongo/s/config_server_test_fixture.cpp')
-rw-r--r--src/mongo/s/config_server_test_fixture.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/mongo/s/config_server_test_fixture.cpp b/src/mongo/s/config_server_test_fixture.cpp
index 50615b80edf..90b815c9eaf 100644
--- a/src/mongo/s/config_server_test_fixture.cpp
+++ b/src/mongo/s/config_server_test_fixture.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
+#include "mongo/db/ops/write_ops.h"
#include "mongo/db/query/cursor_response.h"
#include "mongo/db/query/query_request.h"
#include "mongo/db/repl/oplog.h"
@@ -73,7 +74,6 @@
#include "mongo/s/query/cluster_cursor_manager.h"
#include "mongo/s/set_shard_version_request.h"
#include "mongo/s/shard_id.h"
-#include "mongo/s/write_ops/batched_command_request.h"
#include "mongo/s/write_ops/batched_command_response.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/clock_source_mock.h"
@@ -196,21 +196,16 @@ std::shared_ptr<Shard> ConfigServerTestFixture::getConfigShard() const {
Status ConfigServerTestFixture::insertToConfigCollection(OperationContext* opCtx,
const NamespaceString& ns,
const BSONObj& doc) {
- auto insert(stdx::make_unique<BatchedInsertRequest>());
- insert->addToDocuments(doc);
-
- BatchedCommandRequest request(insert.release());
- request.setNS(ns);
-
- auto config = getConfigShard();
- invariant(config);
-
- auto insertResponse = config->runCommand(opCtx,
- kReadPref,
- ns.db().toString(),
- request.toBSON(),
- Shard::kDefaultConfigCommandTimeout,
- Shard::RetryPolicy::kNoRetry);
+ auto insertResponse = getConfigShard()->runCommand(opCtx,
+ kReadPref,
+ ns.db().toString(),
+ [&]() {
+ write_ops::Insert insertOp(ns);
+ insertOp.setDocuments({doc});
+ return insertOp.toBSON({});
+ }(),
+ Shard::kDefaultConfigCommandTimeout,
+ Shard::RetryPolicy::kNoRetry);
BatchedCommandResponse batchResponse;
auto status = Shard::CommandResponse::processBatchWriteResponse(insertResponse, &batchResponse);