summaryrefslogtreecommitdiff
path: root/jstests/sharding/read_pref_cmd.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/read_pref_cmd.js')
-rw-r--r--jstests/sharding/read_pref_cmd.js68
1 files changed, 30 insertions, 38 deletions
diff --git a/jstests/sharding/read_pref_cmd.js b/jstests/sharding/read_pref_cmd.js
index 1e4aa48ee25..3cf6a694cd0 100644
--- a/jstests/sharding/read_pref_cmd.js
+++ b/jstests/sharding/read_pref_cmd.js
@@ -60,9 +60,7 @@ var testReadPreference = function(conn, hostList, isMongos, mode, tagSets, secEx
assert(cmdResult.ok);
var testedAtLeastOnce = false;
- var query = {
- op: 'command'
- };
+ var query = {op: 'command'};
Object.extend(query, profileQuery);
hostList.forEach(function(node) {
@@ -216,28 +214,28 @@ var testAllModes = function(conn, hostList, isMongos) {
// { tag: 'two' } so we can test the interaction of modes and tags. Test
// a bunch of combinations.
[
- // mode, tagSets, expectedHost
- ['primary', undefined, false],
- ['primary', [], false],
+ // mode, tagSets, expectedHost
+ ['primary', undefined, false],
+ ['primary', [], false],
- ['primaryPreferred', undefined, false],
- ['primaryPreferred', [{tag: 'one'}], false],
- // Correctly uses primary and ignores the tag
- ['primaryPreferred', [{tag: 'two'}], false],
+ ['primaryPreferred', undefined, false],
+ ['primaryPreferred', [{tag: 'one'}], false],
+ // Correctly uses primary and ignores the tag
+ ['primaryPreferred', [{tag: 'two'}], false],
- ['secondary', undefined, true],
- ['secondary', [{tag: 'two'}], true],
- ['secondary', [{tag: 'doesntexist'}, {}], true],
- ['secondary', [{tag: 'doesntexist'}, {tag: 'two'}], true],
+ ['secondary', undefined, true],
+ ['secondary', [{tag: 'two'}], true],
+ ['secondary', [{tag: 'doesntexist'}, {}], true],
+ ['secondary', [{tag: 'doesntexist'}, {tag: 'two'}], true],
- ['secondaryPreferred', undefined, true],
- ['secondaryPreferred', [{tag: 'one'}], false],
- ['secondaryPreferred', [{tag: 'two'}], true],
+ ['secondaryPreferred', undefined, true],
+ ['secondaryPreferred', [{tag: 'one'}], false],
+ ['secondaryPreferred', [{tag: 'two'}], true],
- // We don't have a way to alter ping times so we can't predict where an
- // untagged 'nearest' command should go, hence only test with tags.
- ['nearest', [{tag: 'one'}], false],
- ['nearest', [{tag: 'two'}], true]
+ // We don't have a way to alter ping times so we can't predict where an
+ // untagged 'nearest' command should go, hence only test with tags.
+ ['nearest', [{tag: 'one'}], false],
+ ['nearest', [{tag: 'two'}], true]
].forEach(function(args) {
var mode = args[0], tagSets = args[1], secExpected = args[2];
@@ -248,17 +246,17 @@ var testAllModes = function(conn, hostList, isMongos) {
});
[
- // Tags not allowed with primary
- ['primary', [{dc: 'doesntexist'}]],
- ['primary', [{dc: 'ny'}]],
- ['primary', [{dc: 'one'}]],
+ // Tags not allowed with primary
+ ['primary', [{dc: 'doesntexist'}]],
+ ['primary', [{dc: 'ny'}]],
+ ['primary', [{dc: 'one'}]],
- // No matching node
- ['secondary', [{tag: 'one'}]],
- ['nearest', [{tag: 'doesntexist'}]],
+ // No matching node
+ ['secondary', [{tag: 'one'}]],
+ ['nearest', [{tag: 'doesntexist'}]],
- ['invalid-mode', undefined],
- ['secondary', ['misformatted-tags']]
+ ['invalid-mode', undefined],
+ ['secondary', ['misformatted-tags']]
].forEach(function(args) {
var mode = args[0], tagSets = args[1];
@@ -278,14 +276,8 @@ ReplSetTest.awaitRSClientHosts(st.s, st.rs0.nodes);
// Tag primary with { dc: 'ny', tag: 'one' }, secondary with { dc: 'ny', tag: 'two' }
var primary = st.rs0.getPrimary();
var secondary = st.rs0.getSecondary();
-var PRIMARY_TAG = {
- dc: 'ny',
- tag: 'one'
-};
-var SECONDARY_TAG = {
- dc: 'ny',
- tag: 'two'
-};
+var PRIMARY_TAG = {dc: 'ny', tag: 'one'};
+var SECONDARY_TAG = {dc: 'ny', tag: 'two'};
var rsConfig = primary.getDB("local").system.replset.findOne();
jsTest.log('got rsconf ' + tojson(rsConfig));