summaryrefslogtreecommitdiff
path: root/jstests/core/getmore_cmd_maxtimems.js
blob: 1b8e20ba9625fa79ed0a311d5633760d7345724f (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
37
38
39
40
41
42
43
44
45
46
47
48
49
// Cannot implicitly shard accessed collections because of collection existing when none
// expected.
// @tags: [assumes_no_implicit_collection_creation_after_drop, requires_getmore, requires_capped]

// Test attaching maxTimeMS to a getMore command.
(function() {
'use strict';

var cmdRes;
var collName = 'getmore_cmd_maxtimems';
var coll = db[collName];
coll.drop();

for (var i = 0; i < 10; i++) {
    assert.writeOK(coll.insert({a: i}));
}

// Can't attach maxTimeMS to a getMore command for a non-tailable cursor over a non-capped
// collection.
cmdRes = db.runCommand({find: collName, batchSize: 2});
assert.commandWorked(cmdRes);
cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName, maxTimeMS: 60000});
assert.commandFailed(cmdRes);

coll.drop();
assert.commandWorked(db.createCollection(collName, {capped: true, size: 1024}));
for (var i = 0; i < 10; i++) {
    assert.writeOK(coll.insert({a: i}));
}

// Can't attach maxTimeMS to a getMore command for a non-tailable cursor over a capped
// collection.
cmdRes = db.runCommand({find: collName, batchSize: 2});
assert.commandWorked(cmdRes);
cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName, maxTimeMS: 60000});
assert.commandFailed(cmdRes);

// Can't attach maxTimeMS to a getMore command for a non-awaitData tailable cursor.
cmdRes = db.runCommand({find: collName, batchSize: 2, tailable: true});
assert.commandWorked(cmdRes);
cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName, maxTimeMS: 60000});
assert.commandFailed(cmdRes);

// Can attach maxTimeMS to a getMore command for an awaitData cursor.
cmdRes = db.runCommand({find: collName, batchSize: 2, tailable: true, awaitData: true});
assert.commandWorked(cmdRes);
cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName, maxTimeMS: 60000});
assert.commandWorked(cmdRes);
})();