blob: 31b2e513b315466bf258a520796a3644692a73fe (
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
|
// Verifies that snapshot readConcern on mongos is not gated by the enableTestCommands flag.
//
// @tags: [requires_sharding]
(function() {
"use strict";
const dbName = "test";
const collName = "coll";
// Runs multiple commands with read concern level "snapshot" in a session,
// expecting success.
function expectSnapshotReadConcernIsSupported() {
const st = new ShardingTest({shards: 1, config: 1});
const session = st.s.startSession({causalConsistency: false});
let txnNumber = 0;
assert.commandWorked(session.getDatabase(dbName).runCommand({
find: collName,
readConcern: {level: "snapshot"},
txnNumber: NumberLong(txnNumber++),
startTransaction: true,
autocommit: false
}));
assert.commandWorked(session.getDatabase(dbName).runCommand({
aggregate: collName,
pipeline: [],
cursor: {},
readConcern: {level: "snapshot"},
txnNumber: NumberLong(txnNumber++),
startTransaction: true,
autocommit: false
}));
session.endSession();
st.stop();
}
// Snapshot readConcern should succeed when 'enableTestCommands' is set to false.
TestData.enableTestCommands = false;
expectSnapshotReadConcernIsSupported();
// Snapshot readConcern should succeed when 'enableTestCommands' is set to true.
TestData.enableTestCommands = true;
expectSnapshotReadConcernIsSupported();
}());
|