Search in sources :

Example 11 with PipelineInstanceModels

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));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) PipelineNotFoundException(com.thoughtworks.go.config.PipelineNotFoundException)

Example 12 with PipelineInstanceModels

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()));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) Test(org.junit.Test)

Example 13 with PipelineInstanceModels

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));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) Test(org.junit.Test)

Example 14 with PipelineInstanceModels

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"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TimeProvider(com.thoughtworks.go.util.TimeProvider) Date(java.util.Date) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 15 with PipelineInstanceModels

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));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) Test(org.junit.Test)

Aggregations

PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)45 Test (org.junit.Test)37 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)12 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)8 PipelineInstanceModels.createPipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels)4 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 PipelineNotFoundException (com.thoughtworks.go.config.PipelineNotFoundException)2 Permissions (com.thoughtworks.go.config.security.Permissions)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Matchers.anyString (org.mockito.Matchers.anyString)2 SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)1