Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-9417

Flaky BulletinMergerTest.java

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 1.16.0, 1.15.1
    • None
    • None
    • Maven 3.6.0, Java 1.8.0_292

    Description

      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.

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yiming22 Yiming Li
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Time Spent - 0.5h Remaining Estimate - 0.5h
                  0.5h
                  Logged:
                  Time Spent - 0.5h Remaining Estimate - 0.5h
                  0.5h