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

ASF subversion and git services commented on NIFI-9417:
-------------------------------------------------------

Commit c1bb0c0c3421136b045a66415be9b17947952492 in nifi's branch 
refs/heads/NIFI-9428 from Yiming Li
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=c1bb0c0 ]

NIFI-9417: Update BulletinMergerTest.java

Signed-off-by: Matthew Burgess <[email protected]>

This closes #5572


> Flaky BulletinMergerTest.java
> -----------------------------
>
>                 Key: NIFI-9417
>                 URL: https://issues.apache.org/jira/browse/NIFI-9417
>             Project: Apache NiFi
>          Issue Type: Bug
>         Environment: Maven 3.6.0, Java 1.8.0_292
>            Reporter: Yiming Li
>            Priority: Trivial
>             Fix For: 1.16.0
>
>   Original Estimate: 1h
>          Time Spent: 0.5h
>  Remaining Estimate: 0.5h
>
> SHA: 5aced2b4bc66d2dd85b1507755fff2b1fb8c4a64
> The hashmap does not have a guaranteed iteration order, in the process of 
> BulletinMerger.mergeBulletins() (line-78), the order of [copyOfBulletin1, 
> bulletinEntity1] in the list can be eithter copyOfBulletin1 first or 
> bulletinEntity1 first. The mergeBulletins() will keep the most recent 
> bulletin with the larger time, and because all BulletinEntity are created 
> from the function {*}{*}createBulletin()(line-38) and have the same time 
> property in this test, mergeBulletins() will just keep the first in the list. 
> So sometimes bulletinEntity1 will be returned instead of copyOfBulletin1, 
> which results in the failure (line-80): 
> assertTrue(bulletinEntities.contains(copyOfBulletin1));
> The proposed fix is replacing LinkedHashMap with Hashmap to insure the 
> determinism. After this change, the order will always be bulletinEntity1 
> before the copyOfBulletin1 and the merge results will always contain 
> bulletinEntity1 instead of copyOfBulletin1. So I also change the assertion to 
> assertTrue(bulletinEntities.contains(bulletinEntity1);
> Tentative Pull Request: [https://github.com/LeoYimingLi/nifi/pull/1/files]
>  
> The way to reproduce the flaky test failure:
>  0.Environment setup: Maven 3.6.0 and Java 1.8.0_292
>  1.clone the repo:
>   git clone https://github.com/spring-projects/spring-data-cassandra
>   cd spring-data-cassandra
>   git checkout 5aced2b4bc66d2dd85b1507755fff2b1fb8c4a64
>  2.run with [Nondex tool](https://github.com/TestingResearchIllinois/NonDex) 
> (which explores different behaviors of under-determined APIs and reports test 
> failures)
>   mvn install -pl 
> nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster 
> -am -DskipTests
>   mvn -pl 
> nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster 
> edu.illinois:nondex-maven-plugin:1.1.2:debug 
> -Dtest=org.apache.nifi.cluster.manager.BulletinMergerTest#mergeBulletins
>  
>   3.then we can get the test failure:
> ----------
> [INFO] Results:
> [INFO] 
> [ERROR] Failures: 
> [ERROR]   BulletinMergerTest.mergeBulletins:80 expected [true] but found 
> [false]
> [INFO] 
> [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
> -----------
> And BulletinMergerTest.mergeBulletins line-80 is :
> assertTrue(bulletinEntities.contains(copyOfBulletin1));
> in this case, the bulletinEntities did not contain copyOfBulletin1 but 
> bulletinEntity1.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to