Search in sources :

Example 1 with SleepStartEvent

use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.

the class FlowComponentTest method startFlowThenWaitForFail.

@Test
public void startFlowThenWaitForFail() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepStartEvent sleepStartEvent = SleepStartEvent.alwaysFail(resourceId, SLEEP_TIME);
    FlowAcceptResult acceptResult = startSleepFlow(sleepStartEvent);
    assertRunningInFlow(acceptResult);
    waitFlowToFail(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 2 with SleepStartEvent

use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.

the class FlowComponentTest method retryFailedFlowAllowedMultipleTimes.

@Test
public void retryFailedFlowAllowedMultipleTimes() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepStartEvent sleepStartEvent = SleepStartEvent.alwaysFail(resourceId, SLEEP_TIME);
    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());
    waitFlowToFail(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
    flowIdentifier = flow2Handler.retryLastFailedFlow(resourceId, noOp());
    assertEquals(FlowType.FLOW, flowIdentifier.getType());
    assertEquals(acceptResult.getAsFlowId(), flowIdentifier.getPollableId());
    waitFlowToFail(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
}
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 3 with SleepStartEvent

use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.

the class FlowComponentTest method startingDifferentFlowFailsBeforeFirstCompletes.

@Test
public void startingDifferentFlowFailsBeforeFirstCompletes() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepStartEvent sleepStartEvent1 = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
    SleepStartEvent sleepStartEvent2 = SleepStartEvent.alwaysFail(resourceId, SLEEP_TIME);
    FlowAcceptResult acceptResult = startSleepFlow(sleepStartEvent1);
    FlowAcceptResult rejectResult = startSleepFlow(sleepStartEvent2);
    assertRunningInFlow(acceptResult);
    assertRejected(rejectResult);
    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 4 with SleepStartEvent

use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.

the class FlowComponentTest method retryPendingFlowFails.

@Test
public void retryPendingFlowFails() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepStartEvent sleepStartEvent = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
    FlowAcceptResult acceptResult = startSleepFlow(sleepStartEvent);
    assertRunningInFlow(acceptResult);
    BadRequestException exception = assertThrows(BadRequestException.class, () -> flow2Handler.retryLastFailedFlow(resourceId, noOp()));
    assertEquals("Retry cannot be performed, because there is already an active flow.", exception.getMessage());
    waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
}
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 5 with SleepStartEvent

use of com.sequenceiq.flow.component.sleep.event.SleepStartEvent in project cloudbreak by hortonworks.

the class FlowComponentTest method startingFlowChainFailsWhenFlowIsAlreadyRunning.

@Test
public void startingFlowChainFailsWhenFlowIsAlreadyRunning() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepStartEvent sleepStartEvent = SleepStartEvent.neverFail(resourceId, SLEEP_TIME);
    SleepChainTriggerEvent sleepChainTriggerEvent = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)));
    FlowAcceptResult acceptResult = startSleepFlow(sleepStartEvent);
    FlowAcceptResult rejectResult = startSleepFlowChain(sleepChainTriggerEvent);
    assertRunningInFlow(acceptResult);
    assertRejected(rejectResult);
    waitFlowToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepStartEvent(com.sequenceiq.flow.component.sleep.event.SleepStartEvent) SleepChainTriggerEvent(com.sequenceiq.flow.component.sleep.event.SleepChainTriggerEvent) NestedSleepChainTriggerEvent(com.sequenceiq.flow.component.sleep.event.NestedSleepChainTriggerEvent) SleepConfig(com.sequenceiq.flow.component.sleep.event.SleepConfig) 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