[SERVER-58890] Improve debug-ability of index_many2.js Created: 27/Jul/21  Updated: 29/Oct/23  Resolved: 03/Aug/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Dianna Hohensee (Inactive) Assignee: Dianna Hohensee (Inactive)
Resolution: Fixed Votes: 0
Labels: techdebt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to SERVER-59096 clean up tests: index_many2.js countc... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2021-08-09
Participants:
Linked BF Score: 150

 Description   

got to looking at the test while diagnosing a test failure. want to update the understandability of the test.

make the following changes:

diff --git a/jstests/core/index_many2.js b/jstests/core/index_many2.js
index 70fada7396..5ff9349b20 100644
--- a/jstests/core/index_many2.js
+++ b/jstests/core/index_many2.js
@@ -15,19 +15,31 @@ function make(n) {
     return x;
 }
 
+jsTestLog("Creating 1000 indexes.");
+
+// Try to create 1000 indexes. Only 64 will succeed because 64 is the maximum number of indexes
+// allowed on a collection.
 for (i = 1; i < 1000; i++) {
+    // Cannot assert success because only 64 will succeed.
     t.createIndex(make(i));
 }
 
-assert.eq(64, t.getIndexKeys().length, "A2");
-
 num = t.getIndexKeys().length;
+assert.eq(64, num, "Expected 64 keys, found: " + num);
+
+jsTestLog("Dropping an index.");
+
+assert.commandWorked(t.dropIndex(make(num - 1)));
+assert.eq(num - 1, t.getIndexKeys().length, "After dropping an index, there should be 63 left.");
+
+jsTestLog("Creating an index.");
+
+assert.commandWorked(t.createIndex({z: 1}));
+assert.eq(num, t.getIndexKeys().length, "Expected 64 indexes.");
 
-t.dropIndex(make(num - 1));
-assert.eq(num - 1, t.getIndexKeys().length, "B0");
+jsTestLog("Dropping all indexes with wildcard '*'");
 
-t.createIndex({z: 1});
-assert.eq(num, t.getIndexKeys().length, "B1");
+assert.commandWorked(t.dropIndexes("*"));
+assert.eq(1, t.getIndexKeys().length, "Expected only one index after dropping indexes via '*'");
 
-t.dropIndexes("*");
-assert.eq(1, t.getIndexKeys().length, "C1");
+jsTestLog("Test index_many2.js complete.");

Update:
well, minus the assert.commandWorked additions. That causes passthrough suites to fail...



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 03/Aug/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-58890 fix js redeclaration error
Branch: master
https://github.com/mongodb/mongo/commit/f1ed43a00dbe4caa681291e26fe80272d05aeb1f

Comment by Githook User [ 03/Aug/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-58890 Improve debug-ability of index_many2.js
Branch: master
https://github.com/mongodb/mongo/commit/29e7de221b3e32c4a85dbff86e922553a5852ae8

Generated at Thu Feb 08 05:45:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.