summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2018-04-25 14:48:04 -0400
committerDavid Storch <david.storch@10gen.com>2018-04-25 18:18:16 -0400
commit1f5410fdad8ee3c4c1d8b88d8a852d8bd1b43b7b (patch)
tree23089aa5fe7db424a7529090a6d3ea0bbd6b64e7
parentc50a57061af31f92c1c6aab09b1417ab127fed0c (diff)
downloadmongo-1f5410fdad8ee3c4c1d8b88d8a852d8bd1b43b7b.tar.gz
SERVER-34678 Make list_all_local_cursors.js easier to diagnose on failure.
-rw-r--r--jstests/core/list_all_local_cursors.js38
1 files changed, 18 insertions, 20 deletions
diff --git a/jstests/core/list_all_local_cursors.js b/jstests/core/list_all_local_cursors.js
index cf10615e5a3..09397467b55 100644
--- a/jstests/core/list_all_local_cursors.js
+++ b/jstests/core/list_all_local_cursors.js
@@ -7,16 +7,14 @@
"use strict";
const admin = db.getSisterDB("admin");
- const countAllMatchingLocalCursors = function(match) {
+ function listAllCursorsWithId(cursorId) {
return admin
.aggregate([
{"$listLocalCursors": {}},
- {"$match": match},
- {"$count": "matches"},
+ {"$match": {"id": cursorId}},
])
- .next()
- .matches;
- };
+ .toArray();
+ }
let session = db.getMongo().startSession();
let testDb = db.getSisterDB("listAllLocalCursors");
@@ -29,20 +27,20 @@
let cursorIdWithoutSession =
assert.commandWorked(testDb.runCommand({find: "data", batchSize: 0})).cursor.id;
- // Ensure that the cache now contains the session and is visible by admin.
- const count = countAllMatchingLocalCursors({
- "ns": "listAllLocalCursors.data",
- "$or": [
- {
- "id": cursorIdWithSession,
- "lsid.id": session._serverSession.handle.getId().id,
- },
- {
- "id": cursorIdWithoutSession,
- },
- ],
- });
- assert.eq(count, 2);
+ // Verify that we correctly list the cursor which is outside of a session.
+ let foundCursors = listAllCursorsWithId(cursorIdWithoutSession);
+ assert.eq(foundCursors.length, 1, tojson(foundCursors));
+ assert.eq(foundCursors[0].ns, "listAllLocalCursors.data", tojson(foundCursors));
+ assert.eq(foundCursors[0].id, cursorIdWithoutSession, tojson(foundCursors));
+
+ // Verify that we correctly list the cursor which is inside of a session.
+ foundCursors = listAllCursorsWithId(cursorIdWithSession);
+ assert.eq(foundCursors.length, 1, tojson(foundCursors));
+ assert.eq(foundCursors[0].ns, "listAllLocalCursors.data", tojson(foundCursors));
+ assert.eq(foundCursors[0].id, cursorIdWithSession, tojson(foundCursors));
+ assert(foundCursors[0].hasOwnProperty("lsid"), tojson(foundCursors));
+ assert.eq(
+ foundCursors[0].lsid.id, session._serverSession.handle.getId().id, tojson(foundCursors));
assert.commandWorked(testDbWithSession.runCommand(
{killCursors: "data", cursors: [cursorIdWithSession, cursorIdWithoutSession]}));