summaryrefslogtreecommitdiff
path: root/jstests/core/nestedobj1.js
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2017-03-06 13:16:52 -0500
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2017-03-06 13:16:52 -0500
commite2474a4d0d0fd1ba84d8edd201cf0c2334828c9e (patch)
tree2a154f2687a6e8035cae9fdbe5926baeb2dccd46 /jstests/core/nestedobj1.js
parent3084639dfcd5516e77e5ca2e5909356ecf6c9cd4 (diff)
downloadmongo-e2474a4d0d0fd1ba84d8edd201cf0c2334828c9e.tar.gz
Revert "SERVER-26703 reject commands exceeding the BSON depth limit"
This reverts commit c2b3178e0cae20a24bc9cc39a750bb864def17e3.
Diffstat (limited to 'jstests/core/nestedobj1.js')
-rw-r--r--jstests/core/nestedobj1.js62
1 files changed, 24 insertions, 38 deletions
diff --git a/jstests/core/nestedobj1.js b/jstests/core/nestedobj1.js
index 3eb4b04dd1c..379224c1775 100644
--- a/jstests/core/nestedobj1.js
+++ b/jstests/core/nestedobj1.js
@@ -1,44 +1,30 @@
-/**
- * Inserts documents with an indexed nested document field, progressively increasing the nesting
- * depth until the key is too large to index. This tests that we support at least the minimum
- * supported BSON nesting depth, as well as maintaining index consistency.
- */
-(function() {
- "use strict";
-
- function makeNestObj(depth) {
- if (depth == 1) {
- return {a: 1};
- } else {
- return {a: makeNestObj(depth - 1)};
- }
+// SERVER-5127, SERVER-5036
+
+function makeNestObj(depth) {
+ toret = {a: 1};
+
+ for (i = 1; i < depth; i++) {
+ toret = {a: toret};
}
- let collection = db.objNestTest;
- collection.drop();
+ return toret;
+}
- assert.commandWorked(collection.ensureIndex({a: 1}));
+t = db.objNestTest;
+t.drop();
- const kMaxDocumentDepthSoftLimit = 100;
- const kJavaScriptMaxDepthLimit = 150;
+t.ensureIndex({a: 1});
- let level;
- for (level = 1; level < kJavaScriptMaxDepthLimit - 3; level++) {
- let object = makeNestObj(level);
- let res = db.runCommand({insert: collection.getName(), documents: [makeNestObj(level)]});
- if (!res.ok) {
- assert.commandFailedWithCode(
- res, 17280, "Expected insertion to fail only because key is too large to index");
- break;
- }
- }
+n = 1;
+while (true) {
+ var before = t.count();
+ t.insert({_id: n, a: makeNestObj(n)});
+ var after = t.count();
+ if (before == after)
+ break;
+ n++;
+}
+
+assert(n > 30, "not enough n: " + n);
- assert.gt(level,
- kMaxDocumentDepthSoftLimit,
- "Unable to insert a document nested with " + level +
- " levels, which is less than the supported limit of " +
- kMaxDocumentDepthSoftLimit);
- assert.eq(collection.count(),
- collection.find().hint({a: 1}).itcount(),
- "Number of documents in collection does not match number of entries in index");
-}());
+assert.eq(t.count(), t.find({_id: {$gt: 0}}).hint({a: 1}).itcount());