Skip to content

NIFI-10592-Fix flaky tests caused by the nondeterministic order of HashMap#6486

Closed
yannizhou05 wants to merge 2 commits intoapache:mainfrom
yannizhou05:main
Closed

NIFI-10592-Fix flaky tests caused by the nondeterministic order of HashMap#6486
yannizhou05 wants to merge 2 commits intoapache:mainfrom
yannizhou05:main

Conversation

@yannizhou05
Copy link

Summary

NIFI-10592

The tests below were found flaky because of the use of HashMaps and HashSet. The orders of elements in the HashMaps and HashSet are not the same every time being called. In this case, LinkedHashMap and LinkedHashSet is applied to replace Hash in order to ensure the orders are not changing.

  • org.apache.nifi.reporting.prometheus.TestPrometheusRecordSink.testSendData
  • org.apache.nifi.reporting.azure.loganalytics.TestAzureLogAnalyticsProvenanceReportingTask.testAddField2
  • org.apache.nifi.distributed.cache.server.map.DistributedMapCacheTest.testSubMap

It matters to fix this flaky test as it may cause potential issues due to the uncertainty of orders from HashMaps and HashSet rather than the program itself.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn install -pl nifi-nar-bundles -am -DskipTests
    • JDK 8
    • JDK 11
    • JDK 17

Test:

  • mvn -pl nifi-nar-bundles/nifi-prometheus-bundle/nifi-prometheus-reporting-task edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=org.apache.nifi.reporting.prometheus.TestPrometheusRecordSink#testSendData

  • mvn -pl nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=org.apache.nifi.reporting.azure.loganalytics.TestAzureLogAnalyticsProvenanceReportingTask#testAddField2

  • mvn -pl nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=org.apache.nifi.distributed.cache.server.map.DistributedMapCacheTest#testSubMap

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@joewitt joewitt self-requested a review October 4, 2022 19:59
@asfgit asfgit closed this in bcec883 Oct 5, 2022
@joewitt
Copy link
Contributor

joewitt commented Oct 5, 2022

fixed the checkstyle issue and merged. thanks

p-kimberley pushed a commit to p-kimberley/nifi that referenced this pull request Oct 15, 2022
…mpl.

Signed-off-by: Joe Witt <joewitt@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants