Search in sources :

Example 16 with SCMDependencyNode

use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.

the class RunStagesPopulatorTest method shouldPopulateOnlyLatestRunOfEachStageForEachPipelineNode.

@Test
public void shouldPopulateOnlyLatestRunOfEachStageForEachPipelineNode() throws Exception {
    /*
            git --> p1 --> p2 --> p3
         */
    ValueStreamMap graph = new ValueStreamMap("p2", new PipelineRevision("p2", 1, ""));
    graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), new PipelineRevision("p1", 1, "1"), "p2");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p1", new MaterialRevision(null));
    Node p3_node = graph.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p2");
    p3_node.addRevision(new PipelineRevision("p3", 1, "1"));
    Stages stagesForP1_1 = stages("s1_p1");
    Stages stagesForP2_1 = stages("s1_p2");
    Stages stagesForP3_1 = stages("s1_p3");
    stagesForP1_1.first().setLatestRun(false);
    Stage latestStage = StageMother.createPassedStage("p1", 1, "s1_p1", 2, "sample", new Date());
    stagesForP1_1.add(latestStage);
    when(stageDao.findAllStagesFor("p1", 1)).thenReturn(stagesForP1_1);
    when(stageDao.findAllStagesFor("p2", 1)).thenReturn(stagesForP2_1);
    when(stageDao.findAllStagesFor("p3", 1)).thenReturn(stagesForP3_1);
    runStagesPopulator.apply(graph);
    VSMTestHelper.assertStageDetailsOf(graph, "p1", "1", new Stages(latestStage));
    VSMTestHelper.assertStageDetailsOf(graph, "p2", "1", stagesForP2_1);
    VSMTestHelper.assertStageDetailsOf(graph, "p3", "1", stagesForP3_1);
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) Stages(com.thoughtworks.go.domain.Stages) Stage(com.thoughtworks.go.domain.Stage) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 17 with SCMDependencyNode

use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.

the class CrossingMinimizationTest method shouldAssignNodesBasedOnMinimumDepthForUpstreamGraph.

@Test
public void shouldAssignNodesBasedOnMinimumDepthForUpstreamGraph() {
    /*
            g1 --> P1 --> P
               \        / ^
                \     /   |
            g2   +->P2    |
               \          |
                \         |
            g3 --> P3-----+
         */
    String p = "P";
    String p1 = "P1";
    String p2 = "P2";
    String p3 = "P3";
    String g1 = "g1";
    String g2 = "g2";
    String g3 = "g3";
    ValueStreamMap graph = new ValueStreamMap(p, null);
    graph.addUpstreamNode(new PipelineDependencyNode(p1, p1), null, p);
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p1, new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode(p2, p2), null, p);
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p2, new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode(p3, p3), null, p);
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g2, g2, "git"), null, p3, new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g3, g3, "git"), null, p3, 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(p1), graph.findNode(p2), graph.findNode(p3))));
    assertThat(levelToNodesMap.get(-2), is(Arrays.asList(graph.findNode(g1), graph.findNode(g2), graph.findNode(g3))));
    assertThat(graph.findNode(g1).getDepth(), is(1));
    assertThat(graph.findNode(g2).getDepth(), is(2));
    assertThat(graph.findNode(g3).getDepth(), is(3));
    assertThat(graph.findNode(p1).getDepth(), is(1));
    assertThat(graph.findNode(p2).getDepth(), is(2));
    assertThat(graph.findNode(p3).getDepth(), is(3));
    assertThat(graph.findNode(p).getDepth(), is(1));
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Example 18 with SCMDependencyNode

use of com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode in project gocd by gocd.

the class CrossingMinimizationTest method shouldReorderNodesBasedOnBaryCenterValueForUpstreamGraph.

@Test
public void shouldReorderNodesBasedOnBaryCenterValueForUpstreamGraph() {
    /*
            g1 --> P1--->P3
               \/      /
               /\    /
            g2    P2
         */
    String p3 = "P3";
    String p1 = "P1";
    String p2 = "P2";
    String g1 = "g1";
    String g2 = "g2";
    ValueStreamMap graph = new ValueStreamMap(p3, null);
    graph.addUpstreamNode(new PipelineDependencyNode(p1, p1), null, p3);
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p1, new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g2, g2, "git"), null, p1, new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode(p2, p2), null, p3);
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p2, new MaterialRevision(null));
    NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
    assertThat(levelToNodesMap.get(-1), is(Arrays.asList(graph.findNode(p1), graph.findNode(p2))));
    crossingMinimization.apply(levelToNodesMap);
    assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.findNode(p3))));
    assertThat(levelToNodesMap.get(-1), is(Arrays.asList(graph.findNode(p2), 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(p1).getDepth(), is(2));
    assertThat(graph.findNode(p2).getDepth(), is(1));
    assertThat(graph.findNode(p3).getDepth(), is(1));
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)18 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 Test (org.junit.Test)18 NodeLevelMap (com.thoughtworks.go.domain.valuestreammap.NodeLevelMap)12 Node (com.thoughtworks.go.domain.valuestreammap.Node)8 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)7 PipelineRevision (com.thoughtworks.go.domain.valuestreammap.PipelineRevision)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)3 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)3 Stages (com.thoughtworks.go.domain.Stages)2 Stage (com.thoughtworks.go.domain.Stage)1 Date (java.util.Date)1