summaryrefslogtreecommitdiff
path: root/jstests/core/index_many2.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/index_many2.js')
-rw-r--r--jstests/core/index_many2.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/jstests/core/index_many2.js b/jstests/core/index_many2.js
index d923ad5cf13..a92da63c406 100644
--- a/jstests/core/index_many2.js
+++ b/jstests/core/index_many2.js
@@ -31,16 +31,22 @@ const maxNumIndexesAllowed = collectionIsClustered ? 65 : 64;
jsTestLog("Creating " + (maxNumIndexesAllowed - 1) + " indexes.");
// Only 63 will succeed because 64 is the maximum number of indexes allowed on a collection.
-let i = 1;
assert.soon(() => {
- const key = make(i++);
- // May fail due to stepdowns and shutdowns. Keep trying until we reach the
+ // Index creation May fail due to stepdowns and shutdowns. Keep trying until we reach the
// server limit for indexes in a collection.
- const res = t.createIndex(key);
- const num = t.getIndexKeys().length;
- jsTestLog('createIndex: ' + tojson(key) + ': ' +
- ' (num indexes: ' + num + '): ' + tojson(res));
- return num === maxNumIndexesAllowed;
+ try {
+ const numCurrentIndexes = t.getIndexKeys().length;
+ for (let i = numCurrentIndexes + 1; i <= maxNumIndexesAllowed; i++) {
+ const key = make(i);
+ const res = assert.commandWorked(t.createIndex(key));
+ jsTestLog('createIndex: ' + tojson(key) + ': ' + tojson(res));
+ }
+ assert.eq(t.getIndexKeys().length, maxNumIndexesAllowed);
+ return true;
+ } catch (e) {
+ jsTest.log("Failed to create indexes: " + e);
+ return false;
+ }
});
const indexKeys = t.getIndexKeys();