diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-04-23 22:06:09 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-04-29 16:47:11 -0400 |
commit | cc5fc3a275c125dd7a1fe06299a1c6611633cb31 (patch) | |
tree | 0a940794a6eec9a367d64ebd2f2d8bf18e2a4487 /jstests/sharding/read_pref_cmd.js | |
parent | 27a8cb772d9e876fc7549a2c6ce3c1a62a4a394f (diff) | |
download | mongo-cc5fc3a275c125dd7a1fe06299a1c6611633cb31.tar.gz |
SERVER-18198 use native runCommand method in the shell
Diffstat (limited to 'jstests/sharding/read_pref_cmd.js')
-rw-r--r-- | jstests/sharding/read_pref_cmd.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/jstests/sharding/read_pref_cmd.js b/jstests/sharding/read_pref_cmd.js index 57c9b55d8a9..520d8c6eecb 100644 --- a/jstests/sharding/read_pref_cmd.js +++ b/jstests/sharding/read_pref_cmd.js @@ -53,7 +53,9 @@ var testReadPreference = function(conn, hostList, isMongos, mode, tagSets, secEx */ var cmdTest = function(cmdObj, secOk, profileQuery) { jsTest.log('about to do: ' + tojson(cmdObj)); - var cmdResult = testDB.runCommand(cmdObj); + // use runReadCommand so that the cmdObj is modified with the readPreference + // set on the connection. + var cmdResult = testDB.runReadCommand(cmdObj); jsTest.log('cmd result: ' + tojson(cmdResult)); assert(cmdResult.ok); @@ -180,19 +182,20 @@ var testBadMode = function(conn, hostList, isMongos, mode, tagSets) { var failureMsg, testDB, cmdResult; jsTest.log('Expecting failure for mode: ' + mode + ', tag sets: ' + tojson(tagSets)); - conn.setReadPref(mode, tagSets); + // use setReadPrefUnsafe to bypass client-side validation + conn._setReadPrefUnsafe(mode, tagSets); testDB = conn.getDB('test'); // Test that a command that could be routed to a secondary fails with bad mode / tags. if (isMongos) { // Command result should have ok: 0. - cmdResult = testDB.runCommand({ distinct: 'user', key: 'x' }); + cmdResult = testDB.runReadCommand({ distinct: 'user', key: 'x' }); jsTest.log('cmd result: ' + tojson(cmdResult)); assert(!cmdResult.ok); } else { try { // conn should throw error - testDB.runCommand({ distinct: 'user', key: 'x' }); + testDB.runReadCommand({ distinct: 'user', key: 'x' }); failureMsg = "Unexpected success running distinct!"; } catch (e) { @@ -211,7 +214,7 @@ var testAllModes = function(conn, hostList, isMongos) { [ // mode, tagSets, expectedHost ['primary', undefined, false], - ['primary', [{}], false], + ['primary', [], false], ['primaryPreferred', undefined, false], ['primaryPreferred', [{tag: 'one'}], false], |