summaryrefslogtreecommitdiff
path: root/jstests/sharding/transactions_read_concerns.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/transactions_read_concerns.js')
-rw-r--r--jstests/sharding/transactions_read_concerns.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/jstests/sharding/transactions_read_concerns.js b/jstests/sharding/transactions_read_concerns.js
index 07b754706c0..914d1d8e933 100644
--- a/jstests/sharding/transactions_read_concerns.js
+++ b/jstests/sharding/transactions_read_concerns.js
@@ -38,7 +38,11 @@
const session = st.s.startSession(sessionOptions);
const sessionDB = session.getDatabase(dbName);
- session.startTransaction({readConcern: readConcern});
+ if (readConcern) {
+ session.startTransaction({readConcern: readConcern});
+ } else {
+ session.startTransaction();
+ }
// Target only the first shard.
assert.commandWorked(sessionDB.runCommand({find: collName, filter: {_id: -1}}));
@@ -52,7 +56,7 @@
// Depending on the transaction's read concern, the new document will or will not be visible
// to the next statement.
- const numExpectedDocs = readConcern.level === "snapshot" ? 0 : 1;
+ const numExpectedDocs = readConcern && readConcern.level === "snapshot" ? 0 : 1;
assert.eq(numExpectedDocs,
sessionDB[collName].find({_id: 5}).itcount(),
"sharded transaction with read concern " + tojson(readConcern) +
@@ -65,6 +69,10 @@
assert.writeOK(sessionDB[collName].remove({_id: 5}));
}
+ // Specifying no read concern level is allowed and should not compute a global snapshot.
+ runTest(st, undefined, {causalConsistency: false});
+ runTest(st, undefined, {causalConsistency: true});
+
const kAllowedReadConcernLevels = ["local", "majority", "snapshot"];
for (let readConcernLevel of kAllowedReadConcernLevels) {
runTest(st, {level: readConcernLevel}, {causalConsistency: false});