Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-58890

Improve debug-ability of index_many2.js

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • Execution Team 2021-08-09
    • 150

      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...

            Assignee:
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Reporter:
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: