summaryrefslogtreecommitdiff
path: root/jstests/replsets/explain_slaveok.js
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/replsets/explain_slaveok.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/replsets/explain_slaveok.js')
-rw-r--r--jstests/replsets/explain_slaveok.js109
1 files changed, 33 insertions, 76 deletions
diff --git a/jstests/replsets/explain_slaveok.js b/jstests/replsets/explain_slaveok.js
index 93069e6ac01..8cd715af648 100644
--- a/jstests/replsets/explain_slaveok.js
+++ b/jstests/replsets/explain_slaveok.js
@@ -38,23 +38,13 @@ assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
//
// Explain a count on the primary.
-var explainOut = primary.getDB("test").runCommand({
- explain: {
- count: "explain_slaveok",
- query: {a: 1}
- },
- verbosity: "executionStats"
-});
+var explainOut = primary.getDB("test").runCommand(
+ {explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
assert.commandWorked(explainOut, "explain read op on primary");
// Explain an update on the primary.
explainOut = primary.getDB("test").runCommand({
- explain: {
- update: "explain_slaveok",
- updates: [
- {q: {a: 1}, u: {$set: {a: 5}}}
- ]
- },
+ explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
verbosity: "executionStats"
});
assert.commandWorked(explainOut, "explain write op on primary");
@@ -78,67 +68,54 @@ assert.eq(1, secondary.getDB("test").explain_slaveok.findOne({a: 1})["a"]);
// Explain a count on the secondary with slaveOk off. Should fail because
// slaveOk is required for explains on a secondary.
secondary.getDB("test").getMongo().setSlaveOk(false);
-explainOut = secondary.getDB("test").runCommand({
- explain: {
- count: "explain_slaveok",
- query: {a: 1}
- },
- verbosity: "executionStats"
-});
+explainOut = secondary.getDB("test").runCommand(
+ {explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
assert.commandFailed(explainOut, "explain read op on secondary, slaveOk false");
// Explain of count should succeed once slaveOk is true.
secondary.getDB("test").getMongo().setSlaveOk(true);
-explainOut = secondary.getDB("test").runCommand({
- explain: {
- count: "explain_slaveok",
- query: {a: 1}
- },
- verbosity: "executionStats"
-});
+explainOut = secondary.getDB("test").runCommand(
+ {explain: {count: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
assert.commandWorked(explainOut, "explain read op on secondary, slaveOk true");
// Explain .find() on a secondary, setting slaveOk directly on the query.
secondary.getDB("test").getMongo().setSlaveOk(false);
assert.throws(function() {
- secondary.getDB("test").explain_slaveok.explain("executionStats")
- .find({a: 1})
- .finish();
+ secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
});
secondary.getDB("test").getMongo().setSlaveOk(false);
-explainOut = secondary.getDB("test").explain_slaveok.explain("executionStats")
- .find({a: 1})
- .addOption(DBQuery.Option.slaveOk)
- .finish();
+explainOut = secondary.getDB("test")
+ .explain_slaveok.explain("executionStats")
+ .find({a: 1})
+ .addOption(DBQuery.Option.slaveOk)
+ .finish();
assert.commandWorked(explainOut, "explain read op on secondary, slaveOk set to true on query");
secondary.getDB("test").getMongo().setSlaveOk(true);
-explainOut = secondary.getDB("test").explain_slaveok.explain("executionStats")
- .find({a: 1})
- .finish();
+explainOut =
+ secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
assert.commandWorked(explainOut, "explain .find() on secondary, slaveOk set to true");
// Explain .find() on a secondary, setting slaveOk to false with various read preferences.
var readPrefModes = ["secondary", "secondaryPreferred", "primaryPreferred", "nearest"];
readPrefModes.forEach(function(prefString) {
secondary.getDB("test").getMongo().setSlaveOk(false);
- explainOut = secondary.getDB("test").explain_slaveok.explain("executionStats")
- .find({a: 1})
- .readPref(prefString)
- .finish();
- assert.commandWorked(explainOut, "explain .find() on secondary, '"
- + prefString
- + "' read preference on query");
+ explainOut = secondary.getDB("test")
+ .explain_slaveok.explain("executionStats")
+ .find({a: 1})
+ .readPref(prefString)
+ .finish();
+ assert.commandWorked(
+ explainOut, "explain .find() on secondary, '" + prefString + "' read preference on query");
// Similarly should succeed if a read preference is set on the connection.
secondary.setReadPref(prefString);
- explainOut = secondary.getDB("test").explain_slaveok.explain("executionStats")
- .find({a: 1})
- .finish();
- assert.commandWorked(explainOut, "explain .find() on secondary, '"
- + prefString
- + "' read preference on connection");
+ explainOut =
+ secondary.getDB("test").explain_slaveok.explain("executionStats").find({a: 1}).finish();
+ assert.commandWorked(
+ explainOut,
+ "explain .find() on secondary, '" + prefString + "' read preference on connection");
// Unset read pref on the connection.
secondary.setReadPref();
});
@@ -146,24 +123,14 @@ readPrefModes.forEach(function(prefString) {
// Fail explain find() on a secondary, setting slaveOk to false with read preference set to primary.
var prefStringPrimary = "primary";
secondary.getDB("test").getMongo().setSlaveOk(false);
-explainOut = secondary.getDB("test").runCommand({
- explain: {
- find: "explain_slaveok",
- query: {a: 1}
- },
- verbosity: "executionStats"
-});
+explainOut = secondary.getDB("test").runCommand(
+ {explain: {find: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
assert.commandFailed(explainOut, "not master and slaveOk=false");
// Similarly should fail if a read preference is set on the connection.
secondary.setReadPref(prefStringPrimary);
-explainOut = secondary.getDB("test").runCommand({
- explain: {
- find: "explain_slaveok",
- query: {a: 1}
- },
- verbosity: "executionStats"
-});
+explainOut = secondary.getDB("test").runCommand(
+ {explain: {find: "explain_slaveok", query: {a: 1}}, verbosity: "executionStats"});
assert.commandFailed(explainOut, "not master and slaveOk=false");
// Unset read pref on the connection.
secondary.setReadPref();
@@ -172,12 +139,7 @@ secondary.setReadPref();
// slaveOk is required for explains on a secondary.
secondary.getDB("test").getMongo().setSlaveOk(false);
explainOut = secondary.getDB("test").runCommand({
- explain: {
- update: "explain_slaveok",
- updates: [
- {q: {a: 1}, u: {$set: {a: 5}}}
- ]
- },
+ explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
verbosity: "executionStats"
});
assert.commandFailed(explainOut, "explain write op on secondary, slaveOk false");
@@ -185,12 +147,7 @@ assert.commandFailed(explainOut, "explain write op on secondary, slaveOk false")
// Explain of the update should also fail with slaveOk on.
secondary.getDB("test").getMongo().setSlaveOk(true);
explainOut = secondary.getDB("test").runCommand({
- explain: {
- update: "explain_slaveok",
- updates: [
- {q: {a: 1}, u: {$set: {a: 5}}}
- ]
- },
+ explain: {update: "explain_slaveok", updates: [{q: {a: 1}, u: {$set: {a: 5}}}]},
verbosity: "executionStats"
});
assert.commandFailed(explainOut, "explain write op on secondary, slaveOk true");