summaryrefslogtreecommitdiff
path: root/jstests/core/exhaust.js
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:05:16 -0500
commit502a72fb94bf05d2b6a24d6d2975a9ef14a5abef (patch)
tree596c855e70421fd41b8730b289c47fe3e23ace0c /jstests/core/exhaust.js
parent740921198a324e2b6c6d68e51a678a1f863dda15 (diff)
downloadmongo-502a72fb94bf05d2b6a24d6d2975a9ef14a5abef.tar.gz
SERVER-31897 Fix exhaust queries in the shell
Diffstat (limited to 'jstests/core/exhaust.js')
-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);
+ }
+
+}());