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

Miklos Gergely commented on AMBARI-17004:
-----------------------------------------

PrivilegeEventCreatorTest.putTest
RepositoryVersionEventCreatorTest:putTest
RepositoryVersionEventCreatorTest:postTest
ViewPrivilegeEventCreatorTest.putTest

ClusterPrivilegeChangeRequestAuditEvent:81 iterates over a HashSet

- the expected result of the test at PrivilegeEventCreatorTest:99 assumes to do 
this in the order [Permission2, Permission1], which may or may not happen so.
- the expected result of the test at RepositoryVersionEventCreatorTest:62 
assumes to do this in the order [Operating system: redhat6, Operating system: 
redhat7], which may or may not happen so. 
- the expected result of the test at RepositoryVersionEventCreatorTest:92 
assumes to do this in the order [Operating system: redhat6, Operating system: 
redhat7], which may or may not happen so. 
- the expected result of the test at ViewPrivilegeEventCreatorTest:77 assumes 
to do this in the order [Permission2, Permission1], which may or may not happen 
so.

Suggested solution: instead of comparing the actual result to one string break 
it up to key-value pairs, and compare them individually. In case of the 
Roles/Repositories the value should be a Set, or a Map.

Suggested solution2: have two expected result strings in both orders. After the 
actual result is ready first check if it contains both the Roles/Repositories , 
and if it does then check their order, and compare to the appropriate expected 
result string


> Unit tests failing because of the order of hash sets/maps
> ---------------------------------------------------------
>
>                 Key: AMBARI-17004
>                 URL: https://issues.apache.org/jira/browse/AMBARI-17004
>             Project: Ambari
>          Issue Type: Bug
>            Reporter: Miklos Gergely
>
> Some unit tests are failing because they depend on the order elements are 
> returned by the iterator of a HashSet/HashMap. Usually they are small (2-3 
> entries), so they may easily produce good results. Still in other 
> environments they fail as the order the elements are returned from a 
> HashSet/HashMap may depend on the JVM used.
> The tests will be described in the comments.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to