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;
}
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));
}
}
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));
}
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));
}
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;
}
Aggregations