use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDao method pipelineGraphByNameAndCounter.
public PipelineDependencyGraphOld pipelineGraphByNameAndCounter(String pipelineName, int pipelineCounter) {
PipelineInstanceModels instanceModels = null;
try {
instanceModels = PipelineInstanceModels.createPipelineInstanceModels((List<PipelineInstanceModel>) getSqlMapClientTemplate().queryForList("pipelineAndItsDepedenciesByNameAndCounter", arguments("pipelineName", pipelineName).and("pipelineCounter", pipelineCounter).and("stageLocator", pipelineName + "/" + pipelineCounter + "/%/%").asMap()));
} catch (Exception e) {
throw new RuntimeException(e);
}
if (instanceModels.isEmpty()) {
return null;
}
PipelineInstanceModel upstreamPipeline = instanceModels.find(pipelineName);
loadPipelineHistoryBuildCause(upstreamPipeline);
return new PipelineDependencyGraphOld(upstreamPipeline, dependentPipelines(upstreamPipeline, instanceModels));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldLoadPipelineHistoriesStartingAtTheLatestPipeline.
@Test
public void shouldLoadPipelineHistoriesStartingAtTheLatestPipeline() throws Exception {
PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
mingleConfig.setLabelTemplate("LABEL:${COUNT}");
Pipeline pipeline1 = schedulePipelineWithStages(mingleConfig);
Pipeline pipeline2 = schedulePipelineWithStages(mingleConfig);
Pipeline pipeline3 = schedulePipelineWithStages(mingleConfig);
Pipeline pipeline4 = schedulePipelineWithStages(mingleConfig);
Pipeline pipeline5 = schedulePipelineWithStages(mingleConfig);
PipelineInstanceModels pipelineHistories = pipelineDao.loadHistory(pipeline1.getName(), 2, "latest");
assertThat(pipelineHistories.size(), is(2));
assertThat(pipelineHistories.get(0).getLabel(), is(pipeline5.getLabel()));
assertThat(pipelineHistories.get(1).getLabel(), is(pipeline4.getLabel()));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldLoadPipelineHistoriesWithMultipleSameStage.
@Test
public void shouldLoadPipelineHistoriesWithMultipleSameStage() throws Exception {
String stageName = "dev";
PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", stageName);
Pipeline mingle = schedulePipelineWithStages(mingleConfig);
Stage newInstance = rescheduleStage(stageName, mingleConfig, mingle);
PipelineInstanceModels pipelineHistories = pipelineDao.loadHistory(mingle.getName(), 10, 0);
assertThat(pipelineHistories.size(), is(1));
StageInstanceModels stageHistories = pipelineHistories.first().getStageHistory();
assertThat(stageHistories.size(), is(1));
StageInstanceModel history = stageHistories.first();
assertThat(history.getName(), is(stageName));
assertThat(history.getId(), is(newInstance.getId()));
assertThat(history.getBuildHistory().size(), is(2));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldNotIncludePipelinesNotUsingUpstreamAsDependencyMaterial_evenIfADependencyRevisionGeneratedOutOfParentPipelineAppearsInPMRrangeForANonDependentPipeline.
@Test
public void shouldNotIncludePipelinesNotUsingUpstreamAsDependencyMaterial_evenIfADependencyRevisionGeneratedOutOfParentPipelineAppearsInPMRrangeForANonDependentPipeline() throws Exception {
// shine -> cruise(depends on shine)
// mingle(not related to shine)
final HgMaterial mingleHg = MaterialsMother.hgMaterial();
PipelineConfig mingle = PipelineConfigMother.pipelineConfig("mingle", mingleHg.config(), new JobConfigs(new JobConfig("run-tests")));
PipelineConfig shine = PipelineMother.twoBuildPlansWithResourcesAndMaterials("shine", "compile");
Pipeline shineInstance = dbHelper.newPipelineWithAllStagesPassed(shine);
PipelineConfig cruise = pipelineConfigFor("cruise", "shine", "compile");
final DependencyMaterial cruiseUpstream = new DependencyMaterial(new CaseInsensitiveString("shine"), new CaseInsensitiveString("compile"));
final Modification cruiseMod = new Modification(new Date(), String.format("shine/%s/compile/%s", shineInstance.getCounter(), shineInstance.getStages().get(0).getCounter()), "shine-1", null);
final Modification mingleFrom = ModificationsMother.oneModifiedFile("1234");
saveRev(mingleHg, mingleFrom);
saveRev(cruiseUpstream, cruiseMod);
final Modification mingleTo = ModificationsMother.oneModifiedFile("abcd");
saveRev(mingleHg, mingleTo);
dbHelper.saveMaterialsWIthPassedStages(instanceFactory.createPipelineInstance(mingle, BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(mingleHg, mingleTo, mingleFrom)), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider()));
final Pipeline cruiseInstance = instanceFactory.createPipelineInstance(cruise, BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(cruiseUpstream, cruiseMod)), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
dbHelper.saveMaterialsWIthPassedStages(cruiseInstance);
PipelineDependencyGraphOld dependencyGraph = pipelineDao.pipelineGraphByNameAndCounter("shine", shineInstance.getCounter());
assertPipelineEquals(shineInstance, dependencyGraph.pipeline());
ensureBuildCauseIsLoadedFor(dependencyGraph.pipeline());
PipelineInstanceModels dependencies = dependencyGraph.dependencies();
assertThat(dependencies.size(), is(1));
assertPipelineEquals(cruiseInstance, dependencies.find("cruise"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldLoadPipelineHistoryOnlyForSuppliedPipeline.
@Test
public void shouldLoadPipelineHistoryOnlyForSuppliedPipeline() throws Exception {
PipelineConfig mingleConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
PipelineConfig otherConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("other", "dev");
schedulePipelineWithStages(mingleConfig);
schedulePipelineWithStages(otherConfig);
schedulePipelineWithStages(mingleConfig);
schedulePipelineWithStages(otherConfig);
schedulePipelineWithStages(mingleConfig);
PipelineInstanceModels pipelineHistories = pipelineDao.loadHistory("mingle", 10, 0);
assertThat(pipelineHistories.get(0).getName(), is("mingle"));
assertThat(pipelineHistories.get(1).getName(), is("mingle"));
assertThat(pipelineHistories.get(2).getName(), is("mingle"));
assertThat(pipelineHistories.size(), is(3));
}
Aggregations