[SERVER-73997] Mongot Fake to increase test confidence and readability Created: 14/Feb/23  Updated: 26/Dec/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Ben Shteinfeld Assignee: Backlog - Query Integration
Resolution: Unresolved Votes: 0
Labels: qi-search, qi-vector-search, query-skunkworks
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Query Integration
Participants:

 Description   

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.

Generated at Thu Feb 08 06:26:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.