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));
}
Aggregations