blob: b79cff55cb1a4ceda7a3ba75b3f7c0f25e731fa8 (
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
36
37
|
//
// 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.commandWorked(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.commandWorked(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() {
assert.commandWorked(cmdQuery.next());
});
jsTest.log("DONE!");
st.stop();
|