You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/04/19 06:50:01 UTC

[GitHub] [nifi] ijokarumawak commented on a change in pull request #3438: NIFI-6220: If FlowFile is created by cloning a relationship, do not c…

ijokarumawak commented on a change in pull request #3438: NIFI-6220: If FlowFile is created by cloning a relationship, do not c…
URL: https://github.com/apache/nifi/pull/3438#discussion_r276913980
 
 

 ##########
 File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/provenance/ProvenanceEventsIT.java
 ##########
 @@ -420,4 +420,62 @@ public void testForkAutoGenerated() throws ExecutionException, InterruptedExcept
         final ProvenanceEventRecord thirdEvent = provRepo.getEvent(2L);
         assertEquals(ProvenanceEventType.DROP, thirdEvent.getEventType());
     }
+
+    @Test
+    public void testCloneOnMultipleConnectionsForRelationship() throws ExecutionException, InterruptedException, IOException {
+        final ProcessorNode generateProcessor = createGenerateProcessor(0);
+        final ProcessorNode passThroughProcessor = createProcessorNode((context, session) -> {
+            FlowFile original = session.get();
+            session.transfer(original, REL_SUCCESS);
+        }, REL_SUCCESS);
+
+        connect(generateProcessor, passThroughProcessor, REL_SUCCESS);
+        connect(passThroughProcessor, getTerminateProcessor(), REL_SUCCESS);
+        connect(passThroughProcessor, getTerminateAllProcessor(), REL_SUCCESS);
+
+        triggerOnce(generateProcessor);
+        triggerOnce(passThroughProcessor);
+
+        final ProvenanceEventRepository provRepo = getProvenanceRepository();
+        assertEquals(1L, provRepo.getMaxEventId().longValue());
+
+        final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
+        assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
+
+        final ProvenanceEventRecord secondEvent = provRepo.getEvent(1L);
+        assertEquals(ProvenanceEventType.CLONE, secondEvent.getEventType());
+        assertEquals(1, secondEvent.getParentUuids().size());
+        assertEquals(1, secondEvent.getChildUuids().size());
+    }
+
+    @Test
+    public void testCloneOnMultipleConnectionsForRelationshipIncludesUpToDateAttributes() throws ExecutionException, InterruptedException, IOException {
+        final ProcessorNode generateProcessor = createGenerateProcessor(0);
+        final ProcessorNode passThroughProcessor = createProcessorNode((context, session) -> {
+            FlowFile original = session.get();
+            original = session.putAttribute(original, "test", "integration");
+
+            session.transfer(original, REL_SUCCESS);
+        }, REL_SUCCESS);
+
+        connect(generateProcessor, passThroughProcessor, REL_SUCCESS);
+        connect(passThroughProcessor, getTerminateProcessor(), REL_SUCCESS);
+        connect(passThroughProcessor, getTerminateAllProcessor(), REL_SUCCESS);
+
+        triggerOnce(generateProcessor);
+        triggerOnce(passThroughProcessor);
+
+        final ProvenanceEventRepository provRepo = getProvenanceRepository();
+        assertEquals(1L, provRepo.getMaxEventId().longValue());
 
 Review comment:
   After applying this PR, I run the similar flow, GenerateFlowFile -> UpdateAttribute -> LogAttribute:
   ![image](https://user-images.githubusercontent.com/1107620/56410937-f1665c80-62b9-11e9-9eb0-32611a05f545.png)
   
   And 3 provenance events were created:
   ![image](https://user-images.githubusercontent.com/1107620/56410960-06db8680-62ba-11e9-91c6-f223d329bc08.png)
   
   However, this test case expects only two events are created. This looks different from what actually happens with a live NiFi flow. Also, you used `thirdEvent` below, I wonder if you were expecting 3 events with this?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services