summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/cursor8.js
blob: bcaf2387ae440e53cc68fbd0dec1f734ce7ffde6 (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
// This should get skipped when testing replication.

var t = db.cursor8;
t.drop();
t.save({});
t.save({});
t.save({});

assert.eq(3, t.find().count(), "A0");

var initialTotalOpen = db.serverStatus().metrics.cursor.open.total;

function test(want, msg) {
    var res = db.serverStatus().metrics.cursor;
    assert.eq(want + initialTotalOpen, res.open.total, msg + " " + tojson(res));
}

test(0, "A1");
assert.eq(3, t.find().count(), "A2");
assert.eq(3, t.find({}).count(), "A3");

// This cursor should remain open on the server.
var cursor = t.find({}).batchSize(2);
cursor.next();
test(1, "B1");