Mochalite tests bypass test runners defined by passthrough suites

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: 8.2.0-rc0, 8.3.0-rc0
    • Component/s: None
    • None
    • Replication
    • Fully Compatible
    • ALL
    • Correctness 2025-08-11
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Some of the jstests passthrough suites define a custom test runner, for example magic_restore_sharding_jscore_passthrough. Those test runner assume that they can wrap the entire execution of a jstest, for example to handle errors specially, or run code after the test has finished.

       

      The new Mochalite tests run using a special hook in the shell, which is invoked after the jstest file has been executed. Thus, they run outside the test runner, so they bypass the custom behaviors that the test suite may want to impose.

       

      For example, running this test code in magic_restore_sharding_jscore_passthrough:

      assert.commandWorked(db.adminCommand({doesNotExist: 1}));

      Succeeds, because that suite has a test runner that swallows assertion errors.

       

      However, running this test code, also in magic_restore_sharding_jscore_passthrough:

      import {describe, it} from "jstests/libs/mochalite.js";
      
      describe('Foo', function() {
          it('Bar', function() {
              assert.commandWorked(db.adminCommand({doesNotExist: 1}));
          });
      });
       

      Fails, because the assertion runs later, outside of the test runner.

            Assignee:
            Steve McClure
            Reporter:
            Joan Bruguera Micó
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: