summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/default_read_pref.js
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-08-24 17:12:35 -0400
committerAdam Midvidy <amidvidy@gmail.com>2015-08-24 20:49:26 -0400
commitbe9455abf3126d6136c9ce884a01a4a3e4389bc4 (patch)
tree30b0fc4a83807acaad1150386a485bfd93a0fda2 /jstests/noPassthroughWithMongod/default_read_pref.js
parent3e21b91dcc4d95a06e3f3a80142a686d92896cac (diff)
downloadmongo-be9455abf3126d6136c9ce884a01a4a3e4389bc4.tar.gz
SERVER-20084 do not set slaveOk in runReadCommand if a read pref has not
been set
Diffstat (limited to 'jstests/noPassthroughWithMongod/default_read_pref.js')
-rw-r--r--jstests/noPassthroughWithMongod/default_read_pref.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/default_read_pref.js b/jstests/noPassthroughWithMongod/default_read_pref.js
new file mode 100644
index 00000000000..05be7915626
--- /dev/null
+++ b/jstests/noPassthroughWithMongod/default_read_pref.js
@@ -0,0 +1,28 @@
+// Tests that the default read preference is 'unset', and that the slaveOk bit is not set
+// on read commands run with an 'unset' read preference.
+(function() {
+
+ "use strict";
+
+ var mongo = db.getMongo();
+ try {
+ var commandsRan = [];
+ db._mongo = {
+ getSlaveOk: function() { return false; },
+ getReadPrefMode: function() { return mongo.getReadPrefMode(); },
+ getReadPref: function() { return mongo.getReadPref(); },
+ runCommand: function(db, cmd, opts) {
+ commandsRan.push({db: db, cmd: cmd, opts:opts});
+ }
+ };
+
+ db.runReadCommand({ping: 1});
+ assert.eq(commandsRan.length, 1);
+ assert.docEq(commandsRan[0].cmd, {ping: 1}, "The command should not have been wrapped.");
+ assert.eq(commandsRan[0].opts & DBQuery.Option.slaveOk, 0, "The slaveOk bit should not be set.");
+
+ } finally {
+ db._mongo = mongo;
+ }
+
+})();