Search in sources :

Example 1 with CannotScheduleException

use of com.thoughtworks.go.domain.CannotScheduleException in project gocd by gocd.

the class ScheduleServiceStageTriggerTest method errorInSchedulingSubsequentStageShouldNotRollbackCancelAction.

@Test
public void errorInSchedulingSubsequentStageShouldNotRollbackCancelAction() throws Exception {
    Pipeline oldest = preCondition.createPipelineWithFirstStagePassedAndSecondStageRunning();
    preCondition.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    long cancelledStageId = oldest.getStages().byName(preCondition.ftStage).getId();
    preCondition.setRunOnAllAgentsForSecondStage();
    try {
        scheduleService.cancelAndTriggerRelevantStages(cancelledStageId, null, null);
        fail("Must have failed scheduling the next stage as it has run on all agents");
    } catch (CannotScheduleException expected) {
    }
    Pipeline mostRecent = pipelineService.mostRecentFullPipelineByName(preCondition.pipelineName);
    Stage cancelledStage = stageService.stageById(cancelledStageId);
    assertThat(cancelledStage.stageState(), is(StageState.Cancelled));
    assertThat(mostRecent.getStages().size(), is(1));
}
Also used : Stage(com.thoughtworks.go.domain.Stage) Pipeline(com.thoughtworks.go.domain.Pipeline) CannotScheduleException(com.thoughtworks.go.domain.CannotScheduleException) Test(org.junit.Test)

Aggregations

CannotScheduleException (com.thoughtworks.go.domain.CannotScheduleException)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 Stage (com.thoughtworks.go.domain.Stage)1 Test (org.junit.Test)1