Search in sources :

Example 1 with SleepChainTriggerEvent

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

the class FlowComponentTest method startIdempotentFlowChainWhileTheOtherIsRunningReturnsOriginalFlowChainId.

@Test
public void startIdempotentFlowChainWhileTheOtherIsRunningReturnsOriginalFlowChainId() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepChainTriggerEvent sleepChainTriggerEvent1 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)));
    SleepChainTriggerEvent sleepChainTriggerEvent2 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)));
    FlowAcceptResult acceptResult1 = startSleepFlowChain(sleepChainTriggerEvent1);
    FlowAcceptResult acceptResult2 = startSleepFlowChain(sleepChainTriggerEvent2);
    assertRunningInFlowChain(acceptResult1);
    assertRunningInFlowChain(acceptResult2);
    waitFlowChainToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult2);
}
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 2 with SleepChainTriggerEvent

use of com.sequenceiq.flow.component.sleep.event.SleepChainTriggerEvent 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)

Example 3 with SleepChainTriggerEvent

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

the class FlowComponentTest method startNestedFlowChainThenWaitForComplete.

@Test
public void startNestedFlowChainThenWaitForComplete() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    Promise<AcceptResult> accepted1 = new Promise<>();
    SleepChainTriggerEvent sleepChainTriggerEvent1 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)), accepted1);
    SleepChainTriggerEvent sleepChainTriggerEvent2 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)), accepted1);
    NestedSleepChainTriggerEvent nestedSleepChainTriggerEvent1 = new NestedSleepChainTriggerEvent(resourceId, Lists.newArrayList(sleepChainTriggerEvent1, sleepChainTriggerEvent2), accepted1);
    Promise<AcceptResult> accepted2 = new Promise<>();
    SleepChainTriggerEvent sleepChainTriggerEvent3 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)), accepted2);
    SleepChainTriggerEvent sleepChainTriggerEvent4 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)), accepted2);
    NestedSleepChainTriggerEvent nestedSleepChainTriggerEvent2 = new NestedSleepChainTriggerEvent(resourceId, Lists.newArrayList(sleepChainTriggerEvent3, sleepChainTriggerEvent4), accepted2);
    FlowAcceptResult acceptResult1 = startNestedSleepFlowChain(nestedSleepChainTriggerEvent1);
    FlowAcceptResult acceptResult2 = startNestedSleepFlowChain(nestedSleepChainTriggerEvent2);
    assertRunningInFlowChain(acceptResult1);
    assertRunningInFlowChain(acceptResult2);
    waitFlowChainToComplete(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult1);
}
Also used : Promise(reactor.rx.Promise) FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) NestedSleepChainTriggerEvent(com.sequenceiq.flow.component.sleep.event.NestedSleepChainTriggerEvent) SleepChainTriggerEvent(com.sequenceiq.flow.component.sleep.event.SleepChainTriggerEvent) NestedSleepChainTriggerEvent(com.sequenceiq.flow.component.sleep.event.NestedSleepChainTriggerEvent) AcceptResult(com.sequenceiq.cloudbreak.common.event.AcceptResult) FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepConfig(com.sequenceiq.flow.component.sleep.event.SleepConfig) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SleepChainTriggerEvent

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

the class FlowComponentTest method startingDifferentFlowChainFailsBeforeFirstCompletes.

@Test
public void startingDifferentFlowChainFailsBeforeFirstCompletes() throws InterruptedException {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepChainTriggerEvent sleepChainTriggerEvent1 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)));
    SleepChainTriggerEvent sleepChainTriggerEvent2 = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.ALWAYS_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.ALWAYS_FAIL)));
    FlowAcceptResult acceptResult = startSleepFlowChain(sleepChainTriggerEvent1);
    FlowAcceptResult rejectResult = startSleepFlowChain(sleepChainTriggerEvent2);
    assertRunningInFlowChain(acceptResult);
    assertRejected(rejectResult);
    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 5 with SleepChainTriggerEvent

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

the class FlowComponentTest method startFlowChainWhenSecondFlowTriggerConditionFailsItShouldFail.

@Test
public void startFlowChainWhenSecondFlowTriggerConditionFailsItShouldFail() throws InterruptedException {
    reset(sleepTriggerCondition);
    when(sleepTriggerCondition.isFlowTriggerable(anyLong())).thenReturn(FlowTriggerConditionResult.OK).thenReturn(new FlowTriggerConditionResult("Error"));
    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);
    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) FlowTriggerConditionResult(com.sequenceiq.flow.core.FlowTriggerConditionResult) SleepConfig(com.sequenceiq.flow.component.sleep.event.SleepConfig) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

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 FlowAcceptResult (com.sequenceiq.flow.core.model.FlowAcceptResult)7 Test (org.junit.jupiter.api.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 AcceptResult (com.sequenceiq.cloudbreak.common.event.AcceptResult)1 SleepStartEvent (com.sequenceiq.flow.component.sleep.event.SleepStartEvent)1 FlowTriggerConditionResult (com.sequenceiq.flow.core.FlowTriggerConditionResult)1 Promise (reactor.rx.Promise)1