Repository navigation
Compare generated results unordered - #4600
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4599. Self-reviewed only.
What this solves
Every generated scenario compared its results in order. But the server fixes result order only when the action sorts, and not even then when sort keys tie. Two cases failed on order alone:
$meta's text-score find: no sort, and two matches tie on score. It was excluded in Generate find projections #4596.$replaceWith's pivot:$groupwith no sort. The documented run and Morphia's returned the groups in different orders. It was excluded in Generate $lookup, comparison and boolean expressions, $replaceWith and $sortArray #4599.The change
Generated scenarios now compare results as a multiset (
ordered = false). The serialization check already proves Morphia sends exactly the documented pipeline, including any$sort. Which order the server then returns tests the server, not Morphia.Converted legacy cases keep their own order, and so does the migrated case. Of the 511 cases, the 125 generated ones compare unordered.
$meta's text-score find now generates (510 → 511).$replaceWith's pivot now passes behavior, but stays excluded for a different reason: its page prints the first$addFieldsstage's output as if it were the four-stage pipeline's result.Integration: 523 tests under Critter, then reflection, 0 failures. Audits suite: 447 tests, 0 failures, 4 skipped.
Decision for review
I first tried a narrower rule, and dropped it after review: compare in order after a final
$sortthat no later$group,$bucket,$bucketAutoor$unionWithregroups. Codex showed four ways it still rejected legal results:$sortByCount's equal counts;$setWindowFieldsafter a sort, whose output order isn't guaranteed;$merge/$outwrite's unsorted paired read, which inherited the pipeline's sort.The trade-off of always comparing unordered: a generated case no longer checks that the server honored a sort. That's the server's behavior, though, and it isn't deterministic with ties. If you'd rather keep order checks where keys are provably unique, that would take per-case review rather than a generator rule.
Review
Codex, two local rounds: round 1 rejected the narrower rule as above, and round 2 was clean. The design doc and the progress log are updated.