use of com.thoughtworks.go.config.materials.git.GitMaterial 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.config.materials.git.GitMaterial 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.config.materials.git.GitMaterial in project gocd by gocd.
the class ValueStreamMapServiceIntegrationTest method shouldPopulateInstanceDetailsForUpstreamAndDownstreamPipelines.
@Test
public void shouldPopulateInstanceDetailsForUpstreamAndDownstreamPipelines() throws Exception {
/*
g1 --> p1 --> p --> p2 --> p4
/ \
g2 +-> p3
*/
GitMaterial g1 = u.wf(new GitMaterial("g1"), "f1");
u.checkinInOrder(g1, "g1-1");
GitMaterial g2 = u.wf(new GitMaterial("g2"), "f2");
u.checkinInOrder(g2, "g2-1");
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(g1));
ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g2), u.m(p1));
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));
String p1_1 = u.runAndPass(p1, "g1-1");
String p_1 = u.runAndPass(p, "g2-1", p1_1);
String p2_1 = u.runAndPass(p2, p_1);
String p2_2 = u.runAndPass(p2, p_1);
String p3_1 = u.runAndPass(p3, p_1);
String p4_1 = u.runAndPass(p4, p2_1);
configHelper.addStageToPipeline("p2", "unrun_stage");
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p", 1, username, result);
List<List<Node>> allLevels = graph.getNodesAtEachLevel();
int CURRENT_PIPELINE_LEVEL = 2;
Node currentNode = allLevels.get(CURRENT_PIPELINE_LEVEL).get(0);
assertEquals(currentNode.revisions().get(0), new PipelineRevision(currentNode.getName(), 1, "1"));
Node p1_node = allLevels.get(CURRENT_PIPELINE_LEVEL - 1).get(1);
assertInstances(p1_node, "p1", 1);
assertStageDetails(p1_node, 1, "s", 1, StageState.Passed);
assertInstances(allLevels.get(CURRENT_PIPELINE_LEVEL + 1).get(0), "p3", 1);
Node p2_node = allLevels.get(CURRENT_PIPELINE_LEVEL + 1).get(1);
assertInstances(p2_node, "p2", 1, 2);
assertStageDetails(p2_node, 1, "s", 1, StageState.Passed);
assertStageDetails(p2_node, 2, "s", 1, StageState.Passed);
assertStageDetails(p2_node, 1, "unrun_stage", 0, StageState.Unknown);
assertStageDetails(p2_node, 2, "unrun_stage", 0, StageState.Unknown);
assertInstances(allLevels.get(CURRENT_PIPELINE_LEVEL + 2).get(0), "p4", 1);
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class ValueStreamMapServiceIntegrationTest method shouldDrawPDGForCrissCrossDependencies.
// Scenario: #7192
@Test
public void shouldDrawPDGForCrissCrossDependencies() {
/*
+--------------------------------------------+
| +--------------------------------+ |
| + v v
G1 -----> P2----->P3------------------------->C5
| +---> + +--------------+ ^ ^ ^
| | | | | | |
| | | +--------------+ | | | |
| | ---)--------+ | V | | |
| | | | |---->P4--------+ | |
| | | | | | |
|--)----+ | | | +--------+ |
| | | | | +---)--+ |
| | | | | | | |
| | | | | +---+ | |
+--)----)---)---------)---------)------)----+ |
| | | | | | | |
| | | +-------->C4--+ | | |
| | | ^ | | | |
| | | | | | | |
| | | +-------------+ | | | |
+---+ | | | | | | |
| | | | | | | |
+ v +-+ | v +--->v |
G2 ----->C2------>c3------------------------>P5 |
| | ^ ^ |
| +---------------------------------+ | |
| | |
+-------+------------------------------------+ |
| |
|-----------------------------------------------+
*/
int i = 0;
GitMaterial g1 = u.wf(new GitMaterial("git-1"), "folder3");
u.checkinInOrder(g1, u.d(i++), "g1-1");
GitMaterial g2 = u.wf(new GitMaterial("git-2"), "folder4");
u.checkinInOrder(g2, u.d(i++), "g2-1");
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(g1), u.m(g2));
ScheduleTestUtil.AddedPipeline c2 = u.saveConfigWith("C2", u.m(g1), u.m(g2));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p2));
ScheduleTestUtil.AddedPipeline c3 = u.saveConfigWith("C3", u.m(c2));
ScheduleTestUtil.AddedPipeline c4 = u.saveConfigWith("C4", u.m(c3), u.m(p2));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p3), u.m(c2));
ScheduleTestUtil.AddedPipeline c5 = u.saveConfigWith("C5", u.m(p3), u.m(p2), u.m(g1), u.m(p4), u.m(c4), u.m(g2));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("P5", u.m(c3), u.m(c2), u.m(g1), u.m(p4), u.m(c4), u.m(g2));
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g1-1", "g2-1");
String c2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c2, u.d(i++), "g1-1", "g2-1");
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p2_1);
String c3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c3, u.d(i++), c2_1);
String c4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c4, u.d(i++), c3_1, p2_1);
String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), p3_1, c2_1);
String c5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c5, u.d(i++), p3_1, p2_1, "g1-1", p4_1, c4_1, "g2-1");
String p5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), c3_1, c2_1, "g1-1", p4_1, c4_1, "g2-1");
// PDG for C5
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(pipelineName(c5), 1, username, result);
List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(4), 0, pipelineName(c5));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 4, pipelineName(p4), pipelineName(c4));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 5, pipelineName(p3), pipelineName(c3));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 2, pipelineName(p2), pipelineName(c2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
VSMTestHelper.assertDepth(graph, pipelineName(c5), 1);
VSMTestHelper.assertDepth(graph, pipelineName(p4), 4);
VSMTestHelper.assertDepth(graph, pipelineName(c4), 5);
VSMTestHelper.assertDepth(graph, pipelineName(p3), 2);
VSMTestHelper.assertDepth(graph, pipelineName(c3), 6);
VSMTestHelper.assertDepth(graph, pipelineName(p2), 2);
VSMTestHelper.assertDepth(graph, pipelineName(c2), 4);
VSMTestHelper.assertDepth(graph, g1.getFingerprint(), 1);
VSMTestHelper.assertDepth(graph, g2.getFingerprint(), 2);
// PDG for C4
graph = valueStreamMapService.getValueStreamMap(pipelineName(c4), 1, username, result);
nodesAtEachLevel = valueStreamMapService.getValueStreamMap(pipelineName(c4), 1, username, result).getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(4), 0, pipelineName(c5), pipelineName(p5));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 0, pipelineName(c4));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 0, pipelineName(c3), pipelineName(p2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 2, pipelineName(c2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
VSMTestHelper.assertDepth(graph, pipelineName(p5), 1);
VSMTestHelper.assertDepth(graph, pipelineName(c5), 2);
VSMTestHelper.assertDepth(graph, pipelineName(c4), 1);
VSMTestHelper.assertDepth(graph, pipelineName(c3), 1);
VSMTestHelper.assertDepth(graph, pipelineName(p2), 2);
VSMTestHelper.assertDepth(graph, pipelineName(c2), 1);
VSMTestHelper.assertDepth(graph, g1.getFingerprint(), 1);
VSMTestHelper.assertDepth(graph, g2.getFingerprint(), 2);
// PDG for p3
nodesAtEachLevel = valueStreamMapService.getValueStreamMap(pipelineName(p3), 1, username, result).getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(4), 0, pipelineName(c5), pipelineName(p5));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 1, pipelineName(p4));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 0, pipelineName(p3));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, pipelineName(p2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class ValueStreamMapServiceIntegrationTest method shouldIncludeNewerDownstreamDependenciesIfConfigWasChangedAfterPipelineRun.
//Scenario: #7181
@Test
public void shouldIncludeNewerDownstreamDependenciesIfConfigWasChangedAfterPipelineRun() {
/*
* -----------Before --------------
* g1-----+
* |
* +---------P1------> P2
* |
* g2-----+
* *
* -----After config change ------
*
* g1-----+
* |
* g3-----+---------P1----->P3-------> P2
* |
* g2-----+
* */
int i = 0;
GitMaterial g1 = u.wf(new GitMaterial("git-1"), "folder3");
u.checkinInOrder(g1, u.d(i++), "g1-1");
GitMaterial g2 = u.wf(new GitMaterial("git-2"), "folder4");
u.checkinInOrder(g2, u.d(i++), "g2-1");
GitMaterial g3 = u.wf(new GitMaterial("git-3"), "folder5");
u.checkinInOrder(g3, u.d(i++), "g3-1");
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(g1), u.m(g2));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(p1));
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1-1", "g2-1");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
// PDG for P1/1
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(pipelineName(p1), 1, username, result);
List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 0, pipelineName(p2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, pipelineName(p1));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
// PDG for P2/1
nodesAtEachLevel = valueStreamMapService.getValueStreamMap(pipelineName(p2), 1, username, result).getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 0, pipelineName(p2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, pipelineName(p1));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
// add g3 to p1, and add P3 dependent on p1
u.addMaterialToPipeline(p1, u.m(g3));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p1));
p2 = u.addMaterialToPipeline(p2, u.m(p3));
p2 = u.removeMaterialFromPipeline(p2, u.m(p1));
// PDG for P1/1 after config change, newly added material does not show up
nodesAtEachLevel = valueStreamMapService.getValueStreamMap(pipelineName(p1), 1, username, result).getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 0, pipelineName(p2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 0, pipelineName(p3));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, pipelineName(p1));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
// PDG for P2/1, remains same after config change
nodesAtEachLevel = valueStreamMapService.getValueStreamMap(pipelineName(p2), 1, username, result).getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 0, pipelineName(p2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, pipelineName(p1));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1-1", "g2-1", "g3-1");
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p1_2);
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p3_1);
// PDG for P2/2, with updated dependencies
nodesAtEachLevel = valueStreamMapService.getValueStreamMap(pipelineName(p2), 2, username, result).getNodesAtEachLevel();
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 0, pipelineName(p2));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 0, pipelineName(p3));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, pipelineName(p1));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint(), g2.getFingerprint());
}
Aggregations