Fixed two non deterministic test in MaterializedViewQueryQueryToolChestTest #17461
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.
Fixed 2 non deterministic tests in MaterializedViewQueryQueryToolChestTest
testDecorateObjectMapperMaterializedViewQuery
testDecorateObjectMapper
Steps to reproduce
To reproduce the problem, first build the module
materialized-view-selection
:Then, run the regular test:
For testDecorateObjectMapperMaterializedViewQuery
For testDecorateObjectMapper
To identify the flaky test, execute the following nondex command:
For testDecorateObjectMapperMaterializedViewQuery
For testDecorateObjectMapper
Description
The failure in the testDecorateObjectMapperMaterializedViewQuery test within MaterializedViewQueryQueryToolChestTest appears to be due to a mismatch in the JSON structure, specifically the order of fields within the event object. In this test, there is a comparison between an expected JSON structure and an actual result generated during the test. Here’s what’s happening:
The flaky behavior in the testDecorateObjectMapper test in MaterializedViewQueryQueryToolChestTest also appears to stem from the inconsistency in the ordering of fields within a JSON object. Here’s a closer look at the issue:
The fields in the event object (rows, idx, and alias) are in different orders in the expected vs. actual outputs. As in the previous test, this order discrepancy is likely causing a failure in the direct string comparison of JSON data.
Fix
The fix involves configuring the object mapper for deterministic output by sorting it.
This PR has: