Skip to content

NIFI-5871 ignore UUID attribute when copying flow file attributes#3203

Merged
patricker merged 7 commits intoapache:masterfrom
SavtechSolutions:NIFI-5871
Dec 20, 2018
Merged

NIFI-5871 ignore UUID attribute when copying flow file attributes#3203
patricker merged 7 commits intoapache:masterfrom
SavtechSolutions:NIFI-5871

Conversation

@SavtechSolutions
Copy link
Contributor

@SavtechSolutions SavtechSolutions commented Dec 5, 2018

Thank you for submitting a contribution to Apache NiFi.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically master)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

Copy link
Contributor

@patricker patricker left a comment

Choose a reason for hiding this comment

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

You can probably just copy the existing code from StandardProcessSession, then it will be consistent:

final Map<String, String> updatedAttributes;
if (attributes.containsKey(CoreAttributes.UUID.key())) {
        updatedAttributes = new HashMap<>(attributes);
        updatedAttributes.remove(CoreAttributes.UUID.key());
} else {
        updatedAttributes = attributes;
}


newFlowFile.putAttributes(attrs);
Map<String, String> attrCopy = new HashMap<>();
attrCopy.putAll(attrs);
Copy link
Contributor

Choose a reason for hiding this comment

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

Only change I'd make here is putting that into the constructor. Other than that LGTM.

@SavtechSolutions
Copy link
Contributor Author

@patricker I've incorporated your feedback

@MikeThomsen
Copy link
Contributor

MikeThomsen commented Dec 5, 2018

Approval still stands. Will wait to see what Travis does.

At least one processor's unit tests are expecting the same UUID to be present.

Copy link
Contributor

@MikeThomsen MikeThomsen left a comment

Choose a reason for hiding this comment

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

Running the build locally and got build errors that need to be address:

[ERROR] Tests run: 15, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 0.483 s <<< FAILURE! - in org.apache.nifi.processors.standard.TestWait
[ERROR] testReplaceAttributes(org.apache.nifi.processors.standard.TestWait)  Time elapsed: 0.077 s  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[3d5b9e68-5960-4557-aadd-89f299b7f7c0]> but was:<[5db4833b-4406-405c-bbfe-3e271a2aeec5]>
	at org.apache.nifi.processors.standard.TestWait.testReplaceAttributes(TestWait.java:238)

[ERROR] testWaitForTotalCount(org.apache.nifi.processors.standard.TestWait)  Time elapsed: 0.006 s  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[2bcf93d4-2bca-4377-b647-baa4d26e4e28]> but was:<[d467324b-1bf6-4a62-821d-3d1df7dfa3ba]>
	at org.apache.nifi.processors.standard.TestWait.testWaitForTotalCount(TestWait.java:363)

[ERROR] testWaitForSpecificCount(org.apache.nifi.processors.standard.TestWait)  Time elapsed: 0.006 s  <<< FAILURE!
org.junit.ComparisonFailure: expected:<8[8f03f6e-b58d-432b-95fd-3438e399f018]> but was:<8[22e1e1e-25f0-4db9-8a36-15a8d24b1532]>
	at org.apache.nifi.processors.standard.TestWait.testWaitForSpecificCount(TestWait.java:450)

[ERROR] testKeepOriginalAttributes(org.apache.nifi.processors.standard.TestWait)  Time elapsed: 0.001 s  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[7836fb9a-a276-404d-9c13-d51984bc2f6b]> but was:<[bc5fbf7e-3945-4d79-9d21-e84b44adea57]>
	at org.apache.nifi.processors.standard.TestWait.testKeepOriginalAttributes(TestWait.java:282)

@SavtechSolutions
Copy link
Contributor Author

Now this is strange - is there a remote chance that this behavior (copying UUID) is expected and it's not a bug? Or is this just an unit test with incorrect assumptions?

@patricker
Copy link
Contributor

@SavtechSolutions Yes, this is a bug in the tests I think.
I can see they manually provide a custom UUID instead of letting NiFi generate it.

@SavtechSolutions
Copy link
Contributor Author

@patricker Yes, I'm inclined to agree - the enqueue() call with attributes uses the same putAllAttributes call under the hood, so there's no way it should be able to retain the UUID attribute. I'll get to fix the tests, thanks.

@MikeThomsen
Copy link
Contributor

AFAIK, there is no reason why uuid should be inherited by a flowfile even in a parent-child scenario since the child is a new flowfile branched off.

@patricker
Copy link
Contributor

@MikeThomsen I think the test is showing that this isn't a parent/child scenario, but showing that it's the same FlowFile from start to finish.

If there were a way to inject content into MockFlowFile, then we could build one, pass that in to enqueue and the test would actually work.

@patricker patricker merged commit f9f386b into apache:master Dec 20, 2018
@SavtechSolutions SavtechSolutions deleted the NIFI-5871 branch December 20, 2018 18:31
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