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

ASF GitHub Bot commented on KYLIN-4386:
---------------------------------------

nichunen commented on pull request #1119: KYLIN-4386 Use LinkedHashMap for a 
deterministic order
URL: https://github.com/apache/kylin/pull/1119
 
 
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> 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
>            Priority: Minor
>              Labels: pull-request-available
>
> 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)

Reply via email to