summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/shelllimit.js
blob: cd021a6df613081851fa1d9e54a43b38cd9daa50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// This checks to make sure that cursors with a limit get killed by the shell
// after all their results have been returned. See SERVER-17792.
(function() {
"use strict";

var t = db.cursor_limit_test;
t.drop();
var pre = db.serverStatus().metrics.cursor.open.total;

for (var i = 1; i <= 5; i++) {
    t.save({a: i});
}

var c = t.find().limit(3);
while (c.hasNext()) {
    var v = c.next();
}

assert.eq(pre, db.serverStatus().metrics.cursor.open.total);
t.drop();
}());