Search in sources :

Example 11 with SCMDependencyNode

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

the class CrossingMinimizationTest method shouldInitializeNodeDepthsInDfSOrder.

@Test
public void shouldInitializeNodeDepthsInDfSOrder() {
    /*
        g2   p1 --> P --> p3   p6
          \ /    /          \/
          /\   /           / \
        g1  p2           p4   p5

         */
    String g1 = "g1";
    String g2 = "g2";
    String p1 = "p1";
    String p2 = "p2";
    String p = "p";
    String p3 = "p3";
    String p4 = "p4";
    String p5 = "p5";
    String p6 = "p6";
    ValueStreamMap graph = new ValueStreamMap(p, null);
    graph.addUpstreamNode(new PipelineDependencyNode(p1, p1), null, p);
    graph.addUpstreamNode(new PipelineDependencyNode(p2, p2), null, p);
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g2, g2, "git"), null, p2, new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p1, new MaterialRevision(null));
    graph.addDownstreamNode(new PipelineDependencyNode(p3, p3), p);
    graph.addDownstreamNode(new PipelineDependencyNode(p4, p4), p);
    graph.addDownstreamNode(new PipelineDependencyNode(p6, p6), p4);
    graph.addDownstreamNode(new PipelineDependencyNode(p5, p5), p3);
    crossingMinimization.initializeNodeDepths(nodeLevelMap(graph));
    assertThat(graph.findNode(g1).getDepth(), is(1));
    assertThat(graph.findNode(g2).getDepth(), is(2));
    assertThat(graph.findNode(p1).getDepth(), is(1));
    assertThat(graph.findNode(p2).getDepth(), is(2));
    assertThat(graph.findNode(p).getDepth(), is(1));
    assertThat(graph.findNode(p3).getDepth(), is(1));
    assertThat(graph.findNode(p4).getDepth(), is(2));
    assertThat(graph.findNode(p5).getDepth(), is(1));
    assertThat(graph.findNode(p6).getDepth(), is(2));
}
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) Test(org.junit.Test)

Example 12 with SCMDependencyNode

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

the class DummyNodeCreationTest method shouldMoveNodeAndIntroduceDummyNodesToCorrectLayer_crossMaterialPipelineDependency.

@Test
public void shouldMoveNodeAndIntroduceDummyNodesToCorrectLayer_crossMaterialPipelineDependency() {
    /*
           g1 --- X -----+
            |           V
            +---> d1 --> d2 -->
                               d5
           g2 --> d3 --> d4 -->
            |           ^
            +---- X -----+
         */
    String currentPipeline = "d5";
    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("g1", "g1", "git"), null, "d1", new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), null, "d2", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("d4", "d4"), null, currentPipeline);
    graph.addUpstreamNode(new PipelineDependencyNode("d3", "d3"), null, "d4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g2", "g2", "git"), null, "d3", new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g2", "g2", "git"), null, "d4", new MaterialRevision(null));
    NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
    dummyNodeCreation.apply(graph, nodeLevelMap);
    VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 4);
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(0), 0, "d5");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-1), 0, "d2", "d4");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-2), 2, "d1", "d3");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-3), 0, "g1", "g2");
}
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 13 with SCMDependencyNode

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

the class DummyNodeCreationTest method shouldMoveNodeAndIntroduceDummyNodesCorrectly_shouldHandleDoubleTriangle.

