Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-10834 Fixed Flaky Test failing with NonDex #6672

Closed
wants to merge 5 commits into from

Conversation

priyanka-28
Copy link
Contributor

Summary

NIFI-10834
Tests under TestPutSplunkHTTP express non-deterministic behavior as the order of the query parameters in the URL changes. The fix is generating all possible permutations of the query parameter and then checking the generated permutations with the value passed in the 'Assert' function to ensure deterministic behavior.

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 clean install -P contrib-check
    • JDK 8
    • JDK 11
    • JDK 17

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

@exceptionfactory exceptionfactory added the type: testing Pull requests for changes to test components label Nov 23, 2022
Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @priyanka-28. Although the proposed changes provide one potential solution, the additional swap and permute methods add some complexity to the unit test class. The check for the path attribute is helpful, but it seems like it would be simpler to just check that the path starts with the expected URL path, instead of attempting to check the entire string. This would avoid the need for the complex string parsing.

@@ -131,7 +172,7 @@ public void testHappyPathWithCustomQueryParameters() throws Exception {

// then
testRunner.assertAllFlowFilesTransferred(PutSplunkHTTP.RELATIONSHIP_SUCCESS, 1);
assertEquals("/services/collector/raw?sourcetype=test%3Fsource%3Ftype&source=test_source", path.getValue());
assertTrue(returnPermuations("/services/collector/raw?sourcetype=test%3Fsource%3Ftype&source=test_source").contains(path.getValue()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertTrue(returnPermuations("/services/collector/raw?sourcetype=test%3Fsource%3Ftype&source=test_source").contains(path.getValue()));
assertTrue(path.getValue().startsWith("/services/collector/raw"));

@@ -163,7 +204,7 @@ public void testHappyPathWithCustomQueryParametersFromFlowFile() throws Exceptio

// then
testRunner.assertAllFlowFilesTransferred(PutSplunkHTTP.RELATIONSHIP_SUCCESS, 1);
assertEquals("/services/collector/raw?host=test_host&index=test_index&sourcetype=test%3Fsource%3Ftype&source=test_source", path.getValue());
assertTrue(returnPermuations("/services/collector/raw?host=test_host&index=test_index&sourcetype=test%3Fsource%3Ftype&source=test_source").contains(path.getValue()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertTrue(returnPermuations("/services/collector/raw?host=test_host&index=test_index&sourcetype=test%3Fsource%3Ftype&source=test_source").contains(path.getValue()));
assertTrue(path.getValue().startsWith("/services/collector/raw"));

@priyanka-28
Copy link
Contributor Author

Thanks for the contribution @priyanka-28. Although the proposed changes provide one potential solution, the additional swap and permute methods add some complexity to the unit test class. The check for the path attribute is helpful, but it seems like it would be simpler to just check that the path starts with the expected URL path, instead of attempting to check the entire string. This would avoid the need for the complex string parsing.

Thank you for your reply! I have added the updated changes

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the adjustments @priyanka-28, the latest version looks good! +1 merging

asfgit pushed a commit that referenced this pull request Nov 30, 2022
This closes #6672

Signed-off-by: David Handermann <exceptionfactory@apache.org>
lizhizhou pushed a commit to lizhizhou/nifi that referenced this pull request Jan 2, 2023
This closes apache#6672

Signed-off-by: David Handermann <exceptionfactory@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: testing Pull requests for changes to test components
Projects
None yet
2 participants