use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel 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.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapPerformanceTest method doRun.
private void doRun(int numberOfDownstreamPipelines, CruiseConfig cruiseConfig, String threadName) throws InterruptedException {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
for (PipelineConfig pipelineConfig : cruiseConfig.allPipelines()) {
ValueStreamMapPresentationModel map = valueStreamMapService.getValueStreamMap(pipelineConfig.name().toString(), 1, Username.ANONYMOUS, result);
assertThat(getAllNodes(map).size(), is(numberOfDownstreamPipelines + 2));
}
}
use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceIntegrationTest method shouldShowAllRevisionsWhenFanInIsOff.
@Test
public void shouldShowAllRevisionsWhenFanInIsOff() {
GitMaterial g1 = u.wf(new GitMaterial("g1"), "f1");
u.checkinInOrder(g1, "g1-1");
u.checkinInOrder(g1, "g1-2");
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWithGroup("g1", "p1", u.m(g1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWithGroup("g1", "p2", u.m(g1));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWithGroup("g2", "p3", u.m(p1), u.m(p2));
String p1_1 = u.runAndPass(p1, "g1-1");
String p2_1 = u.runAndPass(p2, "g1-2");
String p3_1 = u.runAndPass(p3, p1_1, p2_1);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, username, result);
Node nodeForGit = graph.getNodesAtEachLevel().get(0).get(0);
assertThat(nodeForGit.revisions().size(), is(2));
Collection<String> revisionStrings = collect(nodeForGit.revisions(), new Transformer() {
@Override
public String transform(Object o) {
Revision revision = (Revision) o;
return revision.getRevisionString();
}
});
assertThat(revisionStrings, IsCollectionContaining.hasItems("g1-1", "g1-2"));
}
use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldGetPipelineDependencyGraphForAPipelineWithDiamondDependency_VSMForMaterial.
@Test
public void shouldGetPipelineDependencyGraphForAPipelineWithDiamondDependency_VSMForMaterial() {
/*
* |----> P1----->
* g |_> p3
* | |
* ---- > P2----->
*
* */
GitMaterial gitMaterial = new GitMaterial("git");
MaterialConfig gitConfig = gitMaterial.config();
GitMaterialInstance gitMaterialInstance = new GitMaterialInstance("git", "master", "submodule", "flyweight");
BuildCause p3buildCause = createBuildCause(asList("p1", "p2"), new ArrayList<>());
BuildCause p2buildCause = createBuildCause(new ArrayList<>(), asList(gitMaterial));
Modification gitModification = p2buildCause.getMaterialRevisions().getRevisions().get(0).getModifications().get(0);
String gitRevision = gitModification.getRevision();
BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(gitMaterial));
when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
PipelineConfig p3Config = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
PipelineConfigs pipelineConfigs = new BasicPipelineConfigs("g1", new Authorization(), p1Config, p2Config, p3Config);
CruiseConfig cruiseConfig = new BasicCruiseConfig(pipelineConfigs);
when(goConfigService.groups()).thenReturn(new PipelineGroups(pipelineConfigs));
when(materialRepository.findMaterialInstance(gitConfig)).thenReturn(gitMaterialInstance);
when(materialRepository.findModificationWithRevision(gitMaterial, gitRevision)).thenReturn(gitModification);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(gitMaterial.getFingerprint(), gitRevision, user, result);
List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
assertThat(graph.getCurrentPipeline(), is(nullValue()));
assertThat(graph.getCurrentMaterial().getId(), is(gitMaterial.getFingerprint()));
assertThat(nodesAtEachLevel.size(), is(3));
List<Node> firstLevel = nodesAtEachLevel.get(0);
assertThat(firstLevel.size(), is(1));
assertNode(0, firstLevel.get(0), gitMaterial.getDisplayName(), gitMaterial.getFingerprint(), 0, "p1", "p2");
assertDepth(graph, firstLevel.get(0).getId(), 1);
List<Node> secondLevel = nodesAtEachLevel.get(1);
assertThat(secondLevel.size(), is(2));
assertNode(1, secondLevel.get(0), "p1", "p1", 0, "p3");
assertDepth(graph, secondLevel.get(0).getId(), 1);
assertNode(1, secondLevel.get(1), "p2", "p2", 0, "p3");
assertDepth(graph, secondLevel.get(1).getId(), 2);
List<Node> thirdLevel = nodesAtEachLevel.get(2);
assertThat(thirdLevel.size(), is(1));
assertNode(2, thirdLevel.get(0), "p3", "p3", 0);
assertDepth(graph, thirdLevel.get(0).getId(), 1);
}
use of com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateAllSCMMaterialRevisionsThatCausedPipelineRun_WhenFaninIsNotObeyed.
@Test
public void shouldPopulateAllSCMMaterialRevisionsThatCausedPipelineRun_WhenFaninIsNotObeyed() {
/*
* git---> p1 --->p2
* | ^
* +-------------+
* **/
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
Modification modification1 = checkinWithComment("rev1", "comment1", new Date());
Modification modification2 = checkinWithComment("rev2", "comment2", new Date());
Modification modification3 = checkinWithComment("rev3", "comment3", new Date());
BuildCause p1buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), new Modifications(modification1, modification2));
BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1)), asList(git), new Modifications(modification3));
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config));
when(pipelineService.findPipelineByCounterOrLabel("p2", "1")).thenReturn(new Pipeline("p2", "LABEL-P2", p2buildCause));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p2", 1, user, result);
VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"));
VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-P2"));
VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, modification1, modification2), new MaterialRevision(git, false, modification3));
verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
Aggregations