private Pipeline manualSchedule(String pipelineName) throws Exception, StageAlreadyBuildingException { scheduleHelper.manuallySchedulePipelineWithRealMaterials( pipelineName, new Username(new CaseInsensitiveString("some user name"))); scheduleService.autoSchedulePipelinesFromRequestBuffer(); return pipelineService.mostRecentFullPipelineByName(pipelineName); }
private Pipeline tryToScheduleAPipeline() { BuildCause buildCause = BuildCause.createWithModifications(modifyOneFile(preCondition.pipelineConfig()), ""); dbHelper.saveMaterials(buildCause.getMaterialRevisions()); pipelineScheduleQueue.schedule(preCondition.pipelineName, buildCause); scheduleService.autoSchedulePipelinesFromRequestBuffer(); return pipelineService.mostRecentFullPipelineByName(preCondition.pipelineName); }
@Test public void shouldConsumeAllBuildCausesInServerHealth() throws Exception { pipelineScheduleQueue.schedule( "mingle", BuildCause.createManualForced(modifyOneFile(mingleConfig), Username.ANONYMOUS)); pipelineScheduleQueue.schedule( "evolve", BuildCause.createManualForced(modifyOneFile(evolveConfig), Username.ANONYMOUS)); scheduleService.autoSchedulePipelinesFromRequestBuffer(); assertThat(pipelineScheduleQueue.toBeScheduled().size(), is(0)); }
private Pipeline manualSchedule(String pipelineName) { final HashMap<String, String> revisions = new HashMap<String, String>(); final HashMap<String, String> environmentVariables = new HashMap<String, String>(); buildCauseProducer.manualProduceBuildCauseAndSave( pipelineName, new Username(new CaseInsensitiveString("some user name")), new ScheduleOptions(revisions, environmentVariables, new HashMap<String, String>()), new ServerHealthStateOperationResult()); scheduleService.autoSchedulePipelinesFromRequestBuffer(); return pipelineService.mostRecentFullPipelineByName(pipelineName); }
@Test public void shouldNotThrowErrorWhenMaterialsChange() throws Exception { configHelper.addPipeline("cruise", "dev", repository); goConfigService.forceNotifyListeners(); scheduleHelper.autoSchedulePipelinesWithRealMaterials("mingle", "evolve", "cruise"); configHelper.replaceMaterialForPipeline( "cruise", svnMaterialConfig("http://new-material", null)); goConfigService.forceNotifyListeners(); try { scheduleService.autoSchedulePipelinesFromRequestBuffer(); } catch (Exception e) { fail("#2520 - should not cause an error if materials have changed"); } }
@Test public void shouldRemoveBuildCauseIfAnyExceptionIsThrown() throws Exception { configHelper.addPipeline("cruise", "dev", repository); goConfigService.forceNotifyListeners(); goConfigService .getCurrentConfig() .pipelineConfigByName(new CaseInsensitiveString("cruise")) .get(0) .jobConfigByConfigName(new CaseInsensitiveString("unit")) .setRunOnAllAgents(true); scheduleHelper.autoSchedulePipelinesWithRealMaterials("cruise"); goConfigService.forceNotifyListeners(); scheduleService.autoSchedulePipelinesFromRequestBuffer(); assertThat(pipelineScheduleQueue.toBeScheduled().size(), is(0)); }
@Test public void shouldRemoveBuildCauseIfPipelineNotExist() throws Exception { configHelper.addPipeline("cruise", "dev", repository); goConfigService.forceNotifyListeners(); scheduleHelper.autoSchedulePipelinesWithRealMaterials("mingle", "evolve", "cruise"); Assertions.assertWillHappen( 2, PipelineScheduleQueueMatcher.numberOfScheduledPipelinesIsAtLeast(pipelineScheduleQueue), Timeout.FIVE_SECONDS); int originalSize = pipelineScheduleQueue.toBeScheduled().size(); assertThat(originalSize, greaterThan(1)); configHelper.initializeConfigFile(); goConfigService.forceNotifyListeners(); scheduleService.autoSchedulePipelinesFromRequestBuffer(); assertThat(pipelineScheduleQueue.toBeScheduled().size(), is(0)); }
@Test public void shouldUpdateServerHealthWhenSchedulePipelineFails() throws Exception { pipelineScheduleQueue.schedule( "blahPipeline", saveMaterials( modifySomeFiles( goConfigService.pipelineConfigNamed(new CaseInsensitiveString("blahPipeline"))))); scheduleService.autoSchedulePipelinesFromRequestBuffer(); List<ServerHealthState> stateList = serverHealthService.filterByScope(HealthStateScope.forStage("blahPipeline", "blahStage")); assertThat(stateList.size(), is(1)); assertThat( stateList.get(0).getMessage(), is("Failed to trigger stage [blahStage] pipeline [blahPipeline]")); assertThat( stateList.get(0).getDescription(), is("Could not find matching agents to run job [job2] of stage [blahStage].")); }
private void autoSchedulePipelines(String... pipelineNames) throws Exception { scheduleHelper.autoSchedulePipelinesWithRealMaterials(pipelineNames); scheduleService.autoSchedulePipelinesFromRequestBuffer(); }