summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorJonathan Reams <jbreams@mongodb.com>2017-11-09 14:27:19 -0500
committerJonathan Reams <jbreams@mongodb.com>2017-11-15 17:06:47 -0500
commit2b27f4a1feb595b1ee96dd1f62db98741a17695f (patch)
tree157227bd716cf0a521a08f6d3c4f9e91b2a54be2 /jstests/core
parentc748c45d62048c93f9fb4764662b5e2d22d241ad (diff)
downloadmongo-2b27f4a1feb595b1ee96dd1f62db98741a17695f.tar.gz
SERVER-31897 Fix exhaust queries in the shell
(cherry picked from commit 502a72fb94bf05d2b6a24d6d2975a9ef14a5abef)
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/exhaust.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/core/exhaust.js b/jstests/core/exhaust.js
new file mode 100644
index 00000000000..cef3b32fcd2
--- /dev/null
+++ b/jstests/core/exhaust.js
@@ -0,0 +1,24 @@
+(function() {
+ 'use strict';
+
+ var c = db.exhaustColl;
+ c.drop();
+
+ const docCount = 4;
+ for (var i = 0; i < docCount; i++) {
+ assert.writeOK(c.insert({a: i}));
+ }
+
+ // Check that the query works without exhaust set
+ assert.eq(c.find().batchSize(1).itcount(), docCount);
+
+ // Now try to run the same query with exhaust
+ try {
+ assert.eq(c.find().batchSize(1).addOption(DBQuery.Option.exhaust).itcount(), docCount);
+ } catch (e) {
+ // The exhaust option is not valid against mongos, ensure that this query throws the right
+ // code
+ assert.eq(e.code, 18526);
+ }
+
+}());