summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2017-09-29 12:18:53 -0400
committerJason Carey <jcarey@argv.me>2017-10-03 16:50:12 -0400
commitf23002e965d29158505575d09432faf403efcb56 (patch)
tree5794d12d94376b7cc55186862e4a43d850cab4d5 /jstests
parent8a4b356682d9a3d39049c2d51ac4f10ed1e6d07e (diff)
downloadmongo-f23002e965d29158505575d09432faf403efcb56.tar.gz
SERVER-30848 make shell getMores use sessions
The shell should attach the logical session used to initiate cursors (via find or aggregate) and use it for successive getMores.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/aggregation/bugs/cursor_timeout.js2
-rw-r--r--jstests/aggregation/bugs/lookup_unwind_getmore.js2
-rw-r--r--jstests/aggregation/bugs/lookup_unwind_killcursor.js2
-rw-r--r--jstests/aggregation/bugs/server3253.js2
-rw-r--r--jstests/aggregation/bugs/server5932.js2
-rw-r--r--jstests/aggregation/bugs/server7781.js2
-rw-r--r--jstests/aggregation/extras/utils.js2
-rw-r--r--jstests/auth/indexSystemUsers.js2
-rw-r--r--jstests/auth/list_local_sessions.js2
-rw-r--r--jstests/concurrency/fsm_workloads/agg_out.js2
-rw-r--r--jstests/concurrency/fsm_workloads/invalidated_cursors.js2
-rw-r--r--jstests/concurrency/fsm_workloads/kill_aggregation.js2
-rw-r--r--jstests/concurrency/fsm_workloads/kill_multicollection_aggregation.js2
-rw-r--r--jstests/concurrency/fsm_workloads/list_indexes.js2
-rw-r--r--jstests/core/commands_with_uuid.js4
-rw-r--r--jstests/core/list_collections1.js6
-rw-r--r--jstests/core/list_collections_filter.js4
-rw-r--r--jstests/core/list_indexes.js6
-rw-r--r--jstests/core/list_indexes_invalidation.js2
-rw-r--r--jstests/core/list_namespaces_invalidation.js2
-rw-r--r--jstests/core/max_time_ms.js2
-rw-r--r--jstests/core/rename_stayTemp.js2
-rw-r--r--jstests/core/views/views_basic.js2
-rw-r--r--jstests/core/views/views_change.js2
-rw-r--r--jstests/core/views/views_find.js2
-rw-r--r--jstests/mmap_v1/list_collections2.js2
-rw-r--r--jstests/mmap_v1/repair_cursor1.js2
-rw-r--r--jstests/noPassthrough/aggregation_zero_batchsize.js8
-rw-r--r--jstests/noPassthrough/currentop_query.js4
-rw-r--r--jstests/noPassthrough/logical_session_cursor_checks.js13
-rw-r--r--jstests/noPassthrough/read_majority.js4
-rw-r--r--jstests/noPassthrough/read_majority_reads.js10
-rw-r--r--jstests/noPassthrough/views_legacy.js8
-rw-r--r--jstests/noPassthroughWithMongod/find_cmd.js4
-rw-r--r--jstests/noPassthroughWithMongod/parallel_collection_scan.js2
-rw-r--r--jstests/replsets/read_committed.js4
-rw-r--r--jstests/replsets/read_committed_after_rollback.js4
-rw-r--r--jstests/replsets/read_committed_on_secondary.js4
-rw-r--r--jstests/replsets/read_committed_with_catalog_changes.js2
-rw-r--r--jstests/replsets/read_majority_two_arbs.js2
-rw-r--r--jstests/replsets/temp_namespace.js4
-rw-r--r--jstests/sharding/move_chunk_open_cursors.js4
-rw-r--r--jstests/sharding/query_config.js7
43 files changed, 81 insertions, 69 deletions
diff --git a/jstests/aggregation/bugs/cursor_timeout.js b/jstests/aggregation/bugs/cursor_timeout.js
index 687692b41f2..8d61d51378f 100644
--- a/jstests/aggregation/bugs/cursor_timeout.js
+++ b/jstests/aggregation/bugs/cursor_timeout.js
@@ -48,7 +48,7 @@
let serverStatus = assert.commandWorked(testDB.serverStatus());
const expectedNumTimedOutCursors = serverStatus.metrics.cursor.timedOut + 1;
- const cursor = new DBCommandCursor(conn, res, batchSize);
+ const cursor = new DBCommandCursor(testDB, res, batchSize);
// Wait until the idle cursor background job has killed the aggregation cursor.
assert.soon(
diff --git a/jstests/aggregation/bugs/lookup_unwind_getmore.js b/jstests/aggregation/bugs/lookup_unwind_getmore.js
index 5d4a9286ef9..1e48f93302a 100644
--- a/jstests/aggregation/bugs/lookup_unwind_getmore.js
+++ b/jstests/aggregation/bugs/lookup_unwind_getmore.js
@@ -46,7 +46,7 @@
},
}));
- const cursor = new DBCommandCursor(conn, res, batchSize);
+ const cursor = new DBCommandCursor(testDB, res, batchSize);
assert.eq(numMatches, cursor.itcount());
MongoRunner.stopMongod(conn);
diff --git a/jstests/aggregation/bugs/lookup_unwind_killcursor.js b/jstests/aggregation/bugs/lookup_unwind_killcursor.js
index 29fd25ea227..428284661d5 100644
--- a/jstests/aggregation/bugs/lookup_unwind_killcursor.js
+++ b/jstests/aggregation/bugs/lookup_unwind_killcursor.js
@@ -45,7 +45,7 @@
},
}));
- const cursor = new DBCommandCursor(conn, res, batchSize);
+ const cursor = new DBCommandCursor(testDB, res, batchSize);
cursor.close(); // Closing the cursor will issue the "killCursors" command.
const serverStatus = assert.commandWorked(testDB.adminCommand({serverStatus: 1}));
diff --git a/jstests/aggregation/bugs/server3253.js b/jstests/aggregation/bugs/server3253.js
index dcff3da3033..a8d00d9a07b 100644
--- a/jstests/aggregation/bugs/server3253.js
+++ b/jstests/aggregation/bugs/server3253.js
@@ -47,7 +47,7 @@ function test(input, pipeline, expected) {
function listCollections(name) {
var collectionInfosCursor = db.runCommand("listCollections", {filter: {name: name}});
- return new DBCommandCursor(db.getMongo(), collectionInfosCursor).toArray();
+ return new DBCommandCursor(db, collectionInfosCursor).toArray();
}
input.insert({_id: 1});
diff --git a/jstests/aggregation/bugs/server5932.js b/jstests/aggregation/bugs/server5932.js
index 942cab3b0d4..1c2752297c5 100644
--- a/jstests/aggregation/bugs/server5932.js
+++ b/jstests/aggregation/bugs/server5932.js
@@ -22,7 +22,7 @@ function makeCursor(cmdOut, followupBatchSize) {
assert.neq(cmdOut.cursor.id, undefined);
assert(cmdOut.cursor.id instanceof NumberLong);
assert(cmdOut.cursor.firstBatch instanceof Array);
- return new DBCommandCursor(db.getMongo(), cmdOut, followupBatchSize);
+ return new DBCommandCursor(db, cmdOut, followupBatchSize);
}
// both batch sizes are optional
diff --git a/jstests/aggregation/bugs/server7781.js b/jstests/aggregation/bugs/server7781.js
index 678a224630a..cfa10c699ed 100644
--- a/jstests/aggregation/bugs/server7781.js
+++ b/jstests/aggregation/bugs/server7781.js
@@ -143,7 +143,7 @@
delete aggCmd.$geoNear.num;
var cmdRes = db[coll].runCommand("aggregate", {pipeline: [aggCmd], cursor: {batchSize: 0}});
assert.commandWorked(cmdRes);
- var cmdCursor = new DBCommandCursor(db[coll].getMongo(), cmdRes, 0);
+ var cmdCursor = new DBCommandCursor(db, cmdRes, 0);
checkOutput(db.runCommand(geoCmd), cmdCursor, 70);
}
diff --git a/jstests/aggregation/extras/utils.js b/jstests/aggregation/extras/utils.js
index 24d05af628e..d664aedb9f1 100644
--- a/jstests/aggregation/extras/utils.js
+++ b/jstests/aggregation/extras/utils.js
@@ -266,7 +266,7 @@ function assertErrorCode(coll, pipe, code, errmsg) {
var cursorRes = coll.runCommand("aggregate", cmd);
if (cursorRes.ok) {
var followupBatchSize = 0; // default
- var cursor = new DBCommandCursor(coll.getMongo(), cursorRes, followupBatchSize);
+ var cursor = new DBCommandCursor(coll.getDB(), cursorRes, followupBatchSize);
var error = assert.throws(function() {
cursor.itcount();
diff --git a/jstests/auth/indexSystemUsers.js b/jstests/auth/indexSystemUsers.js
index fd33e906974..55baae11327 100644
--- a/jstests/auth/indexSystemUsers.js
+++ b/jstests/auth/indexSystemUsers.js
@@ -28,7 +28,7 @@ var collectionInfosCursor = adminDB.runCommand("listCollections", {
}
});
-assert.eq([], new DBCommandCursor(adminDB.getMongo(), collectionInfosCursor).toArray());
+assert.eq([], new DBCommandCursor(adminDB, collectionInfosCursor).toArray());
adminDB.logout();
adminDB.auth('admin', 'x');
diff --git a/jstests/auth/list_local_sessions.js b/jstests/auth/list_local_sessions.js
index a82e8d6673f..40cc66d991e 100644
--- a/jstests/auth/list_local_sessions.js
+++ b/jstests/auth/list_local_sessions.js
@@ -1,4 +1,4 @@
-// All tests for the $listLocalSessions aggregateion stage.
+// All tests for the $listLocalSessions aggregation stage.
(function() {
'use strict';
diff --git a/jstests/concurrency/fsm_workloads/agg_out.js b/jstests/concurrency/fsm_workloads/agg_out.js
index c46ec68daa5..71452161627 100644
--- a/jstests/concurrency/fsm_workloads/agg_out.js
+++ b/jstests/concurrency/fsm_workloads/agg_out.js
@@ -67,7 +67,7 @@ var $config = extendWorkload($config, function($config, $super) {
cursor: {}
});
if (res.ok) {
- const cursor = new DBCommandCursor(db.getMongo(), res);
+ const cursor = new DBCommandCursor(db, res);
assertAlways.eq(0, cursor.itcount()); // No matter how many documents were in the
// original input stream, $out should never
// return any results.
diff --git a/jstests/concurrency/fsm_workloads/invalidated_cursors.js b/jstests/concurrency/fsm_workloads/invalidated_cursors.js
index 98119084870..e7359c77263 100644
--- a/jstests/concurrency/fsm_workloads/invalidated_cursors.js
+++ b/jstests/concurrency/fsm_workloads/invalidated_cursors.js
@@ -62,7 +62,7 @@ var $config = (function() {
});
if (res.ok) {
- this.cursor = new DBCommandCursor(db.getMongo(), res, this.batchSize);
+ this.cursor = new DBCommandCursor(db, res, this.batchSize);
}
},
diff --git a/jstests/concurrency/fsm_workloads/kill_aggregation.js b/jstests/concurrency/fsm_workloads/kill_aggregation.js
index 517e1c49e4a..cd16fbcce20 100644
--- a/jstests/concurrency/fsm_workloads/kill_aggregation.js
+++ b/jstests/concurrency/fsm_workloads/kill_aggregation.js
@@ -32,7 +32,7 @@ var $config = extendWorkload($config, function($config, $super) {
return;
}
- var cursor = new DBCommandCursor(db.getMongo(), res);
+ var cursor = new DBCommandCursor(db, res);
try {
// No documents are ever inserted into the collection.
assertAlways.eq(0, cursor.itcount());
diff --git a/jstests/concurrency/fsm_workloads/kill_multicollection_aggregation.js b/jstests/concurrency/fsm_workloads/kill_multicollection_aggregation.js
index 482eb1777b2..597be28f9ae 100644
--- a/jstests/concurrency/fsm_workloads/kill_multicollection_aggregation.js
+++ b/jstests/concurrency/fsm_workloads/kill_multicollection_aggregation.js
@@ -23,7 +23,7 @@ var $config = extendWorkload($config, function($config, $super) {
{aggregate: collName, pipeline: pipeline, cursor: {batchSize: this.batchSize}});
if (res.ok) {
- this.cursor = new DBCommandCursor(db.getMongo(), res, this.batchSize);
+ this.cursor = new DBCommandCursor(db, res, this.batchSize);
}
};
diff --git a/jstests/concurrency/fsm_workloads/list_indexes.js b/jstests/concurrency/fsm_workloads/list_indexes.js
index e62225eaa51..17726286473 100644
--- a/jstests/concurrency/fsm_workloads/list_indexes.js
+++ b/jstests/concurrency/fsm_workloads/list_indexes.js
@@ -22,7 +22,7 @@ var $config = (function() {
// List indexes, using a batchSize of 2 to ensure getmores happen.
function listIndices(db, collName) {
var cursor = new DBCommandCursor(
- db.getMongo(), db.runCommand({listIndexes: collName, cursor: {batchSize: 2}}));
+ db, db.runCommand({listIndexes: collName, cursor: {batchSize: 2}}));
assertWhenOwnColl.gte(cursor.itcount(), 0);
}
diff --git a/jstests/core/commands_with_uuid.js b/jstests/core/commands_with_uuid.js
index 57d4db2e73e..9b813cd5d6f 100644
--- a/jstests/core/commands_with_uuid.js
+++ b/jstests/core/commands_with_uuid.js
@@ -35,7 +35,7 @@
let cmd = {find: uuid};
let res = db.runCommand(cmd);
assert.commandWorked(res, 'could not run ' + tojson(cmd));
- let cursor = new DBCommandCursor(db.getMongo(), res);
+ let cursor = new DBCommandCursor(db, res);
let errMsg = 'expected more data from command ' + tojson(cmd) + ', with result ' + tojson(res);
assert(cursor.hasNext(), errMsg);
let doc = cursor.next();
@@ -56,7 +56,7 @@
cmd = {listIndexes: uuid};
res = db.runCommand(cmd);
assert.commandWorked(res, 'could not run ' + tojson(cmd));
- cursor = new DBCommandCursor(db.getMongo(), res);
+ cursor = new DBCommandCursor(db, res);
cursor.forEach(function(doc) {
assert.eq(doc.ns, 'test.' + mainCollName);
});
diff --git a/jstests/core/list_collections1.js b/jstests/core/list_collections1.js
index 2997d250362..89499e534c0 100644
--- a/jstests/core/list_collections1.js
+++ b/jstests/core/list_collections1.js
@@ -77,7 +77,7 @@
var getListCollectionsCursor = function(options, subsequentBatchSize) {
return new DBCommandCursor(
- mydb.getMongo(), mydb.runCommand("listCollections", options), subsequentBatchSize);
+ mydb, mydb.runCommand("listCollections", options), subsequentBatchSize);
};
var cursorCountMatching = function(cursor, pred) {
@@ -286,9 +286,9 @@
assert.commandWorked(mydb.createCollection("quux"));
res = mydb.runCommand("listCollections", {cursor: {batchSize: 0}});
- cursor = new DBCommandCursor(mydb.getMongo(), res, 2);
+ cursor = new DBCommandCursor(mydb, res, 2);
cursor.close();
- cursor = new DBCommandCursor(mydb.getMongo(), res, 2);
+ cursor = new DBCommandCursor(mydb, res, 2);
assert.throws(function() {
cursor.hasNext();
});
diff --git a/jstests/core/list_collections_filter.js b/jstests/core/list_collections_filter.js
index 38c99fe13ca..41d80d0a344 100644
--- a/jstests/core/list_collections_filter.js
+++ b/jstests/core/list_collections_filter.js
@@ -19,8 +19,8 @@
filter = {};
}
- var cursor = new DBCommandCursor(mydb.getMongo(),
- mydb.runCommand("listCollections", {filter: filter}));
+ var cursor =
+ new DBCommandCursor(mydb, mydb.runCommand("listCollections", {filter: filter}));
function stripToName(result) {
return result.name;
}
diff --git a/jstests/core/list_indexes.js b/jstests/core/list_indexes.js
index 90abc0f4c62..08972d723a7 100644
--- a/jstests/core/list_indexes.js
+++ b/jstests/core/list_indexes.js
@@ -32,7 +32,7 @@
var getListIndexesCursor = function(coll, options, subsequentBatchSize) {
return new DBCommandCursor(
- coll.getDB().getMongo(), coll.runCommand("listIndexes", options), subsequentBatchSize);
+ coll.getDB(), coll.runCommand("listIndexes", options), subsequentBatchSize);
};
var cursorGetIndexSpecs = function(cursor) {
@@ -167,9 +167,9 @@
assert.commandWorked(coll.ensureIndex({c: 1}, {unique: true}));
res = coll.runCommand("listIndexes", {cursor: {batchSize: 0}});
- cursor = new DBCommandCursor(coll.getDB().getMongo(), res, 2);
+ cursor = new DBCommandCursor(coll.getDB(), res, 2);
cursor.close();
- cursor = new DBCommandCursor(coll.getDB().getMongo(), res, 2);
+ cursor = new DBCommandCursor(coll.getDB(), res, 2);
assert.throws(function() {
cursor.hasNext();
});
diff --git a/jstests/core/list_indexes_invalidation.js b/jstests/core/list_indexes_invalidation.js
index c9500ebd5e0..0a5727d0cbb 100644
--- a/jstests/core/list_indexes_invalidation.js
+++ b/jstests/core/list_indexes_invalidation.js
@@ -23,7 +23,7 @@
printjson(res);
// Ensure the cursor has data, rename or drop the collection, and exhaust the cursor.
- let cursor = new DBCommandCursor(db.getMongo(), res);
+ let cursor = new DBCommandCursor(db, res);
let errMsg =
'expected more data from command ' + tojson(cmd) + ', with result ' + tojson(res);
assert(cursor.hasNext(), errMsg);
diff --git a/jstests/core/list_namespaces_invalidation.js b/jstests/core/list_namespaces_invalidation.js
index 6f8033b5fe4..fb6fcd68ff6 100644
--- a/jstests/core/list_namespaces_invalidation.js
+++ b/jstests/core/list_namespaces_invalidation.js
@@ -25,7 +25,7 @@
printjson(res);
// Ensure the cursor has data, invalidate the namespace, and exhaust the cursor.
- let cursor = new DBCommandCursor(dbInvalid.getMongo(), res);
+ let cursor = new DBCommandCursor(dbInvalid, res);
let errMsg =
'expected more data from command ' + tojson(cmd) + ', with result ' + tojson(res);
assert(cursor.hasNext(), errMsg);
diff --git a/jstests/core/max_time_ms.js b/jstests/core/max_time_ms.js
index 7890b088cc9..b1a9f0e2f9c 100644
--- a/jstests/core/max_time_ms.js
+++ b/jstests/core/max_time_ms.js
@@ -391,7 +391,7 @@ assert.commandWorked(
//
res = t.runCommand({parallelCollectionScan: t.getName(), numCursors: 1, maxTimeMS: 60 * 1000});
assert.commandWorked(res);
-var cursor = new DBCommandCursor(t.getDB().getMongo(), res.cursors[0], 5);
+var cursor = new DBCommandCursor(t.getDB(), res.cursors[0], 5);
assert.commandWorked(
t.getDB().adminCommand({configureFailPoint: "maxTimeAlwaysTimeOut", mode: "alwaysOn"}));
assert.throws(function() {
diff --git a/jstests/core/rename_stayTemp.js b/jstests/core/rename_stayTemp.js
index d8451af2d2d..423e5c6e215 100644
--- a/jstests/core/rename_stayTemp.js
+++ b/jstests/core/rename_stayTemp.js
@@ -11,7 +11,7 @@ function ns(coll) {
function istemp(name) {
var result = db.runCommand("listCollections", {filter: {name: name}});
assert(result.ok);
- var collections = new DBCommandCursor(db.getMongo(), result).toArray();
+ var collections = new DBCommandCursor(db, result).toArray();
assert.eq(1, collections.length);
return collections[0].options.temp ? true : false;
}
diff --git a/jstests/core/views/views_basic.js b/jstests/core/views/views_basic.js
index d6032b105df..18bd486df8f 100644
--- a/jstests/core/views/views_basic.js
+++ b/jstests/core/views/views_basic.js
@@ -13,7 +13,7 @@
let res = viewsDB.runCommand(cmd);
assert.commandWorked(res);
- let cursor = new DBCommandCursor(db.getMongo(), res, 5);
+ let cursor = new DBCommandCursor(db, res, 5);
let actual = cursor.toArray();
assert(arrayEq(actual, expected),
"actual: " + tojson(cursor.toArray()) + ", expected:" + tojson(expected));
diff --git a/jstests/core/views/views_change.js b/jstests/core/views/views_change.js
index 002284095c5..483401ecae8 100644
--- a/jstests/core/views/views_change.js
+++ b/jstests/core/views/views_change.js
@@ -27,7 +27,7 @@
let assertFindResultEq = function(collName, expected) {
let res = viewDB.runCommand({find: collName, filter: {}, projection: {_id: 0, a: 1, b: 1}});
assert.commandWorked(res);
- let arr = new DBCommandCursor(db.getMongo(), res).toArray();
+ let arr = new DBCommandCursor(db, res).toArray();
let errmsg = tojson({expected: expected, got: arr});
assert(arrayEq(arr, expected), errmsg);
};
diff --git a/jstests/core/views/views_find.js b/jstests/core/views/views_find.js
index 428457b7822..bfd7cbcbd98 100644
--- a/jstests/core/views/views_find.js
+++ b/jstests/core/views/views_find.js
@@ -15,7 +15,7 @@
let assertFindResultEq = function(cmd, expected, ordered) {
let res = viewsDB.runCommand(cmd);
assert.commandWorked(res);
- let arr = new DBCommandCursor(db.getMongo(), res, 5).toArray();
+ let arr = new DBCommandCursor(viewsDB, res, 5).toArray();
let errmsg = tojson({expected: expected, got: arr});
if (typeof(ordered) === "undefined" || !ordered)
diff --git a/jstests/mmap_v1/list_collections2.js b/jstests/mmap_v1/list_collections2.js
index fdd77767be7..928d34ad84b 100644
--- a/jstests/mmap_v1/list_collections2.js
+++ b/jstests/mmap_v1/list_collections2.js
@@ -8,7 +8,7 @@ mydb.foo.insert({x: 5});
mydb.runCommand({create: "bar", temp: true});
res = mydb.runCommand("listCollections");
-collections = new DBCommandCursor(db.getMongo(), res).toArray();
+collections = new DBCommandCursor(db, res).toArray();
bar = collections.filter(function(x) {
return x.name == "bar";
diff --git a/jstests/mmap_v1/repair_cursor1.js b/jstests/mmap_v1/repair_cursor1.js
index fefc9bbdecb..0a01bed20f3 100644
--- a/jstests/mmap_v1/repair_cursor1.js
+++ b/jstests/mmap_v1/repair_cursor1.js
@@ -11,7 +11,7 @@ assert(res.ok, tojson(res));
t2 = db.repair_cursor1a;
t2.drop();
-cursor = new DBCommandCursor(db._mongo, res);
+cursor = new DBCommandCursor(db, res);
cursor.forEach(function(z) {
t2.insert(z);
});
diff --git a/jstests/noPassthrough/aggregation_zero_batchsize.js b/jstests/noPassthrough/aggregation_zero_batchsize.js
index 7660985af74..5ffd097c7da 100644
--- a/jstests/noPassthrough/aggregation_zero_batchsize.js
+++ b/jstests/noPassthrough/aggregation_zero_batchsize.js
@@ -23,7 +23,7 @@
let res = assert.commandWorked(
testDB.runCommand({aggregate: coll.getName(), pipeline: [], cursor: {batchSize: 0}}));
- let cursor = new DBCommandCursor(conn, res);
+ let cursor = new DBCommandCursor(testDB, res);
assert.eq(
0, cursor.itcount(), "expected no results from getMore of aggregation on empty collection");
@@ -38,7 +38,7 @@
res = assert.commandWorked(
testDB.runCommand({aggregate: coll.getName(), pipeline: [], cursor: {batchSize: 0}}));
- cursor = new DBCommandCursor(conn, res);
+ cursor = new DBCommandCursor(testDB, res);
assert.eq(nDocs, cursor.itcount(), "expected all results to be returned via getMores");
// Test that an error in a getMore will destroy the cursor.
@@ -58,7 +58,7 @@
pipeline: [{$project: {invalidComputation: {$add: [1, "$stringField"]}}}],
cursor: {batchSize: 0}
}));
- cursor = new DBCommandCursor(conn, res);
+ cursor = new DBCommandCursor(testDB, res);
assertNumOpenCursors(1);
assert.throws(() => cursor.itcount(), [], "expected getMore to fail");
@@ -74,7 +74,7 @@
pipeline: [{$out: "validated_collection"}],
cursor: {batchSize: 0}
}));
- cursor = new DBCommandCursor(conn, res);
+ cursor = new DBCommandCursor(testDB, res);
assertNumOpenCursors(1);
// Add a document validation rule to the $out collection so that insertion will fail.
diff --git a/jstests/noPassthrough/currentop_query.js b/jstests/noPassthrough/currentop_query.js
index e3bb80fd808..4cd763bfd8c 100644
--- a/jstests/noPassthrough/currentop_query.js
+++ b/jstests/noPassthrough/currentop_query.js
@@ -316,7 +316,7 @@
confirmCurrentOpContents({
test: function() {
- var cursor = new DBCommandCursor(db.getMongo(), TestData.commandResult, 5);
+ var cursor = new DBCommandCursor(db, TestData.commandResult, 5);
assert.eq(cursor.itcount(), 10);
},
planSummary: "COLLSCAN",
@@ -445,7 +445,7 @@
confirmCurrentOpContents({
test: function() {
- var cursor = new DBCommandCursor(db.getMongo(), TestData.commandResult, 5);
+ var cursor = new DBCommandCursor(db, TestData.commandResult, 5);
assert.eq(cursor.itcount(), 0);
},
planSummary: "COLLSCAN",
diff --git a/jstests/noPassthrough/logical_session_cursor_checks.js b/jstests/noPassthrough/logical_session_cursor_checks.js
index 196027ff42c..d88fdc5f7f1 100644
--- a/jstests/noPassthrough/logical_session_cursor_checks.js
+++ b/jstests/noPassthrough/logical_session_cursor_checks.js
@@ -45,6 +45,19 @@
session1.endSession();
}
+ // Test that query.js driven getMore works correctly on the same session.
+ {
+ var session1 = conn.startSession();
+ var session2 = conn.startSession();
+ var cursor = session1.getDatabase("data_storage").test.find({}).batchSize(1);
+ cursor.next();
+ cursor.next();
+ cursor.close();
+
+ session2.endSession();
+ session1.endSession();
+ }
+
fixture.stop();
}
diff --git a/jstests/noPassthrough/read_majority.js b/jstests/noPassthrough/read_majority.js
index 6959a91c89a..63c175530f5 100644
--- a/jstests/noPassthrough/read_majority.js
+++ b/jstests/noPassthrough/read_majority.js
@@ -37,14 +37,14 @@ load("jstests/libs/analyze_plan.js");
function getReadMajorityCursor() {
var res = t.runCommand('find', {batchSize: 2, readConcern: {level: "majority"}});
assert.commandWorked(res);
- return new DBCommandCursor(db.getMongo(), res, 2);
+ return new DBCommandCursor(db, res, 2);
}
function getReadMajorityAggCursor() {
var res = t.runCommand(
'aggregate', {pipeline: [], cursor: {batchSize: 2}, readConcern: {level: "majority"}});
assert.commandWorked(res);
- return new DBCommandCursor(db.getMongo(), res, 2);
+ return new DBCommandCursor(db, res, 2);
}
function getExplainPlan(query) {
diff --git a/jstests/noPassthrough/read_majority_reads.js b/jstests/noPassthrough/read_majority_reads.js
index f0a5172e07f..f155ae71cc7 100644
--- a/jstests/noPassthrough/read_majority_reads.js
+++ b/jstests/noPassthrough/read_majority_reads.js
@@ -19,21 +19,21 @@
(function() {
'use strict';
- function makeCursor(mongo, result) {
- return new DBCommandCursor(mongo, result);
+ function makeCursor(db, result) {
+ return new DBCommandCursor(db, result);
}
// These test cases are functions that return a cursor of the documents in collections without
// fetching them yet.
var cursorTestCases = {
find: function(coll) {
- return makeCursor(coll.getMongo(),
+ return makeCursor(coll.getDB(),
assert.commandWorked(coll.runCommand(
'find', {readConcern: {level: 'majority'}, batchSize: 0})));
},
aggregate: function(coll) {
return makeCursor(
- coll.getMongo(),
+ coll.getDB(),
assert.commandWorked(coll.runCommand(
'aggregate',
{readConcern: {level: 'majority'}, cursor: {batchSize: 0}, pipeline: []})));
@@ -43,7 +43,7 @@
{readConcern: {level: 'majority'}, numCursors: 1});
assert.commandWorked(res);
assert.eq(res.cursors.length, 1, tojson(res));
- return makeCursor(coll.getMongo(), res.cursors[0]);
+ return makeCursor(coll.getDB(), res.cursors[0]);
},
};
diff --git a/jstests/noPassthrough/views_legacy.js b/jstests/noPassthrough/views_legacy.js
index 63951ef8d91..c52aca93bc3 100644
--- a/jstests/noPassthrough/views_legacy.js
+++ b/jstests/noPassthrough/views_legacy.js
@@ -25,7 +25,7 @@
let cmdRes =
viewsDB.runCommand({find: "view", filter: {a: {$gt: 0}}, sort: {a: 1}, batchSize: 0});
assert.commandWorked(cmdRes);
- let cursor = new DBCommandCursor(viewsDB.getMongo(), cmdRes, 2);
+ let cursor = new DBCommandCursor(viewsDB, cmdRes, 2);
let err = assert.throws(function() {
cursor.itcount();
@@ -37,7 +37,7 @@
//
cmdRes = viewsDB.runCommand({find: "view", filter: {a: {$gt: 0}}, sort: {a: 1}, batchSize: 0});
assert.commandWorked(cmdRes);
- cursor = new DBCommandCursor(viewsDB.getMongo(), cmdRes, 2);
+ cursor = new DBCommandCursor(viewsDB, cmdRes, 2);
// When DBCommandCursor is constructed under legacy readMode, cursor.close() will execute a
// legacy killcursors operation.
@@ -72,12 +72,12 @@
cmdRes = viewsDB.runCommand({find: "view", filter: {a: {$gt: 0}}, sort: {a: 1}, batchSize: 0});
assert.commandWorked(cmdRes);
- cursor = new DBCommandCursor(viewsDB.getMongo(), cmdRes, 2);
+ cursor = new DBCommandCursor(viewsDB, cmdRes, 2);
assert.eq(0, cursor.itcount());
cmdRes = viewsDB.runCommand({aggregate: "view", pipeline: [], cursor: {batchSize: 0}});
assert.commandWorked(cmdRes);
- cursor = new DBCommandCursor(viewsDB.getMongo(), cmdRes, 2);
+ cursor = new DBCommandCursor(viewsDB, cmdRes, 2);
assert.eq(0, cursor.itcount());
MongoRunner.stopMongod(conn);
diff --git a/jstests/noPassthroughWithMongod/find_cmd.js b/jstests/noPassthroughWithMongod/find_cmd.js
index 31d3311832c..6ca536972c6 100644
--- a/jstests/noPassthroughWithMongod/find_cmd.js
+++ b/jstests/noPassthroughWithMongod/find_cmd.js
@@ -39,7 +39,7 @@ assert.commandWorked(res);
assert.neq(0, res.cursor.id);
assert.eq(101, res.cursor.firstBatch.length);
-cursor = new DBCommandCursor(coll.getDB().getMongo(), res);
+cursor = new DBCommandCursor(coll.getDB(), res);
assert.eq(cursor.itcount(), 140);
// Command doesn't parse.
@@ -50,4 +50,4 @@ assert.commandFailed(coll.runCommand("find", {projection: {_id: 0}, filter: {$fo
// Special command namespace.
assert.commandFailed(coll.getDB().runCommand({find: "$cmd"}));
-assert.commandFailed(coll.getDB().runCommand({find: "$cmd.sys.inprog"})); \ No newline at end of file
+assert.commandFailed(coll.getDB().runCommand({find: "$cmd.sys.inprog"}));
diff --git a/jstests/noPassthroughWithMongod/parallel_collection_scan.js b/jstests/noPassthroughWithMongod/parallel_collection_scan.js
index 11fa5d0bd75..b0547592cb9 100644
--- a/jstests/noPassthroughWithMongod/parallel_collection_scan.js
+++ b/jstests/noPassthroughWithMongod/parallel_collection_scan.js
@@ -18,7 +18,7 @@ function iterateSliced() {
var count = 0;
for (var i = 0; i < res.cursors.length; i++) {
var x = res.cursors[i];
- var cursor = new DBCommandCursor(db.getMongo(), x, 5);
+ var cursor = new DBCommandCursor(db, x, 5);
count += cursor.itcount();
}
diff --git a/jstests/replsets/read_committed.js b/jstests/replsets/read_committed.js
index 767126ea47d..22424ce020a 100644
--- a/jstests/replsets/read_committed.js
+++ b/jstests/replsets/read_committed.js
@@ -84,7 +84,7 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
function doRead(coll, readConcern) {
readConcern.maxTimeMS = 3000;
var res = assert.commandWorked(coll.runCommand('find', readConcern));
- return new DBCommandCursor(coll.getMongo(), res).toArray();
+ return new DBCommandCursor(coll.getDB(), res).toArray();
}
function doDirtyRead(coll) {
@@ -110,7 +110,7 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
limit: 1,
});
assert.commandWorked(res);
- return new DBCommandCursor(coll.getMongo(), res).toArray()[0];
+ return new DBCommandCursor(coll.getDB(), res).toArray()[0];
}
for (var testName in testCases) {
diff --git a/jstests/replsets/read_committed_after_rollback.js b/jstests/replsets/read_committed_after_rollback.js
index 033a83ad2d9..991528bf8d7 100644
--- a/jstests/replsets/read_committed_after_rollback.js
+++ b/jstests/replsets/read_committed_after_rollback.js
@@ -24,14 +24,14 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
coll.runCommand('find', {"readConcern": {"level": "majority"}, "maxTimeMS": 10000});
assert.commandWorked(res,
'reading from ' + coll.getFullName() + ' on ' + coll.getMongo().host);
- return new DBCommandCursor(coll.getMongo(), res).toArray()[0].state;
+ return new DBCommandCursor(coll.getDB(), res).toArray()[0].state;
}
function doDirtyRead(coll) {
var res = coll.runCommand('find', {"readConcern": {"level": "local"}});
assert.commandWorked(res,
'reading from ' + coll.getFullName() + ' on ' + coll.getMongo().host);
- return new DBCommandCursor(coll.getMongo(), res).toArray()[0].state;
+ return new DBCommandCursor(coll.getDB(), res).toArray()[0].state;
}
// Set up a set and grab things for later.
diff --git a/jstests/replsets/read_committed_on_secondary.js b/jstests/replsets/read_committed_on_secondary.js
index aca4d77c459..1994142ba83 100644
--- a/jstests/replsets/read_committed_on_secondary.js
+++ b/jstests/replsets/read_committed_on_secondary.js
@@ -84,7 +84,7 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
});
assert.commandWorked(res);
log("done doing dirty read.");
- return new DBCommandCursor(secondary, res).toArray()[0].state;
+ return new DBCommandCursor(dbSecondary, res).toArray()[0].state;
}
function doCommittedRead(lastOp) {
@@ -95,7 +95,7 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
});
assert.commandWorked(res);
log("done doing committed read.");
- return new DBCommandCursor(secondary, res).toArray()[0].state;
+ return new DBCommandCursor(dbSecondary, res).toArray()[0].state;
}
// Do a write, wait for it to replicate, and ensure it is visible.
diff --git a/jstests/replsets/read_committed_with_catalog_changes.js b/jstests/replsets/read_committed_with_catalog_changes.js
index 5516f42792e..8a48593ec3b 100644
--- a/jstests/replsets/read_committed_with_catalog_changes.js
+++ b/jstests/replsets/read_committed_with_catalog_changes.js
@@ -227,7 +227,7 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
coll.runCommand('find', {"readConcern": {"level": "majority"}, "maxTimeMS": timeoutMs});
assert.commandWorked(res, 'reading from ' + coll.getFullName());
// Exhaust the cursor to avoid leaking cursors on the server.
- new DBCommandCursor(coll.getMongo(), res).itcount();
+ new DBCommandCursor(coll.getDB(), res).itcount();
}
// Set up a set and grab things for later.
diff --git a/jstests/replsets/read_majority_two_arbs.js b/jstests/replsets/read_majority_two_arbs.js
index bfb1870264d..6f3ebbdb145 100644
--- a/jstests/replsets/read_majority_two_arbs.js
+++ b/jstests/replsets/read_majority_two_arbs.js
@@ -41,7 +41,7 @@ load("jstests/replsets/rslib.js"); // For startSetIfSupportsReadMajority.
function doRead(readConcern) {
readConcern.maxTimeMS = 3000;
var res = assert.commandWorked(t.runCommand('find', readConcern));
- var docs = (new DBCommandCursor(db.getMongo(), res)).toArray();
+ var docs = (new DBCommandCursor(db, res)).toArray();
assert.gt(docs.length, 0, "no docs returned!");
return docs[0].state;
}
diff --git a/jstests/replsets/temp_namespace.js b/jstests/replsets/temp_namespace.js
index ccf566add02..32aca2eedf0 100644
--- a/jstests/replsets/temp_namespace.js
+++ b/jstests/replsets/temp_namespace.js
@@ -39,13 +39,13 @@ assert.writeOK(masterDB.keep4.insert({}, {writeConcern: {w: 2}}));
function countCollection(mydb, nameFilter) {
var result = mydb.runCommand("listCollections", {filter: {name: nameFilter}});
assert.commandWorked(result);
- return new DBCommandCursor(mydb.getMongo(), result).itcount();
+ return new DBCommandCursor(mydb, result).itcount();
}
function countIndexesFor(mydb, nameFilter) {
var result = mydb.runCommand("listCollections", {filter: {name: nameFilter}});
assert.commandWorked(result);
- var arr = new DBCommandCursor(mydb.getMongo(), result).toArray();
+ var arr = new DBCommandCursor(mydb, result).toArray();
var total = 0;
for (var i = 0; i < arr.length; i++) {
var coll = arr[i];
diff --git a/jstests/sharding/move_chunk_open_cursors.js b/jstests/sharding/move_chunk_open_cursors.js
index fed31a651fc..a821aa0d549 100644
--- a/jstests/sharding/move_chunk_open_cursors.js
+++ b/jstests/sharding/move_chunk_open_cursors.js
@@ -29,7 +29,7 @@
const getMoreBatchSize = 100;
const aggResponse = assert.commandWorked(
coll.runCommand({aggregate: collName, pipeline: [], cursor: {batchSize: 0}}));
- const aggCursor = new DBCommandCursor(st.s0, aggResponse, getMoreBatchSize);
+ const aggCursor = new DBCommandCursor(coll.getDB(), aggResponse, getMoreBatchSize);
assert(st.adminCommand({split: testNs, middle: {_id: nDocs / 2}}));
assert(st.adminCommand({moveChunk: testNs, find: {_id: nDocs - 1}, to: "shard0001"}));
@@ -42,7 +42,7 @@
// Test the same behavior with the find command.
const findResponse = assert.commandWorked(
coll.runCommand({find: collName, filter: {}, batchSize: getMoreBatchSize}));
- const findCursor = new DBCommandCursor(st.s0, findResponse, getMoreBatchSize);
+ const findCursor = new DBCommandCursor(coll.getDB(), findResponse, getMoreBatchSize);
assert(st.adminCommand({split: testNs, middle: {_id: nDocs / 4}}));
assert(st.adminCommand({moveChunk: testNs, find: {_id: 0}, to: "shard0001"}));
diff --git a/jstests/sharding/query_config.js b/jstests/sharding/query_config.js
index 7547eef007a..486e81637ce 100644
--- a/jstests/sharding/query_config.js
+++ b/jstests/sharding/query_config.js
@@ -3,14 +3,13 @@
'use strict';
var getListCollectionsCursor = function(database, options, subsequentBatchSize) {
- return new DBCommandCursor(database.getMongo(),
- database.runCommand("listCollections", options),
- subsequentBatchSize);
+ return new DBCommandCursor(
+ database, database.runCommand("listCollections", options), subsequentBatchSize);
};
var getListIndexesCursor = function(coll, options, subsequentBatchSize) {
return new DBCommandCursor(
- coll.getDB().getMongo(), coll.runCommand("listIndexes", options), subsequentBatchSize);
+ coll.getDB(), coll.runCommand("listIndexes", options), subsequentBatchSize);
};
var arrayGetNames = function(array) {