@Test
public void shouldMoveNodeAndIntroduceDummyNodesCorrectly_shouldHandleDoubleTriangle() {
    /*
        * +----- X ------+
        * |              v
        * g---->d1----->d2 ---> d3
        *        |              ^
        *        ------ 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, 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, "d2", new MaterialRevision(null));
    NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
    dummyNodeCreation.apply(graph, nodeLevelMap);
    VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 4);
    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(1));
    VSMTestHelper.assertThatNodeHasChildren(graph, "d1", 1, "d2");
    VSMTestHelper.assertThatNodeHasChildren(graph, "g", 1, "d1");
    VSMTestHelper.assertThatNodeHasParents(graph, "d3", 1, "d2");
    VSMTestHelper.assertThatNodeHasParents(graph, "d2", 1, "d1");
    VSMTestHelper.assertThatNodeHasParents(graph, "d1", 0, "g");
}
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 14 with SCMDependencyNode

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

the class LevelAssignmentTest method shouldAssignLevelsForDownstreamNodesOfCurrentPipeline.

@Test
public void shouldAssignLevelsForDownstreamNodesOfCurrentPipeline() throws Exception {
    /*
                ---> p1 ----
               /            \
    	git --> p ----------> p3
              \            /
               ---> p2 ----
    	*/
    String current = "p";
    Node p1 = new PipelineDependencyNode("p1", "p1");
    Node p2 = new PipelineDependencyNode("p2", "p2");
    Node p3 = new PipelineDependencyNode("p3", "p3");
    Node gitNode = new SCMDependencyNode("git", "g", "git");
    ValueStreamMap valueStreamMap = new ValueStreamMap(current, new PipelineRevision(current, 1, "1"));
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("trunk"), "p", new MaterialRevision(null));
    valueStreamMap.addDownstreamNode(p1, current);
    valueStreamMap.addDownstreamNode(p2, current);
    valueStreamMap.addDownstreamNode(p3, p1.getId());
    valueStreamMap.addDownstreamNode(p3, p2.getId());
    NodeLevelMap levelToNodeMap = new LevelAssignment().apply(valueStreamMap);
    assertThat(valueStreamMap.getCurrentPipeline().getLevel(), is(0));
    assertThat(gitNode.getLevel(), is(-1));
    assertThat(p1.getLevel(), is(1));
    assertThat(p2.getLevel(), is(1));
    assertThat(p3.getLevel(), is(2));
    assertThat(levelToNodeMap.get(0), contains(valueStreamMap.getCurrentPipeline()));
    assertThat(levelToNodeMap.get(-1), contains(gitNode));
    assertThat(levelToNodeMap.get(1), containsInAnyOrder(p1, p2));
    assertThat(levelToNodeMap.get(2), contains(p3));
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Example 15 with SCMDependencyNode

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

the class RunStagesPopulatorTest method shouldPopulateStageDetailsForNodesInGraph.

@Test
public void shouldPopulateStageDetailsForNodesInGraph() throws Exception {
    /*
        * git---> p1 ---> p3
        * |      v      ^
        * +---> p2 -----+
        * **/
    ValueStreamMap graph = new ValueStreamMap("p3", new PipelineRevision("p3", 1, "labelp3-1"));
    graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), new PipelineRevision("p1", 1, "labelp1-1"), "p3");
    graph.addUpstreamNode(new PipelineDependencyNode("p2", "p2"), new PipelineRevision("p2", 1, "labelp2-1"), "p3");
    graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), new PipelineRevision("p1", 2, "labelp1-2"), "p2");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p1", new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p2", new MaterialRevision(null));
    Stages stagesForP1_1 = stages("stages-for-p1-1");
    Stages stagesForP1_2 = stages("stages-for-p1-2");
    Stages stagesForP2_1 = stages("stages-for-p2-1");
    Stages stagesForP3_1 = stages("stages-for-p3-1");
    when(stageDao.findAllStagesFor("p1", 1)).thenReturn(stagesForP1_1);
    when(stageDao.findAllStagesFor("p1", 2)).thenReturn(stagesForP1_2);
    when(stageDao.findAllStagesFor("p2", 1)).thenReturn(stagesForP2_1);
    when(stageDao.findAllStagesFor("p3", 1)).thenReturn(stagesForP3_1);
    runStagesPopulator.apply(graph);
    VSMTestHelper.assertStageDetailsOf(graph, "p1", "1", stagesForP1_1);
    VSMTestHelper.assertStageDetailsOf(graph, "p1", "2", stagesForP1_2);
    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) Stages(com.thoughtworks.go.domain.Stages) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) 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