Search in sources :

Example 6 with PipelineDependencyNode

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

the class DummyNodeCreationTest method shouldCreateDummyNodesAtCorrectLevelsWhenNodesAreAddedUsingDFS.

@Test
public void shouldCreateDummyNodesAtCorrectLevelsWhenNodesAreAddedUsingDFS() {
    /*                +-------X------+
                          |              v
             +---> p1 --> p4 --> p5 ---> P6
            |             ^      ^
           git --> p2 ----+      |
            |                    |
            +---> X -----p3------+
         */
    String currentPipeline = "p6";
    ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
    graph.addUpstreamNode(new PipelineDependencyNode("p4", "p4"), null, currentPipeline);
    graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p1", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p2", "p2"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p2", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p5", "p5"), null, currentPipeline);
    graph.addUpstreamNode(new PipelineDependencyNode("p3", "p3"), null, "p5");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p3", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p4", "p4"), null, "p5");
    graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p1", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p2", "p2"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p2", new MaterialRevision(null));
    NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
    dummyNodeCreation.apply(graph, nodeLevelMap);
    VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 5);
    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(3));
    assertThat(nodeLevelMap.get(-4).size(), 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 7 with PipelineDependencyNode

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

the class DummyNodeCreationTest method shouldHandleDeepTriangle.

@Test
public void shouldHandleDeepTriangle() {
    /*
             +---> d1 ---> d2 ---> d3
             g                     ^
             +---- x ----- 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, "d2");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, "d1", new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, currentPipeline, new MaterialRevision(null));
    NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
    dummyNodeCreation.apply(graph, nodeLevelMap);
    VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 4);
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(0), 0, "d3");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-1), 1, "d2");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-2), 1, "d1");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-3), 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 8 with PipelineDependencyNode

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

the class DummyNodeCreationTest method shouldCreateDummyNodeAtRightIndexToHelpInMinimizingCrossings.

@Test
public void shouldCreateDummyNodeAtRightIndexToHelpInMinimizingCrossings() {
    /*
             +---> d1 ---> d4---->d5
            d3             |
             +---> X ------+
             |             |
             ------d2-----+
         */
    String currentPipeline = "d5";
    ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
    graph.addUpstreamNode(new PipelineDependencyNode("d4", "d4"), null, currentPipeline);
    graph.addUpstreamNode(new PipelineDependencyNode("d1", "d1"), null, "d4");
    graph.addUpstreamNode(new PipelineDependencyNode("d3", "d3"), null, "d1");
    graph.addUpstreamNode(new PipelineDependencyNode("d3", "d3"), null, "d4");
    graph.addUpstreamNode(new PipelineDependencyNode("d2", "d2"), null, "d4");
    graph.addUpstreamNode(new PipelineDependencyNode("d3", "d3"), null, "d2");
    NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
    dummyNodeCreation.apply(graph, nodeLevelMap);
    VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 4);
    VSMTestHelper.assertThatNodeHasChildren(graph, "d3", 1, "d1", "d2");
    Node secondChildOfD3 = graph.findNode("d3").getChildren().get(1);
    assertThat(secondChildOfD3.getType(), is(DependencyNodeType.DUMMY));
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Example 9 with PipelineDependencyNode

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

the class LevelAssignmentTest method shouldAssignLevelsForDownstreamNodesOfCurrentMaterial.

@Test
public void shouldAssignLevelsForDownstreamNodesOfCurrentMaterial() throws Exception {
    /*
				---> p1 ----
			   /            \
		git --> p ----------> p3
			  \            /
			   ---> p2 ----
		*/
    Node p = new PipelineDependencyNode("p", "p");
    Node p1 = new PipelineDependencyNode("p1", "p1");
    Node p2 = new PipelineDependencyNode("p2", "p2");
    Node p3 = new PipelineDependencyNode("p3", "p3");
    GitMaterial material = new GitMaterial("url");
    Modification modification = ModificationsMother.aCheckIn("1");
    ValueStreamMap valueStreamMap = new ValueStreamMap(material, null, modification);
    Node gitNode = valueStreamMap.getCurrentMaterial();
    valueStreamMap.addDownstreamNode(p, gitNode.getId());
    valueStreamMap.addDownstreamNode(p1, p.getId());
    valueStreamMap.addDownstreamNode(p2, p.getId());
    valueStreamMap.addDownstreamNode(p3, p1.getId());
    valueStreamMap.addDownstreamNode(p3, p2.getId());
    NodeLevelMap levelToNodeMap = new LevelAssignment().apply(valueStreamMap);
    assertThat(valueStreamMap.getCurrentMaterial().getLevel(), is(0));
    assertThat(p.getLevel(), is(1));
    assertThat(p1.getLevel(), is(2));
    assertThat(p2.getLevel(), is(2));
    assertThat(p3.getLevel(), is(3));
    assertThat(levelToNodeMap.get(0), contains(valueStreamMap.getCurrentMaterial()));
    assertThat(levelToNodeMap.get(1), containsInAnyOrder(p));
    assertThat(levelToNodeMap.get(2), containsInAnyOrder(p1, p2));
    assertThat(levelToNodeMap.get(3), contains(p3));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Example 10 with PipelineDependencyNode

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

the class LevelAssignmentTest method shouldAssignLevelsForUpstreamNodesOfCurrentPipeline.

@Test
public void shouldAssignLevelsForUpstreamNodesOfCurrentPipeline() throws Exception {
    /*
        ---> p1 ---
       /            \
       g -----------p3
       \            /
        ---> p2 ---
        */
    String current = "p3";
    Node p1 = new PipelineDependencyNode("p1", "p1");
    Node p2 = new PipelineDependencyNode("p2", "p2");
    Node gitNode = new SCMDependencyNode("git", "g", "git");
    ValueStreamMap valueStreamMap = new ValueStreamMap(current, new PipelineRevision(current, 1, "1"));
    valueStreamMap.addUpstreamNode(p1, new PipelineRevision("p1", 1, "1"), current);
    valueStreamMap.addUpstreamNode(p2, new PipelineRevision("p2", 1, "1"), current);
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("trunk"), "p1", new MaterialRevision(null));
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p3", new MaterialRevision(null));
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p2", new MaterialRevision(null));
    NodeLevelMap levelToNodeMap = new LevelAssignment().apply(valueStreamMap);
    assertThat(valueStreamMap.getCurrentPipeline().getLevel(), is(0));
    assertThat(p1.getLevel(), is(-1));
    assertThat(p2.getLevel(), is(-1));
    assertThat(gitNode.getLevel(), is(-2));
    assertThat(levelToNodeMap.get(0), contains(valueStreamMap.getCurrentPipeline()));
    assertThat(levelToNodeMap.get(-1), containsInAnyOrder(p1, p2));
    assertThat(levelToNodeMap.get(-2), contains(gitNode));
}
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)

Aggregations

PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)22 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)22 Test (org.junit.Test)22 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)21 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)18 NodeLevelMap (com.thoughtworks.go.domain.valuestreammap.NodeLevelMap)15 Node (com.thoughtworks.go.domain.valuestreammap.Node)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 PipelineRevision (com.thoughtworks.go.domain.valuestreammap.PipelineRevision)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)5 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)4 Stages (com.thoughtworks.go.domain.Stages)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)1 Stage (com.thoughtworks.go.domain.Stage)1 Date (java.util.Date)1