[
https://issues.apache.org/jira/browse/KYLIN-4386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xiaoxiang Yu closed KYLIN-4386.
-------------------------------
Resolved in release 3.1.0 (2020-07-03)
> Use LinkedHashMap for a deterministic order in test
> ---------------------------------------------------
>
> Key: KYLIN-4386
> URL: https://issues.apache.org/jira/browse/KYLIN-4386
> Project: Kylin
> Issue Type: Bug
> Components: Tools, Build and Test
> Reporter: cpugputpu
> Assignee: cpugputpu
> Priority: Minor
> Labels: pull-request-available
> Fix For: v3.1.0, v3.0.1
>
>
> The tests in
> _org.apache.kylin.stream.coordinator.CoordinatorTest#testReassignFailOnStartNew_
> and
> _org.apache.kylin.stream.coordinator.CoordinatorTest#testReassignFailOnStopAndSync_
> will fail when making the following assertions:
> _assertSame(ClusterStateException.ClusterState.ROLLBACK_FAILED,
> rune.getClusterState());_
> _assertSame(ClusterStateException.TransactionStep.STOP_AND_SNYC,
> rune.getTransactionStep());_
> The failure is reported as follows:
> java.lang.Exception: Unexpected exception,
> expected<org.apache.kylin.stream.coordinator.exception.ClusterStateException>
> but was<java.lang.AssertionError>
> at
> org.apache.kylin.stream.coordinator.CoordinatorTest.testReassignFailOnStartNew(CoordinatorTest.java:271)
> After my analysis, I find that the root cause is that the variable
> _newAssignMap_ is a HashMap, which makes no guarantee about the order when
> iterating in
> _org.apache.kylin.stream.coordinator.Coordinator.doReassign(Coordinator.java:516)_
> The specification about HashMap says that "this class makes no guarantees as
> to the order of the map; in particular, it does not guarantee that the order
> will remain constant over time". The documentation is here for your
> reference: [https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html]
>
> The fix is to use LinkedHashMap instead of HashMap so that the
> non-deterministic behaviour is eliminated. It will not affect the performance
> and can make the tests more stable.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)