[
https://issues.apache.org/jira/browse/FLINK-33430?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17782344#comment-17782344
]
dserfe commented on FLINK-33430:
--------------------------------
Hi Matthias, thanks for your comments!
To clarify:
1) This PR is to fix a flaky test which can lead to potential test failures,
the test failures may happen even when running the test suite (maybe multiple
times) without NonDex.
> it verifies that the code behaves in the same way among different JVM
> implementations. Is this correct?
Yes, NonDex is designed to detect such potential issues, so the issues can be
fixed to avoid test failures happening.
2) Root cause of test failures:
[testSerializerTree|[https://github.com/apache/flink/blob/master/flink-tests/src/test/java/org/apache/flink/test/misc/GenericTypeInfoTest.java#L35]]
calls method
getSerializerTree(Line 43) to return a string, and then assert it equals to an
expected one. In line 291 of
[getSerializerTree|[https://github.com/dserfe/flink/blob/a4ad86fb083f90503938a9c3d816cdda9dc22427/flink-java/src/main/java/org/apache/flink/api/java/Utils.java#L270]],
it calls another method
getGenericTypeTree([https://github.com/dserfe/flink/blob/a4ad86fb083f90503938a9c3d816cdda9dc22427/flink-java/src/main/java/org/apache/flink/api/java/Utils.java#L301])
that leverages API getDeclaredFields to return an array containing the names
of Field objects reflecting all the declared fields. However, the elements in
the array returned are not sorted and are not in any particular order (from the
documentation
[https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html]). When
iterating the array, the elements are inserted to a string and returned. As a
result, testSerializerTree asserts a non-deterministic string equals
a deterministic one, so the test will fail during some runs.
If you don't like the proposed fix, please let me know and we can discuss other
fixes!
> Fix Test Failures
> -----------------
>
> Key: FLINK-33430
> URL: https://issues.apache.org/jira/browse/FLINK-33430
> Project: Flink
> Issue Type: Bug
> Reporter: dserfe
> Priority: Minor
> Labels: pull-request-available
>
> This issue is to fix test failures caused by flakiness.
> Steps to reproduce test failures:
> 1)Run the following commands
> {code:bash}
> mvn -pl flink-tests edu.illinois:nondex-maven-plugin:2.1.1:nondex
> -Dtest=org.apache.flink.test.misc.GenericTypeInfoTest#testSerializerTree
> {code}
>
> 2) Then we found the following test failures:
> {code:bash}
> [ERROR] GenericTypeInfoTest.testSerializerTree:53 Expected: "GenericTypeInfo
> (PojoWithCollectionGeneric)\n pojos:java.util.List\n key:int\n
> sqlDate:java.sql.Date\n bigInt:java.math.BigInteger\n
> bigDecimalKeepItNull:java.math.BigDecimal\n intVal:java.math.BigInteger\n
> scale:int\n scalaBigInt:scala.math.BigInt\n bigInteger:java.math.BigInteger\n
> mixed:java.util.List\n
> makeMeGeneric:org.apache.flink.test.operators.util.CollectionDataSets$PojoWithDateAndEnum\n
> group:java.lang.String\n date:java.util.Date\n
> cat:org.apache.flink.test.operators.util.CollectionDataSets$Category (is
> enum)\n" but: was "GenericTypeInfo (PojoWithCollectionGeneric)\n key:int\n
> bigDecimalKeepItNull:java.math.BigDecimal\n intVal:java.math.BigInteger\n
> scale:int\n bigInt:java.math.BigInteger\n sqlDate:java.sql.Date\n
> pojos:java.util.List\n scalaBigInt:scala.math.BigInt\n
> bigInteger:java.math.BigInteger\n
> makeMeGeneric:org.apache.flink.test.operators.util.CollectionDataSets$PojoWithDateAndEnum\n
> date:java.util.Date\n
> cat:org.apache.flink.test.operators.util.CollectionDataSets$Category (is
> enum)\n group:java.lang.String\n mixed:java.util.List\n" {code}
> The root cause of the test failure is due to assuming a consistent order of
> {{{}serTree{}}}, but the elements of it are actually not consistent, to fix
> the test failure:
> _change the assertion to compare two lists, which can ignore the orders of
> elements_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)