use of org.apache.nifi.controller.ProcessorNode in project nifi by apache.
the class TestProcessorLifecycle method validateStartFailsOnInvalidProcessorWithMissingProperty.
/**
* Validate that processor will not be validated on failing
* PropertyDescriptor validation.
*/
@Test(expected = IllegalStateException.class)
public void validateStartFailsOnInvalidProcessorWithMissingProperty() throws Exception {
final FlowControllerAndSystemBundle fcsb = this.buildFlowControllerForTest();
fc = fcsb.getFlowController();
ProcessGroup testGroup = fc.createProcessGroup(UUID.randomUUID().toString());
this.setControllerRootGroup(fc, testGroup);
ProcessorNode testProcNode = fc.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(), fcsb.getSystemBundle().getBundleDetails().getCoordinate());
ProcessScheduler ps = fc.getProcessScheduler();
ps.startProcessor(testProcNode, true);
fail();
}
use of org.apache.nifi.controller.ProcessorNode in project nifi by apache.
the class TestProcessorLifecycle method validateEnableOperation.
@Test
public void validateEnableOperation() throws Exception {
final FlowControllerAndSystemBundle fcsb = this.buildFlowControllerForTest();
fc = fcsb.getFlowController();
ProcessGroup testGroup = fc.createProcessGroup(UUID.randomUUID().toString());
this.setControllerRootGroup(fc, testGroup);
final ProcessorNode testProcNode = fc.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());
}
use of org.apache.nifi.controller.ProcessorNode in project nifi by apache.
the class TestProcessorLifecycle method validateStopCallsAreMeaninglessIfProcessorNotStarted.
/**
* Validates that stop calls are harmless and idempotent if processor is not
* in STARTING or RUNNING state.
*/
@Test
public void validateStopCallsAreMeaninglessIfProcessorNotStarted() throws Exception {
final FlowControllerAndSystemBundle fcsb = this.buildFlowControllerForTest();
fc = fcsb.getFlowController();
ProcessGroup testGroup = fc.createProcessGroup(UUID.randomUUID().toString());
this.setControllerRootGroup(fc, testGroup);
final ProcessorNode testProcNode = fc.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);
final ProcessScheduler ps = fc.getProcessScheduler();
ps.stopProcessor(testProcNode);
assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState());
assertTrue(testProcessor.operationNames.isEmpty());
}
use of org.apache.nifi.controller.ProcessorNode in project nifi by apache.
the class TestProcessorLifecycle method validateProcessorCanBeStoppedWhenOnTriggerThrowsException.
/**
* Validates that processor can be stopped if onTrigger() keeps throwing
* exceptions.
*/
@Test
public void validateProcessorCanBeStoppedWhenOnTriggerThrowsException() throws Exception {
final FlowControllerAndSystemBundle fcsb = this.buildFlowControllerForTest();
fc = fcsb.getFlowController();
ProcessGroup testGroup = fc.createProcessGroup(UUID.randomUUID().toString());
this.setControllerRootGroup(fc, testGroup);
ProcessorNode testProcNode = fc.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;
ProcessScheduler ps = fc.getProcessScheduler();
ps.startProcessor(testProcNode, true);
assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), 2000L);
ps.disableProcessor(testProcNode);
assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), 2000L);
ps.stopProcessor(testProcNode);
assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), 2000L);
}
use of org.apache.nifi.controller.ProcessorNode in project nifi by apache.
the class TestProcessorLifecycle method validateProcessScheduledAfterAdministrativeDelayDueToTheOnScheduledException.
/**
* Validates that Processor is eventually started once invocation of
*
* @OnSchedule stopped throwing exceptions.
*/
@Test
public void validateProcessScheduledAfterAdministrativeDelayDueToTheOnScheduledException() throws Exception {
final FlowControllerAndSystemBundle fcsb = this.buildFlowControllerForTest();
fc = fcsb.getFlowController();
ProcessGroup testGroup = fc.createProcessGroup(UUID.randomUUID().toString());
this.setControllerRootGroup(fc, testGroup);
ProcessorNode testProcNode = fc.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;
ProcessScheduler ps = fc.getProcessScheduler();
ps.startProcessor(testProcNode, true);
assertCondition(() -> ScheduledState.RUNNING == testProcNode.getScheduledState(), 10000L);
ps.stopProcessor(testProcNode);
assertCondition(() -> ScheduledState.STOPPED == testProcNode.getScheduledState(), 2000L);
}
Aggregations