Search in sources :

Example 26 with PipelineConfigDependencyGraph

use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.

the class ChangesetService method filterReachableFingerprintHolders.

private <T> List<T> filterReachableFingerprintHolders(List<T> allFingerprintHolders, final FingerprintLoader<T> fingerprintLoader, String pipelineName, Username username, boolean skipCheckForMingle, boolean skipTrackingToolMatch) {
    PipelineConfigDependencyGraph graph = goConfigService.upstreamDependencyGraphOf(pipelineName);
    Set<String> allMaterialFingerprints = graph.allMaterialFingerprints();
    Set<String> reachableMaterialfingerprints = populateReachableFingerprints(graph, username, skipCheckForMingle, skipTrackingToolMatch);
    return filterFingerprintHolders(allFingerprintHolders, reachableMaterialfingerprints, allMaterialFingerprints, fingerprintLoader);
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 27 with PipelineConfigDependencyGraph

use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromThirdWhenSecondIsNotModified.

@Test
public void shouldChooseTheRevisionFromThirdWhenSecondIsNotModified() throws Exception {
    //      Third* <- Second
    //         |     /
    //         |   /
    //         Last
    //
    // * indicates changed
    Date date = new Date();
    MaterialRevisionBuilder builder = new MaterialRevisionBuilder(pipelineDao, materialRepository);
    PipelineConfigDependencyGraph graph = builder.depInstance("last", 1, date, builder.depInstance("third", 3, date, builder.depInstance("second", 2, date, builder.svnInstance("1", date))), builder.depInstance("second", 4, date, builder.svnInstance("2", date))).getGraph();
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(builder.lookingAtDep("third", 3, date).markAsChanged().revision());
    actual.addRevision(builder.lookingAtDep("second", 4, date).revision());
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(builder.depInstance("third", 3, date).getRevision());
    expected.addRevision(builder.depInstance("second", 2, date).getRevision());
    MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(graph, actual);
    assertThat(finalRevisions, is(expected));
    for (int i = 0; i < expected.numberOfRevisions(); i++) {
        assertTrue(finalRevisions.getMaterialRevision(i) == actual.getMaterialRevision(i));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) MaterialRevisionBuilder(com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Date(java.util.Date) Test(org.junit.Test)

Example 28 with PipelineConfigDependencyGraph

use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldIgnoreUpstreamPipelineWhenThereIsNothingInCommon.

@Test
public void shouldIgnoreUpstreamPipelineWhenThereIsNothingInCommon() throws Exception {
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    up1Revision.markAsChanged();
    MaterialRevision earlierUp0Revision = dependencyMaterialRevision("up0", 1, "label", "stage", 1, new Date());
    MaterialRevision laterUp0Revision = dependencyMaterialRevision("up0", 2, "label", "stage", 1, new Date());
    laterUp0Revision.markAsChanged();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(earlierUp0Revision);
    expected.addRevision(up1Revision);
    expected.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    MaterialRevisions allUp1Revisions = new MaterialRevisions();
    allUp1Revisions.addRevision(earlierUp0Revision);
    MaterialRevisions allUp0Revisions = new MaterialRevisions();
    allUp0Revisions.addAll(createHgMaterialWithMultipleRevisions(3L, first));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(laterUp0Revision);
    actual.addRevision(up1Revision);
    actual.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    DependencyMaterialConfig sameUpstream = new DependencyMaterialConfig(new CaseInsensitiveString("up0"), new CaseInsensitiveString("stage"));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", sameUpstream, new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("stage")), MaterialConfigsMother.svnMaterialConfig());
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", sameUpstream);
    PipelineConfig up0 = createPipelineConfigWithMaterialConfig("up0", MaterialConfigsMother.hgMaterialConfig());
    Pipeline up1Pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    up1Pipeline.setId(10);
    Pipeline up0Pipeline = PipelineMother.passedPipelineInstance("up0", "stage", "job");
    up0Pipeline.setId(5);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(up1Pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(allUp1Revisions);
    when(pipelineDao.findPipelineByNameAndCounter("up0", 1)).thenReturn(up0Pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(5)).thenReturn(allUp0Revisions);
    when(pipelineDao.findPipelineByNameAndCounter("up0", 2)).thenReturn(up0Pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(5)).thenReturn(allUp0Revisions);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(up0)), new PipelineConfigDependencyGraph(up0));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 29 with PipelineConfigDependencyGraph

use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsFromTheUpStreamPipelineThatUsesTheSameMaterial.

@Test
public void shouldGetTheRevisionsFromTheUpStreamPipelineThatUsesTheSameMaterial() throws Exception {
    MaterialRevisions expected = new MaterialRevisions();
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    up1Revision.markAsChanged();
    expected.addRevision(up1Revision);
    expected.addAll(createHgMaterialWithMultipleRevisions(1L, first));
    expected.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(up1Revision);
    actual.addAll(createHgMaterialWithMultipleRevisions(1L, third));
    actual.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), actual.getMaterials().get(0).config());
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", expected.getMaterials().get(1).config(), expected.getMaterials().get(2).config());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(expected);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 30 with PipelineConfigDependencyGraph

use of com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph in project gocd by gocd.

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsFromTheNearestUpStreamPipeline.

@Test
public void shouldGetTheRevisionsFromTheNearestUpStreamPipeline() throws Exception {
    MaterialRevisions uppestRevision = createHgMaterialWithMultipleRevisions(1L, first);
    MaterialRevisions secondHgRevision = createHgMaterialWithMultipleRevisions(1L, second);
    ((HgMaterial) secondHgRevision.getMaterialRevision(0).getMaterial()).setFolder("mother");
    MaterialRevisions upRevision = new MaterialRevisions(secondHgRevision.getMaterialRevision(0), dependencyMaterialRevision("up0", 2, "label", "stage", 1, new Date()));
    MaterialRevisions actual = createHgMaterialWithMultipleRevisions(1L, third);
    ((HgMaterial) actual.getMaterials().get(0)).setFolder("mother");
    MaterialRevision up1Modification = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    up1Modification.markAsChanged();
    actual.addRevision(up1Modification);
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", actual.getMaterials().get(0).config(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("stage")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", upRevision.getMaterials().get(0).config(), upRevision.getMaterials().get(1).config());
    PipelineConfig up0 = createPipelineConfigWithMaterialConfig("up0", MaterialConfigsMother.hgMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    Pipeline uppestPipeline = PipelineMother.passedPipelineInstance("up0", "stage", "job");
    uppestPipeline.setId(5);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(upRevision);
    when(pipelineDao.findPipelineByNameAndCounter("up0", 2)).thenReturn(uppestPipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(5)).thenReturn(uppestRevision);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(up0)));
    secondHgRevision.addRevision(up1Modification);
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(secondHgRevision));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)37 Test (org.junit.Test)32 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)31 Date (java.util.Date)28 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)21 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)16 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)8 Pipeline (com.thoughtworks.go.domain.Pipeline)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 ModificationsMother.changedDependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision)7 ModificationsMother.dependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision)7 MaterialRevisionBuilder (com.thoughtworks.go.server.functional.helpers.MaterialRevisionBuilder)6 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)3 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 Materials (com.thoughtworks.go.config.materials.Materials)2