use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateInstancesBuiltFromCurrentPipeline.
@Test
public void shouldPopulateInstancesBuiltFromCurrentPipeline() {
/*
g1 -> P -> P2 --> P4
\ /
+ 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 p3_1 = u.runAndPass(p3, p2_1);
String p4_1 = u.runAndPass(p4, p2_1, p3_1);
downstreamInstancePopulator.apply(valueStreamMap);
assertInstances(nodep2, "p2", 1);
assertInstances(nodep3, "p3", 1);
assertInstances(nodep4, "p4", 1);
}
use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines.
@Test
public void shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines() {
/*
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"), "p");
Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
Node nodep5 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p5", "p5"), "p4");
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");
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);
}
use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class CrossingMinimizationTest method shouldReorderGraphsWithScmMaterialsOccurringInLevelsOtherThanTheFirst.
@Test
public void shouldReorderGraphsWithScmMaterialsOccurringInLevelsOtherThanTheFirst() {
/*
g1 g3 ---> P
\ ^
\ |
g2-->P1+-----+
*/
String g1 = "g1";
String g2 = "g2";
String g3 = "g3";
String p1 = "P1";
String p = "P";
ValueStreamMap graph = new ValueStreamMap(p, null);
graph.addUpstreamMaterialNode(new SCMDependencyNode(g3, g3, "git"), null, p, new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode(p1, p1), null, p);
graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p1, new MaterialRevision(null));
graph.addUpstreamMaterialNode(new SCMDependencyNode(g2, g2, "git"), null, p1, new MaterialRevision(null));
NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
crossingMinimization.apply(levelToNodesMap);
assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.findNode(p))));
assertThat(levelToNodesMap.get(-1), is(Arrays.asList(graph.findNode(g3), graph.findNode(p1))));
assertThat(levelToNodesMap.get(-2), is(Arrays.asList(graph.findNode(g1), graph.findNode(g2))));
assertThat(graph.findNode(g1).getDepth(), is(1));
assertThat(graph.findNode(g2).getDepth(), is(2));
assertThat(graph.findNode(g3).getDepth(), is(1));
assertThat(graph.findNode(p1).getDepth(), is(2));
assertThat(graph.findNode(p).getDepth(), is(1));
}
use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class CrossingMinimizationTest method shouldNotReassignMinimumDepthIfOverallSlopeIncreases.
@Test
public void shouldNotReassignMinimumDepthIfOverallSlopeIncreases() {
/*
g1 g4----> p
\ / /
\ / /
g2--> p1 /
/
g3--> p2
*/
ValueStreamMap graph = new ValueStreamMap("P", null);
Node g4 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g4", "g4", "git"), null, "P", new MaterialRevision(null));
Node p1 = graph.addUpstreamNode(new PipelineDependencyNode("P1", "P1"), null, "P");
Node g1 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), null, "P1", new MaterialRevision(null));
Node g2 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g2", "g2", "git"), null, "P1", new MaterialRevision(null));
Node p2 = graph.addUpstreamNode(new PipelineDependencyNode("P2", "P2"), null, "P");
Node g3 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g3", "g3", "git"), null, "P2", new MaterialRevision(null));
NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
crossingMinimization.apply(levelToNodesMap);
assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.getCurrentPipeline())));
assertThat(levelToNodesMap.get(-1), is(Arrays.asList(g4, p1, p2)));
assertThat(levelToNodesMap.get(-2), is(Arrays.asList(g1, g2, g3)));
assertThat(graph.toString(), g1.getDepth(), is(1));
assertThat(g2.getDepth(), is(2));
assertThat(g3.getDepth(), is(3));
assertThat(g4.getDepth(), is(1));
assertThat(p1.getDepth(), is(2));
assertThat(p2.getDepth(), is(3));
assertThat(graph.getCurrentPipeline().getDepth(), is(1));
}
use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.
the class CrossingMinimizationTest method shouldReorderBasedOnBarycenterForDownstreamGraph.
@Test
public void shouldReorderBasedOnBarycenterForDownstreamGraph() {
/*
g1 -->p ---->p1 -----> p4
\ \ /
\ \ /
\ +->p2 -(---> p5
\ /
\ /
>p3
*/
String g1 = "g1";
String p = "P";
String p1 = "P1";
String p2 = "P2";
String p3 = "P3";
String p4 = "P4";
String p5 = "P5";
ValueStreamMap graph = new ValueStreamMap(p, null);
graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p, new MaterialRevision(null));
graph.addDownstreamNode(new PipelineDependencyNode(p1, p1), p);
graph.addDownstreamNode(new PipelineDependencyNode(p4, p4), p1);
graph.addDownstreamNode(new PipelineDependencyNode(p2, p2), p);
graph.addDownstreamNode(new PipelineDependencyNode(p5, p5), p2);
graph.addDownstreamNode(new PipelineDependencyNode(p3, p3), p);
graph.addDownstreamNode(new PipelineDependencyNode(p4, p4), p3);
NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
crossingMinimization.apply(levelToNodesMap);
assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.findNode(p))));
assertThat(levelToNodesMap.get(-1), is(Arrays.asList(graph.findNode(g1))));
assertThat(levelToNodesMap.get(1), is(Arrays.asList(graph.findNode(p1), graph.findNode(p3), graph.findNode(p2))));
assertThat(levelToNodesMap.get(2), is(Arrays.asList(graph.findNode(p4), graph.findNode(p5))));
assertThat(graph.findNode(g1).getDepth(), is(1));
assertThat(graph.findNode(p).getDepth(), is(1));
assertThat(graph.findNode(p1).getDepth(), is(1));
assertThat(graph.findNode(p2).getDepth(), is(3));
assertThat(graph.findNode(p3).getDepth(), is(2));
assertThat(graph.findNode(p4).getDepth(), is(1));
assertThat(graph.findNode(p5).getDepth(), is(3));
}
Aggregations