Repository navigation
Report $out and planCacheSetFilter failures through the assertion - #729
Conversation
eerxuan
left a comment
There was a problem hiding this comment.
Summary
Turns two crash-on-unsupported patterns into assertion failures: the $out tests index
into listCollections after a failed $out, and the planCacheSetFilter tests subscript
indexFilterSet. I checked the $out change with a stubbed executor that makes $out
fail: main raises IndexError, this branch raises an AssertionError carrying the
engine's error. CI is green on both mongo targets. One file with the same $out pattern
is not covered (item 1).
Critical Issues
- [Required]
test_out_write_behavior.py:100has the same crash and is not changed.
test_out_database_name_acceptancecalls$out, discards the result, then reads
cast(dict, result)["cursor"]["firstBatch"][0]fromlistCollections. An engine that
rejects$outstill gets anIndexErrorthere. It is the third file with this pattern
(grep 'firstBatch"\]\[0\]'instages/out/finds exactly these three). Please apply
the same fix, or say why this file is excluded.
Positive Feedback
- The root cause is correctly identified: the crash hides the engine's actual error.
- The scope is small, and the description says what was run (57 and 24 passed on MongoDB 8.2.4).
.get()forindexFilterSetis correct for the assertion. A missing field yieldsNone,
whichEq(True)rejects, so no test can switch from failing to passing.
Signed-off-by: Samar Farooqi <samafarc@amazon.com>
…lter tests Signed-off-by: Samar Farooqi <samafarc@amazon.com>
…ior tests Signed-off-by: Samar Farooqi <samafarc@amazon.com>
dff5182 to
cf44ec7
Compare
|
Thanks @eerxuan, good catch.
Also rebased onto current main (10eec47) and updated the description and test counts (100/100 on MongoDB 8.2.4, same as main). |
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage); P0 keyword "crash" in body; effort from diff stats (78+59 LOC, 6 files); LLM: Fixes masked test failures where engine errors cause Python crashes (IndexError/KeyError) before reaching assertions, routing them through the standard assertion helpers for proper error reporting. If a label is wrong, remove it manually and ping |
Summary
Some tests crash with a Python error before they reach the assertion when an engine rejects a command. The real engine error is then hidden. This PR routes those failures through the existing assertion helpers, so the report shows what the engine returned.
$out tests (
test_out_acceptance.py,test_out_timeseries.py,test_out_write_behavior.py)These tests ran
$out, ignored its result, and then readlistCollections.cursor.firstBatch[0]. If the engine rejects$out, the batch is empty and the test crashes withIndexError. The tests now keep the$outresult. If it is an exception, it goes straight toassertSuccess, which reports the engine error (for examplecode 40415 "BSON field '$out.timeseries' is an unknown field."). If$outsucceeds, thelistCollectionscheck runs as before. Instages/out/, these three files are the only ones with this pattern.planCacheSetFilter tests (
test_planCacheSetFilter_cross_command.py,test_planCacheSetFilter_effectiveness.py,test_planCacheSetFilter_partial_sparse.py)These tests read
queryPlanner["indexFilterSet"]. If an engine leaves the field out ofexplain, the test crashes withKeyError.indexFilterSetis the property under test, so the tests now read it with.get(). A missing field then shows up as an assertion mismatch (expected True, got None). MongoDB always returns the field, so nothing changes there.Each test still has a single assertion. No expected values change.
Testing
pre-commit(black, isort, flake8, mypy) passes on all changed files.pytest -m unit: 152 passed.main(out_acceptance 31, out_timeseries 26, out_write_behavior 19, planCacheSetFilter cross_command 12 / effectiveness 8 / partial_sparse 4).$outreturns anOperationFailure, then rantest_out_database_name_acceptance. Onmainit raisesIndexError: list index out of range. On this branch it raisesAssertionError: [UNEXPECTED_ERROR] Expected success but got exception: {'code': 40415, ...}.