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

Mongot Fake to increase test confidence and readability

    • Query Integration

      Currently we test our search implementation using mongotmock which requires us to set mock responses for every search command that we issue. This makes it rather tedious and potentially error-prone to write test cases, especially in a sharded environment (example 1, 2).]

      An idea to improve this situation is to add a fake implementation of the search command to mongotmock. In broad strokes, this would mean:

      • The test provides mongotmock with the documents/collection present on the corresponding shard (via explicit list of documents, change steam, etc.) at startup
      • mongotmock stores documents in memory (i.e. std::vector<Document> or similar)
      • mongotmock implements the search command respecting the sort parameter, stored source, limit, etc.
      • Tests no longer need to explicitly enumerate mock responses from mongot. They can rely on the fake to return the correct results

      Some preliminary concerns that this ticket would need to consider:

      • How do we match mongot sort semantics?
        • We already have this problem with mocking results, so this makes it no worse.
      • How do we ensure that mongotmock has all documents that are present on the shard it is representing?
      • How/can we provide a fake implementation for $searchScore?
        • We likely will need to keep the ability to mock responses
      • If we write tests which rely on the new fake's capabilities, we won't be able to backport the tests without also backporting the fake implementation.

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: