[ 
https://issues.apache.org/jira/browse/CALCITE-3883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17071864#comment-17071864
 ] 

dasch commented on CALCITE-3883:
--------------------------------

The environment I'm running these tests in automatically randomizes the 
iteration order of Java collections that have no ordering guarantees (e.g. 
HashSet). It does so to identify potential latent bugs in the code/tests that 
make assumptions about these ordering guarantees.

While I realize this environment is non-standard, I think the concern here is 
that many of these tests will become flaky if a JDK version came out which did 
change the underlying iteration order of these collections.

I'm not sure how you could replicate this behavior short of overriding the 
HashSet iteration order in your own environment.

> Multiple tests can fail if collection ordering is different than expected
> -------------------------------------------------------------------------
>
>                 Key: CALCITE-3883
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3883
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: dasch
>            Priority: Minor
>
> Multiple tests across at least two components (e.g. core and linq4j) can fail 
> if collection ordering (but not contents) is different than expected. Below 
> are a subset of the failing tests. In total, I'm seeing 21 failing tests in 
> core and 4 failing tests in linq4j.
> For example, org.apache.calcite.test.SqlFunctionsTest's testMultiset:
> FAILURE   0.1sec, org.apache.calcite.test.SqlFunctionsTest > testMultiset()
>     java.lang.AssertionError: 
>     Expected: is <[b, e]>
>          but: was <[e, b]>
>         at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
>         at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
>         at 
> org.apache.calcite.test.SqlFunctionsTest.testMultiset(SqlFunctionsTest.java:906)
> This failure is coming from:
> assertThat(SqlFunctions.multisetExceptDistinct(abacee, addc),
>  is(Arrays.asList("b", "e")));
> which is calling into the following function:
> public static <E> Collection<E> multisetExceptDistinct(Collection<E> c1,
>  Collection<E> c2) {
>   final Set<E> result = new HashSet<>(c1);
>   result.removeAll(c2);
>   return new ArrayList<>(result);
>  }
> Another example is org.apache.calcite.linq4j.test.Linq4jTest's 
> testGroupByWithKeySelectorAndElementSelector:
> FAILURE   0.0sec, org.apache.calcite.linq4j.test.Linq4jTest > 
> testGroupByWithKeySelectorAndElementSelector()
>     java.lang.AssertionError: 
>     Expected: is "[10: Fred+Eric+Janet, 30: Bill]"
>          but: was "[30: Bill, 10: Fred+Eric+Janet]"
>         at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
>         at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
>         at 
> org.apache.calcite.linq4j.test.Linq4jTest.testGroupByWithKeySelectorAndElementSelector(Linq4jTest.java:1949)
> This failure is generated from:
> assertThat(s, is("[10: Fred+Eric+Janet, 30: Bill]"));
> This behavior may have similarities with the issue reported in 
> https://issues.apache.org/jira/browse/CALCITE-3389.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to