You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Lehel44 (via GitHub)" <gi...@apache.org> on 2023/04/27 19:52:07 UTC

[GitHub] [nifi] Lehel44 opened a new pull request, #7201: NIFI-11493: Fix properties dynamically modifying the classpath with default values

Lehel44 opened a new pull request, #7201:
URL: https://github.com/apache/nifi/pull/7201

   <!-- 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. -->
   
   # Summary
   
   - Fixes PropertyDescriptors that dynamically modifies the classpath to work with default values
   - Added new system test
   
   [NIFI-11493](https://issues.apache.org/jira/browse/NIFI-11493)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### 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 11
     - [ ] JDK 17
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] Lehel44 commented on a diff in pull request #7201: NIFI-11493: Fix properties dynamically modifying the classpath with default values

Posted by "Lehel44 (via GitHub)" <gi...@apache.org>.
Lehel44 commented on code in PR #7201:
URL: https://github.com/apache/nifi/pull/7201#discussion_r1179653816


##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/DefaultedDynamicClassPathModificationIT.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.processor;
+
+import org.apache.nifi.tests.system.NiFiSystemIT;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException;
+import org.apache.nifi.web.api.entity.ConnectionEntity;
+import org.apache.nifi.web.api.entity.ProcessorEntity;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class DefaultedDynamicClassPathModificationIT extends NiFiSystemIT {
+
+    private ProcessorEntity generateFlowFileProcessor;
+    private ProcessorEntity defaultedModifyClasspathProcessor;
+
+    private ConnectionEntity defaultedModifyClasspathInputConnection;
+    private ConnectionEntity successConnection;
+    private ConnectionEntity failureConnection;
+
+    @Test
+    void testLoadsClassFromDefaultedDynamicModification() throws NiFiClientException, IOException, InterruptedException {
+        createFlow();
+
+        // Update modify to have the appropriate URL, don't update URL to load to let it on default value
+        final Map<String, String> propertyMap = new HashMap<>();
+        propertyMap.put("Class to Load", "org.apache.commons.lang3.StringUtils");
+        getClientUtil().updateProcessorProperties(defaultedModifyClasspathProcessor, propertyMap);

Review Comment:
   We should not set the 'URL to Load' property.



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] asfgit closed pull request #7201: NIFI-11493: Fix properties dynamically modifying the classpath with default values

Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit closed pull request #7201: NIFI-11493: Fix properties dynamically modifying the classpath with default values
URL: https://github.com/apache/nifi/pull/7201


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] markap14 commented on a diff in pull request #7201: NIFI-11493: Fix properties dynamically modifying the classpath with default values

Posted by "markap14 (via GitHub)" <gi...@apache.org>.
markap14 commented on code in PR #7201:
URL: https://github.com/apache/nifi/pull/7201#discussion_r1179623674


