pvillard31 commented on code in PR #11383:
URL: https://github.com/apache/nifi/pull/11383#discussion_r3633569468
##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/util/TestFlowDifferenceFilters.java:
##########
@@ -393,6 +395,94 @@ public void
testControllerServiceCreationEnvironmentalChangeWithoutComponentNode
assertTrue(FlowDifferenceFilters.isEnvironmentalChange(controllerServiceDifference,
null, flowManager, context));
}
+ /**
+ * Changing a processor property that references an external (ancestor)
controller service is not reported as a local
+ * modification, because the same logical service typically has a
different identifier in each environment. This exercises the
+ * directional rule over the set of accessible ancestor controller service
ids: suppression happens only when the versioned-snapshot
+ * reference is not a locally-accessible ancestor service while the local
reference is.
+ */
+ @Test
+ public void testExternalControllerServiceReferenceChangeDirectionalRule() {
+ final String pgInstanceId = "pg-instance";
+ final String parentGroupId = "parent-group";
+ final String propertyName = "SSL Context Service";
+
+ final String ancestorServiceX = "ancestor-service-x";
+ final String ancestorServiceY = "ancestor-service-y";
+ final String foreignServiceId = "foreign-service-id";
+ final String internalServiceId = "internal-service-id";
+
+ // Two controller services defined in the parent (ancestor) group,
i.e. external to the versioned Process Group.
+ final ControllerServiceNode serviceX =
Mockito.mock(ControllerServiceNode.class);
+
Mockito.when(serviceX.getVersionedComponentId()).thenReturn(Optional.of(ancestorServiceX));
+ final ControllerServiceNode serviceY =
Mockito.mock(ControllerServiceNode.class);
+
Mockito.when(serviceY.getVersionedComponentId()).thenReturn(Optional.of(ancestorServiceY));
+
+ final ProcessGroup parentGroup = Mockito.mock(ProcessGroup.class);
+
Mockito.when(parentGroup.getControllerServices(true)).thenReturn(Set.of(serviceX,
serviceY));
+
+ final ProcessGroup liveGroup = Mockito.mock(ProcessGroup.class);
+ Mockito.when(liveGroup.getParent()).thenReturn(parentGroup);
+
+ final FlowManager flowManager = Mockito.mock(FlowManager.class);
+ Mockito.when(flowManager.getGroup(pgInstanceId)).thenReturn(liveGroup);
+
+ final InstantiatedVersionedProcessGroup localGroup = new
InstantiatedVersionedProcessGroup(pgInstanceId, parentGroupId);
+
+ // !accessibleA && accessibleB -> environmental: snapshot points at a
service that does not exist locally
+ // (e.g. a dev-environment id), local points at an existing ancestor
service.
+ assertExternalServiceChange(localGroup, flowManager, parentGroupId,
propertyName, foreignServiceId, ancestorServiceX, true,
+ "Switching from an unavailable external service to a local
ancestor service must be treated as environmental");
+
+ // accessibleA && accessibleB -> NOT environmental: a genuine switch
between two services that both exist locally.
+ assertExternalServiceChange(localGroup, flowManager, parentGroupId,
propertyName, ancestorServiceY, ancestorServiceX, false,
+ "Switching between two locally-accessible ancestor services
must remain a reported change");
+
+ // accessibleA && !accessibleB -> NOT environmental: local points at a
service that is not an accessible ancestor (e.g. one defined
+ // inside the versioned Process Group), so the change must surface.
+ assertExternalServiceChange(localGroup, flowManager, parentGroupId,
propertyName, ancestorServiceX, internalServiceId, false,
+ "Switching to a service that is not an accessible ancestor
(e.g. internal to the group) must remain a reported change");
+
+ // !accessibleA && !accessibleB -> NOT environmental.
+ assertExternalServiceChange(localGroup, flowManager, parentGroupId,
propertyName, "foreign-1", "foreign-2", false,
Review Comment:
Done, thanks
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]