Search in sources :

Example 16 with FlowAcceptResult

use of com.sequenceiq.flow.core.model.FlowAcceptResult 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 17 with FlowAcceptResult

use of com.sequenceiq.flow.core.model.FlowAcceptResult in project cloudbreak by hortonworks.

the class FlowComponentTest method startFlowChainThenWaitForComplete.

@Test
public void startFlowChainThenWaitForComplete() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepChainTriggerEvent sleepChainTriggerEvent = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)));
    FlowAcceptResult acceptResult = startSleepFlowChain(sleepChainTriggerEvent);
    assertRunningInFlowChain(acceptResult);
    waitFlowChainToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) 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)

Example 18 with FlowAcceptResult

use of com.sequenceiq.flow.core.model.FlowAcceptResult in project cloudbreak by hortonworks.

the class FlowComponentTest method startFlowChainThenWaitForFail.

@Test
public void startFlowChainThenWaitForFail() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepChainTriggerEvent sleepChainTriggerEvent = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.ALWAYS_FAIL)));
    FlowAcceptResult acceptResult = startSleepFlowChain(sleepChainTriggerEvent);
    assertRunningInFlowChain(acceptResult);
    waitFlowChainToFail(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) 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)

Example 19 with FlowAcceptResult

use of com.sequenceiq.flow.core.model.FlowAcceptResult 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 20 with FlowAcceptResult

use of com.sequenceiq.flow.core.model.FlowAcceptResult 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)

Aggregations

FlowAcceptResult (com.sequenceiq.flow.core.model.FlowAcceptResult)21 Test (org.junit.jupiter.api.Test)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 SleepStartEvent (com.sequenceiq.flow.component.sleep.event.SleepStartEvent)10 NestedSleepChainTriggerEvent (com.sequenceiq.flow.component.sleep.event.NestedSleepChainTriggerEvent)7 SleepChainTriggerEvent (com.sequenceiq.flow.component.sleep.event.SleepChainTriggerEvent)7 SleepConfig (com.sequenceiq.flow.component.sleep.event.SleepConfig)7 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)6 AcceptResult (com.sequenceiq.cloudbreak.common.event.AcceptResult)4 FlowNotAcceptedException (com.sequenceiq.cloudbreak.exception.FlowNotAcceptedException)3 FlowsAlreadyRunningException (com.sequenceiq.cloudbreak.exception.FlowsAlreadyRunningException)3 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)2 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)2 BadRequestException (javax.ws.rs.BadRequestException)2 Promise (reactor.rx.Promise)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)1 FlowTriggerConditionResult (com.sequenceiq.flow.core.FlowTriggerConditionResult)1 BaseFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseFlowEvent)1