diff options
author | Randolph Tan <randolph@10gen.com> | 2013-08-29 16:25:18 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2013-08-29 18:06:52 -0400 |
commit | 84ff1694c4bf92f3deef5c013ac9a5b912e6f96f (patch) | |
tree | 508a373bad152f78ade1d360dee92f072bd85986 /jstests/aggregation | |
parent | bfdd9917c2e2dea22a6673d45d10882d1d567362 (diff) | |
download | mongo-84ff1694c4bf92f3deef5c013ac9a5b912e6f96f.tar.gz |
SERVER-10594 slaveOk bit ignored for unsharded aggregate
Diffstat (limited to 'jstests/aggregation')
-rw-r--r-- | jstests/aggregation/mongos_slaveok.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/jstests/aggregation/mongos_slaveok.js b/jstests/aggregation/mongos_slaveok.js new file mode 100644 index 00000000000..057aacd9efa --- /dev/null +++ b/jstests/aggregation/mongos_slaveok.js @@ -0,0 +1,41 @@ +/** + * Tests aggregate command against mongos with slaveOk. For more tests on read preference, + * please refer to jstests/sharding/read_pref_cmd.js. + */ + +var NODES = 2; + +var doTest = function(st, doSharded) { +var testDB = st.s.getDB('test'); + +testDB.adminCommand({ enableSharding: 'test' }); +testDB.adminCommand({ shardCollection: 'test.user', key: { x: 1 }}); + +if (doSharded) { + testDB.adminCommand({ enableSharding: 'test' }); + testDB.adminCommand({ shardCollection: 'test.user', key: { x: 1 }}); +} + +testDB.user.insert({ x: 10 }); +testDB.runCommand({ getLastError: 1, w: NODES }); +testDB.setSlaveOk(true); + +var secNode = st.rs0.getSecondary(); +secNode.getDB('test').setProfilingLevel(2); + +var res = testDB.runCommand({ aggregate: 'user', pipeline: [{ $project: { x: 1 }}]}); +assert(res.ok); + +var profileQuery = { op: 'command', ns: 'test.$cmd', 'command.aggregate': 'user' }; +var profileDoc = secNode.getDB('test').system.profile.findOne(profileQuery); + +assert(profileDoc != null); +testDB.dropDatabase(); +}; + +var st = new ShardingTest({ shards: { rs0: { oplogSize: 10, verbose: 1, nodes: NODES }}}); + +doTest(st, false); +doTest(st, true); + +st.stop(); |