Search in sources :

Example 6 with PipelineConfigDependencyGraph

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

the class PipelineServiceTest method createCruiseConfigFromGraph.

private CruiseConfig createCruiseConfigFromGraph(CruiseConfig cruiseConfig, final PipelineConfigDependencyGraph pdg) {
    String groupName = "defaultGroup";
    cruiseConfig.addPipeline(groupName, pdg.getCurrent());
    for (PipelineConfigDependencyGraph upstreamDependency : pdg.getUpstreamDependencies()) {
        createCruiseConfigFromGraph(cruiseConfig, upstreamDependency);
    }
    return cruiseConfig;
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)

Example 7 with PipelineConfigDependencyGraph

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

the class PipelineServiceTriangleDependencyTest method shouldChooseTheRevisionFromSecondWhenThirdIsNotModifiedInspiteOfSecondBeingFirstMaterialInConfig.

@Test
public void shouldChooseTheRevisionFromSecondWhenThirdIsNotModifiedInspiteOfSecondBeingFirstMaterialInConfig() 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("second", 4, date, builder.svnInstance("2", date)), builder.depInstance("third", 3, date, builder.depInstance("second", 2, date, builder.svnInstance("1", date)))).getGraph();
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(builder.lookingAtDep("second", 4, date).markAsChanged().revision());
    actual.addRevision(builder.lookingAtDep("third", 3, date).revision());
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(builder.depInstance("second", 4, date).getRevision());
    expected.addRevision(builder.depInstance("third", 3, 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 8 with PipelineConfigDependencyGraph

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

the class BuildCauseProducerServiceTest method shouldHandleNoModificationExceptionThrownByAutoBuild.

@Test
public void shouldHandleNoModificationExceptionThrownByAutoBuild() {
    String pipelineName = "pipeline";
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    PipelineConfig config = PipelineConfigMother.pipelineConfig(pipelineName);
    Material svnMaterial = MaterialsMother.defaultMaterials().get(0);
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("up"), new CaseInsensitiveString("s1"));
    config.materialConfigs().clear();
    config.addMaterialConfig(svnMaterial.config());
    config.addMaterialConfig(dependencyMaterial.config());
    when(pipelineService.getRevisionsBasedOnDependencies(Matchers.<MaterialRevisions>any(), Matchers.<BasicCruiseConfig>any(), Matchers.<CaseInsensitiveString>any())).thenThrow(new NoModificationsPresentForDependentMaterialException("P/1/S/1"));
    when(pipelineScheduleQueue.mostRecentScheduled(pipelineName)).thenReturn(BuildCause.createNeverRun());
    Modification modification = ModificationsMother.checkinWithComment("r", "c", new Date(), "f1");
    when(materialRepository.findLatestModification(svnMaterial)).thenReturn(ModificationsMother.createSvnMaterialWithMultipleRevisions(1, modification));
    when(materialRepository.findLatestModification(dependencyMaterial)).thenReturn(new MaterialRevisions(ModificationsMother.changedDependencyMaterialRevision("up", 1, "1", "s", 1, new Date())));
    when(specificMaterialRevisionFactory.create(Matchers.<String>any(), Matchers.<Map<String, String>>any())).thenReturn(MaterialRevisions.EMPTY);
    when(goConfigService.upstreamDependencyGraphOf(Matchers.<String>any(), Matchers.<BasicCruiseConfig>any())).thenReturn(new PipelineConfigDependencyGraph(config));
    MaterialConfigs knownMaterialConfigs = new MaterialConfigs(svnMaterial.config(), dependencyMaterial.config());
    Materials materials = new Materials(svnMaterial, dependencyMaterial);
    when(materialConfigConverter.toMaterials(config.materialConfigs())).thenReturn(materials);
    when(materialExpansionService.expandMaterialConfigsForScheduling(config.materialConfigs())).thenReturn(knownMaterialConfigs);
    when(materialConfigConverter.toMaterials(knownMaterialConfigs)).thenReturn(materials);
    AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, pipelineName, new SystemEnvironment(), null, mockServerHealthService);
    ServerHealthState serverHealthState = buildCauseProducerService.newProduceBuildCause(config, autoBuild, result, 12345);
    assertThat(serverHealthState.isSuccess(), is(true));
}
Also used : AutoBuild(com.thoughtworks.go.server.service.AutoBuild) Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) NoModificationsPresentForDependentMaterialException(com.thoughtworks.go.server.service.NoModificationsPresentForDependentMaterialException) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Test(org.junit.Test)

Example 9 with PipelineConfigDependencyGraph

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

the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependency.

/* TRIANGLE TEST BEGIN */
@Test
public void shouldResolveTriangleDependency() throws Exception {
    GitMaterial git = new GitMaterial("git");
    String[] git_revs = { "g1" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
    ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
    ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
    String p4_1 = u.runAndPass(p4, "g1");
    String p4_2 = u.runAndPass(p4, "g1");
    String p5_1 = u.runAndPass(p5, p4_2);
    String p4_3 = u.runAndPass(p4, "g1");
    String p4_4 = u.runAndPass(p4, "g1");
    PipelineConfigDependencyGraph graph = new PipelineConfigDependencyGraph(p6.config, new PipelineConfigDependencyGraph(p5.config), new PipelineConfigDependencyGraph(p4.config));
    MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
    MaterialRevisions expected = u.mrs(u.mr(p4, true, p4_2), u.mr(p5, true, p5_1));
    assertThat(pipelineService.getRevisionsBasedOnDependencies(graph, given), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 10 with PipelineConfigDependencyGraph

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

the class ChangesetService method modificationsOfPipelines.

public Map<Long, List<ModificationForPipeline>> modificationsOfPipelines(List<Long> pipelineIds, String pipelineName, Username username) {
    Map<Long, List<ModificationForPipeline>> modificationsForPipelineIds = materialRepository.findModificationsForPipelineIds(pipelineIds);
    PipelineConfigDependencyGraph graph = goConfigService.upstreamDependencyGraphOf(pipelineName);
    Set<String> allMaterialFingerprints = graph.allMaterialFingerprints();
    Set<String> reachableMaterialfingerprints = populateReachableFingerprints(graph, username, true, true);
    FingerprintLoader<ModificationForPipeline> loader = new FingerprintLoader<ModificationForPipeline>() {

        public String getFingerprint(ModificationForPipeline modificationForPipeline) {
            return modificationForPipeline.getMaterialFingerprint();
        }
    };
    for (Map.Entry<Long, List<ModificationForPipeline>> pipelineIdAndModifications : modificationsForPipelineIds.entrySet()) {
        List<ModificationForPipeline> visibleModifications = filterFingerprintHolders(pipelineIdAndModifications.getValue(), reachableMaterialfingerprints, allMaterialFingerprints, loader);
        pipelineIdAndModifications.setValue(visibleModifications);
    }
    return modificationsForPipelineIds;
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) ModificationForPipeline(com.thoughtworks.go.server.ui.ModificationForPipeline) ArrayList(java.util.ArrayList) List(java.util.List) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

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