summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildscripts/resmokeconfig/suites/read_concern_majority_passthrough.yml5
-rw-r--r--jstests/libs/override_methods/set_majority_read_and_write_concerns.js45
2 files changed, 38 insertions, 12 deletions
diff --git a/buildscripts/resmokeconfig/suites/read_concern_majority_passthrough.yml b/buildscripts/resmokeconfig/suites/read_concern_majority_passthrough.yml
index da97c11d67b..cc7a15dab0a 100644
--- a/buildscripts/resmokeconfig/suites/read_concern_majority_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/read_concern_majority_passthrough.yml
@@ -60,13 +60,12 @@ selector:
- jstests/core/shellkillop.js # db.eval() used
- jstests/core/shell_writeconcern.js # checks write concern shell helpers
- jstests/core/storefunc.js # db.eval() used
+ - jstests/core/write_result.js # Tests invalid writeConcern, we shouldn't override.
# Tests that need triaging & remediation | blacklist decision
# Comments list possible problem point under review.
- jstests/core/capped6.js # Uses captrunc test command.
- jstests/core/convert_to_capped_nonexistant.js # Uses convertToCapped and captrunc command.
- jstests/core/stages_delete.js # Uses stageDebug command for deletes.
- - jstests/core/update_multi5.js # bulk_api not calling getWriteConcern when writeConcern passed in update
-
executor:
js_test:
@@ -85,4 +84,4 @@ executor:
enableMajorityReadConcern: ''
num_nodes: 2
# Needs to be set for any ephemeral or no-journaling storage engine
- write_concern_majority_journal_default: false \ No newline at end of file
+ write_concern_majority_journal_default: false
diff --git a/jstests/libs/override_methods/set_majority_read_and_write_concerns.js b/jstests/libs/override_methods/set_majority_read_and_write_concerns.js
index 4e01fd9753a..767134d43a4 100644
--- a/jstests/libs/override_methods/set_majority_read_and_write_concerns.js
+++ b/jstests/libs/override_methods/set_majority_read_and_write_concerns.js
@@ -6,8 +6,29 @@
"use strict";
var defaultWriteConcern = {
w: "majority",
- wtimeout: 60000
+ // Use a "signature" value that won't typically match a value assigned in normal use.
+ wtimeout: 60321
};
+ var defaultReadConcern = {
+ level: "majority"
+ };
+
+ var originalDBQuery = DBQuery;
+
+ DBQuery = function(mongo, db, collection, ns, query, fields, limit, skip, batchSize, options) {
+ if (ns.endsWith("$cmd")) {
+ if (query.hasOwnProperty("writeConcern") &&
+ bsonWoCompare(query.writeConcern, defaultWriteConcern) !== 0) {
+ jsTestLog("Warning: DBQuery overriding existing writeConcern of: " +
+ tojson(query.writeConcern));
+ query.writeConcern = defaultWriteConcern;
+ }
+ }
+
+ return originalDBQuery.apply(this, arguments);
+ };
+
+ DBQuery.Option = originalDBQuery.Option;
var originalStartParallelShell = startParallelShell;
startParallelShell = function(jsCode, port, noConnect) {
@@ -85,19 +106,25 @@
if (forceWriteConcern) {
if (obj.hasOwnProperty("writeConcern")) {
- jsTestLog("Warning: overriding existing writeConcern of: " +
- tojson(obj.writeConcern));
+ if (bsonWoCompare(obj.writeConcern, defaultWriteConcern) !== 0) {
+ jsTestLog("Warning: _runCommandImpl overriding existing writeConcern of: " +
+ tojson(obj.writeConcern));
+ obj.writeConcern = defaultWriteConcern;
+ }
+ } else {
+ obj.writeConcern = defaultWriteConcern;
}
- obj.writeConcern = defaultWriteConcern;
} else if (forceReadConcern) {
if (obj.hasOwnProperty("readConcern")) {
- jsTestLog("Warning: overriding existing readConcern of: " +
- tojson(obj.readConcern));
+ if (bsonWoCompare(obj.readConcern, defaultReadConcern) !== 0) {
+ jsTestLog("Warning: _runCommandImpl overriding existing readConcern of: " +
+ tojson(obj.readConcern));
+ obj.readConcern = defaultReadConcern;
+ }
+ } else {
+ obj.readConcern = defaultReadConcern;
}
- obj.readConcern = {
- level: "majority"
- };
}
var res = this.getMongo().runCommand(dbName, obj, options);