Use JsonNode for comparing Json strings to fix the flaky test#1
Use JsonNode for comparing Json strings to fix the flaky test#1prathyushreddylpr wants to merge 9 commits into
Conversation
|
About PR description text: It might be better to add one more sentence at the end of the About code changes: None. |
|
Please refrain from using screenshots since it's hard to copy. |
|
This PR looks good to me with a clear root cause of the problem and how to solve the flaky test. |
updated |
Updated |
|
You can proceed to open a real PR. Once you open a real PR, please mark this tentative PR as |
|
Have you opened a real PR for this? If so, please mark this as "Opened" in your |
Description
Fixed the flaky test
testDateHandlinginsideTimestampsParquetReaderTestclass.druid/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/TimestampsParquetReaderTest.java
Line 40 in ad32f84
Root Cause
The test
testDateHandlinghas been reported as flaky when run with the NonDex tool. The test failed because it is trying to compare two Json strings, but since the JSON library used here is internally using HashMap. The HashMap in Java is implemented in such a way that it does not store the order in which the keys and values are inserted. As a result, when the expected Json string(which is hard-coded) is compared with the actual one, it caused the failure.Fix
This test is fixed using the Jackson library which contains classes JsonNode and ObjectMapper. These are used to parse two JSON strings to tree models and then compare these trees node by node. So when we use this, the order of the elements in the JSON strings is ignored and only the content is checked.
How this has been tested?
Java: openjdk version "11.0.20.1"
Maven: Apache Maven 3.6.3
Command used -
Command used -
Command used -
NonDex test passed after the fix.
This PR has: