Skip to content

Route $sample statistics and the modify smoke test through assertions - #738

Merged
eerxuan merged 1 commit into
documentdb:mainfrom
samafarc:fix/sample-modify-assertions
Nov 24, 2026
Merged

eerxuan merged 1 commit into
documentdb:mainfrom
samafarc:fix/sample-modify-assertions

Conversation

@samafarc

Copy link
Copy Markdown
Contributor

Summary

Three tests fail on some engines in a way the assertion helpers never see, so a
run cannot judge them. This PR routes each one through an assertion helper.
Nothing changes for an engine that passes them today.

  • test_sample_statistical_randomness and test_sample_statistical_uniformity
    ran the $sample loop and then raised their own AssertionError. They now
    compute the same statistic and check it with assertSuccess:
    {"unreached": []} (documents never returned within 1500 runs) and
    {"underfilled": []} (documents returned fewer than 50 times out of 3000).
    The thresholds are unchanged. An error from any run is passed to
    assertSuccess as is, which reports it as before.
  • test_smoke_changeStream_modify changed the validator to
    {"x": {"$type": "int"}}. An engine that only supports $jsonSchema
    validators rejects that collMod, so the smoke test reported the validator,
    not the modify event. It now uses {"$jsonSchema": {"required": ["x"]}}.
    Like the other change stream smoke tests after Make smoke tests capability probes; fix 5 that crash on engine divergence (PR#718 Rebased) #731 and Route remaining test-side failures through the assertion #736, it reads with
    execute_command_until and checks the batch with assertChangeStreamEvent.
    The $match stage still selects only modify events.

Testing

  • MongoDB 8.2.4 replica set: the 3 tests passed in 2 runs.
  • DocumentDB: the 2 $sample tests now fail through assertSuccess
    ({'unreached': [1, 2, 3, 4]}, {'underfilled': [1, 2, 3, 4]}) instead of a
    bare AssertionError. The collMod with the $jsonSchema validator
    succeeds.
  • pytest documentdb_tests/framework: 86 passed.
  • pre-commit (black, isort, flake8, mypy) passes.

Signed-off-by: Samar Farooqi <samafarc@amazon.com>
@samafarc
samafarc requested a review from a team as a code owner November 20, 2026 23:30
@documentdb-triage-tool documentdb-triage-tool Bot added the compatibility test Compatibility test related label Nov 21, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test
Project fields suggested: Component test-coverage · Priority P2 · Effort M · Status Needs Review
Confidence: 0.95 (deterministic)

Reasoning

component from path globs (test-coverage); effort from diff stats (53+23 LOC, 2 files)

If a label is wrong, ping @patty-chow so the rules can be tuned. Issues with component labels are left alone; PR component labels are reconciled from changed paths on every run.

@eerxuan
eerxuan merged commit 4177489 into documentdb:main Nov 24, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants