use of com.thoughtworks.go.domain.valuestreammap.PipelineRevision in project gocd by gocd.
the class DownstreamInstancePopulator method populateRevisionsForAllChildrenOf.
private void populateRevisionsForAllChildrenOf(Node node, Set<Revision> visitedRevisions) {
for (Revision revision : node.revisions()) {
if (visitedRevisions.contains(revision)) {
continue;
}
visitedRevisions.add(revision);
for (Node child : node.getChildren()) {
List<PipelineIdentifier> pipelineIdentifiers = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial(child.getName(), ((PipelineRevision) revision).getPipelineIdentifier());
addRevisionsToNode(child, pipelineIdentifiers);
populateRevisionsForAllChildrenOf(child, visitedRevisions);
}
}
}
use of com.thoughtworks.go.domain.valuestreammap.PipelineRevision in project gocd by gocd.
the class LevelAssignmentTest method shouldAssignLevelsForUpstreamNodesOfCurrentPipeline.
@Test
public void shouldAssignLevelsForUpstreamNodesOfCurrentPipeline() throws Exception {
/*
---> p1 ---
/ \
g -----------p3
\ /
---> p2 ---
*/
CaseInsensitiveString current = new CaseInsensitiveString("p3");
CaseInsensitiveString p1name = new CaseInsensitiveString("p1");
CaseInsensitiveString p2name = new CaseInsensitiveString("p2");
Node p1 = new PipelineDependencyNode(p1name, p1name.toString());
Node p2 = new PipelineDependencyNode(p2name, p2name.toString());
Node gitNode = new SCMDependencyNode("git", "g", "git");
ValueStreamMap valueStreamMap = new ValueStreamMap(current, new PipelineRevision(current.toString(), 1, "1"));
valueStreamMap.addUpstreamNode(p1, new PipelineRevision(p1name.toString(), 1, "1"), current);
valueStreamMap.addUpstreamNode(p2, new PipelineRevision(p2name.toString(), 1, "1"), current);
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("trunk"), p1name, new MaterialRevision(null));
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), new CaseInsensitiveString("p3"), new MaterialRevision(null));
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), p2name, new MaterialRevision(null));
NodeLevelMap levelToNodeMap = new LevelAssignment().apply(valueStreamMap);
assertThat(valueStreamMap.getCurrentPipeline().getLevel(), is(0));
assertThat(p1.getLevel(), is(-1));
assertThat(p2.getLevel(), is(-1));
assertThat(gitNode.getLevel(), is(-2));
assertThat(levelToNodeMap.get(0), contains(valueStreamMap.getCurrentPipeline()));
assertThat(levelToNodeMap.get(-1), containsInAnyOrder(p1, p2));
assertThat(levelToNodeMap.get(-2), contains(gitNode));
}
use of com.thoughtworks.go.domain.valuestreammap.PipelineRevision in project gocd by gocd.
the class RunStagesPopulator method apply.
public void apply(ValueStreamMap graph) {
for (Node node : graph.allNodes()) {
for (Revision revision : node.revisions()) {
if (revision instanceof PipelineRevision) {
PipelineRevision pipelineRevision = (PipelineRevision) revision;
Stages latestStages = latestRunStagesForRevsion(pipelineRevision);
pipelineRevision.addStages(latestStages);
}
}
}
}
use of com.thoughtworks.go.domain.valuestreammap.PipelineRevision in project gocd by gocd.
the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateInstancesBuiltFromCurrentPipeline.
@Test
public void shouldPopulateInstancesBuiltFromCurrentPipeline() {
/*
g1 -> P -> P2 --> P4
\ /
+ P3 +
*/
CaseInsensitiveString pName = new CaseInsensitiveString("p");
CaseInsensitiveString p2name = new CaseInsensitiveString("p2");
CaseInsensitiveString p3name = new CaseInsensitiveString("p3");
CaseInsensitiveString p4name = new CaseInsensitiveString("p4");
ValueStreamMap valueStreamMap = new ValueStreamMap(pName, new PipelineRevision(pName.toString(), 1, "13.1.1"));
Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode(p2name, p2name.toString()), pName);
Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode(p3name, p3name.toString()), p2name);
Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode(p4name, p4name.toString()), p3name);
valueStreamMap.addDownstreamNode(new PipelineDependencyNode(p4name, p4name.toString()), p2name);
valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), pName, new MaterialRevision(null));
GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
u.checkinInOrder(g1, "g_1");
ScheduleTestUtil.AddedPipeline p = u.saveConfigWith(pName.toString(), u.m(g1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith(p2name.toString(), u.m(p));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith(p3name.toString(), u.m(p2));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith(p4name.toString(), u.m(p2), u.m(p3));
String p_1 = u.runAndPass(p, "g_1");
String p2_1 = u.runAndPass(p2, p_1);
String p3_1 = u.runAndPass(p3, p2_1);
String p4_1 = u.runAndPass(p4, p2_1, p3_1);
downstreamInstancePopulator.apply(valueStreamMap);
assertInstances(nodep2, p2name.toString(), 1);
assertInstances(nodep3, p3name.toString(), 1);
assertInstances(nodep4, p4name.toString(), 1);
}
use of com.thoughtworks.go.domain.valuestreammap.PipelineRevision in project gocd by gocd.
the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines.
@Test
public void shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines() {
/*
g1 -> P -> P2 -> P4 --> P5
\ /
P3
*/
ValueStreamMap valueStreamMap = new ValueStreamMap(new CaseInsensitiveString("p"), new PipelineRevision("p", 1, "13.1.1"));
Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode(new CaseInsensitiveString("p2"), "p2"), new CaseInsensitiveString("p"));
Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode(new CaseInsensitiveString("p3"), "p3"), new CaseInsensitiveString("p"));
Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode(new CaseInsensitiveString("p4"), "p4"), new CaseInsensitiveString("p2"));
valueStreamMap.addDownstreamNode(new PipelineDependencyNode(new CaseInsensitiveString("p4"), "p4"), new CaseInsensitiveString("p3"));
Node nodep5 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode(new CaseInsensitiveString("p5"), "p5"), new CaseInsensitiveString("p4"));
valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), new CaseInsensitiveString("p"), new MaterialRevision(null));
GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
u.checkinInOrder(g1, "g_1");
u.checkinInOrder(g1, "g_2");
ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
String p_1 = u.runAndPass(p, "g_1");
String p_2 = u.runAndPass(p, "g_2");
String p2_1 = u.runAndPass(p2, p_1);
String p2_2 = u.runAndPass(p2, p_1);
String p2_3 = u.runAndPass(p2, p_2);
String p3_1 = u.runAndPass(p3, p_1);
String p3_2 = u.runAndPass(p3, p_1);
String p4_1 = u.runAndPass(p4, p2_1, p3_1);
String p4_2 = u.runAndPass(p4, p2_2, p3_1);
String p4_3 = u.runAndPass(p4, p2_3, p3_2);
String p5_1 = u.runAndPass(p5, p4_1);
String p5_2 = u.runAndPass(p5, p4_2);
String p5_3 = u.runAndPass(p5, p4_3);
downstreamInstancePopulator.apply(valueStreamMap);
assertInstances(nodep2, "p2", 1, 2);
assertInstances(nodep3, "p3", 1, 2);
assertInstances(nodep4, "p4", 1, 2, 3);
assertInstances(nodep5, "p5", 1, 2, 3);
}
Aggregations