summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/tailable_getmore_to_mongos_does_not_timeout.js
blob: 3847ad526facd1e599c3b470f25f1b171a2b2256 (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
// Tests that specifying a maxTimeMS on a getMore request to mongos is not interpreted as a deadline
// for the operationfor a tailable + awaitData cursor.
// This test was designed to reproduce SERVER-33942 against a mongos.
// @tags: [
//   requires_capped,
//   requires_sharding,
// ]
(function() {
"use strict";

const st = new ShardingTest({shards: 2});

const db = st.s.getDB("test");
const coll = db.capped;
assert.commandWorked(db.runCommand({create: "capped", capped: true, size: 1024}));
assert.commandWorked(coll.insert({}));
const findResult = assert.commandWorked(
    db.runCommand({find: "capped", filter: {}, tailable: true, awaitData: true}));

const cursorId = findResult.cursor.id;
assert.neq(cursorId, 0);

// Test that the getMores on this tailable cursor are immune to interrupt.
assert.commandWorked(
    db.adminCommand({configureFailPoint: "maxTimeAlwaysTimeOut", mode: "alwaysOn"}));
assert.commandWorked(db.runCommand({getMore: cursorId, collection: "capped", maxTimeMS: 30}));
assert.commandWorked(db.runCommand({getMore: cursorId, collection: "capped"}));
assert.commandWorked(db.adminCommand({configureFailPoint: "maxTimeAlwaysTimeOut", mode: "off"}));

st.stop();
}());