summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/getmore_error.js
blob: 4fed6c38d3d7dddf4fb09ff1ec37fb5cf40387aa (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
31
32
33
34
35
36
// ensure errors in getmore are properly reported to users

var t = db.getmore_error;

for (var i = 0; i < 10; i++) {
    t.insert({_id: i});
}

var cursor = t.find().batchSize(2);  // 1 is a special case

// first batch (only one from OP_QUERY)
assert.eq(cursor.next(), {_id: 0});
assert.eq(cursor.next(), {_id: 1});
assert.eq(cursor.objsLeftInBatch(), 0);

// second batch (first from OP_GETMORE)
assert.eq(cursor.next(), {_id: 2});
assert.eq(cursor.next(), {_id: 3});
assert.eq(cursor.objsLeftInBatch(), 0);

/*
// QUERY_MIGRATION disabling this because it's hard to have a failpoint in 2 parallel
// systems
// make the next OP_GETMORE fail
assert.commandWorked(
    db.adminCommand({configureFailPoint: 'getMoreError', mode: {times: 1}})
);

// attempt to get next batch should fail with a failpoint error
var error = assert.throws(function(){cursor.next();});
if (!error.search(/failpoint/))
    assert(false, "got a non-failpoint error: " + error);
*/

// make sure we won't break other tests by breaking getmore for them
assert.eq(t.find().batchSize(2).itcount(), 10);