use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.
the class FlowComponentTest method retryCompletedFlowFails.
@Test
public void retryCompletedFlowFails() throws InterruptedException {
long resourceId = RESOURCE_ID_SEC.incrementAndGet();
SleepStartEvent sleepStartEvent = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
FlowAcceptResult acceptResult = startSleepFlow(sleepStartEvent);
assertRunningInFlow(acceptResult);
waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
BadRequestException exception = assertThrows(BadRequestException.class, () -> flow2Handler.retryLastFailedFlow(resourceId, noOp()));
assertEquals("Retry cannot be performed, because the last action was successful.", exception.getMessage());
}
use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.
the class FlowComponentTest method retryFirstFailedThenCompletedFlowFails.
@Test
public void retryFirstFailedThenCompletedFlowFails() throws InterruptedException {
long resourceId = RESOURCE_ID_SEC.incrementAndGet();
SleepStartEvent sleepStartEvent = new SleepStartEvent(resourceId, SLEEP_TIME, LocalDateTime.now().plus(SLEEP_TIME.multipliedBy(2)));
FlowAcceptResult acceptResult = startSleepFlow(sleepStartEvent);
assertRunningInFlow(acceptResult);
waitFlowToFail(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
FlowIdentifier flowIdentifier = flow2Handler.retryLastFailedFlow(resourceId, noOp());
assertEquals(FlowType.FLOW, flowIdentifier.getType());
assertEquals(acceptResult.getAsFlowId(), flowIdentifier.getPollableId());
waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
assertThrows(BadRequestException.class, () -> flow2Handler.retryLastFailedFlow(resourceId, noOp()));
}
use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.
the class FlowComponentTest method startFlowThenWaitForComplete.
@Test
public void startFlowThenWaitForComplete() throws InterruptedException {
long resourceId = RESOURCE_ID_SEC.incrementAndGet();
SleepStartEvent sleepStartEvent = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
FlowAcceptResult acceptResult = startSleepFlow(sleepStartEvent);
assertRunningInFlow(acceptResult);
waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
}
use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.
the class FlowComponentTest method startIdempotentFlowWhileTheOtherIsRunningReturnsOriginalFlowId.
@Test
public void startIdempotentFlowWhileTheOtherIsRunningReturnsOriginalFlowId() throws InterruptedException {
long resourceId = RESOURCE_ID_SEC.incrementAndGet();
SleepStartEvent sleepStartEvent1 = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
SleepStartEvent sleepStartEvent2 = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
FlowAcceptResult acceptResult1 = startSleepFlow(sleepStartEvent1);
FlowAcceptResult acceptResult2 = startSleepFlow(sleepStartEvent2);
assertRunningInFlow(acceptResult1);
assertRunningInFlow(acceptResult2);
waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult2);
}
use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.
the class FlowComponentTest method startSecondFlowWhenFirstCompletedThenWaitForComplete.
@Test
public void startSecondFlowWhenFirstCompletedThenWaitForComplete() throws InterruptedException {
long resourceId = RESOURCE_ID_SEC.incrementAndGet();
SleepStartEvent sleepStartEvent1 = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
FlowAcceptResult acceptResult1 = startSleepFlow(sleepStartEvent1);
assertRunningInFlow(acceptResult1);
waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult1);
SleepStartEvent sleepStartEvent2 = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
FlowAcceptResult acceptResult2 = startSleepFlow(sleepStartEvent2);
assertRunningInFlow(acceptResult2);
waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult2);
}
Aggregations