exceptionfactory commented on code in PR #10865:
URL: https://github.com/apache/nifi/pull/10865#discussion_r2775641229


##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/parameters/ParameterSensitivityWithGhostedComponentIT.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.tests.system.parameters;
+
+import org.apache.nifi.tests.system.NiFiInstance;
+import org.apache.nifi.tests.system.NiFiSystemIT;
+import org.apache.nifi.toolkit.client.NiFiClientException;
+import org.apache.nifi.web.api.entity.ParameterContextEntity;
+import org.apache.nifi.web.api.entity.ParameterContextUpdateRequestEntity;
+import org.apache.nifi.web.api.entity.ProcessorEntity;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * System test that verifies parameter updates succeed when a referencing 
processor is ghosted.
+ *
+ * When a processor is ghosted (its NAR is missing), all of its properties are 
treated as sensitive because
+ * NiFi does not know the actual property descriptors. This means a 
non-sensitive parameter that was originally
+ * referenced from a non-sensitive property now appears to be referenced from 
a sensitive property, which would
+ * normally block any update to that parameter. The fix in 
StandardParameterContext skips validation for ghosted
+ * components entirely, allowing the parameter to be updated.
+ *
+ * This test exercises the full lifecycle:
+ * 1. A processor references a non-sensitive parameter via a non-sensitive 
property.
+ * 2. The processor's NAR is removed and NiFi is restarted, causing the 
processor to become ghosted.
+ * 3. While the processor is ghosted, the parameter value is updated 
(remaining non-sensitive).
+ * 4. The NAR is restored and NiFi is restarted.
+ * 5. The processor is no longer ghosted and can still be used with the 
updated parameter value.
+ */
+public class ParameterSensitivityWithGhostedComponentIT extends NiFiSystemIT {
+    private static final Logger logger = 
LoggerFactory.getLogger(ParameterSensitivityWithGhostedComponentIT.class);
+
+    private static final String TEST_EXTENSIONS_NAR_PREFIX = 
"nifi-system-test-extensions-nar";
+
+    @Override
+    protected boolean isDestroyEnvironmentAfterEachTest() {
+        return true;
+    }
+
+    @Override
+    protected boolean isAllowFactoryReuse() {
+        return false;
+    }
+
+    @Test
+    public void testParameterUpdateWhileProcessorGhosted() throws 
NiFiClientException, IOException, InterruptedException {
+        // Create a parameter context with a non-sensitive parameter
+        final ParameterContextEntity paramContext = 
getClientUtil().createParameterContext("TestContext", "myParam", "hello", 
false);
+        final String paramContextId = paramContext.getId();
+
+        // Create a CountEvents processor and set its non-sensitive "Name" 
property to reference the parameter
+        final ProcessorEntity processor = 
getClientUtil().createProcessor("CountEvents");
+        getClientUtil().updateProcessorProperties(processor, 
Collections.singletonMap("Name", "#{myParam}"));
+        final String processorId = processor.getId();
+
+        // Bind parameter context to root process group
+        getClientUtil().setParameterContext("root", paramContext);
+
+        // Verify processor is VALID
+        getClientUtil().waitForValidProcessor(processorId);
+        logger.info("Processor {} is VALID with non-sensitive parameter value 
'hello'", processorId);

Review Comment:
   Most of the system test do not have local logging, it seems like most or all 
of the test logging should be removed.



##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/parameter/TestStandardParameterContext.java:
##########
@@ -396,6 +398,79 @@ private static void enableControllerService(final 
ControllerServiceNode serviceN
         setControllerServiceState(serviceNode, ControllerServiceState.ENABLED);
     }
 
+    @Test
+    public void testGhostedProcessorSkippedDuringParameterValidation() {
+        final HashMapParameterReferenceManager referenceManager = new 
HashMapParameterReferenceManager();
+        final ParameterContext context = 
createStandardParameterContext(referenceManager);
+
+        final ProcessorNode procNode = getProcessorNode("abc", 
referenceManager);
+        Mockito.when(procNode.isExtensionMissing()).thenReturn(true);

Review Comment:
   I recommend replacing the qualified `Mockito.when` and `Mockito.mock()` 
references with static imports.



-- 
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]

Reply via email to