You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2023/09/24 22:49:18 UTC
[nifi] branch main updated: NIFI-12120 This closes #7784. Removed Obsolete Framework Integration Tests
This is an automated email from the ASF dual-hosted git repository.
joewitt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new bcc54953c4 NIFI-12120 This closes #7784. Removed Obsolete Framework Integration Tests
bcc54953c4 is described below
commit bcc54953c4551717f60b8615a2f71c6939d6b545
Author: exceptionfactory <ex...@apache.org>
AuthorDate: Sat Sep 23 11:36:19 2023 -0500
NIFI-12120 This closes #7784. Removed Obsolete Framework Integration Tests
- Removed integration tests from org.apache.nifi.integration in nifi-framework-core
Signed-off-by: Joseph Witt <jo...@apache.org>
---
.../nifi/controller/StandardProcessorNodeIT.java | 802 -----------
.../scheduling/ProcessorLifecycleIT.java | 752 ----------
.../StandardControllerServiceProviderIT.java | 192 ---
.../nifi/flowanalysis/AbstractFlowAnalysisIT.java | 126 --
.../flowanalysis/FlowAnalysisRuleLifeCycleIT.java | 197 ---
.../apache/nifi/flowanalysis/FlowAnalyzerIT.java | 1437 --------------------
.../integration/AlwaysAuthorizedAuthorizer.java | 56 -
.../DirectInjectionExtensionManager.java | 70 -
.../nifi/integration/FrameworkIntegrationTest.java | 626 ---------
.../apache/nifi/integration/NopAuditService.java | 64 -
.../nifi/integration/auth/AlwaysAuthenticate.java | 46 -
.../auth/VolatileAccessPolicyProvider.java | 118 --
.../auth/VolatileUserGroupProvider.java | 111 --
.../cs/ControllerServiceReferenceIT.java | 106 --
.../cs/ControllerServiceReferencingProcessor.java | 70 -
.../org/apache/nifi/integration/cs/Counter.java | 25 -
.../integration/cs/CounterControllerService.java | 35 -
.../cs/LongValidatingControllerService.java | 59 -
...tipleControllerServiceReferencingProcessor.java | 58 -
.../nifi/integration/cs/NopControllerService.java | 22 -
.../cs/NopServiceReferencingProcessor.java | 46 -
.../flowanalysis/DelegateFlowAnalysisRule.java | 64 -
.../flowfilerepo/OOMEFlowFileRepoUpdateIT.java | 76 --
.../OOMEWriteAheadFlowFileRepository.java | 139 --
.../integration/lifecycle/ContentCleanupIT.java | 184 ---
.../lifecycle/FlowFileRepositoryLifecycleIT.java | 148 --
.../nifi/integration/parameters/ParametersIT.java | 502 -------
.../processgroup/StandardProcessGroupIT.java | 282 ----
.../integration/processor/BiConsumerProcessor.java | 63 -
.../processor/ProcessorParameterTokenIT.java | 214 ---
.../integration/processors/GenerateProcessor.java | 81 --
.../nifi/integration/processors/NopProcessor.java | 28 -
.../nifi/integration/processors/TerminateAll.java | 34 -
.../nifi/integration/processors/TerminateOnce.java | 33 -
.../UpdateAttributeCreateOwnProperty.java | 69 -
.../processors/UpdateAttributeNoEL.java | 66 -
.../processors/UpdateAttributeWithEL.java | 66 -
.../processors/UsernamePasswordProcessor.java | 62 -
.../integration/provenance/ProvenanceEventsIT.java | 481 -------
.../integration/swap/StandaloneSwapFileIT.java | 93 --
.../nifi/integration/versioned/ImportFlowIT.java | 781 -----------
.../resources/int-tests/clustered-nifi.properties | 245 ----
.../resources/int-tests/default-nifi.properties | 245 ----
.../test/resources/int-tests/state-management.xml | 32 -
.../test/resources/int-tests/zookeeper.properties | 45 -
.../test/resources/lifecycletest.nifi.properties | 124 --
46 files changed, 9175 deletions(-)
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardProcessorNodeIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardProcessorNodeIT.java
deleted file mode 100644
index 09c19fa8ec..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardProcessorNodeIT.java
+++ /dev/null
@@ -1,802 +0,0 @@
-/*
- * 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.controller;
-
-import org.apache.nifi.admin.service.AuditService;
-import org.apache.nifi.annotation.lifecycle.OnScheduled;
-import org.apache.nifi.annotation.lifecycle.OnStopped;
-import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
-import org.apache.nifi.authorization.Authorizer;
-import org.apache.nifi.bundle.Bundle;
-import org.apache.nifi.bundle.BundleCoordinate;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyValue;
-import org.apache.nifi.components.ValidationContext;
-import org.apache.nifi.components.state.StateManagerProvider;
-import org.apache.nifi.controller.exception.ControllerServiceInstantiationException;
-import org.apache.nifi.controller.exception.ProcessorInstantiationException;
-import org.apache.nifi.controller.flowanalysis.FlowAnalysisRuleInstantiationException;
-import org.apache.nifi.controller.flowanalysis.FlowAnalyzer;
-import org.apache.nifi.controller.kerberos.KerberosConfig;
-import org.apache.nifi.controller.repository.FlowFileEventRepository;
-import org.apache.nifi.controller.scheduling.LifecycleState;
-import org.apache.nifi.controller.scheduling.SchedulingAgent;
-import org.apache.nifi.controller.scheduling.StandardLifecycleStateManager;
-import org.apache.nifi.controller.scheduling.StandardProcessScheduler;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.controller.status.history.StatusHistoryRepository;
-import org.apache.nifi.engine.FlowEngine;
-import org.apache.nifi.events.VolatileBulletinRepository;
-import org.apache.nifi.expression.ExpressionLanguageCompiler;
-import org.apache.nifi.nar.ExtensionDiscoveringManager;
-import org.apache.nifi.nar.InstanceClassLoader;
-import org.apache.nifi.nar.NarClassLoader;
-import org.apache.nifi.nar.NarCloseable;
-import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
-import org.apache.nifi.nar.SystemBundle;
-import org.apache.nifi.parameter.ParameterContext;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Processor;
-import org.apache.nifi.processor.ProcessorInitializationContext;
-import org.apache.nifi.processor.StandardProcessContext;
-import org.apache.nifi.processor.StandardProcessorInitializationContext;
-import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.processor.util.StandardValidators;
-import org.apache.nifi.provenance.MockProvenanceRepository;
-import org.apache.nifi.registry.VariableDescriptor;
-import org.apache.nifi.registry.VariableRegistry;
-import org.apache.nifi.registry.flow.FlowRegistryClientNode;
-import org.apache.nifi.registry.variable.FileBasedVariableRegistry;
-import org.apache.nifi.registry.variable.StandardComponentVariableRegistry;
-import org.apache.nifi.test.processors.AlwaysInvalid;
-import org.apache.nifi.test.processors.DynamicPropertiesTestProcessor;
-import org.apache.nifi.test.processors.ModifiesClasspathNoAnnotationProcessor;
-import org.apache.nifi.test.processors.ModifiesClasspathProcessor;
-import org.apache.nifi.util.MockPropertyValue;
-import org.apache.nifi.util.MockVariableRegistry;
-import org.apache.nifi.util.NiFiProperties;
-import org.apache.nifi.util.SynchronousValidationTrigger;
-import org.apache.nifi.validation.RuleViolationsManager;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Function;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class StandardProcessorNodeIT {
-
- private MockVariableRegistry variableRegistry;
- private Bundle systemBundle;
- private ExtensionDiscoveringManager extensionManager;
- private NiFiProperties niFiProperties;
-
- private final AtomicReference<InstanceClassLoader> currentInstanceClassLoaderHolder = new AtomicReference<>();
-
- @BeforeEach
- public void setup() {
- variableRegistry = new MockVariableRegistry();
- niFiProperties = NiFiProperties.createBasicNiFiProperties("src/test/resources/conf/nifi.properties");
-
- systemBundle = SystemBundle.create(niFiProperties);
- extensionManager = new StandardExtensionDiscoveringManager() {
- @Override
- public InstanceClassLoader createInstanceClassLoader(String classType, String instanceIdentifier, Bundle bundle, Set<URL> additionalUrls) {
- InstanceClassLoader instanceClassLoader = super.createInstanceClassLoader(classType, instanceIdentifier, bundle, additionalUrls);
-
- currentInstanceClassLoaderHolder.set(instanceClassLoader);
-
- return instanceClassLoader;
-
- }
- };
- extensionManager.discoverExtensions(systemBundle, Collections.emptySet());
- }
-
- @Timeout(10)
- public void testStart() throws InterruptedException {
- final ProcessorThatThrowsExceptionOnScheduled processor = new ProcessorThatThrowsExceptionOnScheduled();
- final String uuid = UUID.randomUUID().toString();
-
- ProcessorInitializationContext initContext = new StandardProcessorInitializationContext(uuid, null, null, null, KerberosConfig.NOT_CONFIGURED);
- processor.initialize(initContext);
-
- final ReloadComponent reloadComponent = mock(ReloadComponent.class);
- final BundleCoordinate coordinate = mock(BundleCoordinate.class);
-
- final LoggableComponent<Processor> loggableComponent = new LoggableComponent<>(processor, coordinate, null);
- final StandardProcessorNode procNode = new StandardProcessorNode(loggableComponent, uuid, createValidationContextFactory(), null, null,
- new StandardComponentVariableRegistry(VariableRegistry.EMPTY_REGISTRY), reloadComponent, extensionManager, new SynchronousValidationTrigger());
- final ScheduledExecutorService taskScheduler = new FlowEngine(1, "TestClasspathResources", true);
-
- final StandardProcessContext processContext = new StandardProcessContext(procNode, null, null, () -> false, null);
- final SchedulingAgentCallback schedulingAgentCallback = new FailIfTriggeredSchedulingAgentCallback(taskScheduler);
-
- procNode.performValidation();
- procNode.start(taskScheduler, 20000L, 10000L, () -> processContext, schedulingAgentCallback, true, true);
-
- Thread.sleep(1000L);
- assertEquals(1, processor.onScheduledCount);
- assertEquals(1, processor.onUnscheduledCount);
- assertEquals(1, processor.onStoppedCount);
- }
-
-
- @Test
- public void testSinglePropertyDynamicallyModifiesClasspath() throws MalformedURLException {
- final MockReloadComponent reloadComponent = new MockReloadComponent();
-
- final PropertyDescriptor classpathProp = new PropertyDescriptor.Builder().name("Classpath Resources")
- .dynamicallyModifiesClasspath(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
- final ModifiesClasspathProcessor processor = new ModifiesClasspathProcessor(Arrays.asList(classpathProp));
- final StandardProcessorNode procNode = createProcessorNode(processor, reloadComponent);
-
- try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getIdentifier())){
-
- // Should not have any of the test resources loaded at this point
- final URL[] testResources = getTestResources();
- for (URL testResource : testResources) {
- if (containsResource(reloadComponent.getAdditionalUrls(), testResource)) {
- fail("found resource that should not have been loaded");
- }
- }
-
- // Simulate setting the properties of the processor to point to the test resources directory
- final Map<String, String> properties = new HashMap<>();
- properties.put(classpathProp.getName(), "src/test/resources/TestClasspathResources");
- procNode.setProperties(properties);
-
- // Should have all of the resources loaded into the InstanceClassLoader now
- for (URL testResource : testResources) {
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResource));
- }
-
- assertEquals(ModifiesClasspathProcessor.class.getCanonicalName(), reloadComponent.getNewType());
-
- // Should pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
- } finally {
- extensionManager.removeInstanceClassLoader(procNode.getIdentifier());
- }
- }
-
- @EnabledOnOs(OS.MAC)
- @Test
- public void testNativeLibLoadedFromDynamicallyModifiesClasspathProperty() {
- // Init NiFi
- NarClassLoader narClassLoader = mock(NarClassLoader.class);
- when(narClassLoader.getURLs()).thenReturn(new URL[0]);
-
- Bundle narBundle = SystemBundle.create(niFiProperties, narClassLoader);
-
- final NiFiProperties nifiProperties = createBasicNiFiPropertiesWithMocks();
-
- final FlowController flowController = FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties,
- mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(),
- new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths()),
- extensionManager, mock(StatusHistoryRepository.class), null);
-
- // Init processor
- final PropertyDescriptor classpathProp = new PropertyDescriptor.Builder().name("Classpath Resources")
- .dynamicallyModifiesClasspath(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
-
- final ModifiesClasspathProcessor processor = new ModifiesClasspathProcessor(Arrays.asList(classpathProp));
- final String uuid = UUID.randomUUID().toString();
-
- final ValidationContextFactory validationContextFactory = createValidationContextFactory();
- final ProcessScheduler processScheduler = mock(ProcessScheduler.class);
- final TerminationAwareLogger componentLog = mock(TerminationAwareLogger.class);
-
- final ReloadComponent reloadComponent = new StandardReloadComponent(flowController);
- ProcessorInitializationContext initContext = new StandardProcessorInitializationContext(uuid, componentLog, null, null, KerberosConfig.NOT_CONFIGURED);
- ((Processor) processor).initialize(initContext);
-
- final LoggableComponent<Processor> loggableComponent = new LoggableComponent<>(processor, narBundle.getBundleDetails().getCoordinate(), componentLog);
- final StandardProcessorNode procNode = new StandardProcessorNode(loggableComponent, uuid, validationContextFactory, processScheduler,
- null, new StandardComponentVariableRegistry(variableRegistry), reloadComponent, extensionManager, new SynchronousValidationTrigger());
-
- final Map<String, String> properties = new HashMap<>();
- properties.put(classpathProp.getName(), "src/test/resources/native");
- procNode.setProperties(properties);
-
- try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getIdentifier())){
- // Should pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
-
- // WHEN
- String actualLibraryLocation = currentInstanceClassLoaderHolder.get().findLibrary("testjni");
-
- // THEN
- assertThat(actualLibraryLocation, containsString(currentInstanceClassLoaderHolder.get().getIdentifier()));
- } finally {
- extensionManager.removeInstanceClassLoader(procNode.getIdentifier());
- }
- }
-
- @Test
- public void testDynamicPropertiesArePreservedAfterReload() throws ProcessorInstantiationException {
- // Init NiFi
- NarClassLoader narClassLoader = mock(NarClassLoader.class);
- when(narClassLoader.getURLs()).thenReturn(new URL[0]);
-
- Bundle narBundle = SystemBundle.create(niFiProperties, narClassLoader);
-
- final NiFiProperties nifiProperties = createBasicNiFiPropertiesWithMocks();
-
- final FlowController flowController = FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties,
- mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(),
- new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths()),
- extensionManager, mock(StatusHistoryRepository.class), null);
-
- // Init processor
- final DynamicPropertiesTestProcessor processor = new DynamicPropertiesTestProcessor();
- final String uuid = UUID.randomUUID().toString();
-
- final ValidationContextFactory validationContextFactory = createValidationContextFactory();
- final TerminationAwareLogger componentLog = mock(TerminationAwareLogger.class);
-
- final ReloadComponent reloadComponent = new StandardReloadComponent(flowController);
-
- final StateManagerProvider stateManagerProvider = mock(StateManagerProvider.class);
-
- final ProcessScheduler processScheduler = new StandardProcessScheduler(null, flowController,
- stateManagerProvider, nifiProperties, new StandardLifecycleStateManager());
-
- final LoggableComponent<Processor> loggableComponent = new LoggableComponent<>(processor, narBundle.getBundleDetails().getCoordinate(), componentLog);
- final StandardProcessorNode procNode = new StandardProcessorNode(loggableComponent, uuid, validationContextFactory, processScheduler,
- null, new StandardComponentVariableRegistry(variableRegistry), reloadComponent, extensionManager, new SynchronousValidationTrigger());
- processor.setProcessorNode(procNode);
- ProcessorInitializationContext initContext = new StandardProcessorInitializationContext(uuid, componentLog, null, null, KerberosConfig.NOT_CONFIGURED);
- ((Processor) processor).initialize(initContext);
- final BundleCoordinate existingCoordinate = procNode.getBundleCoordinate();
-
- final Map<String, String> properties = new HashMap<>();
- properties.put(DynamicPropertiesTestProcessor.STATIC_PROPERTY.getName(), "${value}");
- properties.put("dynamic-property", "value");
- procNode.setProperties(properties);
- procNode.performValidation();
-
- // Start out with one dynamic property name
- assertEquals(1, processor.getDynamicPropertyNames().size());
-
- // Reload the processor, which happens during a 'terminate' operation
- reloadComponent.reload(procNode, processor.getClass().getName(), existingCoordinate, null);
-
- // After terminate, we should still have one dynamic property, and the static property should be untouched
- assertEquals(1, ((DynamicPropertiesTestProcessor) procNode.getProcessor()).getDynamicPropertyNames().size());
- assertEquals("${value}", procNode.getProperties().get(DynamicPropertiesTestProcessor.STATIC_PROPERTY).getRawValue());
- }
-
- private NiFiProperties createBasicNiFiPropertiesWithMocks() {
- HashMap<String, String> additionalProperties = new HashMap<>();
- additionalProperties.put(NiFiProperties.ADMINISTRATIVE_YIELD_DURATION, "1 sec");
- additionalProperties.put(NiFiProperties.STATE_MANAGEMENT_CONFIG_FILE, "target/test-classes/state-management.xml");
- additionalProperties.put(NiFiProperties.STATE_MANAGEMENT_LOCAL_PROVIDER_ID, "local-provider");
- additionalProperties.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
- additionalProperties.put("nifi.remote.input.socket.port", "");
- additionalProperties.put("nifi.remote.input.secure", "");
-
- return NiFiProperties.createBasicNiFiProperties("src/test/resources/conf/nifi.properties", additionalProperties);
- }
-
- @Test
- public void testUpdateOtherPropertyDoesNotImpactClasspath() throws MalformedURLException {
- final MockReloadComponent reloadComponent = new MockReloadComponent();
-
- final PropertyDescriptor classpathProp = new PropertyDescriptor.Builder().name("Classpath Resources")
- .dynamicallyModifiesClasspath(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
-
- final PropertyDescriptor otherProp = new PropertyDescriptor.Builder().name("My Property")
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
-
- final ModifiesClasspathProcessor processor = new ModifiesClasspathProcessor(Arrays.asList(classpathProp, otherProp));
- final StandardProcessorNode procNode = createProcessorNode(processor, reloadComponent);
-
- try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getIdentifier())){
- // Should not have any of the test resources loaded at this point
- final URL[] testResources = getTestResources();
- for (URL testResource : testResources) {
- if (containsResource(reloadComponent.getAdditionalUrls(), testResource)) {
- fail("found resource that should not have been loaded");
- }
- }
-
- // Simulate setting the properties of the processor to point to the test resources directory
- final Map<String, String> properties = new HashMap<>();
- properties.put(classpathProp.getName(), "src/test/resources/TestClasspathResources");
- procNode.setProperties(properties);
-
- // Should have all of the resources loaded into the InstanceClassLoader now
- for (URL testResource : testResources) {
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResource));
- }
-
- // Should pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
-
- // Simulate setting updating the other property which should not change the classpath
- final Map<String, String> otherProperties = new HashMap<>();
- otherProperties.put(otherProp.getName(), "foo");
- procNode.setProperties(otherProperties);
-
- // Should STILL have all of the resources loaded into the InstanceClassLoader now
- for (URL testResource : testResources) {
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResource));
- }
-
- // Should STILL pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
-
- // Lets update the classpath property and make sure the resources get updated
- final Map<String, String> newClasspathProperties = new HashMap<>();
- newClasspathProperties.put(classpathProp.getName(), "src/test/resources/TestClasspathResources/resource1.txt");
- procNode.setProperties(newClasspathProperties);
-
- // Should only have resource1 loaded now
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResources[0]));
- assertFalse(containsResource(reloadComponent.getAdditionalUrls(), testResources[1]));
- assertFalse(containsResource(reloadComponent.getAdditionalUrls(), testResources[2]));
-
- assertEquals(ModifiesClasspathProcessor.class.getCanonicalName(), reloadComponent.getNewType());
-
- // Should STILL pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
- } finally {
- extensionManager.removeInstanceClassLoader(procNode.getIdentifier());
- }
- }
-
- @Test
- public void testMultiplePropertiesDynamicallyModifyClasspathWithExpressionLanguage() throws MalformedURLException {
- final MockReloadComponent reloadComponent = new MockReloadComponent();
-
- final PropertyDescriptor classpathProp1 = new PropertyDescriptor.Builder().name("Classpath Resource 1")
- .dynamicallyModifiesClasspath(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
- final PropertyDescriptor classpathProp2 = new PropertyDescriptor.Builder().name("Classpath Resource 2")
- .dynamicallyModifiesClasspath(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
-
- final ModifiesClasspathProcessor processor = new ModifiesClasspathProcessor(Arrays.asList(classpathProp1, classpathProp2));
- final StandardProcessorNode procNode = createProcessorNode(processor, reloadComponent);
-
- try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getIdentifier())){
-
- // Should not have any of the test resources loaded at this point
- final URL[] testResources = getTestResources();
- for (URL testResource : testResources) {
- if (containsResource(reloadComponent.getAdditionalUrls(), testResource)) {
- fail("found resource that should not have been loaded");
- }
- }
-
- // Simulate setting the properties pointing to two of the resources
- final Map<String, String> properties = new HashMap<>();
- properties.put(classpathProp1.getName(), "src/test/resources/TestClasspathResources/resource1.txt");
- properties.put(classpathProp2.getName(), "src/test/resources/TestClasspathResources/${myResource}");
-
- variableRegistry.setVariable(new VariableDescriptor("myResource"), "resource3.txt");
-
- procNode.setProperties(properties);
-
- // Should have resources 1 and 3 loaded into the InstanceClassLoader now
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResources[0]));
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResources[2]));
- assertFalse(containsResource(reloadComponent.getAdditionalUrls(), testResources[1]));
-
- assertEquals(ModifiesClasspathProcessor.class.getCanonicalName(), reloadComponent.getNewType());
-
- // Should pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
- } finally {
- extensionManager.removeInstanceClassLoader(procNode.getIdentifier());
- }
- }
-
- @Test
- public void testSomeNonExistentPropertiesDynamicallyModifyClasspath() throws MalformedURLException {
- final MockReloadComponent reloadComponent = new MockReloadComponent();
-
- final PropertyDescriptor classpathProp1 = new PropertyDescriptor.Builder().name("Classpath Resource 1")
- .dynamicallyModifiesClasspath(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
- final PropertyDescriptor classpathProp2 = new PropertyDescriptor.Builder().name("Classpath Resource 2")
- .dynamicallyModifiesClasspath(true).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
-
- final ModifiesClasspathProcessor processor = new ModifiesClasspathProcessor(Arrays.asList(classpathProp1, classpathProp2));
- final StandardProcessorNode procNode = createProcessorNode(processor, reloadComponent);
-
- try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getIdentifier())){
-
- // Should not have any of the test resources loaded at this point
- final URL[] testResources = getTestResources();
- for (URL testResource : testResources) {
- if (containsResource(reloadComponent.getAdditionalUrls(), testResource)) {
- fail("found resource that should not have been loaded");
- }
- }
-
- // Simulate setting the properties pointing to two of the resources
- final Map<String, String> properties = new HashMap<>();
- properties.put(classpathProp1.getName(), "src/test/resources/TestClasspathResources/resource1.txt");
- properties.put(classpathProp2.getName(), "src/test/resources/TestClasspathResources/DoesNotExist.txt");
- procNode.setProperties(properties);
-
- // Should have resources 1 and 3 loaded into the InstanceClassLoader now
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResources[0]));
- assertFalse(containsResource(reloadComponent.getAdditionalUrls(), testResources[1]));
- assertFalse(containsResource(reloadComponent.getAdditionalUrls(), testResources[2]));
-
- assertEquals(ModifiesClasspathProcessor.class.getCanonicalName(), reloadComponent.getNewType());
-
- // Should pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
- } finally {
- extensionManager.removeInstanceClassLoader(procNode.getIdentifier());
- }
- }
-
- @Test
- public void testPropertyModifiesClasspathWhenProcessorMissingAnnotation() throws MalformedURLException {
- final MockReloadComponent reloadComponent = new MockReloadComponent();
- final ModifiesClasspathNoAnnotationProcessor processor = new ModifiesClasspathNoAnnotationProcessor();
- final StandardProcessorNode procNode = createProcessorNode(processor, reloadComponent);
-
- try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, procNode.getProcessor().getClass(), procNode.getIdentifier())){
-
- final Map<String, String> properties = new HashMap<>();
- properties.put(ModifiesClasspathNoAnnotationProcessor.CLASSPATH_RESOURCE.getName(),
- "src/test/resources/TestClasspathResources/resource1.txt");
- procNode.setProperties(properties);
-
- final URL[] testResources = getTestResources();
- assertTrue(containsResource(reloadComponent.getAdditionalUrls(), testResources[0]));
- assertFalse(containsResource(reloadComponent.getAdditionalUrls(), testResources[1]));
- assertFalse(containsResource(reloadComponent.getAdditionalUrls(), testResources[2]));
-
- assertEquals(ModifiesClasspathNoAnnotationProcessor.class.getCanonicalName(), reloadComponent.getNewType());
-
- // Should pass validation
- assertTrue(procNode.computeValidationErrors(procNode.getValidationContext()).isEmpty());
- } finally {
- extensionManager.removeInstanceClassLoader(procNode.getIdentifier());
- }
- }
-
- @Test
- public void testVerifyCanUpdateBundle() {
- final ReloadComponent reloadComponent = new MockReloadComponent();
- final ModifiesClasspathNoAnnotationProcessor processor = new ModifiesClasspathNoAnnotationProcessor();
- final StandardProcessorNode procNode = createProcessorNode(processor, reloadComponent);
- final BundleCoordinate existingCoordinate = procNode.getBundleCoordinate();
-
- // should be allowed to update when the bundle is the same
- procNode.verifyCanUpdateBundle(existingCoordinate);
-
- // should be allowed to update when the group and id are the same but version is different
- final BundleCoordinate diffVersion = new BundleCoordinate(existingCoordinate.getGroup(), existingCoordinate.getId(), "v2");
- assertNotEquals(existingCoordinate.getVersion(), diffVersion.getVersion());
- procNode.verifyCanUpdateBundle(diffVersion);
-
- // should not be allowed to update when the bundle id is different
- final BundleCoordinate diffId = new BundleCoordinate(existingCoordinate.getGroup(), "different-id", existingCoordinate.getVersion());
- assertNotEquals(existingCoordinate.getId(), diffId.getId());
- assertThrows(Exception.class, () -> procNode.verifyCanUpdateBundle(diffId));
-
- // should not be allowed to update when the bundle group is different
- final BundleCoordinate diffGroup = new BundleCoordinate("different-group", existingCoordinate.getId(), existingCoordinate.getVersion());
- assertNotEquals(existingCoordinate.getGroup(), diffGroup.getGroup());
- assertThrows(Exception.class, () -> procNode.verifyCanUpdateBundle(diffGroup));
- }
-
- @Test
- public void testStartInvalidProcessorThenStopFutureTriggered() throws ExecutionException, InterruptedException, TimeoutException {
- final Processor alwaysInvalid = new AlwaysInvalid();
- final ProcessorNode procNode = createProcessorNode(alwaysInvalid, new MockReloadComponent());
-
- final ScheduledExecutorService taskScheduler = new FlowEngine(1, "TestStartInvalidProcessorThenStopFutureTriggered", true);
- final StandardProcessContext processContext = new StandardProcessContext(procNode, null, null, () -> false, null);
- final SchedulingAgentCallback schedulingAgentCallback = new FailIfTriggeredSchedulingAgentCallback(taskScheduler);
-
- procNode.start(taskScheduler, 20000L, 10000L, () -> processContext, schedulingAgentCallback, true, true);
- assertEquals(ScheduledState.STARTING, procNode.getPhysicalScheduledState());
-
- final ProcessScheduler processScheduler = mock(ProcessScheduler.class);
- final SchedulingAgent schedulingAgent = mock(SchedulingAgent.class);
- final LifecycleState lifecycleState = new LifecycleState(procNode.getIdentifier());
-
- final Future<Void> future = procNode.stop(processScheduler, taskScheduler, processContext, schedulingAgent, lifecycleState, true);
- final ScheduledState currentState = procNode.getPhysicalScheduledState();
- assertTrue(currentState == ScheduledState.STOPPED || currentState == ScheduledState.STOPPING);
-
- future.get(15, TimeUnit.SECONDS);
- assertEquals(ScheduledState.STOPPED, procNode.getPhysicalScheduledState());
- }
-
- private StandardProcessorNode createProcessorNode(final Processor processor, final ReloadComponent reloadComponent) {
- final String uuid = UUID.randomUUID().toString();
- final ValidationContextFactory validationContextFactory = createValidationContextFactory();
- final ProcessScheduler processScheduler = mock(ProcessScheduler.class);
- final TerminationAwareLogger componentLog = mock(TerminationAwareLogger.class);
-
- extensionManager.createInstanceClassLoader(processor.getClass().getName(), uuid, systemBundle, null);
-
- ProcessorInitializationContext initContext = new StandardProcessorInitializationContext(uuid, componentLog, null, null, KerberosConfig.NOT_CONFIGURED);
- processor.initialize(initContext);
-
- final LoggableComponent<Processor> loggableComponent = new LoggableComponent<>(processor, systemBundle.getBundleDetails().getCoordinate(), componentLog);
- return new StandardProcessorNode(loggableComponent, uuid, validationContextFactory, processScheduler,
- null, new StandardComponentVariableRegistry(variableRegistry), reloadComponent, extensionManager, new SynchronousValidationTrigger());
- }
-
- private static class MockReloadComponent implements ReloadComponent {
-
- private String newType;
- private final Set<URL> additionalUrls = new LinkedHashSet<>();
-
- public Set<URL> getAdditionalUrls() {
- return this.additionalUrls;
- }
-
- public String getNewType() {
- return newType;
- }
-
- @Override
- public void reload(ProcessorNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
- reload(newType, additionalUrls);
- }
-
- @Override
- public void reload(ControllerServiceNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) throws ControllerServiceInstantiationException {
- reload(newType, additionalUrls);
- }
-
- @Override
- public void reload(ReportingTaskNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
- reload(newType, additionalUrls);
- }
-
- @Override
- public void reload(FlowAnalysisRuleNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) throws FlowAnalysisRuleInstantiationException {
- reload(newType, additionalUrls);
- }
-
- @Override
- public void reload(ParameterProviderNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
- reload(newType, additionalUrls);
- }
-
- @Override
- public void reload(FlowRegistryClientNode existingNode, String newType, BundleCoordinate bundleCoordinate, Set<URL> additionalUrls) {
- reload(newType, additionalUrls);
- }
-
- private void reload(String newType, Set<URL> additionalUrls) {
- this.newType = newType;
- this.additionalUrls.clear();
- if (additionalUrls != null) {
- this.additionalUrls.addAll(additionalUrls);
- }
- }
- }
-
- private boolean containsResource(Set<URL> resources, URL resourceToFind) {
- for (URL resource : resources) {
- if (resourceToFind.getPath().equals(resource.getPath())) {
- return true;
- }
- }
- return false;
- }
-
- private URL[] getTestResources() throws MalformedURLException {
- URL resource1 = new File("src/test/resources/TestClasspathResources/resource1.txt").toURI().toURL();
- URL resource2 = new File("src/test/resources/TestClasspathResources/resource2.txt").toURI().toURL();
- URL resource3 = new File("src/test/resources/TestClasspathResources/resource3.txt").toURI().toURL();
- return new URL[] { resource1, resource2, resource3 };
- }
-
-
- private ValidationContextFactory createValidationContextFactory() {
- return new ValidationContextFactory() {
- @Override
- public ValidationContext newValidationContext(Map<PropertyDescriptor, PropertyConfiguration> properties, String annotationData, String groupId, String componentId,
- ParameterContext context, boolean validateConnections) {
- return new ValidationContext() {
-
- @Override
- public ControllerServiceLookup getControllerServiceLookup() {
- return null;
- }
-
- @Override
- public ValidationContext getControllerServiceValidationContext(ControllerService controllerService) {
- return null;
- }
-
- @Override
- public ExpressionLanguageCompiler newExpressionLanguageCompiler() {
- return null;
- }
-
- @Override
- public PropertyValue getProperty(PropertyDescriptor property) {
- final PropertyConfiguration configuration = properties.get(property);
- return newPropertyValue(configuration == null ? null : configuration.getRawValue());
- }
-
- @Override
- public PropertyValue newPropertyValue(String value) {
- return new MockPropertyValue(value);
- }
-
- @Override
- public Map<PropertyDescriptor, String> getProperties() {
- final Map<PropertyDescriptor, String> propertyMap = new HashMap<>();
- properties.forEach((k, v) -> propertyMap.put(k, v == null ? null : v.getRawValue()));
- return propertyMap;
- }
-
- @Override
- public Map<String, String> getAllProperties() {
- final Map<String, String> propValueMap = new LinkedHashMap<>();
- for (final Map.Entry<PropertyDescriptor, String> entry : getProperties().entrySet()) {
- propValueMap.put(entry.getKey().getName(), entry.getValue());
- }
- return propValueMap;
- }
-
- @Override
- public String getAnnotationData() {
- return null;
- }
-
- @Override
- public boolean isValidationRequired(ControllerService service) {
- return false;
- }
-
- @Override
- public boolean isExpressionLanguagePresent(String value) {
- return false;
- }
-
- @Override
- public boolean isExpressionLanguageSupported(String propertyName) {
- return false;
- }
-
- @Override
- public String getProcessGroupIdentifier() {
- return groupId;
- }
-
- @Override
- public Collection<String> getReferencedParameters(final String propertyName) {
- return Collections.emptyList();
- }
-
- @Override
- public boolean isParameterDefined(final String parameterName) {
- return false;
- }
-
- @Override
- public boolean isParameterSet(final String parameterName) {
- return false;
- }
-
- @Override
- public boolean isDependencySatisfied(final PropertyDescriptor propertyDescriptor, final Function<String, PropertyDescriptor> propertyDescriptorLookup) {
- return false;
- }
- };
- }
-
- @Override
- public RuleViolationsManager getRuleViolationsManager() {
- return null;
- }
-
- @Override
- public FlowAnalyzer getFlowAnalyzer() {
- return null;
- }
- };
- }
-
-
- public static class ProcessorThatThrowsExceptionOnScheduled extends AbstractProcessor {
- private int onScheduledCount = 0;
- private int onUnscheduledCount = 0;
- private int onStoppedCount = 0;
-
- @Override
- public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
- }
-
- @OnScheduled
- public void onScheduled() {
- onScheduledCount++;
- throw new ProcessException("OnScheduled called - Unit Test throws Exception intentionally");
- }
-
- @OnUnscheduled
- public void onUnscheduled() {
- onUnscheduledCount++;
- }
-
- @OnStopped
- public void onStopped() {
- onStoppedCount++;
- }
- }
-
- private static class FailIfTriggeredSchedulingAgentCallback implements SchedulingAgentCallback {
- private final ScheduledExecutorService executorService;
-
- public FailIfTriggeredSchedulingAgentCallback(final ScheduledExecutorService executorService) {
- this.executorService = executorService;
- }
-
- @Override
- public void onTaskComplete() {
- }
-
- @Override
- public Future<?> scheduleTask(final Callable<?> task) {
- return executorService.submit(task);
- }
-
- @Override
- public void trigger() {
- fail("Should not have completed");
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/ProcessorLifecycleIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/ProcessorLifecycleIT.java
deleted file mode 100644
index 10d2278cf8..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/ProcessorLifecycleIT.java
+++ /dev/null
@@ -1,752 +0,0 @@
-/*
- * 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.controller.scheduling;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.nifi.admin.service.AuditService;
-import org.apache.nifi.annotation.lifecycle.OnScheduled;
-import org.apache.nifi.annotation.lifecycle.OnStopped;
-import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
-import org.apache.nifi.authorization.Authorizer;
-import org.apache.nifi.bundle.Bundle;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.ValidationContext;
-import org.apache.nifi.components.ValidationResult;
-import org.apache.nifi.components.Validator;
-import org.apache.nifi.controller.AbstractControllerService;
-import org.apache.nifi.controller.ControllerService;
-import org.apache.nifi.controller.FlowController;
-import org.apache.nifi.controller.ProcessScheduler;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.ScheduledState;
-import org.apache.nifi.controller.flow.FlowManager;
-import org.apache.nifi.controller.repository.FlowFileEventRepository;
-import org.apache.nifi.controller.status.history.StatusHistoryRepository;
-import org.apache.nifi.events.VolatileBulletinRepository;
-import org.apache.nifi.groups.ProcessGroup;
-import org.apache.nifi.nar.ExtensionDiscoveringManager;
-import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
-import org.apache.nifi.nar.SystemBundle;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.provenance.MockProvenanceRepository;
-import org.apache.nifi.registry.variable.FileBasedVariableRegistry;
-import org.apache.nifi.util.NiFiProperties;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.LockSupport;
-import java.util.function.Supplier;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-
-/**
- * Validate Processor's life-cycle operation within the context of
- * {@link FlowController} and {@link StandardProcessScheduler}
- */
-public class ProcessorLifecycleIT {
-
- private static final Logger logger = LoggerFactory.getLogger(ProcessorLifecycleIT.class);
- private static final long SHORT_DELAY_TOLERANCE = 10000L;
- private static final long MEDIUM_DELAY_TOLERANCE = 15000L;
- private static final long LONG_DELAY_TOLERANCE = 20000L;
-
- private FlowManager flowManager;
- private Map<String, String> properties = new HashMap<>();
- private volatile String propsFile = "src/test/resources/lifecycletest.nifi.properties";
- private ProcessScheduler processScheduler;
-
- @BeforeEach
- public void before() throws Exception {
- properties.put("P", "hello");
- }
-
- @AfterEach
- public void after() throws Exception {
- if (processScheduler != null) {
- processScheduler.shutdown();
- processScheduler = null;
- }
-
- FileUtils.deleteDirectory(new File("./target/lifecycletest"));
- }
-
- private void assertCondition(final Supplier<Boolean> supplier) {
- assertCondition(supplier, SHORT_DELAY_TOLERANCE);
- }
-
- private void assertCondition(final Supplier<Boolean> supplier, final long delayToleranceMillis) {
- final long startTime = System.currentTimeMillis();
- while (((System.currentTimeMillis() - startTime) < delayToleranceMillis) && !supplier.get()) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException ex) {
- Thread.interrupted();
- break;
- }
- }
- assertTrue(supplier.get());
- }
-
- @Test
- public void validateEnableOperation() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- final ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(),
- UUID.randomUUID().toString(), fcsb.getSystemBundle().getBundleDetails().getCoordinate());
-
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState());
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getPhysicalScheduledState());
- // validates idempotency
- for (int i = 0; i < 2; i++) {
- testProcNode.enable();
- }
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState());
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getPhysicalScheduledState());
- testProcNode.disable();
- assertCondition(() -> ScheduledState.DISABLED == testProcNode.getScheduledState());
- assertCondition(() -> ScheduledState.DISABLED == testProcNode.getPhysicalScheduledState());
- }
-
- @Test
- public void validateDisableOperation() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- final ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(),
- UUID.randomUUID().toString(), fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState());
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getPhysicalScheduledState());
- // validates idempotency
- for (int i = 0; i < 2; i++) {
- testProcNode.disable();
- }
- assertCondition(() -> ScheduledState.DISABLED == testProcNode.getScheduledState());
- assertCondition(() -> ScheduledState.DISABLED == testProcNode.getPhysicalScheduledState());
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- assertCondition(() -> ScheduledState.DISABLED == testProcNode.getPhysicalScheduledState());
- }
-
- /**
- * Will validate the idempotent nature of processor start operation which
- * can be called multiple times without any side-effects.
- */
- @Test
- public void validateIdempotencyOfProcessorStartOperation() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- final ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
-
- // sets the scenario for the processor to run
- this.noop(testProcessor);
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- processScheduler.startProcessor(testProcNode, true);
- processScheduler.startProcessor(testProcNode, true);
-
- Thread.sleep(500);
- assertCondition(() -> testProcessor.operationNames.size() == 1);
- assertEquals("@OnScheduled", testProcessor.operationNames.get(0));
- }
-
- /**
- * Validates that stop calls are harmless and idempotent if processor is not
- * in STARTING or RUNNING state.
- */
- @Test
- public void validateStopCallsAreMeaninglessIfProcessorNotStarted() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- final ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState());
- // sets the scenario for the processor to run
- int randomDelayLimit = 3000;
- this.randomOnTriggerDelay(testProcessor, randomDelayLimit);
-
- processScheduler.stopProcessor(testProcNode);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState());
- assertTrue(testProcessor.operationNames.isEmpty());
- }
-
- /**
- * Validates the processors start/stop sequence where the order of
- * operations can only be @OnScheduled, @OnUnscheduled, @OnStopped.
- */
- @Test
- @Disabled
- public void validateSuccessfulAndOrderlyShutdown() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
-
- // sets the scenario for the processor to run
- int randomDelayLimit = 3000;
- this.randomOnTriggerDelay(testProcessor, randomDelayLimit);
-
- testProcNode.setMaxConcurrentTasks(4);
- testProcNode.setSchedulingPeriod("500 millis");
- testProcNode.setAutoTerminatedRelationships(Collections.singleton(new Relationship.Builder().name("success").build()));
-
- testGroup.addProcessor(testProcNode);
-
- flowManager.getGroup(testGroup.getIdentifier()).startProcessing();
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), SHORT_DELAY_TOLERANCE);
-
- flowManager.getRootGroup().stopProcessing();
-
- Thread.sleep(randomDelayLimit); // up to randomDelayLimit, otherwise next assertion may fail as the processor still executing
-
- // validates that regardless of how many running tasks, lifecycle
- // operation are invoked atomically (once each).
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), SHORT_DELAY_TOLERANCE);
- // . . . hence only 3 operations must be in the list
- assertCondition(() -> testProcessor.operationNames.size() == 3, SHORT_DELAY_TOLERANCE);
- // . . . and ordered as @OnScheduled, @OnUnscheduled, @OnStopped
- assertEquals("@OnScheduled", testProcessor.operationNames.get(0));
- assertEquals("@OnUnscheduled", testProcessor.operationNames.get(1));
- assertEquals("@OnStopped", testProcessor.operationNames.get(2));
- }
-
- /**
- * Concurrency test that is basically hammers on both stop and start
- * operation validating their idempotency.
- */
- @Test
- @Disabled
- public void validateLifecycleOperationOrderWithConcurrentCallsToStartStop() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- final ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
-
- // sets the scenario for the processor to run
- this.noop(testProcessor);
-
- ExecutorService executor = Executors.newFixedThreadPool(100);
- int startCallsCount = 10000;
- final CountDownLatch countDownCounter = new CountDownLatch(startCallsCount);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState());
- final Random random = new Random();
- for (int i = 0; i < startCallsCount / 2; i++) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- LockSupport.parkNanos(random.nextInt(9000000));
- processScheduler.stopProcessor(testProcNode);
- countDownCounter.countDown();
- }
- });
- }
- for (int i = 0; i < startCallsCount / 2; i++) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- LockSupport.parkNanos(random.nextInt(9000000));
- processScheduler.startProcessor(testProcNode, true);
- countDownCounter.countDown();
- }
- });
- }
- assertTrue(countDownCounter.await(1000000, TimeUnit.MILLISECONDS));
- String previousOperation = null;
- for (String operationName : testProcessor.operationNames) {
- if (previousOperation == null || previousOperation.equals("@OnStopped")) {
- assertEquals("@OnScheduled", operationName);
- } else if (previousOperation.equals("@OnScheduled")) {
- assertEquals("@OnUnscheduled", operationName);
- } else if (previousOperation.equals("@OnUnscheduled")) {
- assertTrue(operationName.equals("@OnStopped") || operationName.equals("@OnScheduled"));
- }
- previousOperation = operationName;
- }
- executor.shutdownNow();
- }
-
- /**
- * Validates that processor can be stopped before start sequence finished.
- */
- @Test
- public void validateProcessorUnscheduledAndStoppedWhenStopIsCalledBeforeProcessorFullyStarted() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
-
- // sets the scenario for the processor to run
- int delay = 200;
- this.longRunningOnSchedule(testProcessor, delay);
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), MEDIUM_DELAY_TOLERANCE);
-
- processScheduler.stopProcessor(testProcNode);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), MEDIUM_DELAY_TOLERANCE);
- assertCondition(() -> testProcessor.operationNames.size() == 3, LONG_DELAY_TOLERANCE);
- assertEquals("@OnScheduled", testProcessor.operationNames.get(0));
- assertEquals("@OnUnscheduled", testProcessor.operationNames.get(1));
- assertEquals("@OnStopped", testProcessor.operationNames.get(2));
- }
-
- /**
- * Validates that Processor is eventually started once invocation of
- *
- * @OnSchedule stopped throwing exceptions.
- */
- @Test
- public void validateProcessScheduledAfterAdministrativeDelayDueToTheOnScheduledException() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
-
- // sets the scenario for the processor to run
- this.noop(testProcessor);
- testProcessor.generateExceptionOnScheduled = true;
- testProcessor.keepFailingOnScheduledTimes = 2;
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), LONG_DELAY_TOLERANCE);
- processScheduler.stopProcessor(testProcNode);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), SHORT_DELAY_TOLERANCE);
- }
-
- /**
- * Validates that Processor can be stopped when @OnScheduled constantly
- * fails. Basically validates that the re-try loop breaks if user initiated
- * stopProcessor.
- */
- @Test
- public void validateProcessorCanBeStoppedWhenOnScheduledConstantlyFails() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
-
- // sets the scenario for the processor to run
- this.longRunningOnUnschedule(testProcessor, 100);
- testProcessor.generateExceptionOnScheduled = true;
- testProcessor.keepFailingOnScheduledTimes = Integer.MAX_VALUE;
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), SHORT_DELAY_TOLERANCE);
- processScheduler.stopProcessor(testProcNode);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), SHORT_DELAY_TOLERANCE);
- }
-
- /**
- * Validates that the Processor can be stopped when @OnScheduled blocks
- * indefinitely but written to react to thread interrupts
- */
- @Test
- public void validateProcessorCanBeStoppedWhenOnScheduledBlocksIndefinitelyInterruptable() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest(NiFiProperties.PROCESSOR_SCHEDULING_TIMEOUT, "5 sec");
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
- // sets the scenario for the processor to run
- this.blockingInterruptableOnUnschedule(testProcessor);
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), SHORT_DELAY_TOLERANCE);
- processScheduler.stopProcessor(testProcNode);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), MEDIUM_DELAY_TOLERANCE);
- }
-
- /**
- * Validates that the Processor can be stopped when @OnScheduled blocks
- * indefinitely and written to ignore thread interrupts
- */
- @Test
- public void validateProcessorCanBeStoppedWhenOnScheduledBlocksIndefinitelyUninterruptable() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest(NiFiProperties.PROCESSOR_SCHEDULING_TIMEOUT, "1 sec");
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
- // sets the scenario for the processor to run
- this.blockingUninterruptableOnUnschedule(testProcessor);
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), MEDIUM_DELAY_TOLERANCE);
- processScheduler.stopProcessor(testProcNode);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), MEDIUM_DELAY_TOLERANCE);
- }
-
- /**
- * Validates that processor can be stopped if onTrigger() keeps throwing
- * exceptions.
- */
- @Test
- public void validateProcessorCanBeStoppedWhenOnTriggerThrowsException() throws Exception {
- final FlowManagerAndSystemBundle fcsb = this.buildFlowControllerForTest();
- flowManager = fcsb.getFlowManager();
-
- ProcessGroup testGroup = flowManager.createProcessGroup(UUID.randomUUID().toString());
- ProcessorNode testProcNode = flowManager.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(),
- fcsb.getSystemBundle().getBundleDetails().getCoordinate());
- testProcNode.setProperties(properties);
- TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
-
- // sets the scenario for the processor to run
- this.noop(testProcessor);
- testProcessor.generateExceptionOnTrigger = true;
-
- testProcNode.performValidation();
- processScheduler.startProcessor(testProcNode, true);
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), LONG_DELAY_TOLERANCE);
- processScheduler.disableProcessor(testProcNode);
- assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), LONG_DELAY_TOLERANCE);
- processScheduler.stopProcessor(testProcNode);
- assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), LONG_DELAY_TOLERANCE);
- }
-
-
- /**
- * Scenario where onTrigger() is executed with random delay limited to
- * 'delayLimit', yet with guaranteed exit from onTrigger().
- */
- private void randomOnTriggerDelay(TestProcessor testProcessor, int delayLimit) {
- EmptyRunnable emptyRunnable = new EmptyRunnable();
- RandomOrFixedDelayedRunnable delayedRunnable = new RandomOrFixedDelayedRunnable(delayLimit, true);
- testProcessor.setScenario(emptyRunnable, emptyRunnable, emptyRunnable, delayedRunnable);
- }
-
- /**
- * Scenario where @OnSchedule is executed with delay limited to
- * 'delayLimit'.
- */
- private void longRunningOnSchedule(TestProcessor testProcessor, int delayLimit) {
- EmptyRunnable emptyRunnable = new EmptyRunnable();
- RandomOrFixedDelayedRunnable delayedRunnable = new RandomOrFixedDelayedRunnable(delayLimit, false);
- testProcessor.setScenario(delayedRunnable, emptyRunnable, emptyRunnable, emptyRunnable);
- }
-
- /**
- * Scenario where @OnUnschedule is executed with delay limited to
- * 'delayLimit'.
- */
- private void longRunningOnUnschedule(TestProcessor testProcessor, int delayLimit) {
- EmptyRunnable emptyRunnable = new EmptyRunnable();
- RandomOrFixedDelayedRunnable delayedRunnable = new RandomOrFixedDelayedRunnable(delayLimit, false);
- testProcessor.setScenario(emptyRunnable, delayedRunnable, emptyRunnable, emptyRunnable);
- }
-
- /**
- * Scenario where @OnSchedule blocks indefinitely yet interruptible.
- */
- private void blockingInterruptableOnUnschedule(TestProcessor testProcessor) {
- EmptyRunnable emptyRunnable = new EmptyRunnable();
- BlockingInterruptableRunnable blockingRunnable = new BlockingInterruptableRunnable();
- testProcessor.setScenario(blockingRunnable, emptyRunnable, emptyRunnable, emptyRunnable);
- }
-
- /**
- * Scenario where @OnSchedule blocks indefinitely and un-interruptible.
- */
- private void blockingUninterruptableOnUnschedule(TestProcessor testProcessor) {
- EmptyRunnable emptyRunnable = new EmptyRunnable();
- BlockingUninterruptableRunnable blockingRunnable = new BlockingUninterruptableRunnable();
- testProcessor.setScenario(blockingRunnable, emptyRunnable, emptyRunnable, emptyRunnable);
- }
-
- /**
- * Scenario where all tasks are no op.
- */
- private void noop(TestProcessor testProcessor) {
- EmptyRunnable emptyRunnable = new EmptyRunnable();
- testProcessor.setScenario(emptyRunnable, emptyRunnable, emptyRunnable, emptyRunnable);
- }
-
- private FlowManagerAndSystemBundle buildFlowControllerForTest(final String propKey, final String propValue) throws Exception {
- final Map<String, String> addProps = new HashMap<>();
- addProps.put(NiFiProperties.ADMINISTRATIVE_YIELD_DURATION, "1 sec");
- addProps.put(NiFiProperties.STATE_MANAGEMENT_CONFIG_FILE, "target/test-classes/state-management.xml");
- addProps.put(NiFiProperties.STATE_MANAGEMENT_LOCAL_PROVIDER_ID, "local-provider");
- addProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
- addProps.put("nifi.remote.input.socket.port", "");
- addProps.put("nifi.remote.input.secure", "");
- if (propKey != null && propValue != null) {
- addProps.put(propKey, propValue);
- }
- final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, addProps);
-
- final Bundle systemBundle = SystemBundle.create(nifiProperties);
- final ExtensionDiscoveringManager extensionManager = new StandardExtensionDiscoveringManager();
- extensionManager.discoverExtensions(systemBundle, Collections.emptySet());
-
- final FlowController flowController = FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties,
- mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(),
- new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths()),
- extensionManager, mock(StatusHistoryRepository.class), null);
-
- final FlowManager flowManager = flowController.getFlowManager();
- this.processScheduler = flowController.getProcessScheduler();
-
- return new FlowManagerAndSystemBundle(flowManager, systemBundle);
- }
-
- private FlowManagerAndSystemBundle buildFlowControllerForTest() throws Exception {
- return buildFlowControllerForTest(null, null);
- }
-
-
- private static class FlowManagerAndSystemBundle {
-
- private final FlowManager flowManager;
- private final Bundle systemBundle;
-
- public FlowManagerAndSystemBundle(FlowManager flowManager, Bundle systemBundle) {
- this.flowManager = flowManager;
- this.systemBundle = systemBundle;
- }
-
- public FlowManager getFlowManager() {
- return flowManager;
- }
-
- public Bundle getSystemBundle() {
- return systemBundle;
- }
- }
-
- /**
- *
- */
- public static class TestProcessor extends AbstractProcessor {
- private static final Runnable NOP = () -> {
- };
-
- private Runnable onScheduleCallback = NOP;
- private Runnable onUnscheduleCallback = NOP;
- private Runnable onStopCallback = NOP;
- private Runnable onTriggerCallback = NOP;
-
- private boolean generateExceptionOnScheduled;
- private boolean generateExceptionOnTrigger;
-
- private boolean withService;
-
- private int keepFailingOnScheduledTimes;
-
- private int onScheduledExceptionCount;
-
- private final List<String> operationNames = new LinkedList<>();
-
- void setScenario(Runnable onScheduleCallback, Runnable onUnscheduleCallback, Runnable onStopCallback, Runnable onTriggerCallback) {
- this.onScheduleCallback = onScheduleCallback;
- this.onUnscheduleCallback = onUnscheduleCallback;
- this.onStopCallback = onStopCallback;
- this.onTriggerCallback = onTriggerCallback;
- }
-
- @OnScheduled
- public void schedule(ProcessContext ctx) {
- this.operationNames.add("@OnScheduled");
- if (this.generateExceptionOnScheduled
- && this.onScheduledExceptionCount++ < this.keepFailingOnScheduledTimes) {
- throw new RuntimeException("Intentional");
- }
- this.onScheduleCallback.run();
- }
-
- @OnUnscheduled
- public void unschedule() {
- this.operationNames.add("@OnUnscheduled");
- this.onUnscheduleCallback.run();
- }
-
- @OnStopped
- public void stop() {
- this.operationNames.add("@OnStopped");
- this.onStopCallback.run();
- }
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- PropertyDescriptor PROP = new PropertyDescriptor.Builder()
- .name("P")
- .description("Blah Blah")
- .required(true)
- .addValidator(new Validator() {
- @Override
- public ValidationResult validate(final String subject, final String value, final ValidationContext context) {
- return new ValidationResult.Builder().subject(subject).input(value).valid(value != null && !value.isEmpty()).explanation(subject + " cannot be empty").build();
- }
- })
- .build();
-
- PropertyDescriptor SERVICE = new PropertyDescriptor.Builder()
- .name("S")
- .description("Blah Blah")
- .required(true)
- .identifiesControllerService(ITestservice.class)
- .build();
-
- return this.withService ? Arrays.asList(PROP, SERVICE) : Arrays.asList(PROP);
- }
-
- @Override
- public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
- if (this.generateExceptionOnTrigger) {
- throw new RuntimeException("Intentional");
- }
- this.onTriggerCallback.run();
- }
- }
-
-
- public static class TestService extends AbstractControllerService implements ITestservice {
-
- }
-
- public static interface ITestservice extends ControllerService {
- }
-
-
- private static class EmptyRunnable implements Runnable {
-
- @Override
- public void run() {
-
- }
- }
-
-
- private static class BlockingInterruptableRunnable implements Runnable {
-
- @Override
- public void run() {
- try {
- Thread.sleep(Long.MAX_VALUE);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
- }
-
-
- private static class BlockingUninterruptableRunnable implements Runnable {
-
- @Override
- public void run() {
- while (true) {
- try {
- Thread.sleep(Long.MAX_VALUE);
- } catch (InterruptedException e) {
- // ignore
- }
- }
- }
- }
-
-
- private static class RandomOrFixedDelayedRunnable implements Runnable {
-
- private final int delayLimit;
- private final boolean randomDelay;
-
- public RandomOrFixedDelayedRunnable(int delayLimit, boolean randomDelay) {
- this.delayLimit = delayLimit;
- this.randomDelay = randomDelay;
- }
-
- Random random = new Random();
-
- @Override
- public void run() {
- try {
- if (this.randomDelay) {
- Thread.sleep(random.nextInt(this.delayLimit));
- } else {
- Thread.sleep(this.delayLimit);
- }
- } catch (InterruptedException e) {
- logger.warn("Interrupted while sleeping");
- Thread.currentThread().interrupt();
- }
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderIT.java
deleted file mode 100644
index 77cba0126c..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderIT.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * 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.controller.service;
-
-import org.apache.nifi.bundle.Bundle;
-import org.apache.nifi.bundle.BundleCoordinate;
-import org.apache.nifi.components.state.StateManager;
-import org.apache.nifi.components.state.StateManagerProvider;
-import org.apache.nifi.components.validation.ValidationTrigger;
-import org.apache.nifi.controller.ExtensionBuilder;
-import org.apache.nifi.controller.FlowController;
-import org.apache.nifi.controller.NodeTypeProvider;
-import org.apache.nifi.controller.ProcessScheduler;
-import org.apache.nifi.controller.ReloadComponent;
-import org.apache.nifi.controller.flow.FlowManager;
-import org.apache.nifi.controller.scheduling.StandardLifecycleStateManager;
-import org.apache.nifi.controller.scheduling.StandardProcessScheduler;
-import org.apache.nifi.controller.service.mock.MockProcessGroup;
-import org.apache.nifi.controller.service.mock.ServiceA;
-import org.apache.nifi.controller.service.mock.ServiceB;
-import org.apache.nifi.engine.FlowEngine;
-import org.apache.nifi.groups.ProcessGroup;
-import org.apache.nifi.nar.ExtensionDiscoveringManager;
-import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
-import org.apache.nifi.nar.SystemBundle;
-import org.apache.nifi.registry.VariableRegistry;
-import org.apache.nifi.util.NiFiProperties;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
-import org.mockito.Mockito;
-
-import java.beans.PropertyDescriptor;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class StandardControllerServiceProviderIT {
- private static Bundle systemBundle;
- private static NiFiProperties niFiProperties;
- private static ExtensionDiscoveringManager extensionManager;
- private static final VariableRegistry variableRegistry = VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY;
-
- private static final StateManagerProvider stateManagerProvider = new StateManagerProvider() {
- @Override
- public StateManager getStateManager(final String componentId) {
- return Mockito.mock(StateManager.class);
- }
-
- @Override
- public void shutdown() {
- }
-
- @Override
- public void enableClusterProvider() {
- }
-
- @Override
- public void disableClusterProvider() {
- }
-
- @Override
- public void onComponentRemoved(final String componentId) {
- }
- };
-
- @BeforeAll
- public static void setNiFiProps() {
- System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, TestStandardControllerServiceProvider.class.getResource("/conf/nifi.properties").getFile());
- niFiProperties = NiFiProperties.createBasicNiFiProperties(null);
-
- // load the system bundle
- systemBundle = SystemBundle.create(niFiProperties);
- extensionManager = new StandardExtensionDiscoveringManager();
- extensionManager.discoverExtensions(systemBundle, Collections.emptySet());
- }
-
- /**
- * We run the same test 1000 times and prior to bug fix (see NIFI-1143) it
- * would fail on some iteration. For more details please see
- * {@link PropertyDescriptor}.isDependentServiceEnableable() as well as
- * https://issues.apache.org/jira/browse/NIFI-1143
- */
- @Test
- @Timeout(120)
- public void testConcurrencyWithEnablingReferencingServicesGraph() throws InterruptedException, ExecutionException {
- final StandardProcessScheduler scheduler = new StandardProcessScheduler(new FlowEngine(1, "Unit Test", true), Mockito.mock(FlowController.class),
- stateManagerProvider, niFiProperties, new StandardLifecycleStateManager());
-
- for (int i = 0; i < 5000; i++) {
- testEnableReferencingServicesGraph(scheduler);
- }
- }
-
- private ControllerServiceNode createControllerService(final String type, final String id, final BundleCoordinate bundleCoordinate, final ControllerServiceProvider serviceProvider) {
- final ControllerServiceNode serviceNode = new ExtensionBuilder()
- .identifier(id)
- .type(type)
- .bundleCoordinate(bundleCoordinate)
- .controllerServiceProvider(serviceProvider)
- .processScheduler(Mockito.mock(ProcessScheduler.class))
- .nodeTypeProvider(Mockito.mock(NodeTypeProvider.class))
- .validationTrigger(Mockito.mock(ValidationTrigger.class))
- .reloadComponent(Mockito.mock(ReloadComponent.class))
- .variableRegistry(variableRegistry)
- .stateManagerProvider(Mockito.mock(StateManagerProvider.class))
- .extensionManager(extensionManager)
- .buildControllerService();
-
- serviceProvider.onControllerServiceAdded(serviceNode);
-
- return serviceNode;
- }
-
- public void testEnableReferencingServicesGraph(final StandardProcessScheduler scheduler) throws InterruptedException, ExecutionException {
- final FlowManager flowManager = Mockito.mock(FlowManager.class);
- final ProcessGroup procGroup = new MockProcessGroup(flowManager);
-
- Mockito.when(flowManager.getGroup(Mockito.anyString())).thenReturn(procGroup);
-
- final ControllerServiceProvider serviceProvider = new StandardControllerServiceProvider(scheduler, null, flowManager, extensionManager);
-
- // build a graph of controller services with dependencies as such:
- //
- // A -> B -> D
- // C ---^----^
- //
- // In other words, A references B, which references D.
- // AND
- // C references B and D.
- //
- // So we have to verify that if D is enabled, when we enable its referencing services,
- // we enable C and B, even if we attempt to enable C before B... i.e., if we try to enable C, we cannot do so
- // until B is first enabled so ensure that we enable B first.
- final ControllerServiceNode serviceNode1 = createControllerService(ServiceA.class.getName(), "1", systemBundle.getBundleDetails().getCoordinate(), serviceProvider);
- final ControllerServiceNode serviceNode2 = createControllerService(ServiceA.class.getName(), "2", systemBundle.getBundleDetails().getCoordinate(), serviceProvider);
- final ControllerServiceNode serviceNode3 = createControllerService(ServiceA.class.getName(), "3", systemBundle.getBundleDetails().getCoordinate(), serviceProvider);
- final ControllerServiceNode serviceNode4 = createControllerService(ServiceB.class.getName(), "4", systemBundle.getBundleDetails().getCoordinate(), serviceProvider);
-
- procGroup.addControllerService(serviceNode1);
- procGroup.addControllerService(serviceNode2);
- procGroup.addControllerService(serviceNode3);
- procGroup.addControllerService(serviceNode4);
-
- setProperty(serviceNode1, ServiceA.OTHER_SERVICE.getName(), "2");
- setProperty(serviceNode2, ServiceA.OTHER_SERVICE.getName(), "4");
- setProperty(serviceNode3, ServiceA.OTHER_SERVICE.getName(), "2");
- setProperty(serviceNode3, ServiceA.OTHER_SERVICE_2.getName(), "4");
-
- serviceNode4.performValidation();
- serviceProvider.enableControllerService(serviceNode4).get();
- serviceProvider.enableReferencingServices(serviceNode4);
-
- // Verify that the services are either ENABLING or ENABLED, and wait for all of them to become ENABLED.
- // Note that we set a timeout of 10 seconds, in case a bug occurs and the services never become ENABLED.
- final Set<ControllerServiceState> validStates = new HashSet<>();
- validStates.add(ControllerServiceState.ENABLED);
- validStates.add(ControllerServiceState.ENABLING);
-
- while (serviceNode3.getState() != ControllerServiceState.ENABLED || serviceNode2.getState() != ControllerServiceState.ENABLED || serviceNode1.getState() != ControllerServiceState.ENABLED) {
- assertTrue(validStates.contains(serviceNode3.getState()));
- assertTrue(validStates.contains(serviceNode2.getState()));
- assertTrue(validStates.contains(serviceNode1.getState()));
- }
- }
-
- private void setProperty(ControllerServiceNode serviceNode, String propName, String propValue) {
- Map<String, String> props = new LinkedHashMap<>();
- props.put(propName, propValue);
- serviceNode.setProperties(props);
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/AbstractFlowAnalysisIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/AbstractFlowAnalysisIT.java
deleted file mode 100644
index f1432604ca..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/AbstractFlowAnalysisIT.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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.flowanalysis;
-
-import org.apache.nifi.connectable.Connectable;
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.controller.FlowAnalysisRuleNode;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.flowanalysis.FlowAnalysisUtil;
-import org.apache.nifi.flow.VersionedProcessGroup;
-import org.apache.nifi.groups.ProcessGroup;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.integration.flowanalysis.DelegateFlowAnalysisRule;
-import org.apache.nifi.integration.processors.NopProcessor;
-import org.apache.nifi.nar.SystemBundle;
-import org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper;
-import org.junit.jupiter.api.BeforeEach;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.UUID;
-
-public abstract class AbstractFlowAnalysisIT extends FrameworkIntegrationTest {
- protected NiFiRegistryFlowMapper mapper;
-
- @BeforeEach()
- public void setUpAbstractFlowAnalysisIT() throws Exception {
- mapper = FlowAnalysisUtil.createMapper(getFlowController().getExtensionManager());
- }
-
- protected ProcessGroup createProcessGroup(ProcessGroup parent) {
- String id = UUID.randomUUID().toString();
-
- ProcessGroup processGroup = getFlowController().getFlowManager().createProcessGroup(id);
-
- processGroup.setName(id);
- processGroup.setParent(parent);
-
- parent.addProcessGroup(processGroup);
-
- return processGroup;
- }
-
- protected ProcessorNode createProcessorNode(ProcessGroup processGroup) {
- ProcessorNode processorNode = getFlowController().getFlowManager().createProcessor(
- NopProcessor.class.getSimpleName(),
- UUID.randomUUID().toString(),
- SystemBundle.SYSTEM_BUNDLE_COORDINATE,
- Collections.emptySet(),
- true,
- true,
- null
- );
-
- processGroup.addProcessor(processorNode);
-
- return processorNode;
- }
-
- protected Connection createConnection(
- ProcessGroup processGroup,
- String name,
- Connectable source,
- Connectable destination,
- Collection<String> relationshipNames
- ) {
- Connection connection = getFlowController().getFlowManager().createConnection(
- UUID.randomUUID().toString(),
- name,
- source,
- destination,
- relationshipNames
- );
-
- processGroup.addConnection(connection);
-
- return connection;
- }
-
- protected VersionedProcessGroup mapProcessGroup(ProcessGroup processGroup) {
- return mapper.mapProcessGroup(
- processGroup,
- getFlowController().getControllerServiceProvider(),
- getFlowController().getFlowManager(),
- true
- );
- }
-
- protected FlowAnalysisRuleNode createAndEnableFlowAnalysisRuleNode(FlowAnalysisRule flowAnalysisRule) {
- FlowAnalysisRuleNode flowAnalysisRuleNode = createFlowAnalysisRuleNode(flowAnalysisRule);
-
- flowAnalysisRuleNode.enable();
-
- return flowAnalysisRuleNode;
- }
-
- protected FlowAnalysisRuleNode createFlowAnalysisRuleNode(FlowAnalysisRule flowAnalysisRule) {
- final FlowAnalysisRuleNode flowAnalysisRuleNode = getFlowController().getFlowManager().createFlowAnalysisRule(
- DelegateFlowAnalysisRule.class.getName(),
- UUID.randomUUID().toString(),
- SystemBundle.SYSTEM_BUNDLE_COORDINATE,
- Collections.emptySet(),
- true,
- true,
- null
- );
-
- ((DelegateFlowAnalysisRule) flowAnalysisRuleNode.getFlowAnalysisRule()).setDelegate(flowAnalysisRule);
-
- return flowAnalysisRuleNode;
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/FlowAnalysisRuleLifeCycleIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/FlowAnalysisRuleLifeCycleIT.java
deleted file mode 100644
index 6c1cab7d0e..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/FlowAnalysisRuleLifeCycleIT.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * 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.flowanalysis;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.controller.ComponentNode;
-import org.apache.nifi.controller.FlowAnalysisRuleNode;
-import org.apache.nifi.controller.scheduling.TestStandardProcessScheduler;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.nar.SystemBundle;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-public class FlowAnalysisRuleLifeCycleIT extends AbstractFlowAnalysisIT {
- @Test
- public void testCreateRules() throws Exception {
- // GIVEN
- FlowAnalysisRuleNode rule1 = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
- FlowAnalysisRuleNode rule2 = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
-
- Set<FlowAnalysisRuleNode> expected = new HashSet<FlowAnalysisRuleNode>() {{
- add(rule1);
- add(rule2);
- }};
-
- // WHEN
- Set<FlowAnalysisRuleNode> actual = getFlowController().getFlowManager().getAllFlowAnalysisRules();
-
- // THEN
- assertEquals(expected, actual);
- }
-
- @Test
- public void testCannotDeleteEnabledRule() throws Exception {
- // GIVEN
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
-
- // WHEN
- try {
- getFlowController().getFlowManager().removeFlowAnalysisRule(rule);
- fail();
- } catch (IllegalStateException e) {
- // THEN
- assertEquals(
- "Cannot delete " + rule.getIdentifier() + " because it is enabled",
- e.getMessage()
- );
- }
- }
-
- @Test
- public void testDeleteRule() throws Exception {
- // GIVEN
- FlowAnalysisRuleNode rule1 = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
- FlowAnalysisRuleNode rule2 = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
-
- Set<FlowAnalysisRuleNode> expected = new HashSet<FlowAnalysisRuleNode>() {{
- add(rule2);
- }};
-
- // WHEN
- rule1.disable();
- getFlowController().getFlowManager().removeFlowAnalysisRule(rule1);
- Set<FlowAnalysisRuleNode> actual = getFlowController().getFlowManager().getAllFlowAnalysisRules();
-
- // THEN
- assertEquals(expected, actual);
- }
-
- @Test
- public void testCannotEnableEnabledRule() throws Exception {
- // GIVEN
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
-
- // WHEN
- try {
- rule.enable();
- fail();
- } catch (IllegalStateException e) {
- // THEN
- assertEquals(
- "Cannot enable " + rule.getIdentifier() + " because it is not disabled",
- e.getMessage()
- );
- }
- }
-
- @Test
- public void testCannotDisableDisabledRule() throws Exception {
- // GIVEN
- FlowAnalysisRuleNode rule = createFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
-
- // WHEN
- try {
- rule.disable();
- fail();
- } catch (IllegalStateException e) {
- // THEN
- assertEquals(
- "Cannot disable " + rule.getIdentifier() + " because it is already disabled",
- e.getMessage()
- );
- }
- }
-
- @Test
- public void testEnableAndDisableServiceEnablesAndDisablesReferencingRule() throws Exception {
- // GIVEN
- PropertyDescriptor controllerServiceReferencingPropertyDescriptor = new PropertyDescriptor.Builder()
- .name("controllerService")
- .identifiesControllerService(TestStandardProcessScheduler.SimpleTestService.class)
- .required(true)
- .build();
-
- FlowAnalysisRuleNode rule = createFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- List<PropertyDescriptor> propertyDescriptors = new ArrayList<>();
- propertyDescriptors.add(controllerServiceReferencingPropertyDescriptor);
-
- return propertyDescriptors;
- }
- });
-
- final ControllerServiceNode service = getFlowController().getFlowManager().createControllerService(
- TestStandardProcessScheduler.SimpleTestService.class.getName(),
- UUID.randomUUID().toString(),
- SystemBundle.SYSTEM_BUNDLE_COORDINATE,
- Collections.emptySet(),
- true,
- true,
- null
- );
- getFlowController().getFlowManager().addRootControllerService(service);
- service.resetValidationState();
-
- Map<String, String> ruleProperties = new HashMap<>();
- ruleProperties.put(controllerServiceReferencingPropertyDescriptor.getName(), service.getIdentifier());
- rule.setProperties(ruleProperties);
-
- // WHEN
- // THEN
- assertFalse(rule.isEnabled());
-
- getFlowController().getControllerServiceProvider().enableControllerService(service).get();
- service.awaitEnabled(5, TimeUnit.SECONDS);
- rule.resetValidationState();
- getFlowController().getControllerServiceProvider().scheduleReferencingComponents(service);
-
- assertTrue(rule.isEnabled());
-
- getFlowController().getControllerServiceProvider().disableControllerService(service).get();
- rule.resetValidationState();
- Map<ComponentNode, Future<Void>> futureMap = getFlowController().getControllerServiceProvider().unscheduleReferencingComponents(service);
- for (Future<Void> future : futureMap.values()) {
- future.get();
- }
-
- assertFalse(rule.isEnabled());
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/FlowAnalyzerIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/FlowAnalyzerIT.java
deleted file mode 100644
index 10f1cb93ba..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/flowanalysis/FlowAnalyzerIT.java
+++ /dev/null
@@ -1,1437 +0,0 @@
-/*
- * 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.flowanalysis;
-
-import org.apache.nifi.components.ValidationResult;
-import org.apache.nifi.components.validation.ValidationStatus;
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.controller.FlowAnalysisRuleNode;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.flow.VersionedComponent;
-import org.apache.nifi.flow.VersionedProcessGroup;
-import org.apache.nifi.groups.ProcessGroup;
-import org.apache.nifi.integration.cs.CounterControllerService;
-import org.apache.nifi.validation.RuleViolation;
-import org.apache.nifi.validation.RuleViolationsManager;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class FlowAnalyzerIT extends AbstractFlowAnalysisIT {
- public static final String EXPLANATION_PREFIX = "explanation_";
-
- private ExecutorService executorService;
- private StandardFlowAnalyzer standardFlowAnalyzer;
-
- private AtomicReference<CountDownLatch> startRunAnalysis = new AtomicReference<>();
- private AtomicReference<CountDownLatch> finishAnalysis = new AtomicReference<>();
-
- private AtomicReference<RuntimeException> groupAnalysisError = new AtomicReference<>();
-
- @BeforeEach
- public void setUpFlowAnalyzerIT() throws Exception {
- // By default, we don't wait
- startRunAnalysis.set(new CountDownLatch(0));
- finishAnalysis.set(new CountDownLatch(0));
-
- executorService = Executors.newSingleThreadExecutor();
- standardFlowAnalyzer = new StandardFlowAnalyzer(
- getFlowController().getFlowManager().getRuleViolationsManager(),
- getFlowController(),
- getExtensionManager()
- ) {
- @Override
- public void analyzeProcessGroup(VersionedProcessGroup processGroup) {
- if (groupAnalysisError.get() != null) {
- throw groupAnalysisError.get();
- }
-
- super.analyzeProcessGroup(processGroup);
-
- try {
- finishAnalysis.get().await();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
-
- }
- };
- standardFlowAnalyzer.initialize(getFlowController().getControllerServiceProvider());
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- executorService.shutdown();
- }
-
- @Test
- public void testAnalyzeProcessorNoRule() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- Collection<RuleViolation> expected = new HashSet<>();
-
- // WHEN
- // THEN
- testAnalyzeProcessor(processorNode, expected);
-
- }
-
- @Test
- public void testAnalyzeProcessorNoViolation() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- });
-
- Collection<RuleViolation> expected = new HashSet<>();
-
- // WHEN
- // THEN
- testAnalyzeProcessor(processorNode, expected);
- }
-
- @Test
- public void testAnalyzeProcessorDisableRuleBeforeAnalysis() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(
- analyzingComponent("disappearing_issueId", "Violation removed when rule is disabled")
- );
- flowAnalysisRuleNode.disable();
-
- Collection<RuleViolation> expected = new HashSet<>();
-
- // WHEN
- // THEN
- testAnalyzeProcessor(processorNode, expected);
- }
-
- @Test
- public void testAnalyzeProcessorProduceViolation() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(
- analyzingComponent(issueId, violationMessage)
- );
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- violationMessage,
- flowAnalysisRuleNode,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- )
- ));
-
- // WHEN
- // THEN
- testAnalyzeProcessor(processorNode, expected);
- }
-
- @Test
- public void testAnalyzeProcessorProduceMultipleViolations() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId1 = "issueId1";
- String violationMessage1 = "Violation 1";
-
- String issueId2 = "issueId2";
- String violationMessage2 = "Violation 2";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(
- analyzingComponent(new HashMap<String, String>() {{
- put(issueId1, violationMessage1);
- put(issueId2, violationMessage2);
- }})
- );
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId1,
- violationMessage1,
- flowAnalysisRuleNode,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- ),
- createRuleViolation(
- issueId2,
- violationMessage2,
- flowAnalysisRuleNode,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- )
- ));
-
- // WHEN
- // THEN
- testAnalyzeProcessor(processorNode, expected);
- }
-
- @Test
- public void testAnalyzeProcessorThenAnalyzeAgainWithDifferentResult() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId = "issueId";
- String violationMessage1 = "Previous violation gets overwritten";
- String violationMessage2 = "New violation";
-
- AtomicReference<String> violationMessageHolder = new AtomicReference<>(violationMessage1);
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<ComponentAnalysisResult> analyzeComponent(VersionedComponent component, FlowAnalysisRuleContext context) {
- ComponentAnalysisResult result = new ComponentAnalysisResult(
- issueId,
- violationMessageHolder.get(),
- EXPLANATION_PREFIX + violationMessageHolder.get()
- );
-
- return Collections.singleton(result);
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- violationMessage2,
- flowAnalysisRuleNode,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- )
- ));
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
- violationMessageHolder.set(violationMessage2);
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- // THEN
- checkActualViolations(expected);
- }
-
-
- @Test
- public void testAnalyzeProcessorProduceViolationFirstNoViolationSecond() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId = "disappearing_issueId";
- String violationMessage = "Violation removed when second analysis doesn't reproduce it";
-
- AtomicReference<String> violationMessageHolder = new AtomicReference<>(violationMessage);
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<ComponentAnalysisResult> analyzeComponent(VersionedComponent component, FlowAnalysisRuleContext context) {
- String violationMessage = violationMessageHolder.get();
-
- if (violationMessage != null) {
- ComponentAnalysisResult result = new ComponentAnalysisResult(
- issueId,
- violationMessageHolder.get()
- );
-
- return Collections.singleton(result);
- } else {
- return Collections.emptySet();
- }
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>();
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
- violationMessageHolder.set(null);
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testAnalyzeProcessorDisableRuleAfterAnalysis() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId = "disappearing_issueId";
- String violationMessage = "Violation removed when rule is disabled";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(analyzingComponent(issueId, violationMessage));
-
- Collection<RuleViolation> expectedBeforeDisable = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- violationMessage,
- flowAnalysisRuleNode,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- )
- ));
-
- Collection<RuleViolation> expectedAfterDisable = new HashSet<>();
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- // THEN
- checkActualViolations(expectedBeforeDisable);
-
- // WHEN
- flowAnalysisRuleNode.disable();
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- // THEN
- checkActualViolations(expectedAfterDisable);
- }
-
- @Test
- public void testAnalyzeProcessorAndControllerServiceWithSameRuleProduceIndependentViolations() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- ControllerServiceNode controllerServiceNode = createControllerServiceNode(CounterControllerService.class.getName());
-
- String issueId = "issueId";
- String violationMessage = "Same violation message for both processor node and controller service";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(analyzingComponent(issueId, violationMessage));
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- violationMessage,
- flowAnalysisRuleNode,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- ),
- createRuleViolation(
- issueId,
- violationMessage,
- flowAnalysisRuleNode,
- controllerServiceNode.getIdentifier(),
- controllerServiceNode.getIdentifier(),
- controllerServiceNode.getName(),
- controllerServiceNode.getProcessGroupIdentifier()
- )
- ));
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
- standardFlowAnalyzer.analyzeControllerService(controllerServiceNode);
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupDisableRuleBeforeAnalysis() throws Exception {
- // GIVEN
- String issueId = "disappearing_issueId";
- String violationMessage = "Violation removed when rule is disabled";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(analyzingProcessGroup(issueId, violationMessage));
-
- Collection<RuleViolation> expected = new HashSet<>();
-
- // WHEN
- // THEN
- rule.disable();
- testAnalyzeProcessGroup(versionedProcessGroup, expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupProduceViolation() throws Exception {
- // GIVEN
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(analyzingProcessGroup(issueId, violationMessage));
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- violationMessage,
- rule,
- processGroup.getIdentifier(),
- processGroup.getIdentifier(),
- processGroup.getName(),
- processGroup.getIdentifier()
- )
- ));
-
- // WHEN
- // THEN
- testAnalyzeProcessGroup(versionedProcessGroup, expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupWithProcessor() throws Exception {
- // GIVEN
- String groupViolationIssueId = "group_violation_issueId";
- String groupViolationMessage = "Group violation";
-
- String processorViolationIssueId = "processor_violation_IssueId";
- String processorViolationMessage = "Processor violation";
-
- ProcessGroup group = createProcessGroup(getRootGroup());
-
- ProcessorNode processorNode = createProcessorNode(group);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(group);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- results.add(newResultForGroup(groupViolationIssueId, groupViolationMessage));
-
- processGroup.getProcessors().stream()
- .map(processor -> newResultForComponent(processor, processorViolationIssueId, processorViolationMessage))
- .forEach(results::add);
-
- return results;
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- groupViolationIssueId,
- groupViolationMessage,
- rule,
- group.getIdentifier(),
- group.getIdentifier(),
- group.getName(),
- group.getIdentifier()
- ),
- createRuleViolation(
- processorViolationIssueId,
- processorViolationMessage,
- rule,
- group.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- group.getIdentifier()
- )
- ));
-
- // WHEN
- // THEN
- testAnalyzeProcessGroup(versionedProcessGroup, expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupWithConnectionThatHasNoName() throws Exception {
- // GIVEN
-
- String connectionViolationIssueId = "connection_violation_IssueId";
- String connectionViolationMessage = "Connection violation";
-
- ProcessGroup group = createProcessGroup(getRootGroup());
-
- ProcessorNode sourceProcessor = createProcessorNode(group);
- ProcessorNode destinationProcessor = createProcessorNode(group);
- Connection connection = createConnection(group, null, sourceProcessor, destinationProcessor, Arrays.asList("success", "other_relationship"));
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(group);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- processGroup.getConnections().stream()
- .map(connection -> newResultForComponent(connection, connectionViolationIssueId, connectionViolationMessage))
- .forEach(results::add);
-
- return results;
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- connectionViolationIssueId,
- connectionViolationMessage,
- rule,
- group.getIdentifier(),
- connection.getIdentifier(),
- sourceProcessor.getName() + " > " + "success,other_relationship",
- group.getIdentifier()
- )
- ));
-
- // WHEN
- // THEN
- testAnalyzeProcessGroup(versionedProcessGroup, expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupWithConnectionThatHasName() throws Exception {
- // GIVEN
-
- String connectionViolationIssueId = "connection_violation_IssueId";
- String connectionViolationMessage = "Connection violation";
-
- ProcessGroup group = createProcessGroup(getRootGroup());
-
- ProcessorNode sourceProcessor = createProcessorNode(group);
- ProcessorNode destinationProcessor = createProcessorNode(group);
- Connection connection = createConnection(group, "connectionName", sourceProcessor, destinationProcessor, Arrays.asList("success", "other_relationship"));
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(group);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- processGroup.getConnections().stream()
- .map(connection -> newResultForComponent(connection, connectionViolationIssueId, connectionViolationMessage))
- .forEach(results::add);
-
- return results;
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- connectionViolationIssueId,
- connectionViolationMessage,
- rule,
- group.getIdentifier(),
- connection.getIdentifier(),
- connection.getName(),
- group.getIdentifier()
- )
- ));
-
- // WHEN
- // THEN
- testAnalyzeProcessGroup(versionedProcessGroup, expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupAndProcessorWithDifferentRules() throws Exception {
- // GIVEN
- String groupViolationIssueId = "group_violation_issueId";
- String groupViolationMessage = "Group violation";
-
- String processorViolationIssueId = "processor_violation_issueId";
- String processorViolationMessage = "Processor violation";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
- ProcessorNode processorNode = createProcessorNode(processGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode processGroupAnalyzerRule = createAndEnableFlowAnalysisRuleNode(analyzingProcessGroup(groupViolationIssueId, groupViolationMessage));
- FlowAnalysisRuleNode processorAnalyzerRule = createAndEnableFlowAnalysisRuleNode(analyzingComponent(processorViolationIssueId, processorViolationMessage));
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- groupViolationIssueId,
- groupViolationMessage,
- processGroupAnalyzerRule,
- versionedProcessGroup.getIdentifier(),
- versionedProcessGroup.getIdentifier(),
- versionedProcessGroup.getName(),
- versionedProcessGroup.getIdentifier()
- ),
- createRuleViolation(
- processorViolationIssueId,
- processorViolationMessage,
- processorAnalyzerRule,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- )
- ));
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- // THEN
- checkActualViolations(expected);
-
- }
-
- @Test
- public void testAnalyzeProcessorIndividuallyAndAsPartOfGroup() throws Exception {
- // GIVEN
- String groupViolationIssueId = "group_violation_issueId";
- String groupViolationMessage = "Group violation";
-
- String processorViolationIssueIdInGroupAnalysis = "processor_inGroupAnalysis_violationIssueId";
- String processorViolationMessageInGroupAnalysis = "Processor violation when analyzed as part of the group";
-
- String processorViolationIssueIdInComponentAnalysis = "processor_inComponentAnalysis_ViolationMessage";
- String processorViolationMessageInComponentAnalysis = "Processor violation when analyzed as individual component";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
-
- ProcessorNode processorNode = createProcessorNode(processGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode processGroupAnalyzerRule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- results.add(newResultForGroup(groupViolationIssueId, groupViolationMessage));
-
- processGroup.getProcessors().stream()
- .map(processor -> newResultForComponent(processor, processorViolationIssueIdInGroupAnalysis, processorViolationMessageInGroupAnalysis))
- .forEach(results::add);
-
- return results;
- }
- });
-
- FlowAnalysisRuleNode processorAnalyzerRule = createAndEnableFlowAnalysisRuleNode(analyzingComponent(
- processorViolationIssueIdInComponentAnalysis,
- processorViolationMessageInComponentAnalysis
- ));
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- groupViolationIssueId,
- groupViolationMessage,
- processGroupAnalyzerRule,
- versionedProcessGroup.getIdentifier(),
- versionedProcessGroup.getIdentifier(),
- versionedProcessGroup.getName(),
- versionedProcessGroup.getIdentifier()
- ),
- createRuleViolation(
- processorViolationIssueIdInGroupAnalysis,
- processorViolationMessageInGroupAnalysis,
- processGroupAnalyzerRule,
- versionedProcessGroup.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- versionedProcessGroup.getIdentifier()
- ),
- createRuleViolation(
- processorViolationIssueIdInComponentAnalysis,
- processorViolationMessageInComponentAnalysis,
- processorAnalyzerRule,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- )
- ));
-
- // WHEN;
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testAnalyzeProcessorIndividuallyAndAsPartOfGroupButThenDisableGroupRule() throws Exception {
- // GIVEN
- String groupViolationIssueId = "disappearing_group_violation_issueId";
- String groupViolationMessage = "Group violation removed after rule is disabled";
-
- String processorViolationIssueIdInGroupAnalysis = "disappearing_processor_inGroupAnalysis_violationIssueId";
- String processorViolationMessageInGroupAnalysis = "Processor violation when analyzed as part of the group gets remove after rule is disabled";
-
- String processorViolationIssueIdInComponentAnalysis = "processor_inComponentAnalysis_violationIssueId";
- String processorViolationMessageInComponentAnalysis = "Processor violation when analyzed as individual component";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
-
- ProcessorNode processorNode = createProcessorNode(processGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode processGroupAnalyzerRule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- results.add(newResultForGroup(groupViolationIssueId, groupViolationMessage));
-
- processGroup.getProcessors().stream()
- .map(processor -> newResultForComponent(processor, processorViolationIssueIdInGroupAnalysis, processorViolationMessageInGroupAnalysis))
- .forEach(results::add);
-
- return results;
- }
- });
-
- FlowAnalysisRuleNode processorAnalyzerRule = createAndEnableFlowAnalysisRuleNode(analyzingComponent(
- processorViolationIssueIdInComponentAnalysis,
- processorViolationMessageInComponentAnalysis
- ));
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- processorViolationIssueIdInComponentAnalysis,
- processorViolationMessageInComponentAnalysis,
- processorAnalyzerRule,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processorNode.getProcessGroupIdentifier()
- )
- ));
-
- // WHEN;
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- processGroupAnalyzerRule.disable();
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testAnalyzeProcessorIndividuallyAndAsPartOfGroupButThenDisableProcessorRule() throws Exception {
- // GIVEN
- String groupViolationIssueId = "group_violation_issueId";
- String groupViolationMessage = "Group violation";
-
- String processorViolationIssueIdInGroupAnalysis = "processor_inGroupAnalysis_violationIssueId";
- String processorViolationMessageInGroupAnalysis = "Processor violation when analyzed as part of the group";
-
- String processorViolationIssueIdInComponentAnalysis = "disappearing_processor_inComponentAnalysis_ViolationMessage";
- String processorViolationMessageInComponentAnalysis = "Processor violation when analyzed as individual component removed when rule is disabled";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
-
- ProcessorNode processorNode = createProcessorNode(processGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode processGroupAnalyzerRule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- results.add(newResultForGroup(groupViolationIssueId, groupViolationMessage));
-
- processGroup.getProcessors().stream()
- .map(processor -> newResultForComponent(processor, processorViolationIssueIdInGroupAnalysis, processorViolationMessageInGroupAnalysis))
- .forEach(results::add);
-
- return results;
- }
- });
-
- FlowAnalysisRuleNode processorAnalyzerRule = createAndEnableFlowAnalysisRuleNode(analyzingComponent(
- processorViolationIssueIdInComponentAnalysis,
- processorViolationMessageInComponentAnalysis
- ));
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- groupViolationIssueId,
- groupViolationMessage,
- processGroupAnalyzerRule,
- versionedProcessGroup.getIdentifier(),
- versionedProcessGroup.getIdentifier(),
- versionedProcessGroup.getName(),
- versionedProcessGroup.getIdentifier()
- ),
- createRuleViolation(
- processorViolationIssueIdInGroupAnalysis,
- processorViolationMessageInGroupAnalysis,
- processGroupAnalyzerRule,
- versionedProcessGroup.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- versionedProcessGroup.getIdentifier()
- )
- ));
-
- // WHEN;
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- processorAnalyzerRule.disable();
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupWithGrandChildProcessGroupAllContainingProcessors() throws Exception {
- // GIVEN
- String processorViolationIssueId = "processor_violation";
- String processorViolationMessage = "Processor violation";
-
- String groupViolationIssueId = "group_violation";
- String groupViolationMessage = "Group violation";
-
- String groupScopedProcessorViolationIssueId = "group_scoped_processor_violation";
- String groupScopedProcessorViolationMessage = "Group scoped processor violation";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
- ProcessGroup childProcessGroup = createProcessGroup(processGroup);
- ProcessGroup grandChildProcessGroup = createProcessGroup(childProcessGroup);
-
- ProcessorNode processorNode = createProcessorNode(processGroup);
- ProcessorNode childProcessorNode = createProcessorNode(childProcessGroup);
- ProcessorNode grandChildProcessorNode = createProcessorNode(grandChildProcessGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<ComponentAnalysisResult> analyzeComponent(VersionedComponent component, FlowAnalysisRuleContext context) {
- Collection<ComponentAnalysisResult> results = new HashSet<>();
-
- results.add(new ComponentAnalysisResult(
- processorViolationIssueId,
- processorViolationMessage,
- EXPLANATION_PREFIX + processorViolationMessage
- ));
-
- return results;
- }
-
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- results.add(newResultForGroup(groupViolationIssueId, groupViolationMessage));
-
- processGroup.getProcessors().stream()
- .map(processor -> newResultForComponent(processor, groupScopedProcessorViolationIssueId, groupScopedProcessorViolationMessage))
- .forEach(results::add);
-
- return results;
- }
- });
-
- RuleViolation expectedProcessorViolation = createRuleViolation(
- processorViolationIssueId,
- processorViolationMessage,
- rule,
- processorNode.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processGroup.getIdentifier()
- );
- RuleViolation expectedChildProcessorViolation = createRuleViolation(
- processorViolationIssueId,
- processorViolationMessage,
- rule,
- childProcessorNode.getIdentifier(),
- childProcessorNode.getIdentifier(),
- childProcessorNode.getName(),
- childProcessGroup.getIdentifier()
- );
- RuleViolation expectedGrandChildProcessorViolation = createRuleViolation(
- processorViolationIssueId,
- processorViolationMessage,
- rule,
- grandChildProcessorNode.getIdentifier(),
- grandChildProcessorNode.getIdentifier(),
- grandChildProcessorNode.getName(),
- grandChildProcessGroup.getIdentifier()
- );
-
- RuleViolation expectedGroupScopedProcessorViolation = createRuleViolation(
- groupScopedProcessorViolationIssueId,
- groupScopedProcessorViolationMessage,
- rule,
- processGroup.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processGroup.getIdentifier()
- );
- RuleViolation expectedGroupScopedChildProcessorViolation = createRuleViolation(
- groupScopedProcessorViolationIssueId,
- groupScopedProcessorViolationMessage,
- rule,
- childProcessGroup.getIdentifier(),
- childProcessorNode.getIdentifier(),
- childProcessorNode.getName(),
- childProcessGroup.getIdentifier()
- );
- RuleViolation expectedGroupScopedGrandChildProcessorViolation = createRuleViolation(
- groupScopedProcessorViolationIssueId,
- groupScopedProcessorViolationMessage,
- rule,
- grandChildProcessGroup.getIdentifier(),
- grandChildProcessorNode.getIdentifier(),
- grandChildProcessorNode.getName(),
- grandChildProcessGroup.getIdentifier()
- );
- RuleViolation expectedGroupViolation = createRuleViolation(
- groupViolationIssueId,
- groupViolationMessage,
- rule,
- processGroup.getIdentifier(),
- processGroup.getIdentifier(),
- processGroup.getName(),
- processGroup.getIdentifier()
- );
- RuleViolation expectedChildGroupViolation = createRuleViolation(
- groupViolationIssueId,
- groupViolationMessage,
- rule,
- childProcessGroup.getIdentifier(),
- childProcessGroup.getIdentifier(),
- childProcessGroup.getName(),
- childProcessGroup.getIdentifier()
- );
- RuleViolation expectedGrandChildGroupViolation = createRuleViolation(
- groupViolationIssueId,
- groupViolationMessage,
- rule,
- grandChildProcessGroup.getIdentifier(),
- grandChildProcessGroup.getIdentifier(),
- grandChildProcessGroup.getName(),
- grandChildProcessGroup.getIdentifier()
- );
-
- Collection<RuleViolation> expectedAllViolations = new HashSet<>(Arrays.asList(
- expectedProcessorViolation,
- expectedChildProcessorViolation,
- expectedGrandChildProcessorViolation,
-
- expectedGroupScopedProcessorViolation,
- expectedGroupScopedChildProcessorViolation,
- expectedGroupScopedGrandChildProcessorViolation,
-
- expectedGroupViolation,
- expectedChildGroupViolation,
- expectedGrandChildGroupViolation
- ));
-
- Collection<RuleViolation> expectedAllProcessorViolations = new HashSet<>(Arrays.asList(
- expectedProcessorViolation,
- expectedGroupScopedProcessorViolation
- ));
- Collection<RuleViolation> expectedAllChildProcessorViolations = new HashSet<>(Arrays.asList(
- expectedChildProcessorViolation,
- expectedGroupScopedChildProcessorViolation
- ));
- Collection<RuleViolation> expectedAllGrandChildProcessorViolations = new HashSet<>(Arrays.asList(
- expectedGrandChildProcessorViolation,
- expectedGroupScopedGrandChildProcessorViolation
- ));
-
- Collection<RuleViolation> expectedAllGroupViolations = new HashSet<>(Arrays.asList(
- expectedProcessorViolation,
- expectedGroupScopedProcessorViolation,
- expectedGroupViolation
- ));
- Collection<RuleViolation> expectedAllChildGroupViolations = new HashSet<>(Arrays.asList(
- expectedChildProcessorViolation,
- expectedGroupScopedChildProcessorViolation,
- expectedChildGroupViolation
- ));
- Collection<RuleViolation> expectedAllGrandChildGroupViolations = new HashSet<>(Arrays.asList(
- expectedGrandChildProcessorViolation,
- expectedGroupScopedGrandChildProcessorViolation,
- expectedGrandChildGroupViolation
- ));
-
- // WHEN;
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
-
- // THEN
- checkActualViolations(expectedAllViolations);
-
-
- Collection<RuleViolation> actualAllProcessorViolations = getRuleViolationsManager().getRuleViolationsForSubject(processorNode.getIdentifier());
- assertEquals(expectedAllProcessorViolations, actualAllProcessorViolations);
-
- Collection<RuleViolation> actualAllChildProcessorViolations = getRuleViolationsManager().getRuleViolationsForSubject(childProcessorNode.getIdentifier());
- assertEquals(expectedAllChildProcessorViolations, actualAllChildProcessorViolations);
-
- Collection<RuleViolation> actualAllGrandChildProcessorViolations = getRuleViolationsManager().getRuleViolationsForSubject(grandChildProcessorNode.getIdentifier());
- assertEquals(expectedAllGrandChildProcessorViolations, actualAllGrandChildProcessorViolations);
-
-
- Collection<RuleViolation> actualAllGroupViolations = getRuleViolationsManager().getRuleViolationsForGroup(processGroup.getIdentifier());
- assertEquals(expectedAllGroupViolations, actualAllGroupViolations);
-
- Collection<RuleViolation> actualAllChildGroupViolations = getRuleViolationsManager().getRuleViolationsForGroup(childProcessGroup.getIdentifier());
- assertEquals(expectedAllChildGroupViolations, actualAllChildGroupViolations);
-
- Collection<RuleViolation> actualAllGrandChildGroupViolations = getRuleViolationsManager().getRuleViolationsForGroup(grandChildProcessGroup.getIdentifier());
- assertEquals(expectedAllGrandChildGroupViolations, actualAllGrandChildGroupViolations);
- }
-
- @Test
- public void testAnalyzeProcessGroupProduceViolationThenChildProcessGroupProduceNoViolation() throws Exception {
- // GIVEN
- String issueId = "issueId";
- String processorViolationMessage = "Violation";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
- ProcessGroup childProcessGroup = createProcessGroup(processGroup);
-
- ProcessorNode processorNode = createProcessorNode(processGroup);
- ProcessorNode childProcessorNode = createProcessorNode(childProcessGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
- VersionedProcessGroup versionedChildProcessGroup = mapProcessGroup(childProcessGroup);
-
- AtomicBoolean produceViolation = new AtomicBoolean(true);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- if (produceViolation.get()) {
- processGroup.getProcessors().stream()
- .map(processor -> newResultForComponent(processor, issueId, processorViolationMessage))
- .forEach(results::add);
- }
-
- return results;
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- processorViolationMessage,
- rule,
- processGroup.getIdentifier(),
- processorNode.getIdentifier(),
- processorNode.getName(),
- processGroup.getIdentifier()
- )
- ));
-
- // WHEN;
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
- produceViolation.set(false);
- standardFlowAnalyzer.analyzeProcessGroup(versionedChildProcessGroup);
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupWhereChildGroupProducesViolation() throws Exception {
- // GIVEN
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
- ProcessGroup childProcessGroup = createProcessGroup(processGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- if (processGroup.getIdentifier().equals(childProcessGroup.getIdentifier())) {
- GroupAnalysisResult result = newResultForGroup(issueId, violationMessage);
-
- results.add(result);
- }
-
- return results;
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- violationMessage,
- rule,
- childProcessGroup.getIdentifier(),
- childProcessGroup.getIdentifier(),
- childProcessGroup.getName(),
- childProcessGroup.getIdentifier()
- )
- ));
-
- // WHEN
- // THEN
- testAnalyzeProcessGroup(versionedProcessGroup, expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupNewParentAnalysisCanClearPreviousChildAnalysis() throws Exception {
- // GIVEN
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
- ProcessGroup childProcessGroup = createProcessGroup(processGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
- VersionedProcessGroup versionedChildProcessGroup = mapProcessGroup(childProcessGroup);
-
- AtomicBoolean produceChildViolation = new AtomicBoolean(true);
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- if (produceChildViolation.get() && processGroup.getIdentifier().equals(childProcessGroup.getIdentifier())) {
- GroupAnalysisResult result = newResultForGroup(issueId, violationMessage);
-
- results.add(result);
- }
-
- return results;
- }
- });
-
- Collection<RuleViolation> expected = Collections.emptySet();
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessGroup(versionedChildProcessGroup);
- produceChildViolation.set(false);
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testAnalyzeProcessGroupNewParentAnalysisOverridesPreviousChildAnalysis() throws Exception {
- // GIVEN
- String issueId = "issueId";
- String violationMessage1 = "Previous violation gets overwritten";
- String violationMessage2 = "New violation";
-
- ProcessGroup processGroup = createProcessGroup(getRootGroup());
- ProcessGroup childProcessGroup = createProcessGroup(processGroup);
-
- VersionedProcessGroup versionedProcessGroup = mapProcessGroup(processGroup);
- VersionedProcessGroup versionedChildProcessGroup = mapProcessGroup(childProcessGroup);
-
- AtomicReference<String> violationMessageWrapper = new AtomicReference<>();
-
- FlowAnalysisRuleNode rule = createAndEnableFlowAnalysisRuleNode(new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- Collection<GroupAnalysisResult> results = new HashSet<>();
-
- if (processGroup.getIdentifier().equals(childProcessGroup.getIdentifier())) {
- GroupAnalysisResult result = newResultForGroup(issueId, violationMessageWrapper.get());
-
- results.add(result);
- }
-
- return results;
- }
- });
-
- Collection<RuleViolation> expected = new HashSet<>(Arrays.asList(
- createRuleViolation(
- issueId,
- violationMessage2,
- rule,
- childProcessGroup.getIdentifier(),
- childProcessGroup.getIdentifier(),
- childProcessGroup.getName(),
- childProcessGroup.getIdentifier()
- )
- ));
-
- // WHEN
- violationMessageWrapper.set(violationMessage1);
- standardFlowAnalyzer.analyzeProcessGroup(versionedChildProcessGroup);
- violationMessageWrapper.set(violationMessage2);
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
-
- // THEN
- checkActualViolations(expected);
- }
-
- @Test
- public void testRecommendationDoesNotInvalidateComponent() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(analyzingComponent(issueId, violationMessage));
- flowAnalysisRuleNode.setEnforcementPolicy(EnforcementPolicy.WARN);
-
- Collection<ValidationResult> expected = Collections.emptyList();
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
- processorNode.performValidation();
-
- // THEN
- Collection<ValidationResult> actual = processorNode.getValidationErrors();
-
- assertEquals(expected, actual);
- }
-
- @Test
- public void testPolicyInvalidatesProcessor() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(analyzingComponent(issueId, violationMessage));
- flowAnalysisRuleNode.setEnforcementPolicy(EnforcementPolicy.ENFORCE);
-
- Collection<ValidationResult> expected = Arrays.asList(
- new ValidationResult.Builder()
- .subject(processorNode.getComponent().getClass().getSimpleName())
- .valid(false)
- .explanation(violationMessage)
- .build()
- );
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
- processorNode.performValidation();
-
- // THEN
- Collection<ValidationResult> actual = processorNode.getValidationErrors();
-
- assertEquals(expected, actual);
- }
-
- @Test
- public void testPolicyInvalidatesControllerService() throws Exception {
- // GIVEN
- ControllerServiceNode controllerServiceNode = createControllerServiceNode(CounterControllerService.class.getName());
-
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(analyzingComponent(issueId, violationMessage));
- flowAnalysisRuleNode.setEnforcementPolicy(EnforcementPolicy.ENFORCE);
-
- Collection<ValidationResult> expected = Arrays.asList(
- new ValidationResult.Builder()
- .subject(controllerServiceNode.getComponent().getClass().getSimpleName())
- .valid(false)
- .explanation(violationMessage)
- .build()
- );
-
- // WHEN
- standardFlowAnalyzer.analyzeControllerService(controllerServiceNode);
- controllerServiceNode.performValidation();
-
- // THEN
- Collection<ValidationResult> actual = controllerServiceNode.getValidationErrors();
-
- assertEquals(expected, actual);
- }
-
- @Test
- public void testChangingPolicyToRecommendationRemovesValidationError() throws Exception {
- // GIVEN
- ProcessorNode processorNode = createProcessorNode((context, session) -> {
- });
-
- String issueId = "issueId";
- String violationMessage = "Violation";
-
- FlowAnalysisRuleNode flowAnalysisRuleNode = createAndEnableFlowAnalysisRuleNode(analyzingComponent(issueId, violationMessage));
- flowAnalysisRuleNode.setEnforcementPolicy(EnforcementPolicy.ENFORCE);
-
- Collection<ValidationResult> expected = Arrays.asList();
-
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
- processorNode.performValidation();
-
- assertEquals(ValidationStatus.INVALID, processorNode.getValidationStatus());
-
- flowAnalysisRuleNode.setEnforcementPolicy(EnforcementPolicy.WARN);
-
- standardFlowAnalyzer.analyzeProcessor(processorNode);
- processorNode.performValidation();
-
- // THEN
- assertEquals(ValidationStatus.VALID, processorNode.getValidationStatus());
- Collection<ValidationResult> actual = processorNode.getValidationErrors();
-
- assertEquals(expected, actual);
- }
-
- private AbstractFlowAnalysisRule analyzingComponent(String issueId, String violationMessage) {
- AbstractFlowAnalysisRule rule = analyzingComponent(new HashMap<String, String>() {{
- put(issueId, violationMessage);
- }});
-
- return rule;
- }
-
- private AbstractFlowAnalysisRule analyzingComponent(HashMap<String, String> issueIdToViolationMessage) {
- AbstractFlowAnalysisRule rule = new AbstractFlowAnalysisRule() {
- @Override
- public Collection<ComponentAnalysisResult> analyzeComponent(VersionedComponent component, FlowAnalysisRuleContext context) {
- Set<ComponentAnalysisResult> results = issueIdToViolationMessage.entrySet().stream()
- .map(issueIdAndViolationMessage -> new ComponentAnalysisResult(
- issueIdAndViolationMessage.getKey(),
- issueIdAndViolationMessage.getValue(),
- EXPLANATION_PREFIX + issueIdAndViolationMessage.getValue())
- )
- .collect(Collectors.toSet());
-
- return results;
- }
- };
-
- return rule;
- }
-
- private AbstractFlowAnalysisRule analyzingProcessGroup(String issueId, String violationMessage) {
- return new AbstractFlowAnalysisRule() {
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- GroupAnalysisResult result = newResultForGroup(issueId, violationMessage);
-
- return Collections.singleton(result);
- }
- };
- }
-
- private GroupAnalysisResult newResultForGroup(String issueId, String violationMessage) {
- return GroupAnalysisResult.forGroup(issueId, violationMessage)
- .explanation(EXPLANATION_PREFIX + violationMessage)
- .build();
- }
-
- private GroupAnalysisResult newResultForComponent(VersionedComponent component, String issueId, String violationMessage) {
- return GroupAnalysisResult.forComponent(component, issueId, violationMessage)
- .explanation(EXPLANATION_PREFIX + violationMessage)
- .build();
- }
-
- private void testAnalyzeProcessor(ProcessorNode processorNode, Collection<RuleViolation> expected) {
- // WHEN
- standardFlowAnalyzer.analyzeProcessor(processorNode);
-
- // THEN
- checkActualViolations(expected);
- }
-
- private void testAnalyzeProcessGroup(VersionedProcessGroup versionedProcessGroup, Collection<RuleViolation> expected) {
- // WHEN
- standardFlowAnalyzer.analyzeProcessGroup(versionedProcessGroup);
-
- // THEN
- checkActualViolations(expected);
- }
-
- private void checkActualViolations(Collection<RuleViolation> expected) {
- Collection<RuleViolation> actual = getRuleViolationsManager().getAllRuleViolations();
-
- assertEquals(expected, actual);
- }
-
- private RuleViolation createRuleViolation(
- String issueId,
- String processorViolationMessage,
- FlowAnalysisRuleNode rule,
- String scope,
- String subjectId,
- String subjectDisplayName,
- String groupId
- ) {
- return new RuleViolation(
- rule.getEnforcementPolicy(),
- scope,
- subjectId,
- subjectDisplayName,
- groupId,
- rule.getIdentifier(),
- issueId,
- processorViolationMessage,
- "explanation_" + processorViolationMessage
- );
- }
-
- private RuleViolationsManager getRuleViolationsManager() {
- return getFlowController().getFlowManager().getRuleViolationsManager();
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/AlwaysAuthorizedAuthorizer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/AlwaysAuthorizedAuthorizer.java
deleted file mode 100644
index 872ac153da..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/AlwaysAuthorizedAuthorizer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.integration;
-
-import org.apache.nifi.authorization.AuthorizationRequest;
-import org.apache.nifi.authorization.AuthorizationResult;
-import org.apache.nifi.authorization.Authorizer;
-import org.apache.nifi.authorization.AuthorizerConfigurationContext;
-import org.apache.nifi.authorization.AuthorizerInitializationContext;
-import org.apache.nifi.authorization.exception.AuthorizationAccessException;
-import org.apache.nifi.authorization.exception.AuthorizerCreationException;
-import org.apache.nifi.authorization.exception.AuthorizerDestructionException;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class AlwaysAuthorizedAuthorizer implements Authorizer {
- private List<AuthorizationRequest> requests = new ArrayList<>();
-
- @Override
- public AuthorizationResult authorize(final AuthorizationRequest request) throws AuthorizationAccessException {
- requests.add(request);
- return AuthorizationResult.approved();
- }
-
- @Override
- public void initialize(final AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException {
- }
-
- @Override
- public void onConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
- }
-
- @Override
- public void preDestruction() throws AuthorizerDestructionException {
- }
-
- public List<AuthorizationRequest> getAuthorizationRequests() {
- return Collections.unmodifiableList(requests);
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/DirectInjectionExtensionManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/DirectInjectionExtensionManager.java
deleted file mode 100644
index 289ff528c1..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/DirectInjectionExtensionManager.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.integration;
-
-import org.apache.nifi.bundle.Bundle;
-import org.apache.nifi.bundle.BundleDetails;
-import org.apache.nifi.controller.ControllerService;
-import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
-import org.apache.nifi.nar.SystemBundle;
-import org.apache.nifi.parameter.ParameterProvider;
-import org.apache.nifi.processor.Processor;
-import org.apache.nifi.registry.flow.FlowRegistryClient;
-import org.apache.nifi.reporting.ReportingTask;
-
-import java.io.File;
-
-public class DirectInjectionExtensionManager extends StandardExtensionDiscoveringManager {
- private static final Bundle INTEGRATION_TEST_BUNDLE = new Bundle(new BundleDetails.Builder()
- .workingDir(new File("target"))
- .coordinate(SystemBundle.SYSTEM_BUNDLE_COORDINATE)
- .build(), ClassLoader.getSystemClassLoader());
-
- public void injectExtension(final Object extension) {
- final Class<?> extensionType;
- if (extension instanceof Processor) {
- extensionType = Processor.class;
- } else if (extension instanceof ControllerService) {
- extensionType = ControllerService.class;
- } else if (extension instanceof ReportingTask) {
- extensionType = ReportingTask.class;
- } else if (extension instanceof ParameterProvider) {
- extensionType = ParameterProvider.class;
- } else if (extension instanceof FlowRegistryClient) {
- extensionType = FlowRegistryClient.class;
- } else {
- throw new IllegalArgumentException("Given extension is not a Processor, Controller Service, or Reporting Task");
- }
-
- super.loadExtension(extension.getClass().getName(), extensionType, INTEGRATION_TEST_BUNDLE);
- }
-
- public void injectExtensionType(final Class<?> extensionType, final String implementationClassName) {
- final Class<?> implementationClass;
- try {
- implementationClass = Class.forName(implementationClassName, false, INTEGRATION_TEST_BUNDLE.getClassLoader());
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Could not find implementation class: " + implementationClassName);
- }
-
- injectExtensionType(extensionType, implementationClass);
- }
-
- public void injectExtensionType(final Class<?> extensionType, final Class<?> implementationClass) {
- super.registerExtensionClass(extensionType, implementationClass.getName(), INTEGRATION_TEST_BUNDLE);
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/FrameworkIntegrationTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/FrameworkIntegrationTest.java
deleted file mode 100644
index 1e62ac7c41..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/FrameworkIntegrationTest.java
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * 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.integration;
-
-import org.apache.nifi.admin.service.AuditService;
-import org.apache.nifi.authorization.Authorizer;
-import org.apache.nifi.bundle.Bundle;
-import org.apache.nifi.bundle.BundleCoordinate;
-import org.apache.nifi.cluster.coordination.ClusterCoordinator;
-import org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor;
-import org.apache.nifi.cluster.coordination.node.NodeConnectionState;
-import org.apache.nifi.cluster.coordination.node.NodeConnectionStatus;
-import org.apache.nifi.cluster.protocol.NodeIdentifier;
-import org.apache.nifi.cluster.protocol.NodeProtocolSender;
-import org.apache.nifi.cluster.protocol.StandardDataFlow;
-import org.apache.nifi.components.state.StateProvider;
-import org.apache.nifi.components.validation.ValidationStatus;
-import org.apache.nifi.connectable.Connectable;
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.connectable.StandardConnection;
-import org.apache.nifi.controller.ControllerService;
-import org.apache.nifi.controller.FileSystemSwapManager;
-import org.apache.nifi.controller.FlowController;
-import org.apache.nifi.controller.FlowSerializationStrategy;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.StandardSnippet;
-import org.apache.nifi.controller.XmlFlowSynchronizer;
-import org.apache.nifi.controller.flow.StandardFlowManager;
-import org.apache.nifi.controller.scheduling.StandardLifecycleStateManager;
-import org.apache.nifi.framework.cluster.leader.zookeeper.CuratorLeaderElectionManager;
-import org.apache.nifi.controller.leader.election.LeaderElectionManager;
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.queue.StandardFlowFileQueue;
-import org.apache.nifi.controller.repository.ContentRepository;
-import org.apache.nifi.controller.repository.FileSystemRepository;
-import org.apache.nifi.controller.repository.FlowFileEvent;
-import org.apache.nifi.controller.repository.FlowFileEventRepository;
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.controller.repository.FlowFileRepository;
-import org.apache.nifi.controller.repository.FlowFileSwapManager;
-import org.apache.nifi.controller.repository.QueueProvider;
-import org.apache.nifi.controller.repository.RepositoryContext;
-import org.apache.nifi.controller.repository.RepositoryStatusReport;
-import org.apache.nifi.controller.repository.WriteAheadFlowFileRepository;
-import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
-import org.apache.nifi.controller.repository.metrics.RingBufferEventRepository;
-import org.apache.nifi.controller.scheduling.RepositoryContextFactory;
-import org.apache.nifi.controller.scheduling.SchedulingAgent;
-import org.apache.nifi.controller.scheduling.StandardProcessScheduler;
-import org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent;
-import org.apache.nifi.controller.serialization.FlowSynchronizer;
-import org.apache.nifi.controller.serialization.StandardFlowSynchronizer;
-import org.apache.nifi.controller.serialization.VersionedFlowSynchronizer;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.controller.state.manager.StandardStateManagerProvider;
-import org.apache.nifi.controller.state.providers.local.WriteAheadLocalStateProvider;
-import org.apache.nifi.controller.status.history.StatusHistoryRepository;
-import org.apache.nifi.controller.status.history.VolatileComponentStatusRepository;
-import org.apache.nifi.encrypt.PropertyEncryptor;
-import org.apache.nifi.engine.FlowEngine;
-import org.apache.nifi.events.VolatileBulletinRepository;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.groups.BundleUpdateStrategy;
-import org.apache.nifi.groups.ProcessGroup;
-import org.apache.nifi.integration.processor.BiConsumerProcessor;
-import org.apache.nifi.integration.processors.GenerateProcessor;
-import org.apache.nifi.integration.processors.NopProcessor;
-import org.apache.nifi.integration.processors.TerminateAll;
-import org.apache.nifi.integration.processors.TerminateOnce;
-import org.apache.nifi.integration.processors.UsernamePasswordProcessor;
-import org.apache.nifi.logging.LogRepositoryFactory;
-import org.apache.nifi.nar.ExtensionManager;
-import org.apache.nifi.nar.SystemBundle;
-import org.apache.nifi.persistence.FlowConfigurationArchiveManager;
-import org.apache.nifi.persistence.FlowConfigurationDAO;
-import org.apache.nifi.persistence.StandardFlowConfigurationDAO;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Processor;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.provenance.ProvenanceEventRecord;
-import org.apache.nifi.provenance.ProvenanceEventRepository;
-import org.apache.nifi.provenance.ProvenanceEventType;
-import org.apache.nifi.provenance.ProvenanceRepository;
-import org.apache.nifi.provenance.WriteAheadProvenanceRepository;
-import org.apache.nifi.registry.VariableRegistry;
-import org.apache.nifi.reporting.BulletinRepository;
-import org.apache.nifi.scheduling.SchedulingStrategy;
-import org.apache.nifi.services.FlowService;
-import org.apache.nifi.util.FileUtils;
-import org.apache.nifi.util.NiFiProperties;
-import org.apache.nifi.validation.RuleViolationsManager;
-import org.apache.nifi.validation.StandardRuleViolationsManager;
-import org.apache.nifi.web.revision.RevisionManager;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.mockito.Mockito;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiConsumer;
-import java.util.stream.Collectors;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class FrameworkIntegrationTest {
- private static final Logger logger = LoggerFactory.getLogger(FrameworkIntegrationTest.class);
-
- private ResourceClaimManager resourceClaimManager;
- private StandardProcessScheduler processScheduler;
-
- private FlowEngine flowEngine;
- private FlowController flowController;
- private ProcessorNode nopProcessor;
- private ProcessorNode terminateProcessor;
- private ProcessorNode terminateAllProcessor;
- private FlowFileSwapManager flowFileSwapManager;
- private DirectInjectionExtensionManager extensionManager;
- private ProcessGroup rootProcessGroup;
- private Bundle systemBundle;
- private ClusterCoordinator clusterCoordinator;
- private NiFiProperties nifiProperties;
- private StatusHistoryRepository statusHistoryRepository;
- private RuleViolationsManager ruleViolationsManager;
-
- public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success").build();
-
- @BeforeEach
- public void setup() throws IOException {
- StandardStateManagerProvider.resetProvider();
-
- initialize();
-
- flowController.initializeFlow();
- createFlow();
- }
-
- protected String getNiFiPropertiesFilename() {
- if (isClusteredTest()) {
- return "src/test/resources/int-tests/clustered-nifi.properties";
- } else {
- return "src/test/resources/int-tests/default-nifi.properties";
- }
- }
-
- protected Map<String, String> getNiFiPropertiesOverrides() {
- return Collections.emptyMap();
- }
-
- protected void injectExtensionTypes(final DirectInjectionExtensionManager extensionManager) {
- // Placeholder for subclasses.
- }
-
- protected final void initialize() throws IOException {
- final Map<String, String> propertyOverrides = new HashMap<>(getNiFiPropertiesOverrides());
- if (isClusteredTest()) {
- propertyOverrides.put(NiFiProperties.CLUSTER_IS_NODE, "true");
- propertyOverrides.put(NiFiProperties.FLOW_CONFIGURATION_FILE, "target/int-tests/flow.xml.gz");
- }
-
- final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(getNiFiPropertiesFilename(), propertyOverrides);
- initialize(nifiProperties);
- }
-
- protected final void initialize(final NiFiProperties nifiProperties) throws IOException {
- this.nifiProperties = nifiProperties;
-
- final FlowFileEventRepository flowFileEventRepository = new RingBufferEventRepository(5);
-
- final BulletinRepository bulletinRepo = new VolatileBulletinRepository();
- flowEngine = new FlowEngine(4, "unit test flow engine");
- extensionManager = new DirectInjectionExtensionManager();
-
- extensionManager.injectExtensionType(FlowFileRepository.class, WriteAheadFlowFileRepository.class);
- extensionManager.injectExtensionType(ContentRepository.class, FileSystemRepository.class);
- extensionManager.injectExtensionType(ProvenanceRepository.class, WriteAheadProvenanceRepository.class);
- extensionManager.injectExtensionType(StateProvider.class, WriteAheadLocalStateProvider.class);
- extensionManager.injectExtensionType(StatusHistoryRepository.class, VolatileComponentStatusRepository.class);
- extensionManager.injectExtensionType(FlowFileSwapManager.class, FileSystemSwapManager.class);
-
- extensionManager.injectExtensionType(Processor.class, BiConsumerProcessor.class);
- extensionManager.injectExtensionType(Processor.class, GenerateProcessor.class);
- extensionManager.injectExtensionType(Processor.class, TerminateOnce.class);
- extensionManager.injectExtensionType(Processor.class, TerminateAll.class);
- extensionManager.injectExtensionType(Processor.class, NopProcessor.class);
- extensionManager.injectExtensionType(Processor.class, UsernamePasswordProcessor.class);
-
- injectExtensionTypes(extensionManager);
- systemBundle = SystemBundle.create(nifiProperties);
- extensionManager.discoverExtensions(systemBundle, Collections.emptySet());
-
- statusHistoryRepository = Mockito.mock(StatusHistoryRepository.class);
-
- ruleViolationsManager = new StandardRuleViolationsManager();
-
- final PropertyEncryptor encryptor = createEncryptor();
- final Authorizer authorizer = new AlwaysAuthorizedAuthorizer();
- final AuditService auditService = new NopAuditService();
-
- if (isClusteredTest()) {
- final File zookeeperDir = new File("target/state/zookeeper");
- final File version2Dir = new File(zookeeperDir, "version-2");
-
- if (!version2Dir.exists()) {
- assertTrue(version2Dir.mkdirs());
- }
-
- final File[] children = version2Dir.listFiles();
- if (children != null) {
- for (final File file : children) {
- FileUtils.deleteFile(file, true);
- }
- }
-
- clusterCoordinator = Mockito.mock(ClusterCoordinator.class);
- final HeartbeatMonitor heartbeatMonitor = Mockito.mock(HeartbeatMonitor.class);
- final NodeProtocolSender protocolSender = Mockito.mock(NodeProtocolSender.class);
-
- final LeaderElectionManager leaderElectionManager = new CuratorLeaderElectionManager(nifiProperties);
-
- final NodeIdentifier localNodeId = new NodeIdentifier(UUID.randomUUID().toString(), "localhost", 8111, "localhost", 8081,
- "localhost", 8082, "localhost", 8083, 8084, false, Collections.emptySet());
- final NodeIdentifier node2Id = new NodeIdentifier(UUID.randomUUID().toString(), "localhost", 8222, "localhost", 8081,
- "localhost", 8082, "localhost", 8083, 8084, false, Collections.emptySet());
-
- final Set<NodeIdentifier> nodeIdentifiers = new HashSet<>();
- nodeIdentifiers.add(localNodeId);
- nodeIdentifiers.add(node2Id);
- Mockito.when(clusterCoordinator.getNodeIdentifiers()).thenReturn(nodeIdentifiers);
- Mockito.when(clusterCoordinator.getLocalNodeIdentifier()).thenReturn(localNodeId);
-
- flowController = FlowController.createClusteredInstance(flowFileEventRepository, nifiProperties, authorizer, auditService, encryptor, protocolSender,
- bulletinRepo, clusterCoordinator, heartbeatMonitor, leaderElectionManager, VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY,
- extensionManager, Mockito.mock(RevisionManager.class), statusHistoryRepository, ruleViolationsManager);
-
- flowController.setClustered(true, UUID.randomUUID().toString());
- flowController.setNodeId(localNodeId);
-
- flowController.setConnectionStatus(new NodeConnectionStatus(localNodeId, NodeConnectionState.CONNECTED));
- } else {
- flowController = FlowController.createStandaloneInstance(flowFileEventRepository, nifiProperties, authorizer, auditService, encryptor, bulletinRepo,
- VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY, extensionManager, statusHistoryRepository, ruleViolationsManager);
- }
-
- processScheduler = new StandardProcessScheduler(flowEngine, flowController, flowController.getStateManagerProvider(), nifiProperties, new StandardLifecycleStateManager());
-
- final RepositoryContextFactory repositoryContextFactory = flowController.getRepositoryContextFactory();
- final SchedulingAgent timerDrivenSchedulingAgent = new TimerDrivenSchedulingAgent(flowController, flowEngine, repositoryContextFactory, nifiProperties);
- processScheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, timerDrivenSchedulingAgent);
-
- flowFileSwapManager = flowController.createSwapManager();
- resourceClaimManager = flowController.getResourceClaimManager();
- }
-
- protected void createFlow() {
- rootProcessGroup = flowController.getFlowManager().createProcessGroup(UUID.randomUUID().toString());
- rootProcessGroup.setName("Integration Test");
-
- ((StandardFlowManager) flowController.getFlowManager()).setRootGroup(rootProcessGroup);
-
- nopProcessor = createProcessorNode(NopProcessor.class);
- terminateProcessor = createProcessorNode(TerminateOnce.class);
- terminateAllProcessor = createProcessorNode(TerminateAll.class);
- }
-
- protected boolean isClusteredTest() {
- return false;
- }
-
- protected ClusterCoordinator getClusterCoordinator() {
- return clusterCoordinator;
- }
-
- @AfterEach
- public final void shutdown() throws IOException {
- logger.info("Shutting down...");
-
- if (flowController != null) {
- flowController.shutdown(true);
- }
-
- if (flowEngine != null) {
- flowEngine.shutdownNow();
- }
-
- if (processScheduler != null) {
- processScheduler.shutdown();
- }
-
- deleteDirectory(new File("target/int-tests"));
- }
-
- protected void restart() throws IOException, ExecutionException, InterruptedException {
- logger.info("Shutting down for restart....");
-
- // Save Flow to a byte array
- final FlowConfigurationDAO flowDao = new StandardFlowConfigurationDAO(nifiProperties, getExtensionManager(), FlowSerializationStrategy.WRITE_XML_AND_JSON);
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- flowDao.save(flowController, baos);
- final byte[] flowBytes = baos.toByteArray();
-
- // Shutdown
- flowController.shutdown(true);
- flowEngine.shutdownNow();
- StandardStateManagerProvider.resetProvider();
-
- // Remove all Log Repositories so that we can restart with the same ID's
- for (final ProcessorNode procNode : rootProcessGroup.getProcessors()) {
- LogRepositoryFactory.removeRepository(procNode.getIdentifier());
- }
-
- // Re-initialize the framework components
- initialize();
-
- // Reload the flow
- final XmlFlowSynchronizer xmlFlowSynchronizer = new XmlFlowSynchronizer(nifiProperties, extensionManager);
- final File storageFile = new File("target/int-tests/flow.json.gz");
- final VersionedFlowSynchronizer versionedFlowSynchronizer = new VersionedFlowSynchronizer(extensionManager, storageFile, new FlowConfigurationArchiveManager(nifiProperties));
- final FlowSynchronizer flowSynchronizer = new StandardFlowSynchronizer(xmlFlowSynchronizer, versionedFlowSynchronizer);
- flowController.synchronize(flowSynchronizer, new StandardDataFlow(flowBytes, null, null, Collections.emptySet()), Mockito.mock(FlowService.class),
- BundleUpdateStrategy.USE_SPECIFIED_OR_COMPATIBLE_OR_GHOST);
-
- // Reload FlowFiles / initialize flow
- final ProcessGroup newRootGroup = flowController.getFlowManager().getRootGroup();
- rootProcessGroup = newRootGroup;
- final QueueProvider queueProvider = new QueueProvider() {
- @Override
- public Collection<FlowFileQueue> getAllQueues() {
- return newRootGroup.findAllConnections().stream()
- .map(Connection::getFlowFileQueue)
- .collect(Collectors.toList());
- }
- };
-
- flowController.initializeFlow(queueProvider);
- }
-
- private void deleteDirectory(final File dir) throws IOException {
- if (!dir.exists()) {
- return;
- }
-
- FileUtils.deleteFile(dir, true);
- }
-
- protected FlowFileQueue createFlowFileQueue(final String uuid, final ProcessGroup processGroup) {
- final RepositoryContext repoContext = getRepositoryContext();
- return new StandardFlowFileQueue(uuid, repoContext.getFlowFileRepository(), repoContext.getProvenanceRepository(),
- resourceClaimManager, processScheduler, flowFileSwapManager, flowController.createEventReporter(), 20000,
- processGroup.getDefaultFlowFileExpiration(), processGroup.getDefaultBackPressureObjectThreshold(), processGroup.getDefaultBackPressureDataSizeThreshold());
- }
-
- protected final ProcessorNode createProcessorNode(final Class<? extends Processor> processorType) {
- return createProcessorNode(processorType.getName());
- }
-
- protected final ProcessorNode createProcessorNode(final Class<? extends Processor> processorType, final ProcessGroup destination) {
- return createProcessorNode(processorType.getName(), destination);
- }
-
- protected final ProcessorNode createProcessorNode(final String processorType) {
- return createProcessorNode(processorType, rootProcessGroup);
- }
-
- protected final ProcessorNode createProcessorNode(final String processorType, final ProcessGroup destination) {
- final String uuid = getSimpleTypeName(processorType) + "-" + UUID.randomUUID();
- final BundleCoordinate bundleCoordinate = SystemBundle.SYSTEM_BUNDLE_COORDINATE;
- final ProcessorNode procNode = flowController.getFlowManager().createProcessor(processorType, uuid, bundleCoordinate, Collections.emptySet(), true, true, null);
- if (destination != null) {
- destination.addProcessor(procNode);
- }
-
- return procNode;
- }
-
- protected final ControllerServiceNode createControllerServiceNode(final Class<? extends ControllerService> controllerServiceType) {
- return createControllerServiceNode(controllerServiceType.getName());
- }
-
- protected final ControllerServiceNode createControllerServiceNode(final String controllerServiceType) {
- final String uuid = getSimpleTypeName(controllerServiceType) + "-" + UUID.randomUUID();
- final BundleCoordinate bundleCoordinate = SystemBundle.SYSTEM_BUNDLE_COORDINATE;
- final ControllerServiceNode serviceNode = flowController.getFlowManager().createControllerService(controllerServiceType, uuid, bundleCoordinate, Collections.emptySet(), true, true, null);
- rootProcessGroup.addControllerService(serviceNode);
- return serviceNode;
- }
-
- private String getSimpleTypeName(final String className) {
- final int index = className.lastIndexOf(".");
- if (index >= 0 && index < className.length()) {
- return className.substring(index + 1);
- } else {
- return "";
- }
- }
-
- protected ProcessGroup getRootGroup() {
- return rootProcessGroup;
- }
-
- /**
- * Creates a Processor that is responsible for generating a FlowFile of the given size and routing to "success".
- *
- * @param contentSize the number of bytes for the content
- *
- * @return the ProcessorNode
- */
- protected final ProcessorNode createGenerateProcessor(final int contentSize) {
- return createGenerateProcessor(contentSize, null);
- }
-
- /**
- * Creates a Processor that is responsible for generating a FlowFile of the given size and routing to "success". The generated FlowFile is set in the given AtomicReference
- *
- * @param contentSize the number of bytes for the content
- * @param flowFileReference an AtomicReference to hold the flowfile
- *
- * @return the ProcessorNode
- */
- protected final ProcessorNode createGenerateProcessor(final int contentSize, final AtomicReference<FlowFileRecord> flowFileReference) {
- return createProcessorNode((context, session) -> {
- FlowFile flowFile = session.create();
- flowFile = session.write(flowFile, out -> out.write(new byte[contentSize]));
-
- if (flowFileReference != null) {
- flowFileReference.set((FlowFileRecord) flowFile);
- }
-
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
- }
-
- protected final ProcessorNode createProcessorNode(final BiConsumer<ProcessContext, ProcessSession> trigger, final Relationship... relationships) {
- final Set<Relationship> relationshipSet = new HashSet<>(Arrays.asList(relationships));
-
- final ProcessorNode processorNode = createProcessorNode(BiConsumerProcessor.class.getName());
- final BiConsumerProcessor biConsumerProcessor = (BiConsumerProcessor) processorNode.getProcessor();
- biConsumerProcessor.setRelationships(relationshipSet);
- biConsumerProcessor.setTrigger(trigger);
-
- return processorNode;
- }
-
- protected final Connection connect(final Connectable source, final Connectable destination, final Relationship relationship) {
- return connect(source, destination, Collections.singleton(relationship));
- }
-
- protected final Connection connect(final Connectable source, final Connectable destination, final Collection<Relationship> relationships) {
- return connect(rootProcessGroup, source, destination, relationships);
- }
-
- protected final Connection connect(ProcessGroup processGroup, final Connectable source, final Connectable destination, final Collection<Relationship> relationships) {
- final String id = UUID.randomUUID().toString();
- final Connection connection = new StandardConnection.Builder(processScheduler)
- .source(source)
- .destination(destination)
- .processGroup(processGroup)
- .relationships(relationships)
- .id(id)
- .clustered(false)
- .flowFileQueueFactory((loadBalanceStrategy, partitioningAttribute, processGroup1) -> createFlowFileQueue(id, processGroup))
- .build();
-
- source.addConnection(connection);
- destination.addConnection(connection);
- processGroup.addConnection(connection);
-
- return connection;
- }
-
- protected final Future<Void> start(final ProcessorNode procNode) {
- final ValidationStatus validationStatus = procNode.performValidation();
- if (validationStatus != ValidationStatus.VALID) {
- throw new IllegalStateException("Processor is invalid: " + procNode + ": " + procNode.getValidationErrors());
- }
-
- return procNode.getProcessGroup().startProcessor(procNode, true);
- }
-
- protected final Future<Void> stop(final ProcessorNode procNode) {
- return procNode.getProcessGroup().stopProcessor(procNode);
- }
-
- protected final FlowFileQueue getDestinationQueue(final ProcessorNode procNode, final Relationship relationship) {
- return procNode.getConnections(relationship).stream()
- .map(Connection::getFlowFileQueue)
- .findAny()
- .orElseThrow(() -> new IllegalArgumentException("Could not find queue for relationship with name <" + relationship + ">"));
- }
-
- protected final FlowFileRepository getFlowFileRepository() {
- return getRepositoryContext().getFlowFileRepository();
- }
-
- protected Bundle getSystemBundle() {
- return systemBundle;
- }
-
- protected final ContentRepository getContentRepository() {
- return getRepositoryContext().getContentRepository();
- }
-
- protected final ProvenanceEventRepository getProvenanceRepository() {
- return getRepositoryContext().getProvenanceRepository();
- }
-
- protected RepositoryContext getRepositoryContext() {
- return flowController.getRepositoryContextFactory().newProcessContext(nopProcessor, new AtomicLong(0L));
- }
-
- protected final ProcessorNode getNopProcessor() {
- return nopProcessor;
- }
-
- protected final ProcessorNode getTerminateProcessor() {
- return terminateProcessor;
- }
-
- protected final ProcessorNode getTerminateAllProcessor() {
- return terminateAllProcessor;
- }
-
- protected final FlowController getFlowController() {
- return flowController;
- }
-
- protected void assertProvenanceEventCount(final ProvenanceEventType eventType, final int count) throws IOException {
- int encountered = 0;
-
- for (final ProvenanceEventRecord event : getProvenanceRepository().getEvents(0L, 100_000_000)) {
- if (event.getEventType() == eventType) {
- encountered++;
- }
- }
-
- assertEquals(count, encountered, "Expected to encounter " + count + " Provenance Events of type " + eventType + " but encountered " + encountered);
- }
-
- protected void triggerOnce(final ProcessorNode processor) throws ExecutionException, InterruptedException {
- final String schedulingPeriod = processor.getSchedulingPeriod();
- final FlowFileEvent initialReport = getStatusReport(processor);
- final int initialInvocations = (initialReport == null) ? 0 : initialReport.getInvocations();
-
- processor.setSchedulingPeriod("1 hour");
-
- // We will only trigger the Processor to run once per hour. So we need to ensure that
- // we don't trigger the Processor while it's yielded. So if its yield expiration is in the future,
- // wait until the yield expires.
- while (processor.getYieldExpiration() > System.currentTimeMillis()) {
- Thread.sleep(1L);
- }
-
- start(processor).get();
-
- int totalInvocations = initialInvocations;
- while (totalInvocations < initialInvocations + 1) {
- final FlowFileEvent currentReport = getStatusReport(processor);
- totalInvocations = currentReport == null ? 0 : currentReport.getInvocations();
- }
-
- stop(processor).get();
- processor.setSchedulingPeriod(schedulingPeriod);
- }
-
- protected FlowFileEvent getStatusReport(final ProcessorNode processor) {
- final FlowFileEventRepository repository = getRepositoryContext().getFlowFileEventRepository();
- RepositoryStatusReport statusReport = repository.reportTransferEvents(0L);
- return statusReport.getReportEntry(processor.getIdentifier());
- }
-
- protected void moveProcessor(final ProcessorNode processor, final ProcessGroup destination) {
- final StandardSnippet snippet = new StandardSnippet();
- snippet.setParentGroupId(processor.getProcessGroupIdentifier());
- snippet.addProcessors(Collections.singletonMap(processor.getIdentifier(), null));
-
- processor.getProcessGroup().move(snippet, destination);
- }
-
- protected ExtensionManager getExtensionManager() {
- return extensionManager;
- }
-
- private PropertyEncryptor createEncryptor() {
- return new PropertyEncryptor() {
- @Override
- public String encrypt(String property) {
- return property;
- }
-
- @Override
- public String decrypt(String encryptedProperty) {
- return encryptedProperty;
- }
- };
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/NopAuditService.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/NopAuditService.java
deleted file mode 100644
index e0e84f576b..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/NopAuditService.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.integration;
-
-import org.apache.nifi.action.Action;
-import org.apache.nifi.admin.service.AuditService;
-import org.apache.nifi.history.History;
-import org.apache.nifi.history.HistoryQuery;
-import org.apache.nifi.history.PreviousValue;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-public class NopAuditService implements AuditService {
- @Override
- public void addActions(final Collection<Action> actions) {
-
- }
-
- @Override
- public Map<String, List<PreviousValue>> getPreviousValues(final String componentId) {
- return null;
- }
-
- @Override
- public void deletePreviousValues(String propertyName, String componentId) {
- }
-
- @Override
- public History getActions(final HistoryQuery actionQuery) {
- return null;
- }
-
- @Override
- public History getActions(final int firstActionId, final int maxActions) {
- return null;
- }
-
- @Override
- public Action getAction(final Integer actionId) {
- return null;
- }
-
- @Override
- public void purgeActions(final Date end, final Action purgeAction) {
-
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/AlwaysAuthenticate.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/AlwaysAuthenticate.java
deleted file mode 100644
index 9640be5e78..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/AlwaysAuthenticate.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.integration.auth;
-
-import org.apache.nifi.authentication.AuthenticationResponse;
-import org.apache.nifi.authentication.LoginCredentials;
-import org.apache.nifi.authentication.LoginIdentityProvider;
-import org.apache.nifi.authentication.LoginIdentityProviderConfigurationContext;
-import org.apache.nifi.authentication.LoginIdentityProviderInitializationContext;
-import org.apache.nifi.authentication.exception.IdentityAccessException;
-import org.apache.nifi.authentication.exception.InvalidLoginCredentialsException;
-import org.apache.nifi.authentication.exception.ProviderCreationException;
-import org.apache.nifi.authentication.exception.ProviderDestructionException;
-
-public class AlwaysAuthenticate implements LoginIdentityProvider {
- @Override
- public AuthenticationResponse authenticate(final LoginCredentials credentials) throws InvalidLoginCredentialsException, IdentityAccessException {
- return new AuthenticationResponse(credentials.getUsername(), credentials.getUsername(), 1_000_000L, "unit-test-issuer");
- }
-
- @Override
- public void initialize(final LoginIdentityProviderInitializationContext initializationContext) throws ProviderCreationException {
- }
-
- @Override
- public void onConfigured(final LoginIdentityProviderConfigurationContext configurationContext) throws ProviderCreationException {
- }
-
- @Override
- public void preDestruction() throws ProviderDestructionException {
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/VolatileAccessPolicyProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/VolatileAccessPolicyProvider.java
deleted file mode 100644
index c010f0569b..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/VolatileAccessPolicyProvider.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.integration.auth;
-
-import org.apache.nifi.authorization.AccessPolicy;
-import org.apache.nifi.authorization.AccessPolicyProvider;
-import org.apache.nifi.authorization.AccessPolicyProviderInitializationContext;
-import org.apache.nifi.authorization.AuthorizerConfigurationContext;
-import org.apache.nifi.authorization.RequestAction;
-import org.apache.nifi.authorization.exception.AuthorizationAccessException;
-import org.apache.nifi.authorization.exception.AuthorizerCreationException;
-import org.apache.nifi.authorization.exception.AuthorizerDestructionException;
-
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-public class VolatileAccessPolicyProvider implements AccessPolicyProvider {
- private final VolatileUserGroupProvider userGroupProvider = new VolatileUserGroupProvider();
- private Set<AccessPolicy> accessPolicies = new HashSet<>();
-
- public synchronized void grantAccess(final String user, final String resourceIdentifier, final RequestAction action) {
- final AccessPolicy existingPolicy = getAccessPolicy(resourceIdentifier, action);
-
- final AccessPolicy policy;
- if (existingPolicy == null) {
- policy = new AccessPolicy.Builder()
- .addUser(user)
- .action(action)
- .identifierGenerateRandom()
- .resource(resourceIdentifier)
- .build();
- } else {
- policy = new AccessPolicy.Builder()
- .addUsers(existingPolicy.getUsers())
- .addUser(user)
- .action(action)
- .identifier(existingPolicy.getIdentifier())
- .resource(resourceIdentifier)
- .build();
- }
-
- accessPolicies.remove(existingPolicy);
- accessPolicies.add(policy);
- }
-
- public synchronized void revokeAccess(final String user, final String resourceIdentifier, final RequestAction action) {
- final AccessPolicy existingPolicy = getAccessPolicy(resourceIdentifier, action);
-
- if (existingPolicy == null) {
- return;
- }
-
- final AccessPolicy policy= new AccessPolicy.Builder()
- .addUsers(existingPolicy.getUsers())
- .removeUser(user)
- .action(action)
- .identifier(existingPolicy.getIdentifier())
- .resource(resourceIdentifier)
- .build();
-
- accessPolicies.remove(existingPolicy);
- accessPolicies.add(policy);
- }
-
- @Override
- public synchronized Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException {
- return new HashSet<>(accessPolicies);
- }
-
- @Override
- public synchronized AccessPolicy getAccessPolicy(final String identifier) throws AuthorizationAccessException {
- return accessPolicies.stream()
- .filter(policy -> policy.getIdentifier().equals(identifier))
- .findAny()
- .orElse(null);
- }
-
- @Override
- public synchronized AccessPolicy getAccessPolicy(final String resourceIdentifier, final RequestAction action) throws AuthorizationAccessException {
- return accessPolicies.stream()
- .filter(policy -> Objects.equals(policy.getResource(), resourceIdentifier))
- .filter(policy -> Objects.equals(policy.getAction(), action))
- .findAny()
- .orElse(null);
- }
-
- @Override
- public synchronized VolatileUserGroupProvider getUserGroupProvider() {
- return userGroupProvider;
- }
-
- @Override
- public void initialize(final AccessPolicyProviderInitializationContext initializationContext) throws AuthorizerCreationException {
- }
-
- @Override
- public void onConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
- }
-
- @Override
- public void preDestruction() throws AuthorizerDestructionException {
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/VolatileUserGroupProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/VolatileUserGroupProvider.java
deleted file mode 100644
index 7e4849bcbe..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/auth/VolatileUserGroupProvider.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.integration.auth;
-
-import org.apache.nifi.authorization.AuthorizerConfigurationContext;
-import org.apache.nifi.authorization.Group;
-import org.apache.nifi.authorization.User;
-import org.apache.nifi.authorization.UserAndGroups;
-import org.apache.nifi.authorization.UserGroupProvider;
-import org.apache.nifi.authorization.UserGroupProviderInitializationContext;
-import org.apache.nifi.authorization.exception.AuthorizationAccessException;
-import org.apache.nifi.authorization.exception.AuthorizerCreationException;
-import org.apache.nifi.authorization.exception.AuthorizerDestructionException;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-public class VolatileUserGroupProvider implements UserGroupProvider {
- private final Map<String, User> users = new HashMap<>();
- private final Map<String, Group> groups = new HashMap<>();
- private final Map<User, Set<Group>> userGroupMapping = new HashMap<>();
-
- public void addUser(final User user) {
- this.users.put(user.getIdentifier(), user);
- }
-
- public void addGroup(final Group group) {
- this.groups.put(group.getIdentifier(), group);
- }
-
- public void addUserToGroup(final User user, final Group group) {
- userGroupMapping.computeIfAbsent(user, i -> new HashSet<>()).add(group);
- }
-
- @Override
- public Set<User> getUsers() throws AuthorizationAccessException {
- return new HashSet<>(users.values());
- }
-
- @Override
- public User getUser(final String identifier) throws AuthorizationAccessException {
- return users.get(identifier);
- }
-
- @Override
- public User getUserByIdentity(final String identity) throws AuthorizationAccessException {
- return users.values().stream()
- .filter(user -> Objects.equals(identity, user.getIdentity()))
- .findFirst()
- .orElse(null);
- }
-
- @Override
- public Set<Group> getGroups() throws AuthorizationAccessException {
- return new HashSet<>(groups.values());
- }
-
- @Override
- public Group getGroup(final String identifier) throws AuthorizationAccessException {
- return groups.get(identifier);
- }
-
- @Override
- public UserAndGroups getUserAndGroups(final String identity) throws AuthorizationAccessException {
- final User user = getUserByIdentity(identity);
- final Set<Group> groups = userGroupMapping.get(user);
- final Set<Group> groupCopy = groups == null ? Collections.emptySet() : new HashSet<>(groups);
-
- return new UserAndGroups() {
- @Override
- public User getUser() {
- return user;
- }
-
- @Override
- public Set<Group> getGroups() {
- return groupCopy;
- }
- };
- }
-
- @Override
- public void initialize(final UserGroupProviderInitializationContext initializationContext) throws AuthorizerCreationException {
- }
-
- @Override
- public void onConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
- }
-
- @Override
- public void preDestruction() throws AuthorizerDestructionException {
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferenceIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferenceIT.java
deleted file mode 100644
index d0aa24da88..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferenceIT.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.components.ValidationResult;
-import org.apache.nifi.components.validation.ValidationStatus;
-import org.apache.nifi.controller.ControllerService;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.integration.DirectInjectionExtensionManager;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.processor.Processor;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertSame;
-
-public class ControllerServiceReferenceIT extends FrameworkIntegrationTest {
- @Override
- protected void injectExtensionTypes(final DirectInjectionExtensionManager extensionManager) {
- extensionManager.injectExtensionType(ControllerService.class, CounterControllerService.class);
- extensionManager.injectExtensionType(ControllerService.class, LongValidatingControllerService.class);
- extensionManager.injectExtensionType(Processor.class, ControllerServiceReferencingProcessor.class);
- }
-
-
- @Test
- public void testCallingControllerService() throws ExecutionException, InterruptedException {
- final ProcessorNode counter = createProcessorNode(ControllerServiceReferencingProcessor.class.getName());
-
- final ControllerServiceNode serviceNode = createControllerServiceNode(CounterControllerService.class.getName());
- assertSame(ValidationStatus.VALID, serviceNode.performValidation());
- getFlowController().getControllerServiceProvider().enableControllerService(serviceNode).get();
-
- counter.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
- counter.setProperties(Collections.singletonMap("Counter Service", serviceNode.getIdentifier()));
-
- triggerOnce(counter);
-
- assertEquals(1, ((Counter) serviceNode.getControllerServiceImplementation()).getValue());
- }
-
- @Test
- public void testLongValidatingControllerService() {
- final ControllerServiceNode serviceNode = createControllerServiceNode(LongValidatingControllerService.class.getName());
- serviceNode.setProperties(Collections.singletonMap(LongValidatingControllerService.DELAY.getName(), "250 millis"));
- final ValidationStatus validationStatus = serviceNode.performValidation();
- final Collection<ValidationResult> validationErrors = serviceNode.getValidationErrors();
- assertSame(ValidationStatus.VALID, validationStatus);
- assertEquals(0, validationErrors.size());
- }
-
- @Test
- public void testReferenceCounts() {
- final String FIRST_PROPERTY = "Counter Service";
- final String SECOND_PROPERTY = "Another Counter Service";
-
- final ControllerServiceNode serviceNode = createControllerServiceNode(LongValidatingControllerService.class.getName());
- serviceNode.setProperties(Collections.singletonMap(LongValidatingControllerService.DELAY.getName(), "250 millis"));
-
- final ProcessorNode counter = createProcessorNode(MultipleControllerServiceReferencingProcessor.class);
- final Map<String, String> properties = new HashMap<>();
-
- // Add a reference of the service node in the first property of the processor
- properties.put(FIRST_PROPERTY, serviceNode.getIdentifier());
- counter.setProperties(properties);
- assertEquals(1, serviceNode.getReferences().getReferencingComponents().size());
-
- // Add another reference of the same service node in the second property of the processor
- properties.put(SECOND_PROPERTY, serviceNode.getIdentifier());
- counter.setProperties(properties);
- assertEquals(1, serviceNode.getReferences().getReferencingComponents().size());
-
- // Remove the reference of the service node from the first property of the processor
- properties.put(FIRST_PROPERTY, null);
- counter.setProperties(properties);
- // The counter should still be one because the service node is still referenced by the processor in its second property
- assertEquals(1, serviceNode.getReferences().getReferencingComponents().size());
-
- // Remove also the reference of the service node from the second property of the processor
- properties.put(SECOND_PROPERTY, null);
- counter.setProperties(properties);
- // The counter should become 0 because now the service node is not reference anymore in any processor property
- assertEquals(0, serviceNode.getReferences().getReferencingComponents().size());
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferencingProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferencingProcessor.java
deleted file mode 100644
index 3b6df47d1f..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/ControllerServiceReferencingProcessor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-public class ControllerServiceReferencingProcessor extends AbstractProcessor {
- protected static final PropertyDescriptor SERVICE = new PropertyDescriptor.Builder()
- .name("Counter Service")
- .identifiesControllerService(Counter.class)
- .required(true)
- .build();
-
- protected static final PropertyDescriptor OPTIONAL_SERVICE = new PropertyDescriptor.Builder()
- .name("Optional Service")
- .identifiesControllerService(Counter.class)
- .required(false)
- .build();
-
- protected static final PropertyDescriptor IGNORED_OPTIONAL_SERVICE = new PropertyDescriptor.Builder()
- .name("Ignored Optional Service")
- .identifiesControllerService(Counter.class)
- .required(false)
- .build();
-
- @Override
- public Set<Relationship> getRelationships() {
- return Collections.singleton(FrameworkIntegrationTest.REL_SUCCESS);
- }
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Arrays.asList(SERVICE, OPTIONAL_SERVICE, IGNORED_OPTIONAL_SERVICE);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- context.getProperty(SERVICE).asControllerService(Counter.class).increment(1L);
-
- final Counter optionalCounter = context.getProperty(OPTIONAL_SERVICE).asControllerService(Counter.class);
- if (optionalCounter != null) {
- optionalCounter.increment(1L);
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/Counter.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/Counter.java
deleted file mode 100644
index 6a46400602..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/Counter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.controller.ControllerService;
-
-public interface Counter extends ControllerService {
- long increment(long delta);
-
- long getValue();
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/CounterControllerService.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/CounterControllerService.java
deleted file mode 100644
index 5d49466ab6..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/CounterControllerService.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.controller.AbstractControllerService;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-public class CounterControllerService extends AbstractControllerService implements Counter {
- private final AtomicLong count = new AtomicLong(0L);
-
- @Override
- public long increment(final long delta) {
- return count.addAndGet(delta);
- }
-
- @Override
- public long getValue() {
- return count.get();
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/LongValidatingControllerService.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/LongValidatingControllerService.java
deleted file mode 100644
index 4bad93a61a..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/LongValidatingControllerService.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyDescriptor.Builder;
-import org.apache.nifi.components.ValidationContext;
-import org.apache.nifi.components.ValidationResult;
-import org.apache.nifi.controller.AbstractControllerService;
-import org.apache.nifi.processor.util.StandardValidators;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import static org.apache.nifi.expression.ExpressionLanguageScope.NONE;
-
-public class LongValidatingControllerService extends AbstractControllerService {
- public static final PropertyDescriptor DELAY = new Builder()
- .name("Delay")
- .displayName("Delay")
- .description("Amount of time to sleep during validation")
- .required(true)
- .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
- .expressionLanguageSupported(NONE)
- .defaultValue("2 sec")
- .build();
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Collections.singletonList(DELAY);
- }
-
- @Override
- protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) {
- final long millis = validationContext.getProperty(DELAY).asTimePeriod(TimeUnit.MILLISECONDS);
- try {
- Thread.sleep(millis);
- } catch (final InterruptedException ie) {
- }
-
- return Collections.emptyList();
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/MultipleControllerServiceReferencingProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/MultipleControllerServiceReferencingProcessor.java
deleted file mode 100644
index 8ced8db0e2..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/MultipleControllerServiceReferencingProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-public class MultipleControllerServiceReferencingProcessor extends AbstractProcessor {
-
- private final PropertyDescriptor SERVICE = new PropertyDescriptor.Builder()
- .name("Counter Service")
- .identifiesControllerService(Counter.class)
- .required(false)
- .build();
-
- private final PropertyDescriptor ANOTHER_SERVICE = new PropertyDescriptor.Builder()
- .name("Another Counter Service")
- .identifiesControllerService(Counter.class)
- .required(false)
- .build();
-
- @Override
- public Set<Relationship> getRelationships() {
- return Collections.singleton(FrameworkIntegrationTest.REL_SUCCESS);
- }
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Arrays.asList(SERVICE, ANOTHER_SERVICE);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/NopControllerService.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/NopControllerService.java
deleted file mode 100644
index 2dcc5aa5ca..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/NopControllerService.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.controller.ControllerService;
-
-public interface NopControllerService extends ControllerService {
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/NopServiceReferencingProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/NopServiceReferencingProcessor.java
deleted file mode 100644
index 8c55326ec5..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/cs/NopServiceReferencingProcessor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.integration.cs;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyDescriptor.Builder;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Collections;
-import java.util.List;
-
-public class NopServiceReferencingProcessor extends AbstractProcessor {
- public static final PropertyDescriptor SERVICE = new Builder()
- .name("Controller Service")
- .displayName("Controller Service")
- .description("The Controller Service")
- .required(true)
- .identifiesControllerService(NopControllerService.class)
- .build();
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Collections.singletonList(SERVICE);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowanalysis/DelegateFlowAnalysisRule.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowanalysis/DelegateFlowAnalysisRule.java
deleted file mode 100644
index 23eaab3f11..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowanalysis/DelegateFlowAnalysisRule.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.integration.flowanalysis;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.flow.VersionedComponent;
-import org.apache.nifi.flow.VersionedProcessGroup;
-import org.apache.nifi.flowanalysis.AbstractFlowAnalysisRule;
-import org.apache.nifi.flowanalysis.ComponentAnalysisResult;
-import org.apache.nifi.flowanalysis.FlowAnalysisRule;
-import org.apache.nifi.flowanalysis.FlowAnalysisRuleContext;
-import org.apache.nifi.flowanalysis.GroupAnalysisResult;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-public class DelegateFlowAnalysisRule extends AbstractFlowAnalysisRule {
- private FlowAnalysisRule delegate;
-
- public DelegateFlowAnalysisRule() {
- }
-
- @Override
- public Collection<ComponentAnalysisResult> analyzeComponent(VersionedComponent component, FlowAnalysisRuleContext context) {
- return delegate.analyzeComponent(component, context);
- }
-
- @Override
- public Collection<GroupAnalysisResult> analyzeProcessGroup(VersionedProcessGroup processGroup, FlowAnalysisRuleContext context) {
- return delegate.analyzeProcessGroup(processGroup, context);
- }
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- if (delegate == null) {
- return Collections.emptyList();
- } else {
- return delegate.getPropertyDescriptors();
- }
- }
-
- public FlowAnalysisRule getDelegate() {
- return delegate;
- }
-
- public void setDelegate(FlowAnalysisRule delegate) {
- this.delegate = delegate;
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEFlowFileRepoUpdateIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEFlowFileRepoUpdateIT.java
deleted file mode 100644
index 1de2f3094d..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEFlowFileRepoUpdateIT.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.integration.flowfilerepo;
-
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.repository.FlowFileRepository;
-import org.apache.nifi.controller.repository.WriteAheadFlowFileRepository;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.integration.DirectInjectionExtensionManager;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.reporting.Bulletin;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class OOMEFlowFileRepoUpdateIT extends FrameworkIntegrationTest {
- @Override
- protected Map<String, String> getNiFiPropertiesOverrides() {
- return Collections.singletonMap("nifi.flowfile.repository.implementation", OOMEWriteAheadFlowFileRepository.class.getName());
- }
-
- @Override
- protected void injectExtensionTypes(final DirectInjectionExtensionManager extensionManager) {
- extensionManager.injectExtensionType(FlowFileRepository.class, OOMEWriteAheadFlowFileRepository.class);
- }
-
- @Test
- public void testOOMEOnUpdatePreventsSubsequentUpdates() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode generate = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.create();
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
- connect(generate, getTerminateAllProcessor(), REL_SUCCESS);
-
- for (int i=0; i < 4; i++) {
- triggerOnce(generate);
- }
-
- List<Bulletin> processorBulletins = getFlowController().getBulletinRepository().findBulletinsForSource(generate.getIdentifier());
- assertEquals(1, processorBulletins.size());
-
- triggerOnce(generate);
-
- // FlowFile Repository should not allow us to udpate until it has been checkpointed.
- processorBulletins = getFlowController().getBulletinRepository().findBulletinsForSource(generate.getIdentifier());
- assertEquals(2, processorBulletins.size());
-
- // Checkpoint the repository.
- ((WriteAheadFlowFileRepository) getFlowFileRepository()).checkpoint();
-
- // Should now succeed.
- triggerOnce(generate);
- processorBulletins = getFlowController().getBulletinRepository().findBulletinsForSource(generate.getIdentifier());
- assertEquals(2, processorBulletins.size());
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEWriteAheadFlowFileRepository.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEWriteAheadFlowFileRepository.java
deleted file mode 100644
index 2b5570041b..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/flowfilerepo/OOMEWriteAheadFlowFileRepository.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.integration.flowfilerepo;
-
-import org.apache.nifi.controller.repository.RepositoryRecordSerdeFactory;
-import org.apache.nifi.controller.repository.SerializedRepositoryRecord;
-import org.apache.nifi.controller.repository.StandardRepositoryRecordSerdeFactory;
-import org.apache.nifi.controller.repository.WriteAheadFlowFileRepository;
-import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
-import org.apache.nifi.repository.schema.FieldCache;
-import org.apache.nifi.repository.schema.NoOpFieldCache;
-import org.apache.nifi.util.NiFiProperties;
-import org.wali.SerDe;
-import org.wali.UpdateType;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Map;
-
-public class OOMEWriteAheadFlowFileRepository extends WriteAheadFlowFileRepository {
-
- public OOMEWriteAheadFlowFileRepository() {
- }
-
- public OOMEWriteAheadFlowFileRepository(final NiFiProperties nifiProperties) {
- super(nifiProperties);
- }
-
- @Override
- public void initialize(final ResourceClaimManager claimManager) throws IOException {
- final FieldCache fieldCache = new NoOpFieldCache();
- super.initialize(claimManager, new ThrowOOMERepositoryRecordSerdeFactory(new StandardRepositoryRecordSerdeFactory(claimManager, fieldCache)), fieldCache);
- }
-
-
- private static class ThrowOOMERepositoryRecordSerdeFactory implements RepositoryRecordSerdeFactory {
- private final RepositoryRecordSerdeFactory factory;
-
- public ThrowOOMERepositoryRecordSerdeFactory(final RepositoryRecordSerdeFactory factory) {
- this.factory = factory;
- }
-
- @Override
- public SerDe<SerializedRepositoryRecord> createSerDe(final String encodingName) {
- final SerDe<SerializedRepositoryRecord> serde = factory.createSerDe(encodingName);
- return new ThrowOOMESerde(serde, 3);
- }
-
- @Override
- public Long getRecordIdentifier(final SerializedRepositoryRecord record) {
- return factory.getRecordIdentifier(record);
- }
-
- @Override
- public UpdateType getUpdateType(final SerializedRepositoryRecord record) {
- return factory.getUpdateType(record);
- }
-
- @Override
- public String getLocation(final SerializedRepositoryRecord record) {
- return factory.getLocation(record);
- }
- }
-
-
- private static class ThrowOOMESerde implements SerDe<SerializedRepositoryRecord> {
- private final SerDe<SerializedRepositoryRecord> serde;
- private final int afterSuccessfulAttempts;
- private int successfulUpdates = 0;
-
- public ThrowOOMESerde(final SerDe<SerializedRepositoryRecord> serde, final int afterSuccessfulAttempts) {
- this.serde = serde;
- this.afterSuccessfulAttempts = afterSuccessfulAttempts;
- }
-
- @Override
- public void serializeEdit(final SerializedRepositoryRecord previousRecordState, final SerializedRepositoryRecord newRecordState, final DataOutputStream out) throws IOException {
- if (successfulUpdates++ == afterSuccessfulAttempts) {
- throw new OutOfMemoryError("Intentional OOME for unit test");
- }
-
- serde.serializeEdit(previousRecordState, newRecordState, out);
- }
-
- @Override
- public void serializeRecord(final SerializedRepositoryRecord record, final DataOutputStream out) throws IOException {
- if (successfulUpdates++ == afterSuccessfulAttempts) {
- throw new OutOfMemoryError("Intentional OOME for unit test");
- }
-
- serde.serializeRecord(record, out);
- }
-
- @Override
- public SerializedRepositoryRecord deserializeEdit(final DataInputStream in, final Map<Object, SerializedRepositoryRecord> currentRecordStates, final int version) throws IOException {
- return serde.deserializeEdit(in, currentRecordStates, version);
- }
-
- @Override
- public SerializedRepositoryRecord deserializeRecord(final DataInputStream in, final int version) throws IOException {
- return serde.deserializeRecord(in, version);
- }
-
- @Override
- public Object getRecordIdentifier(final SerializedRepositoryRecord record) {
- return serde.getRecordIdentifier(record);
- }
-
- @Override
- public UpdateType getUpdateType(final SerializedRepositoryRecord record) {
- return serde.getUpdateType(record);
- }
-
- @Override
- public String getLocation(final SerializedRepositoryRecord record) {
- return serde.getLocation(record);
- }
-
- @Override
- public int getVersion() {
- return serde.getVersion();
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/ContentCleanupIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/ContentCleanupIT.java
deleted file mode 100644
index cb8717b053..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/ContentCleanupIT.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.integration.lifecycle;
-
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.repository.FileSystemRepository;
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.controller.repository.WriteAheadFlowFileRepository;
-import org.apache.nifi.controller.repository.claim.ContentClaim;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.provenance.ProvenanceEventType;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class ContentCleanupIT extends FrameworkIntegrationTest {
-
- @Test
- public void testCompletedContentClaimCleanedUpOnCheckpoint() throws InterruptedException, IOException, ExecutionException {
- final AtomicReference<FlowFileRecord> largeFlowFileReference = new AtomicReference<>();
- final AtomicReference<FlowFileRecord> smallFlowFileReference = new AtomicReference<>();
-
- // Processor to write 1 MB of content to a FlowFile
- final ProcessorNode createLargeProcessor = createGenerateProcessor(1024 * 1024, largeFlowFileReference);
- final ProcessorNode createSmallProcessor = createGenerateProcessor(5, smallFlowFileReference);
-
- connect(createLargeProcessor, getTerminateProcessor(), REL_SUCCESS);
- connect(createSmallProcessor, getTerminateProcessor(), REL_SUCCESS);
-
- // Trigger the create processor.
- triggerOnce(createLargeProcessor);
- triggerOnce(createSmallProcessor);
-
- // Ensure content available and has a claim count of 1.
- final ContentClaim largeContentClaim = largeFlowFileReference.get().getContentClaim();
- final ContentClaim smallContentClaim = smallFlowFileReference.get().getContentClaim();
- assertNotEquals(largeContentClaim.getResourceClaim(), smallContentClaim.getResourceClaim());
- assertEquals(1, getContentRepository().getClaimantCount(largeContentClaim));
- assertEquals(1, getContentRepository().getClaimantCount(smallContentClaim));
-
- // Ensure that content is still available and considered 'in use'
- final FileSystemRepository fileSystemRepository = (FileSystemRepository) getContentRepository();
- final Path largeClaimPath = fileSystemRepository.getPath(largeContentClaim, false);
- final Path smallClaimPath = fileSystemRepository.getPath(smallContentClaim, false);
- assertTrue(Files.exists(largeClaimPath));
- assertTrue(largeContentClaim.getResourceClaim().isInUse());
- assertTrue(Files.exists(smallClaimPath));
- assertTrue(smallContentClaim.getResourceClaim().isInUse());
-
- int recordCount = ((WriteAheadFlowFileRepository) getFlowFileRepository()).checkpoint();
- assertEquals(2, recordCount);
-
- // Trigger the delete Processor.
- triggerOnce(getTerminateProcessor());
- triggerOnce(getTerminateProcessor());
-
- // Claim count should now be 0 and resource claim should not be in use.
- assertEquals(0, getContentRepository().getClaimantCount(largeContentClaim));
- assertEquals(0, getContentRepository().getClaimantCount(largeContentClaim));
-
- assertFalse(largeContentClaim.getResourceClaim().isInUse());
- assertTrue(smallContentClaim.getResourceClaim().isInUse());
-
- // Checkpoint the FlowFile Repo
- recordCount = ((WriteAheadFlowFileRepository) getFlowFileRepository()).checkpoint();
- assertEquals(0, recordCount);
-
- // Wait for the data to be deleted/archived.
- waitForClaimDestruction(largeContentClaim);
-
- assertTrue(Files.exists(smallClaimPath));
-
- assertProvenanceEventCount(ProvenanceEventType.CREATE, 2);
- assertProvenanceEventCount(ProvenanceEventType.DROP, 2);
- }
-
-
- @Test
- public void testTransientClaimsNotHeld() throws ExecutionException, InterruptedException, IOException {
- final AtomicReference<ContentClaim> claimReference = new AtomicReference<>();
-
- final ProcessorNode processor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.create();
-
- for (int i=0; i < 1000; i++) {
- final byte[] bytes = String.valueOf(i).getBytes();
- flowFile = session.write(flowFile, out -> out.write(bytes));
- }
-
- // Write 1 MB to the content claim in order to ensure that the claim is no longer usable.
- final byte[] oneMB = new byte[1024 * 1024];
- flowFile = session.write(flowFile, out -> out.write(oneMB));
-
- claimReference.set(((FlowFileRecord) flowFile).getContentClaim());
- session.transfer(flowFile, REL_SUCCESS);
-
- }, REL_SUCCESS);
-
- connect(processor, getTerminateProcessor(), REL_SUCCESS);
- triggerOnce(processor);
-
- final int claimCount = getContentRepository().getClaimantCount(claimReference.get());
- assertEquals(1, claimCount);
-
- int recordCount = ((WriteAheadFlowFileRepository) getFlowFileRepository()).checkpoint();
- assertEquals(1, recordCount);
- assertTrue(claimReference.get().getResourceClaim().isInUse());
-
- triggerOnce(getTerminateProcessor());
- assertFalse(claimReference.get().getResourceClaim().isInUse());
-
- recordCount = ((WriteAheadFlowFileRepository) getFlowFileRepository()).checkpoint();
- assertEquals(0, recordCount);
-
- waitForClaimDestruction(claimReference.get());
-
- assertProvenanceEventCount(ProvenanceEventType.CREATE, 1);
- assertProvenanceEventCount(ProvenanceEventType.DROP, 1);
- }
-
-
- @Test
- public void testCloneIncrementsContentClaim() throws ExecutionException, InterruptedException, IOException {
- final AtomicReference<FlowFileRecord> flowFileReference = new AtomicReference<>();
- final ProcessorNode createProcessor = createGenerateProcessor(1024 * 1024, flowFileReference);
-
- connect(createProcessor, getTerminateProcessor(), REL_SUCCESS);
- connect(createProcessor, getTerminateAllProcessor(), REL_SUCCESS);
-
- triggerOnce(createProcessor);
-
- final ContentClaim contentClaim = flowFileReference.get().getContentClaim();
- assertEquals(2, getContentRepository().getClaimantCount(contentClaim));
- assertTrue(contentClaim.getResourceClaim().isInUse());
-
- triggerOnce(getTerminateProcessor());
- assertEquals(1, getContentRepository().getClaimantCount(contentClaim));
- assertTrue(contentClaim.getResourceClaim().isInUse());
-
- triggerOnce(getTerminateAllProcessor());
- assertEquals(0, getContentRepository().getClaimantCount(contentClaim));
- assertFalse(contentClaim.getResourceClaim().isInUse());
-
- assertEquals(0, ((WriteAheadFlowFileRepository) getFlowFileRepository()).checkpoint());
-
- waitForClaimDestruction(contentClaim);
- }
-
-
- private void waitForClaimDestruction(final ContentClaim contentClaim) {
- final Path path = ((FileSystemRepository) getContentRepository()).getPath(contentClaim, false);
-
- while (Files.exists(path)) {
- try {
- Thread.sleep(10L);
- } catch (final Exception e) {
- }
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/FlowFileRepositoryLifecycleIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/FlowFileRepositoryLifecycleIT.java
deleted file mode 100644
index e7e75c15cb..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/lifecycle/FlowFileRepositoryLifecycleIT.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.integration.lifecycle;
-
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.queue.DropFlowFileState;
-import org.apache.nifi.controller.queue.DropFlowFileStatus;
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.controller.repository.FlowFileSwapManager;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.provenance.ProvenanceEventType;
-import org.apache.nifi.reporting.Bulletin;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-public class FlowFileRepositoryLifecycleIT extends FrameworkIntegrationTest {
-
- @Test
- public void testFlowFilesReloadedIntoQueuesUponRestart() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode procNode = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.get();
- if (flowFile == null) {
- flowFile = session.create();
- }
-
- flowFile = session.putAttribute(flowFile,"creator", "unit-test");
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(procNode, getNopProcessor(), REL_SUCCESS);
- start(procNode);
- final FlowFileQueue queue = getDestinationQueue(procNode, REL_SUCCESS);
-
- while (queue.isEmpty()) {
- try {
- Thread.sleep(10L);
- } catch (InterruptedException e) {
- }
- }
-
- stop(procNode).get();
-
- final int queueSize = queue.size().getObjectCount();
- assertTrue(queueSize > 0);
- assertEquals(0L, queue.size().getByteCount());
-
- assertProvenanceEventCount(ProvenanceEventType.CREATE, queueSize);
-
- shutdown();
-
- final FlowFileQueue restoredQueue = createFlowFileQueue(queue.getIdentifier(), getRootGroup());
- initialize();
- getFlowController().initializeFlow(() -> Collections.singleton(restoredQueue));
-
- for (int i=0; i < queueSize; i++) {
- final FlowFileRecord flowFileRecord = restoredQueue.poll(Collections.emptySet());
- assertNotNull(flowFileRecord);
- assertEquals("unit-test", flowFileRecord.getAttribute("creator"));
- }
-
- assertFalse(restoredQueue.isEmpty());
- assertTrue(restoredQueue.isActiveQueueEmpty());
- assertNull(restoredQueue.poll(Collections.emptySet()));
- }
-
-
- @Test
- public void testMissingSwapFileOnSwapIn() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createProcessorNode((context, session) -> {
- for (int i=0; i < 30_000; i++) {
- session.transfer(session.create(), REL_SUCCESS);
- }
- }, REL_SUCCESS);
-
- connect(createProcessor, getTerminateAllProcessor(), REL_SUCCESS);
- triggerOnce(createProcessor);
-
- // Verify queue sizes
- final FlowFileQueue flowFileQueue = getDestinationQueue(createProcessor, REL_SUCCESS);
- assertEquals(30_000, flowFileQueue.size().getObjectCount());
- assertEquals(10_000, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapQueueSize().getObjectCount());
- assertEquals(1, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapFileCount());
- assertEquals(20_000, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getActiveQueueSize().getObjectCount());
-
- // Delete all swap files
- final FlowFileSwapManager swapManager = getFlowController().createSwapManager();
- swapManager.purge();
-
- // Verify queue sizes haven't changed
- assertEquals(30_000, flowFileQueue.size().getObjectCount());
- assertEquals(10_000, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapQueueSize().getObjectCount());
- assertEquals(1, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapFileCount());
- assertEquals(20_000, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getActiveQueueSize().getObjectCount());
-
- for (int i=0; i < 5; i++) {
- triggerOnce(getTerminateAllProcessor());
-
- // Verify new queue sizes
- assertEquals(10_000, flowFileQueue.size().getObjectCount());
- assertEquals(10_000, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapQueueSize().getObjectCount());
- assertEquals(1, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapFileCount());
- assertEquals(0, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getActiveQueueSize().getObjectCount());
-
- final List<Bulletin> bulletins = getFlowController().getBulletinRepository().findBulletinsForController();
- assertEquals(1, bulletins.size());
- }
-
- assertProvenanceEventCount(ProvenanceEventType.CREATE, 30_000);
- assertProvenanceEventCount(ProvenanceEventType.DROP, 20_000);
-
- final DropFlowFileStatus status = flowFileQueue.dropFlowFiles("unit-test-id-1", "unit-test");
- while (status.getState() != DropFlowFileState.COMPLETE) {
- Thread.sleep(10L);
- }
-
- assertEquals(0, status.getDroppedSize().getObjectCount());
- assertEquals(10_000, flowFileQueue.size().getObjectCount());
- assertEquals(10_000, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapQueueSize().getObjectCount());
- assertEquals(1, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getSwapFileCount());
- assertEquals(0, flowFileQueue.getQueueDiagnostics().getLocalQueuePartitionDiagnostics().getActiveQueueSize().getObjectCount());
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/parameters/ParametersIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/parameters/ParametersIT.java
deleted file mode 100644
index 84220c493c..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/parameters/ParametersIT.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * 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.integration.parameters;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyValue;
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.integration.processors.GenerateProcessor;
-import org.apache.nifi.integration.processors.UpdateAttributeCreateOwnProperty;
-import org.apache.nifi.integration.processors.UpdateAttributeNoEL;
-import org.apache.nifi.integration.processors.UpdateAttributeWithEL;
-import org.apache.nifi.integration.processors.UsernamePasswordProcessor;
-import org.apache.nifi.parameter.Parameter;
-import org.apache.nifi.parameter.ParameterContext;
-import org.apache.nifi.parameter.ParameterDescriptor;
-import org.apache.nifi.parameter.ParameterReference;
-import org.apache.nifi.parameter.ParameterReferenceManager;
-import org.apache.nifi.parameter.StandardParameterContext;
-import org.apache.nifi.parameter.StandardParameterReferenceManager;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.Processor;
-import org.apache.nifi.processor.StandardProcessContext;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.function.BiConsumer;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-public class ParametersIT extends FrameworkIntegrationTest {
-
- @Test
- public void testSimpleParameterSubstitution() throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeNoEL.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
- updateAttribute.setProperties(Collections.singletonMap("test", "#{test}"));
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals("unit", flowFileRecord.getAttribute("test"));
- }
-
- @Test
- public void testNestedParamSubstitution_configProcessorFirst() throws ExecutionException, InterruptedException {
- runParameterSubstitutionInNestedParameterContextTest((updateAttribute, parameterContext) -> {
- updateAttribute.setProperties(Collections.singletonMap("test", "#{test}"));
- getRootGroup().setParameterContext(parameterContext);
- }, "unit");
- }
-
- @Test
- public void testNestedParamSubstitution_configProcessorLast() throws ExecutionException, InterruptedException {
- runParameterSubstitutionInNestedParameterContextTest((updateAttribute, parameterContext) -> {
- getRootGroup().setParameterContext(parameterContext);
- updateAttribute.setProperties(Collections.singletonMap("test", "#{test}"));
- }, "unit");
- }
-
- @Test
- public void testNestedParamSubstitution_updateParamContext() throws ExecutionException, InterruptedException {
- runParameterSubstitutionInNestedParameterContextTest((updateAttribute, parameterContext) -> {
- getRootGroup().setParameterContext(parameterContext);
- updateAttribute.setProperties(Collections.singletonMap("test", "#{test}"));
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "bar")));
-
- getRootGroup().setParameterContext(parameterContext);
- }, "bar");
- }
-
- public void runParameterSubstitutionInNestedParameterContextTest(BiConsumer<ProcessorNode, ParameterContext> testConsumer, String expectedValue) throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeNoEL.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("foo", new Parameter(new ParameterDescriptor.Builder().name("foo").build(), "bar")));
-
- final ParameterContext referencedParameterContext = createParameterContext("param-context-2", referenceManager);
- referencedParameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- parameterContext.setInheritedParameterContexts(Arrays.asList(referencedParameterContext));
-
- testConsumer.accept(updateAttribute, parameterContext);
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals(expectedValue, flowFileRecord.getAttribute("test"));
- }
-
- @Test
- public void testParameterSubstitutionWithinELWhenELNotSupported() throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeNoEL.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
- updateAttribute.setProperties(Collections.singletonMap("test", "${#{test}:toUpper()}"));
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals("${unit:toUpper()}", flowFileRecord.getAttribute("test"));
- }
-
- @Test
- public void testParameterSubstitutionWithinELWhenELIsSupported() throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeWithEL.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
- updateAttribute.setProperties(Collections.singletonMap("test", "${#{test}:toUpper()}"));
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals("UNIT", flowFileRecord.getAttribute("test"));
- }
-
-
- @Test
- public void testMixAndMatchELAndParameters() throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeWithEL.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("mixed", "test ${#{test}} #{test} ${#{test}:toUpper()} ${#{test}:equalsIgnoreCase('uNiT')} again ${#{test}}");
- properties.put("ends with text", "test ${#{test}} #{test} ${#{test}:toUpper()} ${#{test}:equalsIgnoreCase('uNiT')} again");
- properties.put("el and param", "#{test} - ${#{test}}");
- updateAttribute.setProperties(properties);
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals("test unit unit UNIT true again unit", flowFileRecord.getAttribute("mixed"));
- assertEquals("test unit unit UNIT true again", flowFileRecord.getAttribute("ends with text"));
- assertEquals("unit - unit", flowFileRecord.getAttribute("el and param"));
- }
-
- @Test
- public void testParametersInELFromNewPropertyValueAndText() throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeCreateOwnProperty.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("bar", "${#{test}:toUpper()}");
- updateAttribute.setProperties(properties);
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals("UNIT", flowFileRecord.getAttribute("bar"));
- }
-
- @Test
- public void testParametersWhereELSupportedButNotPresent() throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeWithEL.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("foo", "#{test}");
- properties.put("bar", "#{test}#{test}");
- properties.put("baz", "foo#{test}bar");
- updateAttribute.setProperties(properties);
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals("unit", flowFileRecord.getAttribute("foo"));
- assertEquals("unitunit", flowFileRecord.getAttribute("bar"));
- assertEquals("foounitbar", flowFileRecord.getAttribute("baz"));
- }
-
- @Test
- public void testCornerCases() throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeWithEL.class);
- final ProcessorNode terminate = getTerminateProcessor();
-
- final Connection generatedFlowFileConnection = connect(generate, updateAttribute, REL_SUCCESS);
- final Connection updatedAttributeConnection = connect(updateAttribute, terminate, REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> variables = new HashMap<>();
- variables.put("#{test}", "variable #{test}");
- variables.put("${var}", "variable ${var}");
- variables.put("var", "abc");
- variables.put("abc", "123");
- getRootGroup().setVariables(variables);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("foo", "${#{test}}"); // References a Parameter named 'test'
- properties.put("bar", "${'#{test}'}"); // Parameter reference is quoted, which means that it's treated as a String, not a reference. This references a variable/attribute named '#{test}'
- properties.put("baz", "${ # this is a comment\n#{test}}"); // Test Parameter reference following a comment in EL
- properties.put("multi", "${ #### this is a comment\n#{test}}"); // Test several #'s for a comment, followed by a parameter reference
- properties.put("embedded", "${'$${var}'}"); // Here, we reference a variable/attribute named '${var}' - since EL Expressions can be embedded even within quotes, we must escape with extra $.
- properties.put("indirect", "${'${var}'}"); // Reference a variable/attribute whose name is defined by variable/attribute 'var' - i.e., reference variable 'var', whose value is 'abc', then
- // use that to reference variable "abc" to get a value of 123
- updateAttribute.setProperties(properties);
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileQueue flowFileQueue = updatedAttributeConnection.getFlowFileQueue();
- final FlowFileRecord flowFileRecord = flowFileQueue.poll(Collections.emptySet());
-
- assertEquals("unit", flowFileRecord.getAttribute("foo"));
- assertEquals("variable #{test}", flowFileRecord.getAttribute("bar"));
- assertEquals("unit", flowFileRecord.getAttribute("baz"));
- assertEquals("unit", flowFileRecord.getAttribute("multi"));
- assertEquals("variable ${var}", flowFileRecord.getAttribute("embedded"));
- assertEquals("123", flowFileRecord.getAttribute("indirect"));
- }
-
- @Test
- public void testReferencesStoredProperly() {
- final ProcessorNode updateAttributeWithEL = createProcessorNode(UpdateAttributeWithEL.class);
- final ProcessorNode updateAttributeNoEL = createProcessorNode(UpdateAttributeNoEL.class);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("foo", "#{test}");
- properties.put("bar", "${#{test}:toUpper()}");
-
- updateAttributeWithEL.setProperties(properties);
- updateAttributeNoEL.setProperties(properties);
-
- List<ParameterReference> references = updateAttributeWithEL.getProperty(updateAttributeWithEL.getPropertyDescriptor("foo")).getParameterReferences();
- assertEquals(1, references.size());
-
- references = updateAttributeWithEL.getProperty(updateAttributeWithEL.getPropertyDescriptor("bar")).getParameterReferences();
- assertEquals(1, references.size());
-
- references = updateAttributeNoEL.getProperty(updateAttributeNoEL.getPropertyDescriptor("foo")).getParameterReferences();
- assertEquals(1, references.size());
-
- references = updateAttributeNoEL.getProperty(updateAttributeNoEL.getPropertyDescriptor("bar")).getParameterReferences();
- assertEquals(1, references.size());
- }
-
- @Test
- public void testEscaping() throws ExecutionException, InterruptedException {
- testEscaping(UpdateAttributeNoEL.class);
- testEscaping(UpdateAttributeWithEL.class);
- testEscaping(UpdateAttributeCreateOwnProperty.class);
- }
-
- private void testEscaping(final Class<? extends Processor> updateAttributeClass) throws ExecutionException, InterruptedException {
- final ProcessorNode generate = createProcessorNode(GenerateProcessor.class);
- final ProcessorNode updateAttribute = createProcessorNode(updateAttributeClass);
-
- connect(generate, updateAttribute, REL_SUCCESS);
- final Connection terminateConnection = connect(updateAttribute, getTerminateProcessor(), REL_SUCCESS);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("1pound", "#{test}");
- properties.put("2pound", "##{test}");
- properties.put("3pound", "###{test}");
- properties.put("4pound", "####{test}");
- properties.put("5pound", "#####{test}");
-
- updateAttribute.setProperties(properties);
-
- triggerOnce(generate);
- triggerOnce(updateAttribute);
-
- final FlowFileRecord flowFile = terminateConnection.getFlowFileQueue().poll(Collections.emptySet());
- assertEquals("unit", flowFile.getAttribute("1pound"));
- assertEquals("#{test}", flowFile.getAttribute("2pound"));
- assertEquals("#unit", flowFile.getAttribute("3pound"));
- assertEquals("##{test}", flowFile.getAttribute("4pound"));
- assertEquals("##unit", flowFile.getAttribute("5pound"));
- }
-
- @Test
- public void testParameterReferenceCounts() {
- final ProcessorNode updateAttribute = createProcessorNode(UpdateAttributeWithEL.class);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("test", new Parameter(new ParameterDescriptor.Builder().name("test").build(), "unit")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("test", "#{test} #{test}");
- updateAttribute.setProperties(properties);
-
- final Set<String> allParamNames = Collections.singleton("test");
-
- Set<String> referencedParameters = updateAttribute.getReferencedParameterNames();
- assertEquals(allParamNames, referencedParameters);
-
- properties.put("test", "#{test} #{test} #{test}");
- updateAttribute.setProperties(properties);
- referencedParameters = updateAttribute.getReferencedParameterNames();
- assertEquals(allParamNames, referencedParameters);
-
- properties.put("test", null);
- updateAttribute.setProperties(properties);
- referencedParameters = updateAttribute.getReferencedParameterNames();
- assertEquals(Collections.emptySet(), referencedParameters);
-
- properties.put("test", "#{test}");
- updateAttribute.setProperties(properties);
- referencedParameters = updateAttribute.getReferencedParameterNames();
- assertEquals(allParamNames, referencedParameters);
- }
-
- @Test
- public void testSensitivePropertyReferenceParameterSupportsEL() {
- final ProcessorNode usernamePassword = createProcessorNode(UsernamePasswordProcessor.class);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("pass", new Parameter(new ParameterDescriptor.Builder().name("pass").sensitive(true).build(), "secret")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("password", "#{pass}");
- usernamePassword.setProperties(properties);
-
- final ProcessContext processContext = new StandardProcessContext(usernamePassword, getFlowController().getControllerServiceProvider(),
- getFlowController().getStateManagerProvider().getStateManager(usernamePassword.getIdentifier()), () -> false, getFlowController());
- final PropertyDescriptor descriptor = usernamePassword.getPropertyDescriptor("password");
- final PropertyValue propertyValue = processContext.getProperty(descriptor);
- final PropertyValue evaluatedPropertyValue = propertyValue.evaluateAttributeExpressions();
- final String evaluatedPassword = evaluatedPropertyValue.getValue();
- assertEquals("secret", evaluatedPassword);
- }
-
- @Test
- public void testSensitivePropertyNotAccessibleFromWithinEL() {
- final ProcessorNode usernamePassword = createProcessorNode(UsernamePasswordProcessor.class);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("pass", new Parameter(new ParameterDescriptor.Builder().name("pass").sensitive(true).build(), "secret")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("username", "${#{pass}}");
-
- assertThrows(IllegalArgumentException.class, () -> usernamePassword.setProperties(properties),
- "Was able to set properties when referencing sensitive parameter from within EL");
- }
-
- @Test
- public void testSensitivePropertyCannotBeSetToReferenceParamFromEL() {
- final ProcessorNode usernamePassword = createProcessorNode(UsernamePasswordProcessor.class);
-
- final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = createParameterContext(referenceManager);
- parameterContext.setParameters(Collections.singletonMap("pass", new Parameter(new ParameterDescriptor.Builder().name("pass").sensitive(true).build(), "secret")));
-
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, String> properties = new HashMap<>();
- properties.put("password", "${#{pass}}");
-
- assertThrows(IllegalArgumentException.class, () -> usernamePassword.setProperties(properties),
- "Was able to set properties when referencing sensitive parameter from within EL");
- }
-
- private ParameterContext createParameterContext(final ParameterReferenceManager referenceManager) {
- return createParameterContext("param-context", referenceManager);
- }
-
- private ParameterContext createParameterContext(final String name, final ParameterReferenceManager referenceManager) {
- final ParameterContext parameterContext = new StandardParameterContext.Builder()
- .id(UUID.randomUUID().toString())
- .name(name)
- .parameterReferenceManager(referenceManager)
- .build();
- return parameterContext;
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processgroup/StandardProcessGroupIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processgroup/StandardProcessGroupIT.java
deleted file mode 100644
index 6596196007..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processgroup/StandardProcessGroupIT.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * 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.integration.processgroup;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyDescriptor.Builder;
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.controller.ComponentNode;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.StandardSnippet;
-import org.apache.nifi.controller.queue.DropFlowFileState;
-import org.apache.nifi.controller.queue.DropFlowFileStatus;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.groups.ProcessGroup;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.integration.processor.BiConsumerProcessor;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.processor.util.StandardValidators;
-import org.apache.nifi.util.NiFiProperties;
-import org.apache.nifi.web.Revision;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class StandardProcessGroupIT extends FrameworkIntegrationTest {
-
- @Test
- public void testConflictingVersionedComponentId() {
- final ProcessorNode proc1 = createProcessorNode(BiConsumerProcessor.class, null);
- getRootGroup().addProcessor(proc1);
-
- final ProcessorNode proc2 = createProcessorNode(BiConsumerProcessor.class, null);
- proc2.setVersionedComponentId("aaa");
- getRootGroup().addProcessor(proc2);
- // Ensure that id didn't change
- assertEquals("aaa", proc2.getVersionedComponentId().get());
-
- final ProcessorNode proc3 = createProcessorNode(BiConsumerProcessor.class, null);
- proc3.setVersionedComponentId("bbb");
- getRootGroup().addProcessor(proc3);
- assertEquals("bbb", proc3.getVersionedComponentId().get());
-
- final ProcessorNode proc4 = createProcessorNode(BiConsumerProcessor.class, null);
- proc4.setVersionedComponentId("bbb");
- getRootGroup().addProcessor(proc4);
- // Ensure that versioned component id was nulled out
- assertFalse(proc4.getVersionedComponentId().isPresent());
-
- final ProcessGroup childGroup = getFlowController().getFlowManager().createProcessGroup("child");
- childGroup.setName("child");
- getRootGroup().addProcessGroup(childGroup);
-
- final ProcessorNode proc5 = createProcessorNode(BiConsumerProcessor.class, null);
- proc5.setVersionedComponentId("bbb");
- childGroup.addProcessor(proc5);
- assertEquals("bbb", proc5.getVersionedComponentId().get());
-
- // Move processor from child group to parent group.
- // This should null out the ID for proc5 and leave proc3 as is.
- final StandardSnippet snippet = new StandardSnippet();
- snippet.addProcessors(Collections.singletonMap(proc5.getIdentifier(), new Revision(0L, "abc", proc5.getIdentifier())));
- childGroup.move(snippet, getRootGroup());
- assertFalse(proc5.getVersionedComponentId().isPresent());
- assertEquals("bbb", proc3.getVersionedComponentId().get());
- }
-
- @Test
- public void testProcessGroupDefaults() {
- // Connect two processors with default settings of the root process group
- ProcessorNode sourceProcessor = createGenerateProcessor(1);
- ProcessorNode destinationProcessor = createProcessorNode((context, session) -> {});
- Connection connection = connect(sourceProcessor, destinationProcessor, Collections.singleton(REL_SUCCESS));
-
-
- // Verify all defaults are in place on the process group and the connection
- assertEquals("0 sec", getRootGroup().getDefaultFlowFileExpiration());
- assertEquals(NiFiProperties.DEFAULT_BACKPRESSURE_COUNT, (long) getRootGroup().getDefaultBackPressureObjectThreshold());
- assertEquals(NiFiProperties.DEFAULT_BACKPRESSURE_SIZE, getRootGroup().getDefaultBackPressureDataSizeThreshold());
- assertEquals("0 sec", connection.getFlowFileQueue().getFlowFileExpiration());
- assertEquals(NiFiProperties.DEFAULT_BACKPRESSURE_COUNT, (long) connection.getFlowFileQueue().getBackPressureObjectThreshold());
- assertEquals(NiFiProperties.DEFAULT_BACKPRESSURE_SIZE, connection.getFlowFileQueue().getBackPressureDataSizeThreshold());
-
- // Update default settings of the process group, and create a new connection
- getRootGroup().setDefaultFlowFileExpiration("99 min");
- getRootGroup().setDefaultBackPressureObjectThreshold(99L);
- getRootGroup().setDefaultBackPressureDataSizeThreshold("99 MB");
-
- ProcessorNode sourceProcessor1 = createGenerateProcessor(1);
- ProcessorNode destinationProcessor1 = createProcessorNode((context, session) -> {});
- Connection connection1 = connect(sourceProcessor1, destinationProcessor1, Collections.singleton(REL_SUCCESS));
-
- // Verify updated settings are in place on the process group and the connection
- assertEquals("99 min", getRootGroup().getDefaultFlowFileExpiration());
- assertEquals(99, (long) getRootGroup().getDefaultBackPressureObjectThreshold());
- assertEquals("99 MB", getRootGroup().getDefaultBackPressureDataSizeThreshold());
- assertEquals("99 min", connection1.getFlowFileQueue().getFlowFileExpiration());
- assertEquals(99, (long) connection1.getFlowFileQueue().getBackPressureObjectThreshold());
- assertEquals("99 MB", connection1.getFlowFileQueue().getBackPressureDataSizeThreshold());
- }
-
- @Test
- public void testDropAllFlowFilesFromOneConnection() throws Exception {
- ProcessorNode sourceProcessGroup = createGenerateProcessor(1);
- ProcessorNode destinationProcessGroup = createProcessorNode((context, session) -> {});
-
- Connection connection = connect(sourceProcessGroup, destinationProcessGroup, Collections.singleton(REL_SUCCESS));
-
- for (int i = 0; i < 5; i++) {
- triggerOnce(sourceProcessGroup);
- }
- assertEquals(5, connection.getFlowFileQueue().size().getObjectCount());
-
- // WHEN
- DropFlowFileStatus dropFlowFileStatus = getRootGroup().dropAllFlowFiles("requestId", "unimportant");
- while (dropFlowFileStatus.getState() != DropFlowFileState.COMPLETE) {
- TimeUnit.MILLISECONDS.sleep(10);
- dropFlowFileStatus = getRootGroup().getDropAllFlowFilesStatus("requestId");
- }
-
- // THEN
- assertEquals(0, connection.getFlowFileQueue().size().getObjectCount());
- }
-
- @Test
- public void testDropAllFlowFilesFromOneConnectionInChildProcessGroup() throws Exception {
- ProcessGroup childProcessGroup = getFlowController().getFlowManager().createProcessGroup("childProcessGroup");
- childProcessGroup.setName("ChildProcessGroup");
- getRootGroup().addProcessGroup(childProcessGroup);
-
- ProcessorNode sourceProcessGroup = createGenerateProcessor(1);
- moveProcessor(sourceProcessGroup, childProcessGroup);
-
- ProcessorNode destinationProcessGroup = createProcessorNode((context, session) -> {});
- moveProcessor(destinationProcessGroup, childProcessGroup);
-
- Connection connection = connect(childProcessGroup, sourceProcessGroup, destinationProcessGroup, Collections.singleton(REL_SUCCESS));
-
- for (int i = 0; i < 5; i++) {
- triggerOnce(sourceProcessGroup);
- }
- assertEquals(5, connection.getFlowFileQueue().size().getObjectCount());
-
- // WHEN
- DropFlowFileStatus dropFlowFileStatus = getRootGroup().dropAllFlowFiles("requestId", "unimportant");
- while (dropFlowFileStatus.getState() != DropFlowFileState.COMPLETE) {
- TimeUnit.MILLISECONDS.sleep(10);
- dropFlowFileStatus = childProcessGroup.getDropAllFlowFilesStatus("requestId");
- }
-
- // THEN
- assertEquals(0, connection.getFlowFileQueue().size().getObjectCount());
- }
-
- @Test
- public void testDropAllFlowFilesFromMultipleConnections() throws Exception {
- ProcessGroup childProcessGroup = getFlowController().getFlowManager().createProcessGroup("childProcessGroup");
- childProcessGroup.setName("ChildProcessGroup");
- getRootGroup().addProcessGroup(childProcessGroup);
-
- ProcessorNode sourceProcessGroup1 = createGenerateProcessor(4);
- moveProcessor(sourceProcessGroup1, childProcessGroup);
-
- ProcessorNode sourceProcessGroup2 = createGenerateProcessor(5);
- moveProcessor(sourceProcessGroup2, childProcessGroup);
-
- ProcessorNode destinationProcessGroup = createProcessorNode((context, session) -> {});
- moveProcessor(destinationProcessGroup, childProcessGroup);
-
- Connection connection1 = connect(childProcessGroup, sourceProcessGroup1, destinationProcessGroup, Collections.singleton(REL_SUCCESS));
- Connection connection2 = connect(childProcessGroup, sourceProcessGroup2, destinationProcessGroup, Collections.singleton(REL_SUCCESS));
-
- for (int i = 0; i < 5; i++) {
- triggerOnce(sourceProcessGroup1);
- }
- assertEquals(5, connection1.getFlowFileQueue().size().getObjectCount());
-
- for (int i = 0; i < 10; i++) {
- triggerOnce(sourceProcessGroup2);
- }
- assertEquals(10, connection2.getFlowFileQueue().size().getObjectCount());
-
- // WHEN
- DropFlowFileStatus dropFlowFileStatus = getRootGroup().dropAllFlowFiles("requestId", "unimportant");
- while (dropFlowFileStatus.getState() != DropFlowFileState.COMPLETE) {
- TimeUnit.MILLISECONDS.sleep(10);
- dropFlowFileStatus = childProcessGroup.getDropAllFlowFilesStatus("requestId");
- }
-
- // THEN
- assertEquals(5 + 10, dropFlowFileStatus.getOriginalSize().getObjectCount());
- assertEquals(20 + 50, dropFlowFileStatus.getOriginalSize().getByteCount());
-
- assertEquals(0, dropFlowFileStatus.getCurrentSize().getObjectCount());
- assertEquals(0, dropFlowFileStatus.getCurrentSize().getByteCount());
-
- assertEquals(5 + 10, dropFlowFileStatus.getDroppedSize().getObjectCount());
- assertEquals(20 + 50, dropFlowFileStatus.getDroppedSize().getByteCount());
-
- assertEquals(0, connection1.getFlowFileQueue().size().getObjectCount());
- assertEquals(0, connection2.getFlowFileQueue().size().getObjectCount());
- }
-
- @Test
- public void testComponentsAffectedByVariableOverridden() {
- final ProcessGroup child = getFlowController().getFlowManager().createProcessGroup("child");
- child.setName("Child");
- child.setVariables(Collections.singletonMap("number", "5"));
-
- getRootGroup().setVariables(Collections.singletonMap("number", "1"));
- getRootGroup().addProcessGroup(child);
-
- final ProcessorNode processor = createProcessorNode(NumberRefProcessor.class);
- processor.setProperties(Collections.singletonMap(NumberRefProcessor.NUMBER.getName(), "${number}"));
- moveProcessor(processor, child);
-
- final Set<ComponentNode> componentsAffected = child.getComponentsAffectedByVariable("number");
- assertEquals(1, componentsAffected.size());
- assertTrue(componentsAffected.contains(processor));
-
- final Set<ComponentNode> rootAffected = getRootGroup().getComponentsAffectedByVariable("number");
- assertTrue(rootAffected.isEmpty());
-
- processor.setSchedulingPeriod("1 hour");
- child.startProcessor(processor, false);
-
- getRootGroup().setVariables(Collections.singletonMap("number", "2"));
-
- assertThrows(IllegalStateException.class,
- () -> child.setVariables(Collections.singletonMap("number", "10")),
- "Updated variable that is referenced by a running processor");
-
- child.stopProcessor(processor);
- }
-
-
- public static class NumberRefProcessor extends AbstractProcessor {
- static final PropertyDescriptor NUMBER = new Builder()
- .name("Number")
- .displayName("Number")
- .description("A Number")
- .required(true)
- .addValidator(StandardValidators.NUMBER_VALIDATOR)
- .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
- .defaultValue("1")
- .build();
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Collections.singletonList(NUMBER);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
-
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/BiConsumerProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/BiConsumerProcessor.java
deleted file mode 100644
index e55473da1d..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/BiConsumerProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.integration.processor;
-
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.function.BiConsumer;
-
-public class BiConsumerProcessor extends AbstractProcessor {
- private BiConsumer<ProcessContext, ProcessSession> trigger;
- private volatile Set<Relationship> relationships;
-
- public void setTrigger(final BiConsumer<ProcessContext, ProcessSession> trigger) {
- this.trigger = trigger;
- }
-
- public void setRelationships(final Set<Relationship> relationships) {
- this.relationships = relationships;
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- while (relationships == null) {
- try {
- Thread.sleep(1L);
- } catch (final InterruptedException ie) {
- Thread.currentThread().interrupt();
- return Collections.emptySet();
- }
- }
-
- return relationships;
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- if (trigger == null) {
- throw new IllegalStateException("Trigger has not been initialized");
- }
-
- trigger.accept(context, session);
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/ProcessorParameterTokenIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/ProcessorParameterTokenIT.java
deleted file mode 100644
index dae500dbcc..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processor/ProcessorParameterTokenIT.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * 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.integration.processor;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyDescriptor.Builder;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.integration.DirectInjectionExtensionManager;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.parameter.Parameter;
-import org.apache.nifi.parameter.ParameterContext;
-import org.apache.nifi.parameter.ParameterDescriptor;
-import org.apache.nifi.parameter.ParameterReferenceManager;
-import org.apache.nifi.parameter.StandardParameterContext;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Processor;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-import org.junit.jupiter.api.Test;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-
-import static org.apache.nifi.processor.util.StandardValidators.NON_EMPTY_VALIDATOR;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-public class ProcessorParameterTokenIT extends FrameworkIntegrationTest {
-
- @Override
- protected void injectExtensionTypes(final DirectInjectionExtensionManager extensionManager) {
- extensionManager.injectExtensionType(Processor.class, WriteText.class);
- }
-
- @Test
- public void testEscapedParameterReference() throws ExecutionException, InterruptedException {
- final ProcessorNode procNode = createProcessorNode(WriteText.class);
- procNode.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
-
- verifyText(procNode, "hello", "hello");
- verifyText(procNode, "##{foo}", "#{foo}");
- verifyText(procNode, "####{foo}", "##{foo}");
- verifyText(procNode, "## hello ##{foo} ##{bar}", "## hello #{foo} #{bar}");
- }
-
- @Test
- public void testProperReferences() throws ExecutionException, InterruptedException {
- final ProcessorNode procNode = createProcessorNode(WriteText.class);
- procNode.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
-
- final ParameterContext parameterContext = createParameterContext("testEscapedParameterReference");
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, Parameter> parameters = new HashMap<>();
- parameters.put("foo", new Parameter(new ParameterDescriptor.Builder().name("foo").build(), "bar"));
- parameters.put("sensitive", new Parameter(new ParameterDescriptor.Builder().name("sensitive").sensitive(true).build(), "*password*"));
- parameterContext.setParameters(parameters);
-
- verifyText(procNode, "hello", "hello");
- verifyText(procNode, "##{foo}", "#{foo}");
- verifyText(procNode, "#{foo}", "bar");
- verifyText(procNode, "####{foo}", "##{foo}");
- verifyText(procNode, "#####{foo}", "##bar");
- verifyText(procNode, "## hello #{foo} ##{bar}", "## hello bar #{bar}");
-
- try {
- verifyText(procNode, "#{bar}", "ISE");
- } catch (final IllegalStateException expected) {
- // Expect IllegalStateException because processor is not valid because it references a non-existent parameter.
- }
-
- verifyText(procNode, "#{foo}", "password", "barpassword");
- verifyText(procNode, "#{foo}", "#{sensitive}", "bar*password*");
- }
-
- @Test
- public void testSensitiveParameters() throws ExecutionException, InterruptedException {
- final ProcessorNode procNode = createProcessorNode(WriteText.class);
- procNode.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
-
- final ParameterContext parameterContext = createParameterContext("testEscapedParameterReference");
- getRootGroup().setParameterContext(parameterContext);
-
- final Map<String, Parameter> parameters = new HashMap<>();
- parameters.put("foo", new Parameter(new ParameterDescriptor.Builder().name("foo").build(), "bar"));
- parameters.put("sensitive", new Parameter(new ParameterDescriptor.Builder().name("sensitive").sensitive(true).build(), "*password*"));
- parameterContext.setParameters(parameters);
-
- verifyCannotSetParameter(procNode, "#{sensitive}", null);
- verifyCannotSetParameter(procNode, "abc#{sensitive}foo", null);
- verifyCannotSetParameter(procNode, "#{foo}", "#{foo}");
- verifyCannotSetParameter(procNode, null, "#{sensitive}#{sensitive}");
- verifyCannotSetParameter(procNode, null, "#{sensitive}123");
- verifyCannotSetParameter(procNode, null, "123#{sensitive}");
- verifyCannotSetParameter(procNode, null, "#{foo}");
-
- verifyText(procNode, "#{foo}", "#{sensitive}", "bar*password*");
- verifyText(procNode, "#{foo}", "##{sensitive}##{sensitive}##{sensitive}", "bar#{sensitive}#{sensitive}#{sensitive}");
- }
-
- private void verifyCannotSetParameter(final ProcessorNode procNode, final String text, final String password) {
- final Map<String, String> properties = new HashMap<>();
- properties.put(WriteText.TEXT.getName(), text);
- properties.put(WriteText.PASSWORD.getName(), password);
-
- assertThrows(IllegalArgumentException.class, () -> procNode.setProperties(properties),
- "Expected to fail when setting properties to " + properties);
- }
-
- private void verifyText(final ProcessorNode procNode, final String text, final String expectedOutput) throws ExecutionException, InterruptedException {
- verifyText(procNode, text, null, expectedOutput);
- }
-
- private void verifyText(final ProcessorNode procNode, final String text, final String password, final String expectedOutput) throws ExecutionException, InterruptedException {
- final Map<String, String> properties = new HashMap<>();
- properties.put(WriteText.TEXT.getName(), text);
- properties.put(WriteText.PASSWORD.getName(), password);
-
- procNode.setProperties(properties);
- triggerOnce(procNode);
-
- final WriteText writeText = (WriteText) procNode.getProcessor();
- final String textWritten = writeText.getTextLastWritten();
-
- assertEquals("For input text <" + text+ "> and password <" + password + ">, expected output was <" + expectedOutput + "> but got <" + textWritten + ">", expectedOutput, textWritten);
- }
-
-
- public static class WriteText extends AbstractProcessor {
- private volatile String textLastWritten = null;
-
- static final PropertyDescriptor TEXT = new Builder()
- .name("Text")
- .displayName("Text")
- .description("The text to write")
- .required(true)
- .addValidator(NON_EMPTY_VALIDATOR)
- .build();
-
- static final PropertyDescriptor PASSWORD = new Builder()
- .name("password")
- .displayName("password")
- .description("Password")
- .required(false)
- .addValidator(NON_EMPTY_VALIDATOR)
- .sensitive(true)
- .build();
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Arrays.asList(TEXT, PASSWORD);
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return Collections.singleton(REL_SUCCESS);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- FlowFile flowFile = session.create();
-
- final String text = context.getProperty(TEXT).getValue();
-
- final String fullText;
- if (context.getProperty(PASSWORD).isSet()) {
- fullText = text + context.getProperty(PASSWORD).getValue();
- } else {
- fullText = text;
- }
-
- flowFile = session.write(flowFile, out -> out.write(fullText.getBytes(StandardCharsets.UTF_8)));
- session.transfer(flowFile, REL_SUCCESS);
-
- textLastWritten = fullText;
- }
-
- private String getTextLastWritten() {
- return textLastWritten;
- }
- }
-
- private ParameterContext createParameterContext(final String name) {
- return new StandardParameterContext.Builder()
- .id(UUID.randomUUID().toString())
- .name(name)
- .parameterReferenceManager(ParameterReferenceManager.EMPTY)
- .build();
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/GenerateProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/GenerateProcessor.java
deleted file mode 100644
index 1a67871969..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/GenerateProcessor.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyDescriptor.Builder;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.DataUnit;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import static org.apache.nifi.processor.util.StandardValidators.DATA_SIZE_VALIDATOR;
-import static org.apache.nifi.processor.util.StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR;
-
-public class GenerateProcessor extends AbstractProcessor {
- public static final PropertyDescriptor COUNT = new Builder()
- .name("Count")
- .displayName("Count")
- .description("Number of FlowFiles to generate")
- .required(true)
- .addValidator(NON_NEGATIVE_INTEGER_VALIDATOR)
- .defaultValue("1")
- .build();
-
- public static final PropertyDescriptor CONTENT_SIZE = new Builder()
- .name("Content Size")
- .displayName("Content Size")
- .description("Size of the FlowFile")
- .required(true)
- .addValidator(DATA_SIZE_VALIDATOR)
- .defaultValue("0 B")
- .build();
-
- public static final Relationship REL_SUCCESS = new Relationship.Builder()
- .name("success")
- .build();
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Arrays.asList(COUNT, CONTENT_SIZE);
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return Collections.singleton(REL_SUCCESS);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- for (int i=0; i < context.getProperty(COUNT).asInteger(); i++) {
- FlowFile flowFile = session.create();
-
- final int size = context.getProperty(CONTENT_SIZE).asDataSize(DataUnit.B).intValue();
- final byte[] data = new byte[size];
- session.write(flowFile, out -> out.write(data));
- session.transfer(flowFile, REL_SUCCESS);
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/NopProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/NopProcessor.java
deleted file mode 100644
index 94265c4f6f..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/NopProcessor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.exception.ProcessException;
-
-public class NopProcessor extends AbstractProcessor {
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/TerminateAll.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/TerminateAll.java
deleted file mode 100644
index 4295f284e4..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/TerminateAll.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.exception.ProcessException;
-
-public class TerminateAll extends AbstractProcessor {
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- FlowFile flowFile;
- while ((flowFile = session.get()) != null) {
- session.remove(flowFile);
- session.adjustCounter("Removed", 1, false);
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/TerminateOnce.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/TerminateOnce.java
deleted file mode 100644
index 14ed476b48..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/TerminateOnce.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.exception.ProcessException;
-
-public class TerminateOnce extends AbstractProcessor {
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- FlowFile flowFile = session.get();
- if (flowFile != null) {
- session.remove(flowFile);
- }
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeCreateOwnProperty.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeCreateOwnProperty.java
deleted file mode 100644
index b50fc20724..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeCreateOwnProperty.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyValue;
-import org.apache.nifi.components.Validator;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Collections;
-import java.util.Set;
-
-public class UpdateAttributeCreateOwnProperty extends AbstractProcessor {
-
- public static final Relationship REL_SUCCESS = new Relationship.Builder()
- .name("success")
- .build();
-
- @Override
- protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
- return new PropertyDescriptor.Builder()
- .name(propertyDescriptorName)
- .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .addValidator(Validator.VALID)
- .build();
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return Collections.singleton(REL_SUCCESS);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- FlowFile flowFile = session.get();
- if (flowFile == null) {
- return;
- }
-
- for (final String propertyName : context.getAllProperties().keySet()) {
- final String propertyValue = context.getProperty(propertyName).getValue();
- final PropertyValue propValue = context.newPropertyValue(propertyValue);
- final String evaluated = propValue.evaluateAttributeExpressions(flowFile).getValue();
- flowFile = session.putAttribute(flowFile, propertyName, evaluated);
- }
-
- session.transfer(flowFile, REL_SUCCESS);
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeNoEL.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeNoEL.java
deleted file mode 100644
index 1b37197c09..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeNoEL.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.Validator;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Collections;
-import java.util.Set;
-
-public class UpdateAttributeNoEL extends AbstractProcessor {
-
- public static final Relationship REL_SUCCESS = new Relationship.Builder()
- .name("success")
- .build();
-
- @Override
- protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
- return new PropertyDescriptor.Builder()
- .expressionLanguageSupported(ExpressionLanguageScope.NONE)
- .name(propertyDescriptorName)
- .addValidator(Validator.VALID)
- .build();
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return Collections.singleton(REL_SUCCESS);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- FlowFile flowFile = session.get();
- if (flowFile == null) {
- return;
- }
-
- for (final String propertyName : context.getAllProperties().keySet()) {
- final String value = context.getProperty(propertyName).getValue();
- flowFile = session.putAttribute(flowFile, propertyName, value);
- }
-
- session.transfer(flowFile, REL_SUCCESS);
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeWithEL.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeWithEL.java
deleted file mode 100644
index 3cb979f7a3..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UpdateAttributeWithEL.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.Validator;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.exception.ProcessException;
-
-import java.util.Collections;
-import java.util.Set;
-
-public class UpdateAttributeWithEL extends AbstractProcessor {
-
- public static final Relationship REL_SUCCESS = new Relationship.Builder()
- .name("success")
- .build();
-
- @Override
- protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
- return new PropertyDescriptor.Builder()
- .name(propertyDescriptorName)
- .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .addValidator(Validator.VALID)
- .build();
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return Collections.singleton(REL_SUCCESS);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
- FlowFile flowFile = session.get();
- if (flowFile == null) {
- return;
- }
-
- for (final String propertyName : context.getAllProperties().keySet()) {
- final String value = context.getProperty(propertyName).evaluateAttributeExpressions(flowFile).getValue();
- flowFile = session.putAttribute(flowFile, propertyName, value);
- }
-
- session.transfer(flowFile, REL_SUCCESS);
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UsernamePasswordProcessor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UsernamePasswordProcessor.java
deleted file mode 100644
index 09378e0502..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/processors/UsernamePasswordProcessor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.integration.processors;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyDescriptor.Builder;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.processor.util.StandardValidators;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class UsernamePasswordProcessor extends AbstractProcessor {
- public static final PropertyDescriptor USERNAME = new Builder()
- .name("username")
- .displayName("username")
- .description("username")
- .required(false)
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .defaultValue("")
- .build();
-
- public static final PropertyDescriptor PASSWORD = new Builder()
- .name("password")
- .displayName("password")
- .description("password")
- .required(false)
- .sensitive(true)
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .defaultValue("")
- .build();
-
- @Override
- protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return Arrays.asList(USERNAME, PASSWORD);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
-
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/provenance/ProvenanceEventsIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/provenance/ProvenanceEventsIT.java
deleted file mode 100644
index 5848e4e1fb..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/provenance/ProvenanceEventsIT.java
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- * 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.integration.provenance;
-
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.provenance.ProvenanceEventRecord;
-import org.apache.nifi.provenance.ProvenanceEventRepository;
-import org.apache.nifi.provenance.ProvenanceEventType;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-public class ProvenanceEventsIT extends FrameworkIntegrationTest {
-
- @Test
- public void testCreateEventIfNewFlowFileWithoutReceive() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.create();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(createProcessor, getTerminateAllProcessor(), REL_SUCCESS);
- triggerOnce(createProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(0L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
- assertEquals("integration", firstEvent.getAttribute("test"));
- assertEquals("true", firstEvent.getAttribute("integration"));
- }
-
- @Test
- public void testNoCreateEventIfReceiveExplicitlyCreated() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.create();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- session.getProvenanceReporter().receive(flowFile, "nifi://unit.test");
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(createProcessor, getTerminateAllProcessor(), REL_SUCCESS);
- triggerOnce(createProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(0L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.RECEIVE, firstEvent.getEventType());
- assertEquals("integration", firstEvent.getAttribute("test"));
- assertEquals("true", firstEvent.getAttribute("integration"));
- assertEquals("nifi://unit.test", firstEvent.getTransitUri());
- }
-
- @Test
- public void testDropEventIfRoutedToAutoTerminatedRelationship() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.create();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- createProcessor.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
-
- triggerOnce(createProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(1L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
- assertEquals("integration", firstEvent.getAttribute("test"));
- assertEquals("true", firstEvent.getAttribute("integration"));
-
- final ProvenanceEventRecord secondEvent = provRepo.getEvent(1L);
- assertEquals(ProvenanceEventType.DROP, secondEvent.getEventType());
- assertEquals("integration", secondEvent.getAttribute("test"));
- assertEquals("true", secondEvent.getAttribute("integration"));
- }
-
- @Test
- public void testNoEventsIfExplicitlyRemoved() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.create();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- session.remove(flowFile);
- }, REL_SUCCESS);
-
- createProcessor.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
-
- triggerOnce(createProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(-1L, provRepo.getMaxEventId().longValue());
- assertTrue(provRepo.getEvents(0L, 1000).isEmpty());
- }
-
- @Test
- public void testAttributesModifiedIfNothingElse() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createGenerateProcessor(0);
-
- final ProcessorNode updateProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.get();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(createProcessor, updateProcessor, REL_SUCCESS);
- connect(updateProcessor, getTerminateAllProcessor(), REL_SUCCESS);
-
- triggerOnce(createProcessor);
- triggerOnce(updateProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(1L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
- assertNull(firstEvent.getAttribute("test"));
- assertNull(firstEvent.getAttribute("integration"));
-
- final ProvenanceEventRecord secondEvent = provRepo.getEvent(1L);
- assertEquals(ProvenanceEventType.ATTRIBUTES_MODIFIED, secondEvent.getEventType());
- assertEquals("integration", secondEvent.getAttribute("test"));
- assertEquals("true", secondEvent.getAttribute("integration"));
- }
-
- @Test
- public void testAttributesModifiedNotCreatedIfProcessorEmitsIt() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createGenerateProcessor(0);
-
- final ProcessorNode updateProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.get();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- session.getProvenanceReporter().modifyAttributes(flowFile, "Unit Test Details");
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(createProcessor, updateProcessor, REL_SUCCESS);
- connect(updateProcessor, getTerminateAllProcessor(), REL_SUCCESS);
-
- triggerOnce(createProcessor);
- triggerOnce(updateProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(1L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
- assertNull(firstEvent.getAttribute("test"));
- assertNull(firstEvent.getAttribute("integration"));
-
- final ProvenanceEventRecord secondEvent = provRepo.getEvent(1L);
- assertEquals(ProvenanceEventType.ATTRIBUTES_MODIFIED, secondEvent.getEventType());
- assertEquals("integration", secondEvent.getAttribute("test"));
- assertEquals("true", secondEvent.getAttribute("integration"));
- assertEquals("Unit Test Details", secondEvent.getDetails());
- }
-
- @Test
- public void testAttributesModifiedNotCreatedIfProcessorEmitsOtherEvent() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createGenerateProcessor(0);
-
- final ProcessorNode updateProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.get();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- session.getProvenanceReporter().fetch(flowFile, "nifi://unit.test");
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(createProcessor, updateProcessor, REL_SUCCESS);
- connect(updateProcessor, getTerminateAllProcessor(), REL_SUCCESS);
-
- triggerOnce(createProcessor);
- triggerOnce(updateProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(1L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
- assertNull(firstEvent.getAttribute("test"));
- assertNull(firstEvent.getAttribute("integration"));
-
- final ProvenanceEventRecord secondEvent = provRepo.getEvent(1L);
- assertEquals(ProvenanceEventType.FETCH, secondEvent.getEventType());
- assertEquals("integration", secondEvent.getAttribute("test"));
- assertEquals("true", secondEvent.getAttribute("integration"));
- assertEquals("nifi://unit.test", secondEvent.getTransitUri());
- }
-
-
- @Test
- public void testAttributesModifiedNotCreatedIfContentModified() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createGenerateProcessor(0);
-
- final ProcessorNode updateProcessor = createProcessorNode((context, session) -> {
- FlowFile flowFile = session.get();
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- flowFile = session.putAllAttributes(flowFile, attrs);
- flowFile = session.write(flowFile, out -> out.write('A'));
- session.transfer(flowFile, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(createProcessor, updateProcessor, REL_SUCCESS);
- connect(updateProcessor, getTerminateAllProcessor(), REL_SUCCESS);
-
- triggerOnce(createProcessor);
- triggerOnce(updateProcessor);
-
- // There should be exactly 1 event.
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(1L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
- assertNull(firstEvent.getAttribute("test"));
- assertNull(firstEvent.getAttribute("integration"));
-
- final ProvenanceEventRecord secondEvent = provRepo.getEvent(1L);
- assertEquals(ProvenanceEventType.CONTENT_MODIFIED, secondEvent.getEventType());
- assertEquals("integration", secondEvent.getAttribute("test"));
- assertEquals("true", secondEvent.getAttribute("integration"));
- }
-
-
- @Test
- public void testNoAttributesModifiedOnJoin() throws ExecutionException, InterruptedException, IOException {
- testJoin(false);
- }
-
- @Test
- public void testNoAttributesModifiedOnJoinWithExplicitJoinEvent() throws ExecutionException, InterruptedException, IOException {
- testJoin(true);
- }
-
- private void testJoin(final boolean emitJoinEventExplicitly) throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode createProcessor = createGenerateProcessor(0);
-
- final ProcessorNode joinProcessor = createProcessorNode((context, session) -> {
- final List<FlowFile> originals = new ArrayList<>();
- FlowFile flowFile;
- while ((flowFile = session.get()) != null) {
- originals.add(flowFile);
- }
-
- FlowFile merged = session.create(originals);
-
- final Map<String, String> attrs = new HashMap<>();
- attrs.put("test", "integration");
- attrs.put("integration", "true");
-
- merged = session.putAllAttributes(merged, attrs);
- merged = session.write(merged, out -> out.write('A'));
-
- if (emitJoinEventExplicitly) {
- session.getProvenanceReporter().join(originals, merged);
- }
-
- session.remove(originals);
- session.transfer(merged, REL_SUCCESS);
- session.getProvenanceReporter().route(merged, REL_SUCCESS);
- }, REL_SUCCESS);
-
- connect(createProcessor, joinProcessor, REL_SUCCESS);
- joinProcessor.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
-
- for (int i=0; i < 3; i++) {
- triggerOnce(createProcessor);
- }
-
- triggerOnce(joinProcessor);
-
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(8L, provRepo.getMaxEventId().longValue());
-
- // Crete events are from the first 'generate' processor.
- for (int i=0; i < 3; i++) {
- assertEquals(ProvenanceEventType.CREATE, provRepo.getEvent(i).getEventType());
- }
-
- // Any FORK/JOIN events will occur first in the Process Session to ensure that any other events that reference the FlowFile
- // that is created as a result have a FlowFile to actually reference.
- final ProvenanceEventRecord joinEvent = provRepo.getEvent(3);
- assertEquals(ProvenanceEventType.JOIN, joinEvent.getEventType());
- assertEquals("integration", joinEvent.getAttribute("test"));
- assertEquals("true", joinEvent.getAttribute("integration"));
- assertEquals(3, joinEvent.getParentUuids().size());
- assertEquals(1, joinEvent.getChildUuids().size());
- assertEquals(joinEvent.getFlowFileUuid(), joinEvent.getChildUuids().get(0));
-
- // Next event to occur in the Processor is the DORP event
- for (int i=4; i < 7; i++) {
- assertEquals(ProvenanceEventType.DROP, provRepo.getEvent(i).getEventType());
- }
-
- // Finally Processor will ROUTE the FlowFile
- final ProvenanceEventRecord routeEvent = provRepo.getEvent(7);
- assertEquals(ProvenanceEventType.ROUTE, routeEvent.getEventType());
- assertEquals("success", routeEvent.getRelationship());
- assertEquals("integration", routeEvent.getAttribute("test"));
- assertEquals("true", routeEvent.getAttribute("integration"));
-
- // Merged FlowFile is then auto-terminated.
- final ProvenanceEventRecord dropJoinedEvent = provRepo.getEvent(8);
- assertEquals(ProvenanceEventType.DROP, dropJoinedEvent.getEventType());
- assertEquals("integration", dropJoinedEvent.getAttribute("test"));
- assertEquals("true", dropJoinedEvent.getAttribute("integration"));
- }
-
- @Test
- public void testForkAutoGenerated() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode generateProcessor = createGenerateProcessor(0);
- final ProcessorNode forkProcessor = createProcessorNode((context, session) -> {
- FlowFile original = session.get();
-
- for (int i=0; i < 3; i++) {
- FlowFile child = session.create(original);
- child = session.putAttribute(child, "i", String.valueOf(i));
- session.transfer(child, REL_SUCCESS);
- }
-
- session.remove(original);
- }, REL_SUCCESS);
-
- connect(generateProcessor, forkProcessor, REL_SUCCESS);
- connect(forkProcessor, getTerminateAllProcessor(), REL_SUCCESS);
-
- triggerOnce(generateProcessor);
- triggerOnce(forkProcessor);
-
- final ProvenanceEventRepository provRepo = getProvenanceRepository();
- assertEquals(2L, provRepo.getMaxEventId().longValue());
-
- final ProvenanceEventRecord firstEvent = provRepo.getEvent(0L);
- assertEquals(ProvenanceEventType.CREATE, firstEvent.getEventType());
- assertNull(firstEvent.getAttribute("test"));
- assertNull(firstEvent.getAttribute("integration"));
-
- final ProvenanceEventRecord secondEvent = provRepo.getEvent(1L);
- assertEquals(ProvenanceEventType.FORK, secondEvent.getEventType());
- assertEquals(1, secondEvent.getParentUuids().size());
- assertEquals(3, secondEvent.getChildUuids().size());
- assertEquals(secondEvent.getFlowFileUuid(), secondEvent.getParentUuids().get(0));
-
- 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 testCloneOnMultipleConnectionsForRelationshipIncludesUpdatedAttributes() 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());
-
- 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());
- assertEquals("integration", secondEvent.getAttribute("test"));
- }
-
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/swap/StandaloneSwapFileIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/swap/StandaloneSwapFileIT.java
deleted file mode 100644
index 57ba2c3f74..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/swap/StandaloneSwapFileIT.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.integration.swap;
-
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.queue.LocalQueuePartitionDiagnostics;
-import org.apache.nifi.controller.queue.QueueDiagnostics;
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.integration.processors.GenerateProcessor;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-public class StandaloneSwapFileIT extends FrameworkIntegrationTest {
- @Timeout(60)
- @Test
- public void testSwapOnRestart() throws ExecutionException, InterruptedException, IOException {
- final ProcessorNode generator = createProcessorNode(GenerateProcessor.class);
- generator.setProperties(Collections.singletonMap(GenerateProcessor.COUNT.getName(), "60000"));
-
- Connection connection = connect(generator, getTerminateAllProcessor(), REL_SUCCESS);
- triggerOnce(generator);
-
- FlowFileQueue queue = connection.getFlowFileQueue();
- QueueDiagnostics diagnostics = queue.getQueueDiagnostics();
- LocalQueuePartitionDiagnostics localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- assertEquals(20_000, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(4, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(40_000, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(60_000, queue.size().getObjectCount());
-
- // restart nifi
- restart();
-
- // get the new Connection with the same ID
- connection = getRootGroup().getConnection(connection.getIdentifier());
- queue = connection.getFlowFileQueue();
- diagnostics = queue.getQueueDiagnostics();
- localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- // Ensure we have the correct queue sizes
- assertEquals(20_000, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(4, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(40_000, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(60_000, queue.size().getObjectCount());
-
- // Consume all the data
- for (int i=0; i < 60_000; i++) {
- final FlowFileRecord flowFile = queue.poll(Collections.emptySet());
- assertNotNull(flowFile);
-
- queue.acknowledge(flowFile);
- }
-
- assertNull(queue.poll(Collections.emptySet()));
-
- // Check queue sizes again
- diagnostics = queue.getQueueDiagnostics();
- localPartitionDiagnostics = diagnostics.getLocalQueuePartitionDiagnostics();
-
- assertEquals(0, localPartitionDiagnostics.getActiveQueueSize().getObjectCount());
- assertEquals(0, localPartitionDiagnostics.getSwapFileCount());
- assertEquals(0, localPartitionDiagnostics.getSwapQueueSize().getObjectCount());
- assertEquals(0, queue.size().getObjectCount());
- }
-
-
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/versioned/ImportFlowIT.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/versioned/ImportFlowIT.java
deleted file mode 100644
index 91f18fd41f..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/integration/versioned/ImportFlowIT.java
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- * 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.integration.versioned;
-
-import org.apache.nifi.components.ValidationResult;
-import org.apache.nifi.components.validation.ValidationStatus;
-import org.apache.nifi.connectable.Connection;
-import org.apache.nifi.connectable.Funnel;
-import org.apache.nifi.connectable.Port;
-import org.apache.nifi.controller.ControllerService;
-import org.apache.nifi.controller.ProcessorNode;
-import org.apache.nifi.controller.StandardSnippet;
-import org.apache.nifi.controller.service.ControllerServiceNode;
-import org.apache.nifi.flow.VersionedControllerService;
-import org.apache.nifi.flow.VersionedComponent;
-import org.apache.nifi.flow.VersionedExternalFlow;
-import org.apache.nifi.flow.VersionedParameterContext;
-import org.apache.nifi.flow.VersionedProcessGroup;
-import org.apache.nifi.groups.ProcessGroup;
-import org.apache.nifi.integration.DirectInjectionExtensionManager;
-import org.apache.nifi.integration.FrameworkIntegrationTest;
-import org.apache.nifi.integration.cs.LongValidatingControllerService;
-import org.apache.nifi.integration.cs.NopControllerService;
-import org.apache.nifi.integration.cs.NopServiceReferencingProcessor;
-import org.apache.nifi.integration.processors.GenerateProcessor;
-import org.apache.nifi.integration.processors.UsernamePasswordProcessor;
-import org.apache.nifi.parameter.Parameter;
-import org.apache.nifi.parameter.ParameterContext;
-import org.apache.nifi.parameter.ParameterDescriptor;
-import org.apache.nifi.parameter.ParameterReferenceManager;
-import org.apache.nifi.parameter.StandardParameterContext;
-import org.apache.nifi.parameter.StandardParameterReferenceManager;
-import org.apache.nifi.processor.Processor;
-import org.apache.nifi.registry.flow.diff.ComparableDataFlow;
-import org.apache.nifi.registry.flow.diff.ConciseEvolvingDifferenceDescriptor;
-import org.apache.nifi.registry.flow.diff.DifferenceType;
-import org.apache.nifi.registry.flow.diff.FlowComparator;
-import org.apache.nifi.registry.flow.diff.FlowComparatorVersionedStrategy;
-import org.apache.nifi.registry.flow.diff.FlowComparison;
-import org.apache.nifi.registry.flow.diff.FlowDifference;
-import org.apache.nifi.registry.flow.diff.StandardComparableDataFlow;
-import org.apache.nifi.registry.flow.diff.StandardFlowComparator;
-import org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup;
-import org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper;
-import org.apache.nifi.util.FlowDifferenceFilters;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-public class ImportFlowIT extends FrameworkIntegrationTest {
- @Override
- public void setup() throws IOException {
- super.setup();
-
- for (ProcessorNode processor : getRootGroup().getProcessors()) {
- getRootGroup().removeProcessor(processor);
- }
- }
-
- @Override
- protected void injectExtensionTypes(final DirectInjectionExtensionManager extensionManager) {
- extensionManager.injectExtensionType(Processor.class, NopServiceReferencingProcessor.class);
- extensionManager.injectExtensionType(ControllerService.class, LongValidatingControllerService.class);
- }
-
- @Test
- public void testImportFlowWithProcessorAndControllerService() throws ExecutionException, InterruptedException {
- // Build a Versioned Flow that consists of a Controller Service and a Processor
- // that references that Controller Service.
- final ControllerServiceNode controllerService = createControllerServiceNode(LongValidatingControllerService.class);
- controllerService.setProperties(Collections.singletonMap(LongValidatingControllerService.DELAY.getName(), "250 millis"));
-
- final ProcessorNode processor = createProcessorNode(NopServiceReferencingProcessor.class);
- processor.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
- processor.setProperties(Collections.singletonMap(NopServiceReferencingProcessor.SERVICE.getName(), controllerService.getIdentifier()));
-
- final VersionedExternalFlow proposedFlow = createFlowSnapshot();
-
- // Create an Inner Process Group and update it to match the Versioned Flow.
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- innerGroup.updateFlow(proposedFlow, (String) null, false, true, false);
-
- // Ensure that the controller service is valid and enable it.
- final Set<ControllerServiceNode> serviceNodes = innerGroup.findAllControllerServices();
- assertEquals(1, serviceNodes.size());
-
- final ControllerServiceNode serviceNode = serviceNodes.iterator().next();
- final ValidationStatus validationStatus = serviceNode.performValidation();
- assertEquals(ValidationStatus.VALID, validationStatus);
- getFlowController().getControllerServiceProvider().enableControllerService(serviceNode).get();
- assertTrue(serviceNode.isActive());
-
- // Ensure that the processor is valid.
- final List<ProcessorNode> processorNodes = innerGroup.findAllProcessors();
- assertEquals(1, processorNodes.size());
-
- final ProcessorNode procNode = processorNodes.get(0);
- final ValidationStatus procValidationStatus = procNode.performValidation();
- final Collection<ValidationResult> validationErrors = procNode.getValidationErrors();
- System.out.println(validationErrors);
- assertEquals(Collections.emptyList(), validationErrors);
- assertEquals(ValidationStatus.VALID, procValidationStatus);
-
- // Ensure that the reference to the controller service was properly updated
- final String referencedServiceId = procNode.getEffectivePropertyValue(NopServiceReferencingProcessor.SERVICE);
- assertEquals(serviceNode.getIdentifier(), referencedServiceId);
- assertNotEquals("service-id", referencedServiceId);
- }
-
-
- @Test
- public void testLocalModificationWhenSensitivePropReferencesParameter() {
- // Create a processor with a sensitive property
- final ProcessorNode processor = createProcessorNode(UsernamePasswordProcessor.class);
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "password"));
-
- // Create a VersionedExternalFlow that contains the processor
- final VersionedExternalFlow versionedFlowWithExplicitValue = createFlowSnapshot();
-
- // Create child group
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- // Move processor into the child group
- moveProcessor(processor, innerGroup);
-
- // Verify that there are no differences between the versioned flow and the Process Group
- Set<FlowDifference> differences = getLocalModifications(innerGroup, versionedFlowWithExplicitValue);
- assertEquals(0, differences.size());
-
- // Change the value of the sensitive property from one explicit value to another. Verify no local modifications.
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "secret"));
- differences = getLocalModifications(innerGroup, versionedFlowWithExplicitValue);
- assertEquals(0, differences.size());
-
- // Change the value of the sensitive property to now reference a parameter. There should be one local modification.
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "#{secret-parameter}"));
- differences = getLocalModifications(innerGroup, versionedFlowWithExplicitValue);
- assertEquals(1, differences.size());
- assertEquals(DifferenceType.PROPERTY_PARAMETERIZED, differences.iterator().next().getDifferenceType());
-
- // Create a Versioned Flow that contains the Parameter Reference.
- final VersionedExternalFlow versionedFlowWithParameterReference = createFlowSnapshot(innerGroup);
-
- // Ensure no difference between the current configuration and the versioned flow
- differences = getLocalModifications(innerGroup, versionedFlowWithParameterReference);
- assertEquals(0, differences.size());
-
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "secret"));
- differences = getLocalModifications(innerGroup, versionedFlowWithParameterReference);
- assertEquals(1, differences.size());
- assertEquals(DifferenceType.PROPERTY_PARAMETERIZATION_REMOVED, differences.iterator().next().getDifferenceType());
- }
-
- @Test
- public void testParameterCreatedWithNullValueOnImportWithSensitivePropertyReference() {
- // Create a processor with a sensitive property
- final ProcessorNode processor = createProcessorNode(UsernamePasswordProcessor.class);
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "#{secret-param}"));
-
- // Create a VersionedExternalFlow that contains the processor
- final Parameter parameter = new Parameter(new ParameterDescriptor.Builder().name("secret-param").sensitive(true).build(), null);
- setParameter(parameter);
- final VersionedExternalFlow versionedFlowWithParameterReference = createFlowSnapshot();
-
- // Create child group
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- final ParameterReferenceManager parameterReferenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
- final ParameterContext parameterContext = new StandardParameterContext.Builder()
- .id("param-context-id")
- .name("parameter-context")
- .parameterReferenceManager(parameterReferenceManager)
- .build();
- innerGroup.setParameterContext(parameterContext);
-
- assertTrue(parameterContext.getParameters().isEmpty());
-
- innerGroup.updateFlow(versionedFlowWithParameterReference, (String) null, true, true, true);
-
- final Collection<Parameter> parameters = parameterContext.getParameters().values();
- assertEquals(1, parameters.size());
-
- final Parameter firstParameter = parameters.iterator().next();
- assertEquals("secret-param", firstParameter.getDescriptor().getName());
- assertTrue(firstParameter.getDescriptor().isSensitive());
- assertNull(firstParameter.getValue());
- }
-
- @Test
- public void testParameterContextCreatedOnImportWithSensitivePropertyReference() {
- // Create a processor with a sensitive property
- final ProcessorNode processor = createProcessorNode(UsernamePasswordProcessor.class);
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "#{secret-param}"));
-
- // Create a VersionedExternalFlow that contains the processor
- final Parameter parameter = new Parameter(new ParameterDescriptor.Builder().name("secret-param").sensitive(true).build(), null);
- setParameter(parameter);
- final VersionedExternalFlow versionedFlowWithParameterReference = createFlowSnapshot();
-
- // Create child group
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- innerGroup.updateFlow(versionedFlowWithParameterReference, (String) null, true, true, true);
-
- final ParameterContext parameterContext = innerGroup.getParameterContext();
- assertNotNull(parameterContext);
-
- final Collection<Parameter> parameters = parameterContext.getParameters().values();
- assertEquals(1, parameters.size());
-
- final Parameter firstParameter = parameters.iterator().next();
- assertEquals("secret-param", firstParameter.getDescriptor().getName());
- assertTrue(firstParameter.getDescriptor().isSensitive());
- assertNull(firstParameter.getValue());
- }
-
-
- @Test
- public void testChangeVersionFromParameterToExplicitValueSensitiveProperty() {
- // Create a processor with a sensitive property
- final ProcessorNode initialProcessor = createProcessorNode(UsernamePasswordProcessor.class);
- initialProcessor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "#{secret-param}"));
-
- // Create a VersionedExternalFlow that contains the processor
- final Parameter parameter = new Parameter(new ParameterDescriptor.Builder().name("secret-param").sensitive(true).build(), null);
- setParameter(parameter);
- final VersionedExternalFlow versionedFlowWithParameterReference = createFlowSnapshot();
-
- // Update processor to have an explicit value for the second version of the flow.
- initialProcessor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "secret-value"));
- final VersionedExternalFlow versionedFlowExplicitValue = createFlowSnapshot();
-
- // Create child group and update to the first version of the flow, with parameter ref
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- innerGroup.updateFlow(versionedFlowWithParameterReference, (String) null, true, true, true);
-
- final ProcessorNode nodeInGroupWithRef = innerGroup.getProcessors().iterator().next();
- assertNotNull(nodeInGroupWithRef.getProperty(UsernamePasswordProcessor.PASSWORD).getRawValue());
-
- // Update the flow to new version that uses explicit value.
- innerGroup.updateFlow(versionedFlowExplicitValue, (String) null, true, true, true);
-
- // Updated flow has sensitive property that no longer references parameter. Now is an explicit value, so it should be unset
- final ProcessorNode nodeInGroupWithNoValue = innerGroup.getProcessors().iterator().next();
- assertNull(nodeInGroupWithNoValue.getProperty(UsernamePasswordProcessor.PASSWORD).getRawValue());
- }
-
- @Test
- public void testChangeVersionFromExplicitToExplicitValueDoesNotChangeSensitiveProperty() {
- // Create a processor with a sensitive property and create a versioned flow for it.
- final ProcessorNode initialProcessor = createProcessorNode(UsernamePasswordProcessor.class);
- final Map<String, String> initialProperties = new HashMap<>();
- initialProperties.put(UsernamePasswordProcessor.USERNAME.getName(), "user");
- initialProperties.put(UsernamePasswordProcessor.PASSWORD.getName(), "pass");
- initialProcessor.setProperties(initialProperties);
-
- final VersionedExternalFlow initialVersionSnapshot = createFlowSnapshot();
-
- // Update processor to have a different explicit value for both sensitive and non-sensitive properties and create a versioned flow for it.
- final Map<String, String> updatedProperties = new HashMap<>();
- updatedProperties.put(UsernamePasswordProcessor.USERNAME.getName(), "other");
- updatedProperties.put(UsernamePasswordProcessor.PASSWORD.getName(), "pass");
- initialProcessor.setProperties(updatedProperties);
-
- final VersionedExternalFlow updatedVersionSnapshot = createFlowSnapshot();
-
- // Create child group and update to the first version of the flow, with parameter ref
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- // Import the flow into our newly created group
- innerGroup.updateFlow(initialVersionSnapshot, (String) null, true, true, true);
-
- final ProcessorNode initialImportedProcessor = innerGroup.getProcessors().iterator().next();
- assertEquals("user", initialImportedProcessor.getProperty(UsernamePasswordProcessor.USERNAME).getRawValue());
- assertNull(initialImportedProcessor.getProperty(UsernamePasswordProcessor.PASSWORD).getRawValue());
-
- // Update the sensitive property to "pass"
- initialImportedProcessor.setProperties(initialProperties);
- assertEquals("pass", initialImportedProcessor.getProperty(UsernamePasswordProcessor.PASSWORD).getRawValue());
-
- // Update the flow to new version
- innerGroup.updateFlow(updatedVersionSnapshot, (String) null, true, true, true);
-
- // Updated flow has sensitive property that no longer references parameter. Now is an explicit value, so it should be unset
- final ProcessorNode updatedImportedProcessor = innerGroup.getProcessors().iterator().next();
- assertEquals("other", updatedImportedProcessor.getProperty(UsernamePasswordProcessor.USERNAME).getRawValue());
- assertEquals("pass", updatedImportedProcessor.getProperty(UsernamePasswordProcessor.PASSWORD).getRawValue());
- }
-
-
- @Test
- public void testChangeVersionFromParamReferenceToAnotherParamReferenceIsLocalModification() {
- // Create a processor with a sensitive property and create a versioned flow for it.
- final ProcessorNode initialProcessor = createProcessorNode(UsernamePasswordProcessor.class);
- final Map<String, String> initialProperties = new HashMap<>();
- initialProperties.put(UsernamePasswordProcessor.USERNAME.getName(), "user");
- initialProperties.put(UsernamePasswordProcessor.PASSWORD.getName(), "#{secret-param}");
- initialProcessor.setProperties(initialProperties);
-
- final VersionedExternalFlow initialVersionSnapshot = createFlowSnapshot();
-
- // Update processor to have a different explicit value for both sensitive and non-sensitive properties and create a versioned flow for it.
- final Map<String, String> updatedProperties = new HashMap<>();
- updatedProperties.put(UsernamePasswordProcessor.USERNAME.getName(), "user");
- updatedProperties.put(UsernamePasswordProcessor.PASSWORD.getName(), "#{other-param}");
- initialProcessor.setProperties(updatedProperties);
-
- final VersionedExternalFlow updatedVersionSnapshot = createFlowSnapshot();
-
- // Create child group and update to the first version of the flow, with parameter ref
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- // Import the flow into our newly created group
- innerGroup.updateFlow(initialVersionSnapshot, (String) null, true, true, true);
-
- final Set<FlowDifference> localModifications = getLocalModifications(innerGroup, updatedVersionSnapshot);
- assertEquals(1, localModifications.size());
- assertEquals(DifferenceType.PROPERTY_CHANGED, localModifications.iterator().next().getDifferenceType());
- }
-
-
- @Test
- public void testChangeVersionFromExplicitValueToParameterSensitiveProperty() {
- // Create a processor with a sensitive property
- final ProcessorNode processor = createProcessorNode(UsernamePasswordProcessor.class);
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "#{secret-param}"));
-
- // Create a VersionedExternalFlow that contains the processor
- final Parameter parameter = new Parameter(new ParameterDescriptor.Builder().name("secret-param").sensitive(true).build(), null);
- setParameter(parameter);
- final VersionedExternalFlow versionedFlowWithParameterReference = createFlowSnapshot();
-
- processor.setProperties(Collections.singletonMap(UsernamePasswordProcessor.PASSWORD.getName(), "secret-value"));
- final VersionedExternalFlow versionedFlowExplicitValue = createFlowSnapshot();
-
- // Create child group and update to the first version of the flow, with parameter ref
- final ProcessGroup innerGroup = getFlowController().getFlowManager().createProcessGroup("inner-group-id");
- innerGroup.setName("Inner Group");
- getRootGroup().addProcessGroup(innerGroup);
-
- innerGroup.updateFlow(versionedFlowExplicitValue, (String) null, true, true, true);
-
- final ProcessorNode nodeInGroupWithRef = innerGroup.getProcessors().iterator().next();
- assertNotNull(nodeInGroupWithRef.getProperty(UsernamePasswordProcessor.PASSWORD));
-
- // Update the flow to new version that uses explicit value.
- innerGroup.updateFlow(versionedFlowWithParameterReference, (String) null, true, true, true);
-
- // Updated flow has sensitive property that no longer references parameter. Now is an explicit value, so it should be unset
- final ProcessorNode nodeInGroupWithNoValue = innerGroup.getProcessors().iterator().next();
- String actual = nodeInGroupWithNoValue.getProperty(UsernamePasswordProcessor.PASSWORD).getRawValue();
- assertEquals("#{secret-param}", actual);
- }
-
- @Test
- public void testUpdateFlowWithInputPortMovedFromGroupAToGroupB() {
- //Testing use case NIFI-9018
- //Create Process Group A
- final ProcessGroup groupA = createProcessGroup("group-a-id", "Group A", getRootGroup());
-
- //Add Input Port to Process Group A
- final Port port = getFlowController().getFlowManager().createLocalInputPort("input-port-id", "Input Port");
- groupA.addInputPort(port);
-
- //Create a snapshot
- final VersionedExternalFlow version1 = createFlowSnapshot(groupA);
-
- //Create Process Group B under Process Group A
- final ProcessGroup groupB = createProcessGroup("group-b-id", "Group B", groupA);
-
- //Move Input Port from Process Group A to Process Group B
- moveInputPort(port, groupB);
-
- //Create Processor under Process Group A
- final ProcessorNode processor = createProcessorNode(GenerateProcessor.class, groupA);
-
- //Create Connection between Processor in Process Group A and Input Port in Process Group B
- final Connection connection = connect(groupA, processor, port, processor.getRelationships());
-
- //Create another snapshot
- final VersionedExternalFlow version2 = createFlowSnapshot(groupA);
-
- //Change Process Group A version to Version 1
- groupA.updateFlow(version1, null, false, true, true);
-
- //Process Group A should have only one Input Port and no Process Groups, Processors or Connections
- assertTrue(groupA.getProcessGroups().isEmpty());
- assertTrue(groupA.getProcessors().isEmpty());
- assertTrue(groupA.getConnections().isEmpty());
- assertEquals(1, groupA.getInputPorts().size());
- assertEquals(port.getName(), groupA.getInputPorts().stream().findFirst().get().getName());
-
- //Change Process Group A version to Version 2
- groupA.updateFlow(version2, null, false, true, true);
-
- //Process Group A should have a Process Group, a Processor and a Connection and no Input Ports
- assertEquals(1, groupA.getProcessGroups().size());
- assertEquals(groupB.getName(), groupA.getProcessGroups().stream().findFirst().get().getName());
- assertEquals(1, groupA.getProcessors().size());
- assertEquals(processor.getName(), groupA.getProcessors().stream().findFirst().get().getName());
- assertEquals(1, groupA.getConnections().size());
- assertEquals(connection.getName(), groupA.getConnections().stream().findFirst().get().getName());
- assertTrue(groupA.getInputPorts().isEmpty());
- }
-
- @Test
- public void testUpdateFlowWithOutputPortChangedToFunnelInAConnection() {
- //Testing use case NIFI-9229
- //Create Process Group
- final ProcessGroup group = createProcessGroup("p-group-id", "P Group", getRootGroup());
-
- //Create Processor under Process Group
- final ProcessorNode processor = createProcessorNode(GenerateProcessor.class, group);
-
- //Add Output Port to Process Group
- final Port port = getFlowController().getFlowManager().createLocalOutputPort("output-port-id", "Output Port");
- group.addOutputPort(port);
-
- //Create Connection between Processor and Input Port
- final Connection connection = connect(group, processor, port, processor.getRelationships());
-
- //Create a snapshot
- final VersionedExternalFlow version1 = createFlowSnapshot(group);
-
- //Create Funnel under Process Group
- Funnel funnel = getFlowController().getFlowManager().createFunnel("funnel-id");
- group.addFunnel(funnel);
-
- //Modify connection's destination from Output Port to Funnel
- connection.setDestination(funnel);
-
- //Delete Output Port
- group.removeOutputPort(port);
-
- //Create another snapshot
- final VersionedExternalFlow version2 = createFlowSnapshot(group);
-
- //Change Process Group version to Version 1
- group.updateFlow(version1, null, false, true, true);
-
- //Process Group should have only one Output Port, One Processor and One connection
- assertEquals(1, group.getProcessors().size());
- assertEquals(processor.getVersionedComponentId(), group.getProcessors().stream().findFirst().get().getVersionedComponentId());
- assertEquals(1, group.getConnections().size());
- assertEquals(connection.getVersionedComponentId(), group.getConnections().stream().findFirst().get().getVersionedComponentId());
- assertEquals(1, group.getOutputPorts().size());
- assertEquals(port.getName(), group.getOutputPorts().stream().findFirst().get().getName());
- assertTrue(group.getFunnels().isEmpty());
- assertEquals(connection.getDestination().getName(), port.getName());
-
- //Change Process Group version to Version 2
- group.updateFlow(version2, null, false, true, true);
-
- //Process Group should have a Funnel, a Processor, a Connection and no Output Ports
- assertTrue(group.getOutputPorts().isEmpty());
- assertEquals(1, group.getProcessors().size());
- assertEquals(processor.getName(), group.getProcessors().stream().findFirst().get().getName());
- assertEquals(1, group.getConnections().size());
- assertEquals(connection.getName(), group.getConnections().stream().findFirst().get().getName());
- assertEquals(1, group.getFunnels().size());
- assertEquals(funnel.getName(), group.getFunnels().stream().findFirst().get().getName());
- assertEquals(connection.getDestination().getName(), funnel.getName());
- }
-
- @Test
- public void testUpdateFlowWithModifyingConnectionDeletingAndMovingPort() {
- //Create Process Group A
- final ProcessGroup groupA = createProcessGroup("group-a-id", "Group A", getRootGroup());
-
- //Create Process Group B under Process Group A
- final ProcessGroup groupBunderA = createProcessGroup("group-b-id", "Group B", groupA);
-
- //Add Input port under Process Group B
- final Port inputPortBThenStayThenDelete = getFlowController().getFlowManager().createLocalInputPort("input-port-id", "Input Port");
- groupBunderA.addInputPort(inputPortBThenStayThenDelete);
-
- //Add Processor 1 under Process Group A
- final ProcessorNode processorA1 = createProcessorNode(GenerateProcessor.class, groupA);
-
- //Add Processor 2 under Process Group A
- final ProcessorNode processorA2 = createProcessorNode(GenerateProcessor.class, groupA);
-
- //Add Output Port under Process Group A
- final Port outputPortAThenB = getFlowController().getFlowManager().createLocalOutputPort("output-port-id", "Output Port");
- groupA.addOutputPort(outputPortAThenB);
-
- //Connect Processor 1 and Output Port as Connection 1
- final Connection connectionProcessorA1ToOutputPortAThenProcessorA2 = connect(groupA, processorA1, outputPortAThenB, processorA1.getRelationships());
-
- //Connect Processor 1 and Input Port as Connection 2
- final Connection connectionProcessorA1ToInputPortBThenStayThenDelete = connect(groupA, processorA1, inputPortBThenStayThenDelete, processorA1.getRelationships());
-
- //Create a snapshot
- final VersionedExternalFlow version1 = createFlowSnapshot(groupA);
-
- //Modify Connection 1 to point to Processor 2
- connectionProcessorA1ToOutputPortAThenProcessorA2.setDestination(processorA2);
-
- //Move Output Port to Process Group B
- moveOutputPort(outputPortAThenB, groupBunderA);
-
- //Create another snapshot
- final VersionedExternalFlow version2 = createFlowSnapshot(groupA);
-
- //Delete connection 2
- groupA.removeConnection(connectionProcessorA1ToInputPortBThenStayThenDelete);
-
- //Delete Input Port
- groupBunderA.removeInputPort(inputPortBThenStayThenDelete);
-
- //Create another snapshot
- final VersionedExternalFlow version3 = createFlowSnapshot(groupA);
-
- //Change Process Group version to Version 1
- groupA.updateFlow(version1, null, false, true, true);
-
- //Process Group A should have two Processors, 2 Connections, one Output Port and one Process Group with one Input Port
- assertEquals(2, groupA.getProcessors().size());
- assertEquals(2, groupA.getConnections().size());
- assertEquals(connectionProcessorA1ToOutputPortAThenProcessorA2.getDestination().getName(), outputPortAThenB.getName());
- assertEquals(1, groupA.getOutputPorts().size());
- assertEquals(1, groupA.getProcessGroups().size());
- assertEquals(1, groupBunderA.getInputPorts().size());
-
- //Change Process Group version to Version 2
- groupA.updateFlow(version2, null, false, true, true);
-
- //Connection1 destination changed to Processor2 and Output Port moved to Process Group B
- assertTrue(groupA.getOutputPorts().isEmpty());
- assertEquals(connectionProcessorA1ToOutputPortAThenProcessorA2.getDestination().getName(), processorA2.getName());
- assertEquals(1, groupBunderA.getOutputPorts().size());
- assertEquals(outputPortAThenB.getName(), groupBunderA.getOutputPorts().stream().findFirst().get().getName());
-
- //Change Process Group version to Version 3
- groupA.updateFlow(version3, null, false, true, true);
-
- //Connection2 and Input Port should be deleted
- assertEquals(1, groupA.getConnections().size());
- assertEquals(connectionProcessorA1ToOutputPortAThenProcessorA2.getName(), groupA.getConnections().stream().findFirst().get().getName());
- assertTrue(groupBunderA.getInputPorts().isEmpty());
- }
-
- @Test
- public void testUpdateFlowWithDeletingConnectionDeletingAndMovingPort() {
- //Create Process Group A
- final ProcessGroup groupA = createProcessGroup("group-a-id", "Group A", getRootGroup());
-
- //Create Process Group B under Process Group A
- final ProcessGroup groupB = createProcessGroup("group-b-id", "Group B", groupA);
-
- //Add Input port under Process Group B
- final Port inputPort = getFlowController().getFlowManager().createLocalInputPort("input-port-id", "Input Port");
- groupB.addInputPort(inputPort);
-
- //Add Processor 1 under Process Group A
- final ProcessorNode processor1 = createProcessorNode(GenerateProcessor.class, groupA);
-
- //Add Processor 2 under Process Group A
- final ProcessorNode processor2 = createProcessorNode(GenerateProcessor.class, groupA);
-
- //Add Output Port under Process Group A
- final Port outputPort = getFlowController().getFlowManager().createLocalOutputPort("output-port-id", "Output Port");
- groupA.addOutputPort(outputPort);
-
- //Connect Processor 1 and Output Port as Connection 1
- final Connection connection1 = connect(groupA, processor1, outputPort, processor1.getRelationships());
-
- //Connect Processor 1 and Input Port as Connection 2
- final Connection connection2 = connect(groupA, processor1, inputPort, processor1.getRelationships());
-
- //Create a snapshot
- final VersionedExternalFlow version1 = createFlowSnapshot(groupA);
-
- //Modify Connection 1 to point to Processor 2
- connection1.setDestination(processor2);
-
- //Delete Output Port
- groupA.removeOutputPort(outputPort);
-
- //Create another snapshot
- final VersionedExternalFlow version2 = createFlowSnapshot(groupA);
-
- //Delete connection 2
- groupA.removeConnection(connection2);
-
- //Move Input Port to Process Group A
- moveInputPort(inputPort, groupA);
-
- //Create another snapshot
- final VersionedExternalFlow version3 = createFlowSnapshot(groupA);
-
- //Change Process Group version to Version 1
- groupA.updateFlow(version1, null, false, true, true);
-
- //Process Group A should have two Processors, 2 Connections, one Output Port and one Process Group with one Input Port
- assertEquals(2, groupA.getProcessors().size());
- assertEquals(2, groupA.getConnections().size());
- assertEquals(connection1.getDestination().getName(), outputPort.getName());
- assertEquals(1, groupA.getOutputPorts().size());
- assertEquals(1, groupA.getProcessGroups().size());
- assertEquals(1, groupB.getInputPorts().size());
-
- //Change Process Group version to Version 2
- groupA.updateFlow(version2, null, false, true, true);
-
- //Connection1 destination changed to Processor2 and Output Port deleted
- assertEquals(connection1.getDestination().getName(), processor2.getName());
- assertTrue(groupA.getOutputPorts().isEmpty());
- assertTrue(groupB.getOutputPorts().isEmpty());
-
- //Change Process Group version to Version 3
- groupA.updateFlow(version3, null, false, true, true);
-
- //Connection2 should be deleted and Input Port moved to Process Group A
- assertEquals(1, groupA.getConnections().size());
- assertEquals(connection1.getName(), groupA.getConnections().stream().findFirst().get().getName());
- assertTrue(groupB.getInputPorts().isEmpty());
- assertEquals(1, groupA.getInputPorts().size());
- assertEquals(inputPort.getName(), groupA.getInputPorts().stream().findFirst().get().getName());
- }
-
- @Test
- public void testExportImportFlowSwitchesVersionedIdToAndFromInstanceIdOfParameterReferencedControllerService() {
- ControllerServiceNode controllerService = createControllerServiceNode(NopControllerService.class);
-
- ProcessorNode processor = createProcessorNode(NopServiceReferencingProcessor.class);
- processor.setAutoTerminatedRelationships(Collections.singleton(REL_SUCCESS));
- processor.setProperties(Collections.singletonMap(NopServiceReferencingProcessor.SERVICE.getName(), "#{service}"));
-
- // Setting value to the instance id
- Parameter parameter = new Parameter(new ParameterDescriptor.Builder()
- .name("service")
- .build(),
- controllerService.getIdentifier()
- );
- setParameter(parameter);
- VersionedExternalFlow flowSnapshot = createFlowSnapshot();
-
- VersionedControllerService snapshotControllerService = flowSnapshot.getFlowContents().getControllerServices().stream().findAny().get();
-
- assertEquals(controllerService.getIdentifier(), snapshotControllerService.getInstanceIdentifier());
- // Exported flow contains versioned id instead of instance id
- assertEquals(snapshotControllerService.getIdentifier(), flowSnapshot.getParameterContexts().get("unimportant").getParameters().stream().findAny().get().getValue());
-
- getRootGroup().setParameterContext(null);
- getRootGroup().updateFlow(flowSnapshot, null, false, true, true);
-
- // Imported flow contains instance id again
- assertEquals(snapshotControllerService.getInstanceIdentifier(), getRootGroup().getParameterContext().getParameter("service").get().getValue());
- }
-
- private void setParameter(Parameter parameter) {
- ParameterContext rootParameterContext = getFlowController().getFlowManager().getParameterContextManager().getParameterContext("unimportant");
- if (rootParameterContext == null) {
- rootParameterContext = getFlowController().getFlowManager().createParameterContext("unimportant", "unimportant", Collections.emptyMap(), Collections.emptyList(), null);
- getRootGroup().setParameterContext(rootParameterContext);
- }
-
- Map<String, Parameter> parameterMap = new HashMap<>();
- parameterMap.put(parameter.getDescriptor().getName(), parameter);
- rootParameterContext.setParameters(parameterMap);
- }
-
- private ProcessGroup createProcessGroup(final String groupId, final String groupName, final ProcessGroup destination) {
- final ProcessGroup group = getFlowController().getFlowManager().createProcessGroup(groupId);
- group.setName(groupName);
- destination.addProcessGroup(group);
- return group;
- }
-
- private void moveInputPort(final Port port, final ProcessGroup destination) {
- final StandardSnippet snippet = new StandardSnippet();
- snippet.setParentGroupId(port.getProcessGroupIdentifier());
- snippet.addInputPorts(Collections.singletonMap(port.getIdentifier(), null));
-
- port.getProcessGroup().move(snippet, destination);
- }
-
- private void moveOutputPort(final Port port, final ProcessGroup destination) {
- final StandardSnippet snippet = new StandardSnippet();
- snippet.setParentGroupId(port.getProcessGroupIdentifier());
- snippet.addOutputPorts(Collections.singletonMap(port.getIdentifier(), null));
-
- port.getProcessGroup().move(snippet, destination);
- }
-
-
- private Set<FlowDifference> getLocalModifications(final ProcessGroup processGroup, final VersionedExternalFlow VersionedExternalFlow) {
- final NiFiRegistryFlowMapper mapper = new NiFiRegistryFlowMapper(getFlowController().getExtensionManager());
- final VersionedProcessGroup localGroup = mapper.mapProcessGroup(processGroup, getFlowController().getControllerServiceProvider(), getFlowController().getFlowManager(), true);
- final VersionedProcessGroup registryGroup = VersionedExternalFlow.getFlowContents();
-
- final ComparableDataFlow localFlow = new StandardComparableDataFlow("Local Flow", localGroup);
- final ComparableDataFlow registryFlow = new StandardComparableDataFlow("Versioned Flow", registryGroup);
-
- final Set<String> ancestorServiceIds = processGroup.getAncestorServiceIds();
- final FlowComparator flowComparator = new StandardFlowComparator(registryFlow, localFlow, ancestorServiceIds, new ConciseEvolvingDifferenceDescriptor(), Function.identity(),
- VersionedComponent::getIdentifier, FlowComparatorVersionedStrategy.SHALLOW);
- final FlowComparison flowComparison = flowComparator.compare();
- final Set<FlowDifference> differences = flowComparison.getDifferences().stream()
- .filter(FlowDifferenceFilters.FILTER_ADDED_REMOVED_REMOTE_PORTS)
- .filter(FlowDifferenceFilters.FILTER_PUBLIC_PORT_NAME_CHANGES)
- .filter(FlowDifferenceFilters.FILTER_IGNORABLE_VERSIONED_FLOW_COORDINATE_CHANGES)
- .filter(difference -> !FlowDifferenceFilters.isVariableValueChange(difference))
- .collect(Collectors.toCollection(HashSet::new));
-
- return differences;
- }
-
- private VersionedExternalFlow createFlowSnapshot() {
- return createFlowSnapshot(getRootGroup());
- }
-
- private VersionedExternalFlow createFlowSnapshot(final ProcessGroup group) {
- final NiFiRegistryFlowMapper flowMapper = new NiFiRegistryFlowMapper(getExtensionManager());
-
- InstantiatedVersionedProcessGroup instantiatedVersionedProcessGroup = flowMapper.mapNonVersionedProcessGroup(group, getFlowController().getControllerServiceProvider());
- final VersionedExternalFlow flow = new VersionedExternalFlow();
- flow.setFlowContents(instantiatedVersionedProcessGroup);
-
- Map<String, VersionedParameterContext> parameterContexts = new HashMap<>();
- if (getRootGroup().getParameterContext() != null) {
- parameterContexts.put(getRootGroup().getParameterContext().getName(), flowMapper.mapParameterContext(getRootGroup().getParameterContext()));
- }
- Set<ProcessGroup> childProcessGroups = getRootGroup().getProcessGroups();
- for (ProcessGroup processGroup : childProcessGroups) {
- if (processGroup.getParameterContext() != null) {
- parameterContexts.put(processGroup.getParameterContext().getName(), flowMapper.mapParameterContext(processGroup.getParameterContext()));
- }
- }
- flow.setParameterContexts(parameterContexts);
-
- return flow;
- }
-}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/clustered-nifi.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/clustered-nifi.properties
deleted file mode 100644
index 6b2c1baa0e..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/clustered-nifi.properties
+++ /dev/null
@@ -1,245 +0,0 @@
-# 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.
-
-# Core Properties #
-nifi.flow.configuration.file=./target/conf/flow.xml.gz
-nifi.flow.configuration.archive.enabled=true
-nifi.flow.configuration.archive.dir=./target/conf/archive/
-nifi.flow.configuration.archive.max.time=30 days
-nifi.flow.configuration.archive.max.storage=500 MB
-nifi.flow.configuration.archive.max.count=
-nifi.flowcontroller.autoResumeState=true
-nifi.flowcontroller.graceful.shutdown.period=10 sec
-nifi.flowservice.writedelay.interval=500 ms
-nifi.administrative.yield.duration=100 millis
-# If a component has no work to do (is "bored"), how long should we wait before checking again for work?
-nifi.bored.yield.duration=10 millis
-nifi.queue.backpressure.count=10000
-nifi.queue.backpressure.size=1 GB
-
-nifi.authorizer.configuration.file=./target/conf/authorizers.xml
-nifi.login.identity.provider.configuration.file=./target/conf/login-identity-providers.xml
-nifi.ui.banner.text=
-nifi.ui.autorefresh.interval=30 sec
-nifi.nar.library.directory=./target/lib
-nifi.nar.library.autoload.directory=./target/extensions
-nifi.nar.working.directory=./target/work/nar/
-nifi.documentation.working.directory=./target/work/docs/components
-
-####################
-# State Management #
-####################
-nifi.state.management.configuration.file=src/test/resources/int-tests/state-management.xml
-# The ID of the local state provider
-nifi.state.management.provider.local=local-provider
-# The ID of the cluster-wide state provider. This will be ignored if NiFi is not clustered but must be populated if running in a cluster.
-nifi.state.management.provider.cluster=zk-provider
-# Specifies whether or not this instance of NiFi should run an embedded ZooKeeper server
-nifi.state.management.embedded.zookeeper.start=true
-# Properties file that provides the ZooKeeper properties to use if <nifi.state.management.embedded.zookeeper.start> is set to true
-nifi.state.management.embedded.zookeeper.properties=src/test/resources/int-tests/zookeeper.properties
-
-
-# H2 Settings
-nifi.database.directory=./target/database_repository
-nifi.h2.url.append=;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE
-
-# FlowFile Repository
-nifi.flowfile.repository.implementation=org.apache.nifi.controller.repository.WriteAheadFlowFileRepository
-nifi.flowfile.repository.wal.implementation=org.apache.nifi.wali.SequentialAccessWriteAheadLog
-nifi.flowfile.repository.directory=./target/int-tests/flowfile_repository
-nifi.flowfile.repository.partitions=256
-nifi.flowfile.repository.checkpoint.interval=5 mins
-nifi.flowfile.repository.always.sync=false
-
-nifi.swap.manager.implementation=org.apache.nifi.controller.FileSystemSwapManager
-nifi.queue.swap.threshold=20000
-nifi.swap.in.period=5 sec
-nifi.swap.in.threads=1
-nifi.swap.out.period=5 sec
-nifi.swap.out.threads=4
-
-# Content Repository
-nifi.content.repository.implementation=org.apache.nifi.controller.repository.FileSystemRepository
-nifi.content.claim.max.appendable.size=1 MB
-nifi.content.claim.max.flow.files=100
-nifi.content.repository.directory.default=./target/int-tests/content_repository
-nifi.content.repository.archive.max.retention.period=12 hours
-nifi.content.repository.archive.max.usage.percentage=50%
-nifi.content.repository.archive.enabled=true
-nifi.content.repository.always.sync=false
-nifi.content.viewer.url=../nifi-content-viewer/
-
-# Provenance Repository Properties
-nifi.provenance.repository.implementation=org.apache.nifi.provenance.WriteAheadProvenanceRepository
-nifi.provenance.repository.debug.frequency=1000000
-
-# Persistent Provenance Repository Properties
-nifi.provenance.repository.directory.default=./target/int-tests/provenance_repository
-nifi.provenance.repository.max.storage.time=24 hours
-nifi.provenance.repository.max.storage.size=1 GB
-nifi.provenance.repository.rollover.time=30 secs
-nifi.provenance.repository.rollover.size=100 MB
-nifi.provenance.repository.query.threads=2
-nifi.provenance.repository.index.threads=2
-nifi.provenance.repository.compress.on.rollover=true
-nifi.provenance.repository.always.sync=false
-# Comma-separated list of fields. Fields that are not indexed will not be searchable. Valid fields are:
-# EventType, FlowFileUUID, Filename, TransitURI, ProcessorID, AlternateIdentifierURI, Relationship, Details
-nifi.provenance.repository.indexed.fields=EventType, FlowFileUUID, Filename, ProcessorID, Relationship
-# FlowFile Attributes that should be indexed and made searchable. Some examples to consider are filename, uuid, mime.type
-nifi.provenance.repository.indexed.attributes=
-# Large values for the shard size will result in more Java heap usage when searching the Provenance Repository
-# but should provide better performance
-nifi.provenance.repository.index.shard.size=500 MB
-# Indicates the maximum length that a FlowFile attribute can be when retrieving a Provenance Event from
-# the repository. If the length of any attribute exceeds this value, it will be truncated when the event is retrieved.
-nifi.provenance.repository.max.attribute.length=65536
-nifi.provenance.repository.concurrent.merge.threads=2
-
-
-# Volatile Provenance Respository Properties
-nifi.provenance.repository.buffer.size=100000
-
-# Component Status Repository
-nifi.components.status.repository.implementation=org.apache.nifi.controller.status.history.VolatileComponentStatusRepository
-nifi.components.status.repository.buffer.size=1440
-nifi.components.status.snapshot.frequency=1 min
-
-# Site to Site properties
-nifi.remote.input.host=
-nifi.remote.input.secure=false
-nifi.remote.input.socket.port=
-nifi.remote.input.http.enabled=true
-nifi.remote.input.http.transaction.ttl=30 sec
-nifi.remote.contents.cache.expiration=30 secs
-
-# web properties #
-nifi.web.war.directory=./target/lib
-nifi.web.http.host=
-nifi.web.http.port=8080
-nifi.web.http.network.interface.default=
-nifi.web.https.host=
-nifi.web.https.port=
-nifi.web.https.network.interface.default=
-nifi.web.jetty.working.directory=./target/work/jetty
-nifi.web.jetty.threads=200
-nifi.web.max.header.size=16 KB
-nifi.web.proxy.context.path=
-nifi.web.proxy.host=
-
-nifi.security.keystore=
-nifi.security.keystoreType=
-nifi.security.keystorePasswd=
-nifi.security.keyPasswd=
-nifi.security.truststore=
-nifi.security.truststoreType=
-nifi.security.truststorePasswd=
-nifi.security.user.authorizer=managed-authorizer
-nifi.security.user.login.identity.provider=
-nifi.security.ocsp.responder.url=
-nifi.security.ocsp.responder.certificate=
-
-# OpenId Connect SSO Properties #
-nifi.security.user.oidc.discovery.url=
-nifi.security.user.oidc.connect.timeout=5 secs
-nifi.security.user.oidc.read.timeout=5 secs
-nifi.security.user.oidc.client.id=
-nifi.security.user.oidc.client.secret=
-nifi.security.user.oidc.preferred.jwsalgorithm=
-
-# Apache Knox SSO Properties #
-nifi.security.user.knox.url=
-nifi.security.user.knox.publicKey=
-nifi.security.user.knox.cookieName=hadoop-jwt
-nifi.security.user.knox.audiences=
-
-# Identity Mapping Properties #
-# These properties allow normalizing user identities such that identities coming from different identity providers
-# (certificates, LDAP, Kerberos) can be treated the same internally in NiFi. The following example demonstrates normalizing
-# DNs from certificates and principals from Kerberos into a common identity string:
-#
-# nifi.security.identity.mapping.pattern.dn=^CN=(.*?), OU=(.*?), O=(.*?), L=(.*?), ST=(.*?), C=(.*?)$
-# nifi.security.identity.mapping.value.dn=$1@$2
-# nifi.security.identity.mapping.transform.dn=NONE
-# nifi.security.identity.mapping.pattern.kerb=^(.*?)/instance@(.*?)$
-# nifi.security.identity.mapping.value.kerb=$1@$2
-# nifi.security.identity.mapping.transform.kerb=UPPER
-
-# Group Mapping Properties #
-# These properties allow normalizing group names coming from external sources like LDAP. The following example
-# lowercases any group name.
-#
-# nifi.security.group.mapping.pattern.anygroup=^(.*)$
-# nifi.security.group.mapping.value.anygroup=$1
-# nifi.security.group.mapping.transform.anygroup=LOWER
-
-# cluster common properties (all nodes must have same values) #
-nifi.cluster.protocol.heartbeat.interval=5 sec
-nifi.cluster.protocol.heartbeat.missable.max=8
-nifi.cluster.protocol.is.secure=false
-
-# cluster node properties (only configure for cluster nodes) #
-nifi.cluster.is.node=true
-nifi.cluster.node.address=localhost
-nifi.cluster.node.protocol.port=0
-nifi.cluster.node.protocol.threads=10
-nifi.cluster.node.protocol.max.threads=50
-nifi.cluster.node.event.history.size=25
-nifi.cluster.node.connection.timeout=5 sec
-nifi.cluster.node.read.timeout=5 sec
-nifi.cluster.node.max.concurrent.requests=100
-nifi.cluster.firewall.file=
-nifi.cluster.flow.election.max.wait.time=5 mins
-nifi.cluster.flow.election.max.candidates=
-
-# cluster load balancing properties #
-nifi.cluster.load.balance.host=
-nifi.cluster.load.balance.port=0
-nifi.cluster.load.balance.connections.per.node=4
-nifi.cluster.load.balance.max.thread.count=8
-nifi.cluster.load.balance.comms.timeout=30 sec
-
-# zookeeper properties, used for cluster management #
-nifi.zookeeper.connect.string=localhost:62181
-nifi.zookeeper.connect.timeout=3 secs
-nifi.zookeeper.session.timeout=3 secs
-nifi.zookeeper.root.node=/nifi-integration-tests
-
-# Zookeeper properties for the authentication scheme used when creating acls on znodes used for cluster management
-# Values supported for nifi.zookeeper.auth.type are "default", which will apply world/anyone rights on znodes
-# and "sasl" which will give rights to the sasl/kerberos identity used to authenticate the nifi node
-# The identity is determined using the value in nifi.kerberos.service.principal and the removeHostFromPrincipal
-# and removeRealmFromPrincipal values (which should align with the kerberos.removeHostFromPrincipal and kerberos.removeRealmFromPrincipal
-# values configured on the zookeeper server).
-nifi.zookeeper.auth.type=
-nifi.zookeeper.kerberos.removeHostFromPrincipal=
-nifi.zookeeper.kerberos.removeRealmFromPrincipal=
-
-# kerberos #
-nifi.kerberos.krb5.file=
-
-# kerberos service principal #
-nifi.kerberos.service.principal=
-nifi.kerberos.service.keytab.location=
-
-# kerberos spnego principal #
-nifi.kerberos.spnego.principal=
-nifi.kerberos.spnego.keytab.location=
-nifi.kerberos.spnego.authentication.expiration=12 hours
-
-# external properties files for variable registry
-# supports a comma delimited list of file locations
-nifi.variable.registry.properties=
\ No newline at end of file
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/default-nifi.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/default-nifi.properties
deleted file mode 100644
index 24dd33fa85..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/default-nifi.properties
+++ /dev/null
@@ -1,245 +0,0 @@
-# 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.
-
-# Core Properties #
-nifi.flow.configuration.file=./target/conf/flow.xml.gz
-nifi.flow.configuration.archive.enabled=true
-nifi.flow.configuration.archive.dir=./target/conf/archive/
-nifi.flow.configuration.archive.max.time=30 days
-nifi.flow.configuration.archive.max.storage=500 MB
-nifi.flow.configuration.archive.max.count=
-nifi.flowcontroller.autoResumeState=true
-nifi.flowcontroller.graceful.shutdown.period=10 sec
-nifi.flowservice.writedelay.interval=500 ms
-nifi.administrative.yield.duration=100 millis
-# If a component has no work to do (is "bored"), how long should we wait before checking again for work?
-nifi.bored.yield.duration=10 millis
-nifi.queue.backpressure.count=10000
-nifi.queue.backpressure.size=1 GB
-
-nifi.authorizer.configuration.file=./target/conf/authorizers.xml
-nifi.login.identity.provider.configuration.file=./target/conf/login-identity-providers.xml
-nifi.ui.banner.text=
-nifi.ui.autorefresh.interval=30 sec
-nifi.nar.library.directory=./target/lib
-nifi.nar.library.autoload.directory=./target/extensions
-nifi.nar.working.directory=./target/work/nar/
-nifi.documentation.working.directory=./target/work/docs/components
-
-####################
-# State Management #
-####################
-nifi.state.management.configuration.file=src/test/resources/int-tests/state-management.xml
-# The ID of the local state provider
-nifi.state.management.provider.local=local-provider
-# The ID of the cluster-wide state provider. This will be ignored if NiFi is not clustered but must be populated if running in a cluster.
-nifi.state.management.provider.cluster=zk-provider
-# Specifies whether or not this instance of NiFi should run an embedded ZooKeeper server
-nifi.state.management.embedded.zookeeper.start=false
-# Properties file that provides the ZooKeeper properties to use if <nifi.state.management.embedded.zookeeper.start> is set to true
-nifi.state.management.embedded.zookeeper.properties=./target/conf/zookeeper.properties
-
-
-# H2 Settings
-nifi.database.directory=./target/database_repository
-nifi.h2.url.append=;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE
-
-# FlowFile Repository
-nifi.flowfile.repository.implementation=org.apache.nifi.controller.repository.WriteAheadFlowFileRepository
-nifi.flowfile.repository.wal.implementation=org.apache.nifi.wali.SequentialAccessWriteAheadLog
-nifi.flowfile.repository.directory=./target/int-tests/flowfile_repository
-nifi.flowfile.repository.partitions=256
-nifi.flowfile.repository.checkpoint.interval=5 mins
-nifi.flowfile.repository.always.sync=false
-
-nifi.swap.manager.implementation=org.apache.nifi.controller.FileSystemSwapManager
-nifi.queue.swap.threshold=20000
-nifi.swap.in.period=5 sec
-nifi.swap.in.threads=1
-nifi.swap.out.period=5 sec
-nifi.swap.out.threads=4
-
-# Content Repository
-nifi.content.repository.implementation=org.apache.nifi.controller.repository.FileSystemRepository
-nifi.content.claim.max.appendable.size=1 MB
-nifi.content.claim.max.flow.files=100
-nifi.content.repository.directory.default=./target/int-tests/content_repository
-nifi.content.repository.archive.max.retention.period=12 hours
-nifi.content.repository.archive.max.usage.percentage=50%
-nifi.content.repository.archive.enabled=true
-nifi.content.repository.always.sync=false
-nifi.content.viewer.url=../nifi-content-viewer/
-
-# Provenance Repository Properties
-nifi.provenance.repository.implementation=org.apache.nifi.provenance.WriteAheadProvenanceRepository
-nifi.provenance.repository.debug.frequency=1000000
-
-# Persistent Provenance Repository Properties
-nifi.provenance.repository.directory.default=./target/int-tests/provenance_repository
-nifi.provenance.repository.max.storage.time=24 hours
-nifi.provenance.repository.max.storage.size=1 GB
-nifi.provenance.repository.rollover.time=30 secs
-nifi.provenance.repository.rollover.size=100 MB
-nifi.provenance.repository.query.threads=2
-nifi.provenance.repository.index.threads=2
-nifi.provenance.repository.compress.on.rollover=true
-nifi.provenance.repository.always.sync=false
-# Comma-separated list of fields. Fields that are not indexed will not be searchable. Valid fields are:
-# EventType, FlowFileUUID, Filename, TransitURI, ProcessorID, AlternateIdentifierURI, Relationship, Details
-nifi.provenance.repository.indexed.fields=EventType, FlowFileUUID, Filename, ProcessorID, Relationship
-# FlowFile Attributes that should be indexed and made searchable. Some examples to consider are filename, uuid, mime.type
-nifi.provenance.repository.indexed.attributes=
-# Large values for the shard size will result in more Java heap usage when searching the Provenance Repository
-# but should provide better performance
-nifi.provenance.repository.index.shard.size=500 MB
-# Indicates the maximum length that a FlowFile attribute can be when retrieving a Provenance Event from
-# the repository. If the length of any attribute exceeds this value, it will be truncated when the event is retrieved.
-nifi.provenance.repository.max.attribute.length=65536
-nifi.provenance.repository.concurrent.merge.threads=2
-
-
-# Volatile Provenance Respository Properties
-nifi.provenance.repository.buffer.size=100000
-
-# Component Status Repository
-nifi.components.status.repository.implementation=org.apache.nifi.controller.status.history.VolatileComponentStatusRepository
-nifi.components.status.repository.buffer.size=1440
-nifi.components.status.snapshot.frequency=1 min
-
-# Site to Site properties
-nifi.remote.input.host=
-nifi.remote.input.secure=false
-nifi.remote.input.socket.port=
-nifi.remote.input.http.enabled=true
-nifi.remote.input.http.transaction.ttl=30 sec
-nifi.remote.contents.cache.expiration=30 secs
-
-# web properties #
-nifi.web.war.directory=./target/lib
-nifi.web.http.host=
-nifi.web.http.port=8080
-nifi.web.http.network.interface.default=
-nifi.web.https.host=
-nifi.web.https.port=
-nifi.web.https.network.interface.default=
-nifi.web.jetty.working.directory=./target/work/jetty
-nifi.web.jetty.threads=200
-nifi.web.max.header.size=16 KB
-nifi.web.proxy.context.path=
-nifi.web.proxy.host=
-
-nifi.security.keystore=
-nifi.security.keystoreType=
-nifi.security.keystorePasswd=
-nifi.security.keyPasswd=
-nifi.security.truststore=
-nifi.security.truststoreType=
-nifi.security.truststorePasswd=
-nifi.security.user.authorizer=managed-authorizer
-nifi.security.user.login.identity.provider=
-nifi.security.ocsp.responder.url=
-nifi.security.ocsp.responder.certificate=
-
-# OpenId Connect SSO Properties #
-nifi.security.user.oidc.discovery.url=
-nifi.security.user.oidc.connect.timeout=5 secs
-nifi.security.user.oidc.read.timeout=5 secs
-nifi.security.user.oidc.client.id=
-nifi.security.user.oidc.client.secret=
-nifi.security.user.oidc.preferred.jwsalgorithm=
-
-# Apache Knox SSO Properties #
-nifi.security.user.knox.url=
-nifi.security.user.knox.publicKey=
-nifi.security.user.knox.cookieName=hadoop-jwt
-nifi.security.user.knox.audiences=
-
-# Identity Mapping Properties #
-# These properties allow normalizing user identities such that identities coming from different identity providers
-# (certificates, LDAP, Kerberos) can be treated the same internally in NiFi. The following example demonstrates normalizing
-# DNs from certificates and principals from Kerberos into a common identity string:
-#
-# nifi.security.identity.mapping.pattern.dn=^CN=(.*?), OU=(.*?), O=(.*?), L=(.*?), ST=(.*?), C=(.*?)$
-# nifi.security.identity.mapping.value.dn=$1@$2
-# nifi.security.identity.mapping.transform.dn=NONE
-# nifi.security.identity.mapping.pattern.kerb=^(.*?)/instance@(.*?)$
-# nifi.security.identity.mapping.value.kerb=$1@$2
-# nifi.security.identity.mapping.transform.kerb=UPPER
-
-# Group Mapping Properties #
-# These properties allow normalizing group names coming from external sources like LDAP. The following example
-# lowercases any group name.
-#
-# nifi.security.group.mapping.pattern.anygroup=^(.*)$
-# nifi.security.group.mapping.value.anygroup=$1
-# nifi.security.group.mapping.transform.anygroup=LOWER
-
-# cluster common properties (all nodes must have same values) #
-nifi.cluster.protocol.heartbeat.interval=5 sec
-nifi.cluster.protocol.heartbeat.missable.max=8
-nifi.cluster.protocol.is.secure=false
-
-# cluster node properties (only configure for cluster nodes) #
-nifi.cluster.is.node=false
-nifi.cluster.node.address=
-nifi.cluster.node.protocol.port=
-nifi.cluster.node.protocol.threads=10
-nifi.cluster.node.protocol.max.threads=50
-nifi.cluster.node.event.history.size=25
-nifi.cluster.node.connection.timeout=5 sec
-nifi.cluster.node.read.timeout=5 sec
-nifi.cluster.node.max.concurrent.requests=100
-nifi.cluster.firewall.file=
-nifi.cluster.flow.election.max.wait.time=5 mins
-nifi.cluster.flow.election.max.candidates=
-
-# cluster load balancing properties #
-nifi.cluster.load.balance.host=
-nifi.cluster.load.balance.port=6342
-nifi.cluster.load.balance.connections.per.node=4
-nifi.cluster.load.balance.max.thread.count=8
-nifi.cluster.load.balance.comms.timeout=30 sec
-
-# zookeeper properties, used for cluster management #
-nifi.zookeeper.connect.string=
-nifi.zookeeper.connect.timeout=3 secs
-nifi.zookeeper.session.timeout=3 secs
-nifi.zookeeper.root.node=/nifi
-
-# Zookeeper properties for the authentication scheme used when creating acls on znodes used for cluster management
-# Values supported for nifi.zookeeper.auth.type are "default", which will apply world/anyone rights on znodes
-# and "sasl" which will give rights to the sasl/kerberos identity used to authenticate the nifi node
-# The identity is determined using the value in nifi.kerberos.service.principal and the removeHostFromPrincipal
-# and removeRealmFromPrincipal values (which should align with the kerberos.removeHostFromPrincipal and kerberos.removeRealmFromPrincipal
-# values configured on the zookeeper server).
-nifi.zookeeper.auth.type=
-nifi.zookeeper.kerberos.removeHostFromPrincipal=
-nifi.zookeeper.kerberos.removeRealmFromPrincipal=
-
-# kerberos #
-nifi.kerberos.krb5.file=
-
-# kerberos service principal #
-nifi.kerberos.service.principal=
-nifi.kerberos.service.keytab.location=
-
-# kerberos spnego principal #
-nifi.kerberos.spnego.principal=
-nifi.kerberos.spnego.keytab.location=
-nifi.kerberos.spnego.authentication.expiration=12 hours
-
-# external properties files for variable registry
-# supports a comma delimited list of file locations
-nifi.variable.registry.properties=
\ No newline at end of file
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/state-management.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/state-management.xml
deleted file mode 100644
index 159f5180b2..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/state-management.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- 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.
--->
-<stateManagement>
- <local-provider>
- <id>local-provider</id>
- <class>org.apache.nifi.controller.state.providers.local.WriteAheadLocalStateProvider</class>
- <property name="Directory">./target/int-tests/state/local</property>
- <property name="Always Sync">false</property>
- <property name="Partitions">16</property>
- <property name="Checkpoint Interval">2 mins</property>
- </local-provider>
- <cluster-provider>
- <id>zk-provider</id>
- <class>org.apache.nifi.controller.state.providers.zookeeper.ZooKeeperStateProvider</class>
- <property name="Connect String">localhost:62181</property>
- <property name="Root Node">/nifi-integration-test</property>
- <property name="Session Timeout">30 seconds</property>
- <property name="Access Control">Open</property>
- </cluster-provider>
-</stateManagement>
\ No newline at end of file
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/zookeeper.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/zookeeper.properties
deleted file mode 100644
index 47b9290a51..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/zookeeper.properties
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-#
-# 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.
-#
-#
-#
-
-clientPort=62181
-initLimit=10
-autopurge.purgeInterval=24
-syncLimit=5
-tickTime=2000
-dataDir=target/state/zookeeper
-autopurge.snapRetainCount=30
-
-#
-# Specifies the servers that are part of this zookeeper ensemble. For
-# every NiFi instance running an embedded zookeeper, there needs to be
-# a server entry below. For instance:
-#
-# server.1=nifi-node1-hostname:2888:3888
-# server.2=nifi-node2-hostname:2888:3888
-# server.3=nifi-node3-hostname:2888:3888
-#
-# The index of the server corresponds to the myid file that gets created
-# in the dataDir of each node running an embedded zookeeper. See the
-# administration guide for more details.
-#
-
-server.1=localhost:5777:6777
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/lifecycletest.nifi.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/lifecycletest.nifi.properties
deleted file mode 100644
index 341ba3301b..0000000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/lifecycletest.nifi.properties
+++ /dev/null
@@ -1,124 +0,0 @@
-# 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.
-
-# Core Properties #
-nifi.flow.configuration.file=./target/lifecycletest/flow.xml.gz
-nifi.flow.configuration.archive.dir=./target/lifecycletest/archive/
-nifi.flowcontroller.autoResumeState=true
-nifi.flowcontroller.graceful.shutdown.period=10 sec
-nifi.flowservice.writedelay.interval=2 sec
-nifi.administrative.yield.duration=500 millis
-
-nifi.reporting.task.configuration.file=./target/lifecycletest/reporting-tasks.xml
-nifi.controller.service.configuration.file=./target/lifecycletest/controller-services.xml
-nifi.ui.banner.text=UI Banner Text
-nifi.ui.autorefresh.interval=30 sec
-nifi.nar.library.directory=./target/lifecycletest/lib
-nifi.nar.working.directory=./target/lifecycletest/work/nar/
-
-nifi.state.management.configuration.file=src/test/resources/state-management.xml
-nifi.state.management.provider.local=local-provider
-
-# H2 Settings
-nifi.database.directory=./target/lifecycletest/database_repository
-nifi.h2.url.append=;LOCK_TIMEOUT=25000;WRITE_DELAY=0;AUTO_SERVER=FALSE
-
-# FlowFile Repository
-nifi.flowfile.repository.directory=./target/lifecycletest/test-repo
-nifi.flowfile.repository.partitions=1
-nifi.flowfile.repository.checkpoint.interval=2 mins
-nifi.queue.swap.threshold=20000
-nifi.swap.storage.directory=./target/lifecycletest/test-repo/swap
-nifi.swap.in.period=5 sec
-nifi.swap.in.threads=1
-nifi.swap.out.period=5 sec
-nifi.swap.out.threads=4
-
-# Content Repository
-nifi.content.claim.max.appendable.size=10 MB
-nifi.content.claim.max.flow.files=100
-nifi.content.repository.directory.default=./target/lifecycletest/content_repository
-nifi.content.repository.archive.enabled=true
-nifi.content.repository.archive.max.usage.percentage=95%
-
-# Provenance Repository Properties
-nifi.provenance.repository.storage.directory=./target/lifecycletest/provenance_repository
-nifi.provenance.repository.max.storage.time=24 hours
-nifi.provenance.repository.max.storage.size=1 GB
-nifi.provenance.repository.rollover.time=30 secs
-nifi.provenance.repository.rollover.size=100 MB
-
-# Site to Site properties
-nifi.remote.input.socket.port=9990
-nifi.remote.input.secure=true
-
-# web properties #
-nifi.web.war.directory=./target/lifecycletest/lib
-nifi.web.http.host=
-nifi.web.http.port=8080
-nifi.web.https.host=
-nifi.web.https.port=
-nifi.web.jetty.working.directory=./target/lifecycletest/work/jetty
-
-# security properties #
-nifi.sensitive.props.key=SENSITIVE_PROPS_KEY
-nifi.sensitive.props.algorithm=NIFI_PBKDF2_AES_GCM
-
-nifi.security.keystore=
-nifi.security.keystoreType=
-nifi.security.keystorePasswd=
-nifi.security.keyPasswd=
-nifi.security.truststore=
-nifi.security.truststoreType=
-nifi.security.truststorePasswd=
-nifi.security.user.authorizer=
-
-# cluster common properties (cluster manager and nodes must have same values) #
-nifi.cluster.protocol.heartbeat.interval=5 sec
-nifi.cluster.protocol.is.secure=false
-nifi.cluster.protocol.socket.timeout=30 sec
-nifi.cluster.protocol.connection.handshake.timeout=45 sec
-# if multicast is used, then nifi.cluster.protocol.multicast.xxx properties must be configured #
-nifi.cluster.protocol.use.multicast=false
-nifi.cluster.protocol.multicast.address=
-nifi.cluster.protocol.multicast.port=
-nifi.cluster.protocol.multicast.service.broadcast.delay=500 ms
-nifi.cluster.protocol.multicast.service.locator.attempts=3
-nifi.cluster.protocol.multicast.service.locator.attempts.delay=1 sec
-
-# cluster node properties (only configure for cluster nodes) #
-nifi.cluster.is.node=false
-nifi.cluster.node.address=
-nifi.cluster.node.protocol.port=
-nifi.cluster.node.protocol.threads=2
-# if multicast is not used, nifi.cluster.node.unicast.xxx must have same values as nifi.cluster.manager.xxx #
-nifi.cluster.node.unicast.manager.address=
-nifi.cluster.node.unicast.manager.protocol.port=
-nifi.cluster.node.unicast.manager.authority.provider.port=
-
-# cluster manager properties (only configure for cluster manager) #
-nifi.cluster.is.manager=false
-nifi.cluster.manager.address=
-nifi.cluster.manager.protocol.port=
-nifi.cluster.manager.authority.provider.port=
-nifi.cluster.manager.authority.provider.threads=10
-nifi.cluster.manager.node.firewall.file=
-nifi.cluster.manager.node.event.history.size=10
-nifi.cluster.manager.node.api.connection.timeout=30 sec
-nifi.cluster.manager.node.api.read.timeout=30 sec
-nifi.cluster.manager.node.api.request.threads=10
-nifi.cluster.manager.flow.retrieval.delay=5 sec
-nifi.cluster.manager.protocol.threads=10
-nifi.cluster.manager.safemode.duration=0 sec