Kerr0220 opened a new issue, #13472: URL: https://github.com/apache/druid/issues/13472
### Description 2 tests in `org.apache.druid.storage.aliyun.OssDataSegmentPusherConfigTest` of `extensions-contrib/aliyun-oss-extensions` is flaky tests. Thay can pass the maven-test while showing non-deterministic behavior under [NonDex](https://github.com/TestingResearchIllinois/NonDex) and thus failed. ### Error Message ``` [ERROR] org.apache.druid.storage.aliyun.OssDataSegmentPusherConfigTest.testSerialization Time elapsed: 0 s <<< FAILURE! org.junit.ComparisonFailure: expected:<{"[bucket":"bucket1","prefix":"dataSource]1"}> but was:<{"[prefix":"dataSource1","bucket":"bucket]1"}> at org.junit.Assert.assertEquals(Assert.java:117) at org.junit.Assert.assertEquals(Assert.java:146) at org.apache.druid.storage.aliyun.OssDataSegmentPusherConfigTest.testSerialization(OssDataSegmentPusherConfigTest.java:39) [ERROR] org.apache.druid.storage.aliyun.OssDataSegmentPusherConfigTest.testSerializationWithDefaults Time elapsed: 0 s <<< FAILURE! org.junit.ComparisonFailure: expected:<{"[bucket":"bucket1","prefix":"dataSource]1"}> but was:<{"[prefix":"dataSource1","bucket":"bucket]1"}> at org.junit.Assert.assertEquals(Assert.java:117) at org.junit.Assert.assertEquals(Assert.java:146) at org.apache.druid.storage.aliyun.OssDataSegmentPusherConfigTest.testSerializationWithDefaults(OssDataSegmentPusherConfigTest.java:49) ``` ### Steps to reproduce the failure: 1. (optional) check [NonDex](https://github.com/TestingResearchIllinois/NonDex) 2. run the following command in druid: ``` MODULE=core TEST=org.apache.druid.math.expr.ParserTest#testApplyFunctions mvn install -pl $MODULE -am -DskipTests mvn -pl $MODULE edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=$TEST ``` 3. the result will be saved under the package folder in .nondex ### Configurations ``` Apache Maven 3.6.0; openjdk version "1.8.0_342"; OpenJDK Runtime Environment (build 1.8.0_342-8u342-b07-0ubuntu1~20.04-b07); OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode); ``` ### Potential Cause This is likely caused by ObjectMapper, which if you didn't configure it with `MapperFeature.SORT_PROPERTIES_ALPHABETICALLY`, then the return of `writeValueAsString()` would be non-deterministic. Please refer to [Java Document](https://fasterxml.github.io/jackson-databind/javadoc/2.7/com/fasterxml/jackson/databind/ObjectMapper.html#writeValueAsString(java.lang.Object)): > public String writeValueAsString(Object value) throws JsonProcessingException Method that can be used to serialize any Java value as a String. Functionally equivalent to calling [writeValue(Writer,Object)](https://fasterxml.github.io/jackson-databind/javadoc/2.7/com/fasterxml/jackson/databind/ObjectMapper.html#writeValue(java.io.Writer,%20java.lang.Object)) with [StringWriter](http://docs.oracle.com/javase/7/docs/api/java/io/StringWriter.html?is-external=true) and constructing String, but more efficient. And it's declared in the description of [writeValue(Writer,Object)](https://fasterxml.github.io/jackson-databind/javadoc/2.7/com/fasterxml/jackson/databind/ObjectMapper.html#writeValue(java.io.Writer,%20java.lang.Object)) that: > The fields may be set in any order In conclusion, the non-deterministic behavior of these 2 tests is caused by these features. -- 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]
