Search in sources :

Example 6 with SleepStartEvent

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());
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepStartEvent(com.sequenceiq.flow.component.sleep.event.SleepStartEvent) BadRequestException(javax.ws.rs.BadRequestException) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with SleepStartEvent

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()));
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepStartEvent(com.sequenceiq.flow.component.sleep.event.SleepStartEvent) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with SleepStartEvent

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);
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepStartEvent(com.sequenceiq.flow.component.sleep.event.SleepStartEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with SleepStartEvent

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);
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepStartEvent(com.sequenceiq.flow.component.sleep.event.SleepStartEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with SleepStartEvent

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);
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepStartEvent(com.sequenceiq.flow.component.sleep.event.SleepStartEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SleepStartEvent (com.sequenceiq.flow.component.sleep.event.SleepStartEvent)10 FlowAcceptResult (com.sequenceiq.flow.core.model.FlowAcceptResult)10 Test (org.junit.jupiter.api.Test)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)2 BadRequestException (javax.ws.rs.BadRequestException)2 NestedSleepChainTriggerEvent (com.sequenceiq.flow.component.sleep.event.NestedSleepChainTriggerEvent)1 SleepChainTriggerEvent (com.sequenceiq.flow.component.sleep.event.SleepChainTriggerEvent)1 SleepConfig (com.sequenceiq.flow.component.sleep.event.SleepConfig)1