summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/index_limits_not_bypassed.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthroughWithMongod/index_limits_not_bypassed.js')
-rw-r--r--jstests/noPassthroughWithMongod/index_limits_not_bypassed.js49
1 files changed, 24 insertions, 25 deletions
diff --git a/jstests/noPassthroughWithMongod/index_limits_not_bypassed.js b/jstests/noPassthroughWithMongod/index_limits_not_bypassed.js
index bc55bda6550..33e2e5cec8e 100644
--- a/jstests/noPassthroughWithMongod/index_limits_not_bypassed.js
+++ b/jstests/noPassthroughWithMongod/index_limits_not_bypassed.js
@@ -3,36 +3,35 @@
* the 'createIndexes()' command to create multiple indexes in one request.
*/
(function() {
- "use strict";
+"use strict";
- const collName = "index_limits_not_bypassed";
- const coll = db.getCollection(collName);
- coll.drop();
+const collName = "index_limits_not_bypassed";
+const coll = db.getCollection(collName);
+coll.drop();
- // A single collection can have no more than 64 indexes. We'll create 62 indexes here to
- // have a total of 63 indexes (the _id index and the 62 about to be created).
- for (let index = 0; index < 62; index++) {
- let spec = {};
- spec[index] = 1;
- assert.commandWorked(coll.createIndex(spec));
- }
+// A single collection can have no more than 64 indexes. We'll create 62 indexes here to
+// have a total of 63 indexes (the _id index and the 62 about to be created).
+for (let index = 0; index < 62; index++) {
+ let spec = {};
+ spec[index] = 1;
+ assert.commandWorked(coll.createIndex(spec));
+}
- let indexes = db.runCommand({listIndexes: collName});
- assert.eq(63, indexes.cursor.firstBatch.length);
+let indexes = db.runCommand({listIndexes: collName});
+assert.eq(63, indexes.cursor.firstBatch.length);
- // Creating multiple indexes via 'createIndexes()' shouldn't bypass index limits.
- assert.commandFailedWithCode(coll.createIndexes([{x: 1}, {y: 1}]),
- ErrorCodes.CannotCreateIndex);
+// Creating multiple indexes via 'createIndexes()' shouldn't bypass index limits.
+assert.commandFailedWithCode(coll.createIndexes([{x: 1}, {y: 1}]), ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.dropIndex("x"), ErrorCodes.IndexNotFound);
- assert.commandFailedWithCode(coll.dropIndex("y"), ErrorCodes.IndexNotFound);
+assert.commandFailedWithCode(coll.dropIndex("x"), ErrorCodes.IndexNotFound);
+assert.commandFailedWithCode(coll.dropIndex("y"), ErrorCodes.IndexNotFound);
- // Try to create two text indexes at the same time using 'createIndexes()'. The limit for text
- // indexes is one per collection.
- assert.commandFailedWithCode(
- coll.createIndexes([{x: "text", weights: {x: 5}}, {y: "text", weights: {y: 10}}]),
- ErrorCodes.CannotCreateIndex);
+// Try to create two text indexes at the same time using 'createIndexes()'. The limit for text
+// indexes is one per collection.
+assert.commandFailedWithCode(
+ coll.createIndexes([{x: "text", weights: {x: 5}}, {y: "text", weights: {y: 10}}]),
+ ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.dropIndex("x"), ErrorCodes.IndexNotFound);
- assert.commandFailedWithCode(coll.dropIndex("y"), ErrorCodes.IndexNotFound);
+assert.commandFailedWithCode(coll.dropIndex("x"), ErrorCodes.IndexNotFound);
+assert.commandFailedWithCode(coll.dropIndex("y"), ErrorCodes.IndexNotFound);
}());