summaryrefslogtreecommitdiff
path: root/jstests/libs/global_snapshot_reads_util.js
blob: a83ddfbb3402531cee04d9a0f8b86e6673112ef2 (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
/**
 * Tests invalid getMore attempts against an established global snapshot cursor on mongos. The
 * cursor should still be valid and usable after each failed attempt.
 */
function verifyInvalidGetMoreAttempts(mainDb, sessionDb, collName, cursorId, txnNumber) {
    // Reject getMores without a session.
    assert.commandFailedWithCode(
        mainDb.runCommand({getMore: cursorId, collection: collName, batchSize: 1}), 50800);

    // Subsequent getMore requests without the same session id are rejected. The cursor should
    // still be valid and usable after this failed attempt.
    assert.commandFailedWithCode(mainDb.runCommand({
        getMore: cursorId,
        collection: collName,
        batchSize: 1,
        txnNumber: NumberLong(txnNumber),
        lsid: {id: UUID()}
    }),
                                 50801);

    // Reject getMores without without txnNumber.
    assert.commandFailedWithCode(
        sessionDb.runCommand({getMore: cursorId, collection: collName, batchSize: 1}), 50803);

    // Reject getMores without without same txnNumber.
    assert.commandFailedWithCode(
        sessionDb.runCommand(
            {getMore: cursorId, collection: collName, batchSize: 1, txnNumber: NumberLong(50)}),
        50804);
}