Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6712

Legacy driver tests fail with CSOT changes

    • Type: Icon: Build Failure Build Failure
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • legacy-6.1.4
    • Affects Version/s: None
    • Component/s: None
    • 2
    • 2
    • Not Needed
    • None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      The legacy driver unit tests have an implicit dependency on each other. Gridfs upload streams perform a find on initialization, which auto connect the client (ignoring failures), which instantiates a topology. Bulk write comes next, which tries to create an ordered bulk op and succeeds because the topology is defined (the client must be connected to instantiate a collection level bulk write operation, which we ensure by checking that the topology is defined on the mongo client).

      During the CSOT implementation, the gridfs initialization was moved to be processed asynchronously. This makes the bulk op fail because there is no topology defined, resulting in the test suite failing entirely.

      The CSOT change was the right change to make because `Stream._construct` is the correct place for asynchronous initialization logic. However, this means that bulk write tests fail in the legacy driver because the client isn't connected.

      Further complicating things, we can't just connect the client before each test because:

      1. There is no server running (these are unit tests)
      2. The error is thrown synchronously, when instantiating the test suite.
      3. The instantiated driver resources are then used during the construction of the test suite. We assert on the object and access properties of the function under test.

      A proper solution would restructure the test suite to instantiate resources asynchronously, before the test runs that needs it, and to remove the dependence on instantiated driver objects when constructing the test suite.

      A short-term hack could be to just call `connect` but not await it before running each test.

      Implementation Requirements

      • Remove all shared state between test runs to ensure tests run in isolation
      • Restructure the existing test suite construction to only use raw data available from the hard-coded api.js file (no driver class instances)
      • Restructure the test suite to construct instances of relevant driver objects at test execution time (i.e., in a before hook), not during test suite instantiation.

      Testing Requirements

      • Ensure all existing tests pass.

      Double check that the total number of tests has not changed, just to be sure.

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: