Tests for the Mongo semantics the heuristics calculator does not reproduce - #1761
Closed
LautaroPetaccio wants to merge 1 commit into
Closed
LautaroPetaccio wants to merge 1 commit into
LautaroPetaccio wants to merge 1 commit into
Conversation
…oduce Thirteen queries where the calculator disagrees with the database, and three neighbouring cases that it already answers correctly, kept as guards so that a fix can be told apart from a regression in the path next to it. Every expected value was taken from a MongoDB 7.0.41 server answering the same query against the same document, so the assertions state what the database does rather than a reading of the documentation. Six of the queries make the calculator throw, and MongoHandler catches nothing around computeDistanceDocuments, so the exception costs the action its whole ExtraHeuristicsDto, the SQL heuristics included. Two of those six are queries the database answers normally: $regex against an array holding no strings, and $not holding a bare regex. The failing tests carry @disabled with the reason, following the convention of the section at the end of MongoHeuristicsCalculatorTest. They are one per defect, so they can be enabled independently and in any order.
Collaborator
Author
|
Reopened as #1762 from a branch on this repo instead of a fork. |
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.
Follow-up to the review on #1750, turning each comment there into a test. Based on
fix_all_semanticsrather thanmaster, since most of these are about code that only exists on that branch.Sixteen tests. Thirteen fail and carry
@Disabledwith the reason, three pass and are there as guards. Every expected value came from a MongoDB 7.0.41 server answering the same query against the same document, so the assertions say what the database does rather than what the documentation implies.Queries that make the calculator throw
MongoHandlercatches nothing aroundcomputeDistanceDocuments, so the exception costs the action its wholeExtraHeuristicsDto, the SQL heuristics computed before it included.{a:{$regex:"x"}}vs{a:[1,2,3]}IllegalArgumentException{a:{$bitsAllSet: BinData(0,"Ag==")}}vs{a:2}NullPointerException{a:{$not:/x/}}vs{a:"aa"}NullPointerException{a:{$mod:[0,0]}}ArithmeticException{a:{$size:-1}}NullPointerExceptionThe first one is a regression: the code this PR replaces returned
C_FALSEfor it.Queries that are answered, but not the way the database answers them
{a:{$bitsAllSet:[-1]}}vs{a: Long.MIN_VALUE}{a:{$bitsAllSet: 3.9}}vs{a:3}{a:{$bitsAllSet: -1}}vs{a:-1}{a:{$all:[1,1]}}vs{a:1}{a:{$all:[null,null]}}vs{b:1}{a:{$eq:{$comment:"note",x:1}}}vs the same document{a:{$in:[/x/]}}vs{a:"xy"}The three bitmask rows share a cause: nothing validates the mask itself, while the field side of the same comparison is validated by
getIntegralLongValue.One that is not about MongoDB semantics
computeDistanceDocumentswalks itsIterablethree times, andMongoHandlerpeeks at it once before that. What is passed in today is aFindIterable, which replays, so this is fourfindround trips per action rather than a wrong answer. The test uses anIterablethat cannot be replayed, which the signature currently accepts, and that one is scored as if the collection were empty while still reporting the documents counted on the first pass.The three that pass
One per group of defects, covering the neighbouring case that is already handled: a
byte[]bitmask,$commentat the top level, and$allholding a single null. They are there so a fix can be told apart from a regression in the path beside it.Running them
Green as they stand, 16 run and 13 skipped. Dropping the
@Disabledannotations turns those 13 into failures. The wholemongopackage is 351 tests, 0 failures, 18 skipped with this branch applied.🤖 Generated with Claude Code