adnan199823 opened a new pull request, #5658:
URL: https://github.com/apache/ignite-3/pull/5658
## 🛠️ Fix flaky test:
`ConfigurationAsmGeneratorTest.testNestedConfigurationWithInjectedNameField`
### What is the purpose of this PR?
This PR addresses a flaky test in the `ignite-3` project:
`org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest.testNestedConfigurationWithInjectedNameField`.
The test exhibited nondeterministic behavior due to inconsistent ordering of
injected names under randomized execution, particularly when run with the
NonDex tool.
---
### Why the test fails
The test relies on the value of injected names derived from registered
polymorphic configuration instances. These names (e.g., `"first"`, `"second"`,
`"nestedDefaultPoly"`) are sensitive to the order in which polymorphic schema
classes are registered.
Since the original implementation used `List.of(...)`, which does not
guarantee iteration order across JVMs or randomization tools like NonDex, the
test would fail intermittently when the injected names appeared in unexpected
order.
---
### How to reproduce the test failure
To observe the flaky behavior, run:
```bash
mvn -pl modules/configuration edu.illinois:nondex-maven-plugin:2.1.1:nondex \
-Dtest=org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest#testNestedConfigurationWithInjectedNameField
\
-DnondexRuns=20
This will likely produce an assertion error such as:
`Unexpected injected name value: first
Expected: nestedDefaultPoly`
### Description of fix ###
To eliminate nondeterministic behavior, I modified the beforeEach() method
in ConfigurationAsmGeneratorTest to register polymorphic configuration classes
using a deterministic collection. Specifically, I replaced:
`Collection<Class<?>> polymorphicExtensions = List.of(...);`
with:
`Collection<Class<?>> polymorphicExtensions = new LinkedHashSet<>(List.of(
FirstPolymorphicInstanceTestConfigurationSchema.class,
SecondPolymorphicInstanceTestConfigurationSchema.class,
NonDefaultPolymorphicInstanceTestConfigurationSchema.class,
FirstPolymorphicNamedInstanceTestConfigurationSchema.class,
SecondPolymorphicNamedInstanceTestConfigurationSchema.class,
PolyInst0InjectedNameConfigurationSchema.class,
PolyInst1InjectedNameConfigurationSchema.class
));
`
--
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]