Kerr0220 opened a new issue, #13470:
URL: https://github.com/apache/druid/issues/13470

   ### Problem Description
   `org.apache.druid.math.expr.ParserTest#testApplyFunctions` in `core` is a 
flaky test. It 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.math.expr.ParserTest.testApplyFunctions  Time 
elapsed: 0 s  <<< FAILURE!
   java.lang.AssertionError: x + map((x) -> x + 1, y) expected:<[x, y]> but 
was:<[y, x]>
           at org.junit.Assert.fail(Assert.java:89)
           at org.junit.Assert.failNotEquals(Assert.java:835)
           at org.junit.Assert.assertEquals(Assert.java:120)
           at 
org.apache.druid.math.expr.ParserTest.validateParser(ParserTest.java:836)
           at 
org.apache.druid.math.expr.ParserTest.testApplyFunctions(ParserTest.java:541)
           ......
   ```
   ### 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
   The problem might be caused by the non-deterministic feature of `HashSet`. 
Here's the description of `HashSet` in [JavaSE-8 
specification](https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html):
   > It makes no guarantees as to the iteration order of the set; in 
particular, it does not guarantee that the order will remain constant over time.
   
   This feature leads to the non-deterministic order of the return given by 
`Expr.getRequiredBindingsList()` since it simply converts a `HashSet` object 
got from `Expr.map()` to an `ArrayList`.
   
   ```java
     public List<String> getRequiredBindingsList() {
       return new ArrayList<>(getRequiredBindings());
     }
   
   
     public Set<String> getRequiredBindings() {
       return map(freeVariables, IdentifierExpr::getBindingIfIdentifier);
     }
   
   
     private static Set<String> map(
         Set<IdentifierExpr> variables,
         java.util.function.Function<IdentifierExpr, String> mapper
     ) {
       Set<String> results = Sets.newHashSetWithExpectedSize(variables.size());
       for (IdentifierExpr variable : variables) {
         results.add(mapper.apply(variable));
       }
       return results;
     }
   ```
   


-- 
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