aditya-kumbhar opened a new pull request, #9966:
URL: https://github.com/apache/pinot/pull/9966

   The test `org.apache.pinot.common.utils.PinotDataTypeTest#testObject` was 
detected to be flaky, using the 
[NonDex](https://github.com/TestingResearchIllinois/NonDex) tool:
   
   Command to reproduce using Nondex: 
   `edu.illinois:nondex-maven-plugin:2.1.1:nondex 
-Dtest=org.apache.pinot.common.utils.PinotDataTypeTest#testObject 
-Dlicense.skip=true -Drat.skip=true`
   
   The following assertion failed:
   ```
   assertEquals(OBJECT.toJson(getGenericTestObject()),
           
"{\"bytes\":\"AAE=\",\"map\":{\"key1\":\"value\",\"key2\":null,\"array\":[-5.4,4,\"2\"]},"
               + "\"timestamp\":1620324238610}");
   ```
   The test fails due to non-deterministic ordering of the Json objects that 
are being compared for equality.
   
   Error log:
   ```
   [ERROR]   java.lang.AssertionError: expected 
[{"bytes":"AAE=","map":{"key1":"value","key2":null,"array":[-5.4,4,"2"]},"timestamp":1620324238610}]
 but found 
[{"map":{"key1":"value","key2":null,"array":[-5.4,4,"2"]},"bytes":"AAE=","timestamp":1620324238610}]
        at org.testng.Assert.fail(Assert.java:93)
        at org.testng.Assert.failNotEquals(Assert.java:512)
        at org.testng.Assert.assertEqualsImpl(Assert.java:134)
        at org.testng.Assert.assertEquals(Assert.java:115)
        at org.testng.Assert.assertEquals(Assert.java:189)
        at org.testng.Assert.assertEquals(Assert.java:199)
        at 
org.apache.pinot.common.utils.PinotDataTypeTest.testObject(PinotDataTypeTest.java:234)
   ```
   
   Changes proposed in this pull request:
     -
   The flakiness of the test is because the json string created by 
`OBJECT.toJson(getGenericTestObject())` does not have deterministic ordering of 
its elements.
   Using the gson 
[JsonParser](https://stackoverflow.com/questions/2253750/testing-two-json-objects-for-equality-ignoring-child-order-in-java/9065247#9065247).parseString(),
 the json strings are converted to json parse trees. 
   The generated parse trees are then compared for equality in the assertions, 
ignoring the order of the child elements. 
   The tests pass using 
[NonDex](https://github.com/TestingResearchIllinois/NonDex) after this change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to