@Test public void shouldCancelAScheduledJobInCaseThePipelineIsRemovedFromTheConfig_SpecificallyAPipelineRenameToADifferentCaseAndStageNameToADifferentName() throws Exception { Material hgMaterial = new HgMaterial("url", "folder"); String[] hgRevs = new String[] {"h1"}; u.checkinInOrder(hgMaterial, hgRevs); ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("PIPELINE_WHICH_WILL_EVENTUALLY_CHANGE_CASE", u.m(hgMaterial)); u.scheduleWith(p1, hgRevs); ScheduleTestUtil.AddedPipeline renamedPipeline = u.renamePipelineAndFirstStage( p1, "pipeline_which_will_eventually_change_case", "NEW_RANDOM_STAGE_NAME" + UUID.randomUUID()); Pipeline p1_2 = u.scheduleWith(renamedPipeline, hgRevs); CruiseConfig cruiseConfig = configHelper.load(); buildAssignmentService.onTimer(); // To Reload Job Plans buildAssignmentService.onConfigChange(cruiseConfig); Stages allStages = stageDao.findAllStagesFor(p1_2.getName(), p1_2.getCounter()); assertThat( allStages.byName(CaseInsensitiveString.str(p1.config.first().name())).getState(), is(StageState.Cancelled)); }
@Test public void shouldNotAutoSchedulePausedPipeline() throws Exception { ScheduleTestUtil u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper); HgMaterial hg = new HgMaterial("url", null); String[] hg_revs = {"h1", "h2"}; u.checkinInOrder(hg, hg_revs); ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(hg)); ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(hg)); pipelinePauseService.pause(p1.config.name().toString(), "pausing p1", Username.ANONYMOUS); ServerHealthStateOperationResult p1Result = new ServerHealthStateOperationResult(); service.autoSchedulePipeline(p1.config.name().toString(), p1Result, 1234); assertThat(p1Result.canContinue(), is(false)); ServerHealthStateOperationResult p2Result = new ServerHealthStateOperationResult(); service.autoSchedulePipeline(p2.config.name().toString(), p2Result, 1234); assertThat(p2Result.canContinue(), is(true)); }