This is an automated email from the ASF dual-hosted git repository. joewitt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nifi.git
commit 2c18cf22ad0972aebf8c5c547b5b70823238de62 Author: Shawn Weeks <[email protected]> AuthorDate: Thu Jan 9 11:56:39 2020 -0600 NIFI-6852 This closes #3973. Don't Validate Processors that accept any ControllerService Implementation NIFI-6852 Add Integration Tests for Controller Service API Validation Signed-off-by: Joe Witt <[email protected]> --- .../nifi/controller/AbstractComponentNode.java | 4 + .../cs/tests/system/FakeControllerService1.java | 22 ++++ .../system/FakeDynamicPropertiesProcessor.java | 90 ++++++++++++++ .../processors/tests/system/FakeProcessor.java | 70 +++++++++++ .../org.apache.nifi.controller.ControllerService | 3 +- .../services/org.apache.nifi.processor.Processor | 4 +- .../nifi-system-test-extensions2-nar/pom.xml | 55 ++++++++ .../nifi-system-test-extensions2}/pom.xml | 28 +++-- .../cs/tests/system/FakeControllerService2.java | 22 ++++ .../tests/system/FakeGenericProcessor.java | 70 +++++++++++ .../org.apache.nifi.controller.ControllerService | 2 +- .../services/org.apache.nifi.processor.Processor} | 2 +- .../pom.xml | 16 +-- nifi-system-tests/nifi-system-test-suite/pom.xml | 6 + .../ControllerServiceApiValidationIT.java | 138 +++++++++++++++++++++ nifi-system-tests/pom.xml | 1 + 16 files changed, 512 insertions(+), 21 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java index 974c5ad..adf410f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java @@ -719,6 +719,10 @@ public abstract class AbstractComponentNode implements ComponentNode { private ValidationResult validateControllerServiceApi(final PropertyDescriptor descriptor, final ControllerServiceNode controllerServiceNode) { final Class<? extends ControllerService> controllerServiceApiClass = descriptor.getControllerServiceDefinition(); + // If a processor accepts any service don't validate it. + if (controllerServiceApiClass.equals(ControllerService.class)) { + return null; + } final ClassLoader controllerServiceApiClassLoader = controllerServiceApiClass.getClassLoader(); final ExtensionManager extensionManager = serviceProvider.getExtensionManager(); diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/cs/tests/system/FakeControllerService1.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/cs/tests/system/FakeControllerService1.java new file mode 100644 index 0000000..2789bf6 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/cs/tests/system/FakeControllerService1.java @@ -0,0 +1,22 @@ +/* + * 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.cs.tests.system; + +import org.apache.nifi.controller.AbstractControllerService; + +public class FakeControllerService1 extends AbstractControllerService { +} diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/FakeDynamicPropertiesProcessor.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/FakeDynamicPropertiesProcessor.java new file mode 100644 index 0000000..88c0850 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/FakeDynamicPropertiesProcessor.java @@ -0,0 +1,90 @@ +/* + * 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.processors.tests.system; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.cs.tests.system.FakeControllerService1; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessorInitializationContext; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class FakeDynamicPropertiesProcessor extends AbstractProcessor { + private List<PropertyDescriptor> properties; + private Set<Relationship> relationships; + + @Override + protected void init(final ProcessorInitializationContext context) { + final List<PropertyDescriptor> properties = new ArrayList<>(); + this.properties = Collections.unmodifiableList(properties); + + final Set<Relationship> relationships = new HashSet<>(); + this.relationships = Collections.unmodifiableSet(relationships); + + } + + @Override + protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { + if (propertyDescriptorName.startsWith("CS.")) { + return new PropertyDescriptor.Builder() + .name(propertyDescriptorName) + .required(false) + .dynamic(true) + .identifiesControllerService(ControllerService.class) + .build(); + } + if (propertyDescriptorName.startsWith("FCS.")) { + return new PropertyDescriptor.Builder() + .name(propertyDescriptorName) + .required(false) + .dynamic(true) + .identifiesControllerService(FakeControllerService1.class) + .build(); + } + return new PropertyDescriptor.Builder() + .name(propertyDescriptorName) + .required(false) + .addValidator(Validator.VALID) + .dynamic(true) + .build(); + } + + @Override + public Set<Relationship> getRelationships() { + return relationships; + } + + @Override + protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return properties; + } + + @Override + public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { + + } +} diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/FakeProcessor.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/FakeProcessor.java new file mode 100644 index 0000000..febb822 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/java/org/apache/nifi/processors/tests/system/FakeProcessor.java @@ -0,0 +1,70 @@ +/* + * 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.processors.tests.system; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.cs.tests.system.FakeControllerService1; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessorInitializationContext; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class FakeProcessor extends AbstractProcessor { + private List<PropertyDescriptor> properties; + private Set<Relationship> relationships; + + public static final PropertyDescriptor FAKE_SERVICE = new PropertyDescriptor.Builder() + .name("Fake Service") + .description("The Fake Service Being Tested") + .required(true) + .identifiesControllerService(FakeControllerService1.class) + .build(); + + @Override + protected void init(final ProcessorInitializationContext context) { + final List<PropertyDescriptor> properties = new ArrayList<>(); + properties.add(FAKE_SERVICE); + this.properties = Collections.unmodifiableList(properties); + + final Set<Relationship> relationships = new HashSet<>(); + this.relationships = Collections.unmodifiableSet(relationships); + + } + + @Override + public Set<Relationship> getRelationships() { + return relationships; + } + + @Override + protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return properties; + } + + @Override + public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { + + } +} diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService index a76f5a0..e58be89 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -org.apache.nifi.cs.tests.system.StandardSleepService \ No newline at end of file +org.apache.nifi.cs.tests.system.StandardSleepService +org.apache.nifi.cs.tests.system.FakeControllerService1 \ No newline at end of file diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor index ffd9df7..003c917 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor @@ -16,4 +16,6 @@ org.apache.nifi.processors.tests.system.CountEvents org.apache.nifi.processors.tests.system.GenerateFlowFile org.apache.nifi.processors.tests.system.Sleep -org.apache.nifi.processors.tests.system.ValidateFileExists \ No newline at end of file +org.apache.nifi.processors.tests.system.ValidateFileExists +org.apache.nifi.processors.tests.system.FakeProcessor +org.apache.nifi.processors.tests.system.FakeDynamicPropertiesProcessor \ No newline at end of file diff --git a/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2-nar/pom.xml b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2-nar/pom.xml new file mode 100644 index 0000000..030c592 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2-nar/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-system-test-extensions2-bundle</artifactId> + <version>1.11.0-SNAPSHOT</version> + </parent> + + <artifactId>nifi-system-test-extensions2-nar</artifactId> + <version>1.11.0-SNAPSHOT</version> + <packaging>nar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-system-test-extensions2</artifactId> + <version>1.11.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-standard-services-api-nar</artifactId> + <version>1.11.0-SNAPSHOT</version> + <type>nar</type> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-nar-maven-plugin</artifactId> + <configuration> + <enforceDocGeneration>false</enforceDocGeneration> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/nifi-system-tests/pom.xml b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/pom.xml similarity index 62% copy from nifi-system-tests/pom.xml copy to nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/pom.xml index dba2c3c..b16e5ca 100644 --- a/nifi-system-tests/pom.xml +++ b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/pom.xml @@ -13,21 +13,29 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> <parent> - <artifactId>nifi</artifactId> + <artifactId>nifi-system-test-extensions2-bundle</artifactId> <groupId>org.apache.nifi</groupId> <version>1.11.0-SNAPSHOT</version> </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>nifi-system-tests</artifactId> - <packaging>pom</packaging> + <artifactId>nifi-system-test-extensions2</artifactId> - <modules> - <module>nifi-system-test-extensions-bundle</module> - <module>nifi-system-test-suite</module> - </modules> + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + <version>1.11.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-utils</artifactId> + <version>1.11.0-SNAPSHOT</version> + </dependency> + </dependencies> -</project> +</project> \ No newline at end of file diff --git a/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/java/org/apache/nifi/cs/tests/system/FakeControllerService2.java b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/java/org/apache/nifi/cs/tests/system/FakeControllerService2.java new file mode 100644 index 0000000..105b930 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/java/org/apache/nifi/cs/tests/system/FakeControllerService2.java @@ -0,0 +1,22 @@ +/* + * 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.cs.tests.system; + +import org.apache.nifi.controller.AbstractControllerService; + +public class FakeControllerService2 extends AbstractControllerService { +} diff --git a/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/java/org/apache/nifi/processors/tests/system/FakeGenericProcessor.java b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/java/org/apache/nifi/processors/tests/system/FakeGenericProcessor.java new file mode 100644 index 0000000..6a68084 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/java/org/apache/nifi/processors/tests/system/FakeGenericProcessor.java @@ -0,0 +1,70 @@ +/* + * 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.processors.tests.system; + +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessorInitializationContext; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class FakeGenericProcessor extends AbstractProcessor { + private List<PropertyDescriptor> properties; + private Set<Relationship> relationships; + + public static final PropertyDescriptor FAKE_SERVICE = new PropertyDescriptor.Builder() + .name("Fake Service") + .description("The Fake Service Being Tested") + .required(true) + .identifiesControllerService(ControllerService.class) + .build(); + + @Override + protected void init(final ProcessorInitializationContext context) { + final List<PropertyDescriptor> properties = new ArrayList<>(); + properties.add(FAKE_SERVICE); + this.properties = Collections.unmodifiableList(properties); + + final Set<Relationship> relationships = new HashSet<>(); + this.relationships = Collections.unmodifiableSet(relationships); + + } + + @Override + public Set<Relationship> getRelationships() { + return relationships; + } + + @Override + protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return properties; + } + + @Override + public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { + + } +} diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService similarity index 93% copy from nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService copy to nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService index a76f5a0..125ad20 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService +++ b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -org.apache.nifi.cs.tests.system.StandardSleepService \ No newline at end of file +org.apache.nifi.cs.tests.system.FakeControllerService2 \ No newline at end of file diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor similarity index 92% copy from nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService copy to nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor index a76f5a0..d7be6ee 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService +++ b/nifi-system-tests/nifi-system-test-extensions2-bundle/nifi-system-test-extensions2/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -org.apache.nifi.cs.tests.system.StandardSleepService \ No newline at end of file +org.apache.nifi.processors.tests.system.FakeGenericProcessor \ No newline at end of file diff --git a/nifi-system-tests/pom.xml b/nifi-system-tests/nifi-system-test-extensions2-bundle/pom.xml similarity index 76% copy from nifi-system-tests/pom.xml copy to nifi-system-tests/nifi-system-test-extensions2-bundle/pom.xml index dba2c3c..6b3a2d1 100644 --- a/nifi-system-tests/pom.xml +++ b/nifi-system-tests/nifi-system-test-extensions2-bundle/pom.xml @@ -13,21 +13,23 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> <parent> - <artifactId>nifi</artifactId> + <artifactId>nifi-system-tests</artifactId> <groupId>org.apache.nifi</groupId> <version>1.11.0-SNAPSHOT</version> </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>nifi-system-tests</artifactId> + <artifactId>nifi-system-test-extensions2-bundle</artifactId> <packaging>pom</packaging> <modules> - <module>nifi-system-test-extensions-bundle</module> - <module>nifi-system-test-suite</module> + <module>nifi-system-test-extensions2</module> + <module>nifi-system-test-extensions2-nar</module> </modules> -</project> + +</project> \ No newline at end of file diff --git a/nifi-system-tests/nifi-system-test-suite/pom.xml b/nifi-system-tests/nifi-system-test-suite/pom.xml index 821c705..5cd8fc1 100644 --- a/nifi-system-tests/nifi-system-test-suite/pom.xml +++ b/nifi-system-tests/nifi-system-test-suite/pom.xml @@ -173,6 +173,12 @@ <version>1.11.0-SNAPSHOT</version> <type>nar</type> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-system-test-extensions2-nar</artifactId> + <version>1.11.0-SNAPSHOT</version> + <type>nar</type> + </dependency> <!-- dependencies for jaxb/activation/annotation for running NiFi on Java 11 --> <!-- TODO: remove these once minimum Java version is 11 --> diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/ControllerServiceApiValidationIT.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/ControllerServiceApiValidationIT.java new file mode 100644 index 0000000..5de7c95 --- /dev/null +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/controllerservice/ControllerServiceApiValidationIT.java @@ -0,0 +1,138 @@ +package org.apache.nifi.tests.system.controllerservice; + +import org.apache.nifi.tests.system.NiFiSystemIT; +import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; +import org.apache.nifi.web.api.entity.ControllerServiceEntity; +import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity; +import org.apache.nifi.web.api.entity.ProcessorEntity; +import org.junit.Test; + +import java.io.IOException; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; + +public class ControllerServiceApiValidationIT extends NiFiSystemIT { + @Test + public void testMatchingControllerService() throws NiFiClientException, IOException { + final ControllerServiceEntity fakeServiceEntity = getClientUtil().createControllerService("FakeControllerService1"); + final ProcessorEntity fakeProcessorEntity = getClientUtil().createProcessor("FakeProcessor"); + fakeProcessorEntity.getComponent().getConfig().setProperties(Collections.singletonMap("Fake Service", fakeServiceEntity.getId())); + getNifiClient().getProcessorClient().updateProcessor(fakeProcessorEntity); + final ControllerServiceRunStatusEntity runStatusEntity = new ControllerServiceRunStatusEntity(); + runStatusEntity.setState("ENABLED"); + runStatusEntity.setRevision(fakeServiceEntity.getRevision()); + getNifiClient().getControllerServicesClient().activateControllerService(fakeServiceEntity.getId(), runStatusEntity); + getClientUtil().waitForControllerSerivcesEnabled("root"); + String controllerStatus = getNifiClient().getControllerServicesClient().getControllerService(fakeServiceEntity.getId()).getStatus().getRunStatus(); + String processorStatus = getNifiClient().getProcessorClient().getProcessor(fakeProcessorEntity.getId()).getStatus().getRunStatus(); + + assertEquals("ENABLED", controllerStatus); + assertEquals("Stopped", processorStatus); + } + + @Test + public void testMatchingDynamicPropertyControllerService() throws NiFiClientException, IOException { + final ControllerServiceEntity fakeServiceEntity = getClientUtil().createControllerService("FakeControllerService1"); + final ProcessorEntity fakeProcessorEntity = getClientUtil().createProcessor("FakeDynamicPropertiesProcessor"); + fakeProcessorEntity.getComponent().getConfig().setProperties(Collections.singletonMap("FCS.fakeControllerService", fakeServiceEntity.getId())); + getNifiClient().getProcessorClient().updateProcessor(fakeProcessorEntity); + final ControllerServiceRunStatusEntity runStatusEntity = new ControllerServiceRunStatusEntity(); + runStatusEntity.setState("ENABLED"); + runStatusEntity.setRevision(fakeServiceEntity.getRevision()); + getNifiClient().getControllerServicesClient().activateControllerService(fakeServiceEntity.getId(), runStatusEntity); + getClientUtil().waitForControllerSerivcesEnabled("root"); + String controllerStatus = getNifiClient().getControllerServicesClient().getControllerService(fakeServiceEntity.getId()).getStatus().getRunStatus(); + String processorStatus = getNifiClient().getProcessorClient().getProcessor(fakeProcessorEntity.getId()).getStatus().getRunStatus(); + + assertEquals("ENABLED", controllerStatus); + assertEquals("Stopped", processorStatus); + } + + @Test + public void testNonMatchingControllerService() throws NiFiClientException, IOException { + final ControllerServiceEntity fakeServiceEntity = getClientUtil().createControllerService( + NiFiSystemIT.TEST_CS_PACKAGE + ".FakeControllerService2", + "root", + NiFiSystemIT.NIFI_GROUP_ID, + "nifi-system-test-extensions2-nar", + getNiFiVersion()); + final ProcessorEntity fakeProcessorEntity = getClientUtil().createProcessor("FakeProcessor"); + fakeProcessorEntity.getComponent().getConfig().setProperties(Collections.singletonMap("Fake Service", fakeServiceEntity.getId())); + getNifiClient().getProcessorClient().updateProcessor(fakeProcessorEntity); + final ControllerServiceRunStatusEntity runStatusEntity = new ControllerServiceRunStatusEntity(); + runStatusEntity.setState("ENABLED"); + runStatusEntity.setRevision(fakeServiceEntity.getRevision()); + getNifiClient().getControllerServicesClient().activateControllerService(fakeServiceEntity.getId(), runStatusEntity); + getClientUtil().waitForControllerSerivcesEnabled("root"); + String controllerStatus = getNifiClient().getControllerServicesClient().getControllerService(fakeServiceEntity.getId()).getStatus().getRunStatus(); + String processorStatus = getNifiClient().getProcessorClient().getProcessor(fakeProcessorEntity.getId()).getStatus().getRunStatus(); + + assertEquals("ENABLED", controllerStatus); + assertEquals("Invalid", processorStatus); + } + + @Test + public void testNonMatchingDynamicPropertyControllerService() throws NiFiClientException, IOException { + final ControllerServiceEntity fakeServiceEntity = getClientUtil().createControllerService( + NiFiSystemIT.TEST_CS_PACKAGE + ".FakeControllerService2", + "root", + NiFiSystemIT.NIFI_GROUP_ID, + "nifi-system-test-extensions2-nar", + getNiFiVersion()); + final ProcessorEntity fakeProcessorEntity = getClientUtil().createProcessor("FakeDynamicPropertiesProcessor"); + fakeProcessorEntity.getComponent().getConfig().setProperties(Collections.singletonMap("FCS.fakeControllerService", fakeServiceEntity.getId())); + getNifiClient().getProcessorClient().updateProcessor(fakeProcessorEntity); + final ControllerServiceRunStatusEntity runStatusEntity = new ControllerServiceRunStatusEntity(); + runStatusEntity.setState("ENABLED"); + runStatusEntity.setRevision(fakeServiceEntity.getRevision()); + getNifiClient().getControllerServicesClient().activateControllerService(fakeServiceEntity.getId(), runStatusEntity); + getClientUtil().waitForControllerSerivcesEnabled("root"); + String controllerStatus = getNifiClient().getControllerServicesClient().getControllerService(fakeServiceEntity.getId()).getStatus().getRunStatus(); + String processorStatus = getNifiClient().getProcessorClient().getProcessor(fakeProcessorEntity.getId()).getStatus().getRunStatus(); + + assertEquals("ENABLED", controllerStatus); + assertEquals("Invalid", processorStatus); + } + + @Test + public void testMatchingGenericControllerService() throws NiFiClientException, IOException { + final ControllerServiceEntity fakeServiceEntity = getClientUtil().createControllerService("FakeControllerService1"); + final ProcessorEntity fakeProcessorEntity = getClientUtil().createProcessor( + NiFiSystemIT.TEST_PROCESSORS_PACKAGE + ".FakeGenericProcessor", + "root", + NiFiSystemIT.NIFI_GROUP_ID, + "nifi-system-test-extensions2-nar", + getNiFiVersion()); + fakeProcessorEntity.getComponent().getConfig().setProperties(Collections.singletonMap("Fake Service", fakeServiceEntity.getId())); + getNifiClient().getProcessorClient().updateProcessor(fakeProcessorEntity); + final ControllerServiceRunStatusEntity runStatusEntity = new ControllerServiceRunStatusEntity(); + runStatusEntity.setState("ENABLED"); + runStatusEntity.setRevision(fakeServiceEntity.getRevision()); + getNifiClient().getControllerServicesClient().activateControllerService(fakeServiceEntity.getId(), runStatusEntity); + getClientUtil().waitForControllerSerivcesEnabled("root"); + String controllerStatus = getNifiClient().getControllerServicesClient().getControllerService(fakeServiceEntity.getId()).getStatus().getRunStatus(); + String processorStatus = getNifiClient().getProcessorClient().getProcessor(fakeProcessorEntity.getId()).getStatus().getRunStatus(); + + assertEquals("ENABLED", controllerStatus); + assertEquals("Stopped", processorStatus); + } + + @Test + public void testMatchingGenericDynamicPropertyControllerService() throws NiFiClientException, IOException { + final ControllerServiceEntity fakeServiceEntity = getClientUtil().createControllerService("FakeControllerService1"); + final ProcessorEntity fakeProcessorEntity = getClientUtil().createProcessor("FakeDynamicPropertiesProcessor"); + fakeProcessorEntity.getComponent().getConfig().setProperties(Collections.singletonMap("CS.fakeControllerService", fakeServiceEntity.getId())); + getNifiClient().getProcessorClient().updateProcessor(fakeProcessorEntity); + final ControllerServiceRunStatusEntity runStatusEntity = new ControllerServiceRunStatusEntity(); + runStatusEntity.setState("ENABLED"); + runStatusEntity.setRevision(fakeServiceEntity.getRevision()); + getNifiClient().getControllerServicesClient().activateControllerService(fakeServiceEntity.getId(), runStatusEntity); + getClientUtil().waitForControllerSerivcesEnabled("root"); + String controllerStatus = getNifiClient().getControllerServicesClient().getControllerService(fakeServiceEntity.getId()).getStatus().getRunStatus(); + String processorStatus = getNifiClient().getProcessorClient().getProcessor(fakeProcessorEntity.getId()).getStatus().getRunStatus(); + + assertEquals("ENABLED", controllerStatus); + assertEquals("Stopped", processorStatus); + } +} diff --git a/nifi-system-tests/pom.xml b/nifi-system-tests/pom.xml index dba2c3c..a457111 100644 --- a/nifi-system-tests/pom.xml +++ b/nifi-system-tests/pom.xml @@ -27,6 +27,7 @@ <modules> <module>nifi-system-test-extensions-bundle</module> + <module>nifi-system-test-extensions2-bundle</module> <module>nifi-system-test-suite</module> </modules>
