[ 
https://issues.apache.org/jira/browse/IGNITE-18080?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kirill Tkalenko reassigned IGNITE-18080:
----------------------------------------

    Assignee:     (was: Kirill Tkalenko)

> Fix flaky test failure in ConfigurationAsmGeneratorTest#testPolymorphicErrors
> -----------------------------------------------------------------------------
>
>                 Key: IGNITE-18080
>                 URL: https://issues.apache.org/jira/browse/IGNITE-18080
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Mohsen Dehghankar
>            Priority: Major
>              Labels: ignite-3
>             Fix For: 3.0.0-beta2
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> h3. What is the purpose of this PR
> - This PR fixes the flaky test 
> `org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest.testPolymorphicErrors`
> - The mentioned test may fail or pass without changes made to the source code 
> when it is run in different JVMs due to `Class#getDeclaredFields`'s 
> non-deterministic output order.
> h3. Why the test fails
> - According to [Java 
> documentation|(https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields--)]
>  about `getDeclaredFields`, returned array are not sorted and are not in any 
> particular order.
> - `ConfigurationUtil#schemaFields()` uses `getDeclaredFields` to return the 
> list of schema fields. This list is passed to 
> `ConfigurationAsmGenerator#createNodeClass()` and then passed to 
> `ConfigurationAsmGenerator#addNodeTraverseChildrenMethod()`.  In this method 
> at line 1249, there is an assertion to check if `schemaFields.get(0)` is 
> PolymorphicId, but due to the non-deterministic order of this list, the first 
> index of the list might not be PolymorphicId and assertion fails.
> h3. Reproduce the test failure
> - Run the test with 'NonDex' maven plugin. The command to recreate the flaky 
> test failure is `mvn edu.illinois:nondex-maven-plugin:2.1-SNAPSHOT:nondex -pl 
> modules/configuration 
> -Dtest=ConfigurationAsmGeneratorTest#testPolymorphicErrors`
> - Fixing the flaky test now, will prevent flaky test failures in future Java 
> versions.
> h3. Expected Result
> - The tests should run successfully when run with 'NonDex' maven with the 
> same command for recreating the flaky test.
> h3. Actual Result
> - We get the following error:
> ```
> [INFO] Running 
> org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest
> [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.107 
> s <<< FAILURE! - in 
> org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest
> [ERROR] 
> org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest.testPolymorphicErrors
>   Time elapsed: 0.085 s  <<< FAILURE!
> java.lang.AssertionError: 
> org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest$PolymorphicNamedTestConfigurationSchema
>         at 
> org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest.beforeEach(ConfigurationAsmGeneratorTest.java:110)
> ```
> h3. Fix
> - Instead of checking `ConfigurationUtil#isPolymorphicId` on the first 
> element of `schemaFields`, use `schemaFields.stream().anyMatch` to check the 
> whole list.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to