Yiming Li created NIFI-9417:
-------------------------------
Summary: Flaky BulletinMergerTest.java and tentative PR
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
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)