use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class ScheduleServiceIntegrationTest method runAndPass.
private Pipeline runAndPass(PipelineConfig pipelineConfig, int counter) {
BuildCause buildCause = ModificationsMother.modifySomeFiles(pipelineConfig);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
String pipelineName = pipelineConfig.name().toString();
pipelineScheduleQueue.schedule(pipelineName, buildCause);
scheduleService.autoSchedulePipelinesFromRequestBuffer();
Pipeline pipeline = pipelineDao.findPipelineByNameAndCounter(pipelineName, counter);
pipeline = pipelineDao.loadAssociations(pipeline, pipelineName);
dbHelper.pass(pipeline);
return pipeline;
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldForceStagePlanWithModificationsSinceLast.
@Test
public void shouldForceStagePlanWithModificationsSinceLast() throws Exception {
Pipeline completedMingle = scheduleAndCompleteInitialPipelines();
pipelineDao.loadPipeline(completedMingle.getId());
TestingMaterial testingMaterial = new TestingMaterial();
mingleConfig.setMaterialConfigs(new MaterialConfigs(testingMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(testingMaterial, testingMaterial.modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createManualForced(revisions, Username.ANONYMOUS);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline forcedPipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineService.save(forcedPipeline);
verifyMingleScheduledWithModifications();
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldScheduleMultipleJobsWhenToBeRunMultipleInstance.
@Test
public void shouldScheduleMultipleJobsWhenToBeRunMultipleInstance() throws Exception {
configHelper.setRunMultipleInstance(CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", 2);
Material stubMaterial = new TestingMaterial();
evolveConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY, environmentConfigService.agentsForPipeline(evolveConfig.name())), md5, new TimeProvider());
pipelineService.save(pipeline);
Stage instance = scheduleService.scheduleStage(pipeline, STAGE_NAME, "anyone", new ScheduleService.NewStageInstanceCreator(goConfigService), new ScheduleService.ExceptioningErrorHandler());
JobInstances scheduledJobs = instance.getJobInstances();
assertThat(scheduledJobs.size(), is(2));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class InstanceFactoryTest method shouldSchedulePipelineWithFirstStage.
@Test
public void shouldSchedulePipelineWithFirstStage() {
StageConfig stageOneConfig = StageConfigMother.stageConfig("dev", BuildPlanMother.withBuildPlans("functional", "unit"));
StageConfig stageTwoConfig = StageConfigMother.stageConfig("qa", BuildPlanMother.withBuildPlans("suiteOne", "suiteTwo"));
MaterialConfigs materialConfigs = MaterialConfigsMother.defaultMaterialConfigs();
PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("mingle"), materialConfigs, stageOneConfig, stageTwoConfig);
BuildCause buildCause = BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS);
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, buildCause, new DefaultSchedulingContext("test"), "some-md5", new TimeProvider());
assertThat(pipeline.getName(), is("mingle"));
assertThat(pipeline.getStages().size(), is(1));
assertThat(pipeline.getStages().get(0).getName(), is("dev"));
assertThat(pipeline.getStages().get(0).getJobInstances().get(0).getName(), is("functional"));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class ValueStreamMapService method traverseUpstream.
private void traverseUpstream(String pipelineName, BuildCause buildCause, ValueStreamMap graph, List<MaterialRevision> visitedNodes) {
for (MaterialRevision materialRevision : buildCause.getMaterialRevisions()) {
Material material = materialRevision.getMaterial();
if (material instanceof DependencyMaterial) {
String upstreamPipeline = ((DependencyMaterial) material).getPipelineName().toString();
DependencyMaterialRevision revision = (DependencyMaterialRevision) materialRevision.getRevision();
graph.addUpstreamNode(new PipelineDependencyNode(upstreamPipeline, upstreamPipeline), new PipelineRevision(revision.getPipelineName(), revision.getPipelineCounter(), revision.getPipelineLabel()), pipelineName);
if (visitedNodes.contains(materialRevision)) {
continue;
}
visitedNodes.add(materialRevision);
DependencyMaterialRevision dmrOfUpstreamPipeline = buildCause.getMaterialRevisions().findDependencyMaterialRevision(upstreamPipeline);
BuildCause buildCauseForUpstreamPipeline = pipelineService.buildCauseFor(dmrOfUpstreamPipeline.getPipelineName(), dmrOfUpstreamPipeline.getPipelineCounter());
traverseUpstream(upstreamPipeline, buildCauseForUpstreamPipeline, graph, visitedNodes);
} else {
graph.addUpstreamMaterialNode(new SCMDependencyNode(material.getFingerprint(), material.getUriForDisplay(), materialRevision.getMaterialType()), material.getName(), pipelineName, materialRevision);
}
}
}
Aggregations