use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class CrossingMinimizationTest method shouldAssignNodesBasedOnMinimumDepthForDownstreamGraph.
@Test
public void shouldAssignNodesBasedOnMinimumDepthForDownstreamGraph() {
/*
g1 --> P ---> P1 P3
\ /
+-> P2
*/
ValueStreamMap graph = new ValueStreamMap("P", null);
Node g1 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), null, "P", new MaterialRevision(null));
Node p1 = graph.addDownstreamNode(new PipelineDependencyNode("p1", "p1"), "P");
Node p2 = graph.addDownstreamNode(new PipelineDependencyNode("P2", "P2"), "P");
Node p3 = graph.addDownstreamNode(new PipelineDependencyNode("P3", "P3"), "P2");
NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
crossingMinimization.apply(levelToNodesMap);
assertThat(levelToNodesMap.get(-1), is(Arrays.asList(g1)));
assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.getCurrentPipeline())));
assertThat(levelToNodesMap.get(1), is(Arrays.asList(p1, p2)));
assertThat(levelToNodesMap.get(2), is(Arrays.asList(p3)));
assertThat(p1.getDepth(), is(1));
assertThat(p2.getDepth(), is(2));
assertThat(p3.getDepth(), is(2));
}
use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class DummyNodeCreationTest method shouldHandleDeepTriangle.
@Test
public void shouldHandleDeepTriangle() {
/*
+---> d1 ---> d2 ---> d3
g ^
+---- x ----- x ------+
*/
String currentPipeline = "d3";
ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
graph.addUpstreamNode(new PipelineDependencyNode("d2", "d2"), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode("d1", "d1"), null, "d2");
graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, "d1", new MaterialRevision(null));
graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, currentPipeline, new MaterialRevision(null));
NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
dummyNodeCreation.apply(graph, nodeLevelMap);
VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 4);
VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(0), 0, "d3");
VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-1), 1, "d2");
VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-2), 1, "d1");
VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-3), 0, "g");
}
use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class DummyNodeCreationTest method shouldCreateDummyNodesAtCorrectLevelsWhenNodesAreAddedUsingDFS.
@Test
public void shouldCreateDummyNodesAtCorrectLevelsWhenNodesAreAddedUsingDFS() {
/* +-------X------+
| v
+---> p1 --> p4 --> p5 ---> P6
| ^ ^
git --> p2 ----+ |
| |
+---> X -----p3------+
*/
String currentPipeline = "p6";
ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
graph.addUpstreamNode(new PipelineDependencyNode("p4", "p4"), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), null, "p4");
graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p1", new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode("p2", "p2"), null, "p4");
graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p2", new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode("p5", "p5"), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode("p3", "p3"), null, "p5");
graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p3", new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode("p4", "p4"), null, "p5");
graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), null, "p4");
graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p1", new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode("p2", "p2"), null, "p4");
graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p2", new MaterialRevision(null));
NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
dummyNodeCreation.apply(graph, nodeLevelMap);
VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 5);
assertThat(nodeLevelMap.get(0).size(), is(1));
assertThat(nodeLevelMap.get(-1).size(), is(2));
assertThat(nodeLevelMap.get(-2).size(), is(2));
assertThat(nodeLevelMap.get(-3).size(), is(3));
assertThat(nodeLevelMap.get(-4).size(), is(1));
}
use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class LevelAssignmentTest method shouldAssignLevelsForUpstreamNodesOfCurrentPipeline.
@Test
public void shouldAssignLevelsForUpstreamNodesOfCurrentPipeline() throws Exception {
/*
---> p1 ---
/ \
g -----------p3
\ /
---> p2 ---
*/
String current = "p3";
Node p1 = new PipelineDependencyNode("p1", "p1");
Node p2 = new PipelineDependencyNode("p2", "p2");
Node gitNode = new SCMDependencyNode("git", "g", "git");
ValueStreamMap valueStreamMap = new ValueStreamMap(current, new PipelineRevision(current, 1, "1"));
valueStreamMap.addUpstreamNode(p1, new PipelineRevision("p1", 1, "1"), current);
valueStreamMap.addUpstreamNode(p2, new PipelineRevision("p2", 1, "1"), current);
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("trunk"), "p1", new MaterialRevision(null));
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p3", new MaterialRevision(null));
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p2", 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.SCMDependencyNode in project gocd by gocd.
the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateMultipleInstancesBuiltFromUpstreamRevisions.
@Test
public void shouldPopulateMultipleInstancesBuiltFromUpstreamRevisions() {
/*
g1 -> P -> P2 --> P4 --> P5
\ /
+ P3 +
*/
ValueStreamMap valueStreamMap = new ValueStreamMap("p", new PipelineRevision("p", 1, "13.1.1"));
Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p2");
Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p", new MaterialRevision(null));
GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
u.checkinInOrder(g1, "g_1");
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(p2));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
String p_1 = u.runAndPass(p, "g_1");
String p2_1 = u.runAndPass(p2, p_1);
String p2_2 = u.runAndPass(p2, p_1);
String p3_1 = u.runAndPass(p3, p2_2);
String p4_1 = u.runAndPass(p4, p2_1, p3_1);
String p4_2 = u.runAndPass(p4, p2_2, p3_1);
downstreamInstancePopulator.apply(valueStreamMap);
assertInstances(nodep2, "p2", 1, 2);
assertInstances(nodep3, "p3", 1);
assertInstances(nodep4, "p4", 1, 2);
}
Aggregations