##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/DefaultedDynamicClassPathModificationIT.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.processor;
+
+import org.apache.nifi.tests.system.NiFiSystemIT;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException;
+import org.apache.nifi.web.api.entity.ConnectionEntity;
+import org.apache.nifi.web.api.entity.ProcessorEntity;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class DefaultedDynamicClassPathModificationIT extends NiFiSystemIT {
+
+    private ProcessorEntity generateFlowFileProcessor;
+    private ProcessorEntity defaultedModifyClasspathProcessor;
+
+    private ConnectionEntity defaultedModifyClasspathInputConnection;
+    private ConnectionEntity successConnection;
+    private ConnectionEntity failureConnection;
+
+    @Test
+    void testLoadsClassFromDefaultedDynamicModification() throws NiFiClientException, IOException, InterruptedException {
+        createFlow();
+
+        // Update modify to have the appropriate URL, don't update URL to load to let it on default value
+        final Map<String, String> propertyMap = new HashMap<>();
+        propertyMap.put("Class to Load", "org.apache.commons.lang3.StringUtils");
+        getClientUtil().updateProcessorProperties(defaultedModifyClasspathProcessor, propertyMap);

Review Comment:
   To test that things work with default values, we should not set any properties, right?



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] markap14 commented on a diff in pull request #7201: NIFI-11493: Fix properties dynamically modifying the classpath with default values

Posted by "markap14 (via GitHub)" <gi...@apache.org>.
markap14 commented on code in PR #7201:
URL: https://github.com/apache/nifi/pull/7201#discussion_r1179622428


##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/DefaultedDynamicClassPathModificationIT.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.processor;
+
+import org.apache.nifi.tests.system.NiFiSystemIT;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException;
+import org.apache.nifi.web.api.entity.ConnectionEntity;
+import org.apache.nifi.web.api.entity.ProcessorEntity;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class DefaultedDynamicClassPathModificationIT extends NiFiSystemIT {
+
+    private ProcessorEntity generateFlowFileProcessor;
+    private ProcessorEntity defaultedModifyClasspathProcessor;
+
+    private ConnectionEntity defaultedModifyClasspathInputConnection;
+    private ConnectionEntity successConnection;
+    private ConnectionEntity failureConnection;
+
+    @Test
+    void testLoadsClassFromDefaultedDynamicModification() throws NiFiClientException, IOException, InterruptedException {
+        createFlow();
+
+        // Update modify to have the appropriate URL, don't update URL to load to let it on default value
+        final Map<String, String> propertyMap = new HashMap<>();
+        propertyMap.put("Class to Load", "org.apache.commons.lang3.StringUtils");
+        getClientUtil().updateProcessorProperties(defaultedModifyClasspathProcessor, propertyMap);
+        getClientUtil().waitForValidProcessor(defaultedModifyClasspathProcessor.getId());
+
+        // Create a FlowFile
+        getClientUtil().startProcessor(generateFlowFileProcessor);
+        waitForQueueCount(defaultedModifyClasspathInputConnection.getId(), 1);
+
+        // Wait for a FlowFile to be routed to success
+        getClientUtil().startProcessor(defaultedModifyClasspathProcessor);
+        waitForQueueCount(successConnection.getId(), 1);
+
+        getClientUtil().stopProcessor(generateFlowFileProcessor);
+        getClientUtil().waitForStoppedProcessor(generateFlowFileProcessor.getId());
+
+        // Restart and ensure that everything works as expected after restart
+        getNiFiInstance().stop();
+        getNiFiInstance().start(true);
+
+        // Feed another FlowFile through. Upon restart, in order to modify, we need to get the most up-to-date revision so will first fetch the Processor
+        final ProcessorEntity generateAfterRestart = getNifiClient().getProcessorClient().getProcessor(generateFlowFileProcessor.getId());
+        getClientUtil().startProcessor(generateAfterRestart);

Review Comment:
   Upon restart will need to wait for processor to become valid before starting



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] markap14 commented on a diff in pull request #7201: NIFI-11493: Fix properties dynamically modifying the classpath with default values

Posted by "markap14 (via GitHub)" <gi...@apache.org>.
markap14 commented on code in PR #7201:
URL: https://github.com/apache/nifi/pull/7201#discussion_r1179621826


##########
nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/processor/DefaultedDynamicClassPathModificationIT.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.processor;
+
+import org.apache.nifi.tests.system.NiFiSystemIT;
+import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException;
+import org.apache.nifi.web.api.entity.ConnectionEntity;
+import org.apache.nifi.web.api.entity.ProcessorEntity;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class DefaultedDynamicClassPathModificationIT extends NiFiSystemIT {
+
+    private ProcessorEntity generateFlowFileProcessor;
+    private ProcessorEntity defaultedModifyClasspathProcessor;
+
+    private ConnectionEntity defaultedModifyClasspathInputConnection;
+    private ConnectionEntity successConnection;
+    private ConnectionEntity failureConnection;
+
+    @Test
+    void testLoadsClassFromDefaultedDynamicModification() throws NiFiClientException, IOException, InterruptedException {
+        createFlow();
+
+        // Update modify to have the appropriate URL, don't update URL to load to let it on default value
+        final Map<String, String> propertyMap = new HashMap<>();
+        propertyMap.put("Class to Load", "org.apache.commons.lang3.StringUtils");
+        getClientUtil().updateProcessorProperties(defaultedModifyClasspathProcessor, propertyMap);
+        getClientUtil().waitForValidProcessor(defaultedModifyClasspathProcessor.getId());
+
+        // Create a FlowFile
+        getClientUtil().startProcessor(generateFlowFileProcessor);

Review Comment:
   Need to waitForValidProcessor before starting it



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org