summaryrefslogtreecommitdiff
path: root/jstests/sharding/query_sharded.js
blob: 2a4089c69cfbec1f77f3c81ffa132d9ed53cfa7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// Tests mongos-only query behavior
//

var st = new ShardingTest({shards : 1,
                           mongos : 1,
                           verbose : 0});

var mongos = st.s0;
var coll = mongos.getCollection("foo.bar");

//
//
// Ensure we can't use exhaust option through mongos
coll.remove({});
assert.writeOK(coll.insert({a : 'b'}));
var query = coll.find({});
assert.neq(null, query.next());
query = coll.find({}).addOption(DBQuery.Option.exhaust);
assert.throws(function(){ query.next(); });

//
//
// Ensure we can't trick mongos by inserting exhaust option on a command through mongos
coll.remove({});
assert.writeOK(coll.insert({a : 'b'}));
var cmdColl = mongos.getCollection(coll.getDB().toString() + ".$cmd");
var cmdQuery = cmdColl.find({ ping : 1 }).limit(1);
assert.commandWorked(cmdQuery.next());
cmdQuery = cmdColl.find({ ping : 1 }).limit(1).addOption(DBQuery.Option.exhaust);
assert.throws(function(){ cmdQuery.next(); });

jsTest.log("DONE!");

st.stop();