blob: 177afadf24a918e184f5a316722f4dadab134339 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Sessions are asynchronously flushed to disk, so a stepdown immediately after calling
// startSession may cause this test to fail to find the returned sessionId.
// @tags: [does_not_support_stepdowns]
// Basic tests for the $listLocalSessions {allUsers: true} aggregation stage.
(function() {
'use strict';
const admin = db.getSisterDB('admin');
const listAllLocalSessions = function() {
return admin.aggregate([{'$listLocalSessions': {allUsers: true}}]);
};
// Start a new session and capture its sessionId.
const myid = assert.commandWorked(db.runCommand({startSession: 1})).id.id;
assert(myid !== undefined);
// Ensure that the cache now contains the session and is visible by admin.
const resultArray = assert.doesNotThrow(listAllLocalSessions).toArray();
assert.gte(resultArray.length, 1);
const resultArrayMine = resultArray
.map(function(sess) {
return sess._id.id;
})
.filter(function(id) {
return 0 == bsonWoCompare({x: id}, {x: myid});
});
assert.eq(resultArrayMine.length, 1);
})();
|