summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2018-11-14 15:14:02 -0500
committerWilliam Schultz <william.schultz@mongodb.com>2018-11-14 17:39:15 -0500
commit28e95dafe81c4c5d4780aaea7ef44dd69679290f (patch)
tree43ae2365b113562056dae8239da46c6138a770fb /jstests
parent05b47e12cd86214244083516f67d7efee8d07b9f (diff)
downloadmongo-28e95dafe81c4c5d4780aaea7ef44dd69679290f.tar.gz
SERVER-37935 Remove read concern 'majority' overrides from all change streams test suites
(cherry picked from commit dd2b355042d8f64e2a10d7b9986265ba563dddd8)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/libs/override_methods/set_read_and_write_concerns.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/jstests/libs/override_methods/set_read_and_write_concerns.js b/jstests/libs/override_methods/set_read_and_write_concerns.js
index a14f6373596..dc6c0a11cb4 100644
--- a/jstests/libs/override_methods/set_read_and_write_concerns.js
+++ b/jstests/libs/override_methods/set_read_and_write_concerns.js
@@ -1,5 +1,18 @@
/**
* Use prototype overrides to set read concern and write concern while running tests.
+ *
+ * A test can override the default read and write concern of commands by loading this library before
+ * the test is run and setting the 'TestData.defaultReadConcernLevel' or
+ * 'TestData.defaultWriteConcern' variables with the desired read/write concern level. For example,
+ * setting:
+ *
+ * TestData.defaultReadConcernLevel = "majority"
+ * TestData.writeConcernLevel = {w: "majority"}
+ *
+ * will run all commands with read/write concern "majority". It is also possible to only override
+ * the write concern of commands, by setting 'TestData.defaultReadConcernLevel' = null. This will
+ * not affect the default read concern of commands in any way.
+ *
*/
(function() {
"use strict";
@@ -12,6 +25,8 @@
" property on the global TestData object");
}
+ // If the default read concern level is null, that indicates that no read concern overrides
+ // should be applied.
const kDefaultReadConcern = {level: TestData.defaultReadConcernLevel};
const kDefaultWriteConcern =
(TestData.hasOwnProperty("defaultWriteConcern")) ? TestData.defaultWriteConcern : {
@@ -152,7 +167,8 @@
const inWrappedForm = commandObj !== commandObjUnwrapped;
- if (shouldForceReadConcern) {
+ // Only override read concern if an override level was specified.
+ if (shouldForceReadConcern && (kDefaultReadConcern.level !== null)) {
// We create a copy of 'commandObj' to avoid mutating the parameter the caller
// specified.
commandObj = Object.assign({}, commandObj);