summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/shelllimit.js
blob: 3b270bddc128321ba42725c51c1553de7e10c16a (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();
}());