2018-08-24 00:26:18 +02:00
|
|
|
// Verifies that snapshot readConcern on mongos is not gated by the enableTestCommands flag.
|
2018-04-09 18:49:21 +02:00
|
|
|
//
|
|
|
|
// @tags: [requires_sharding]
|
|
|
|
(function() {
|
2019-07-27 00:20:35 +02:00
|
|
|
"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.
|
2019-12-17 20:40:28 +01:00
|
|
|
TestData.enableTestCommands = false;
|
2019-07-27 00:20:35 +02:00
|
|
|
expectSnapshotReadConcernIsSupported();
|
|
|
|
|
|
|
|
// Snapshot readConcern should succeed when 'enableTestCommands' is set to true.
|
2019-12-17 20:40:28 +01:00
|
|
|
TestData.enableTestCommands = true;
|
2019-07-27 00:20:35 +02:00
|
|
|
expectSnapshotReadConcernIsSupported();
|
2018-04-09 18:49:21 +02:00
|
|
|
}());
|