Search in sources :

Example 6 with PipelineRevision

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

the class RunStagesPopulator method apply.

public void apply(ValueStreamMap graph) {
    for (Node node : graph.allNodes()) {
        for (Revision revision : node.revisions()) {
            if (revision instanceof PipelineRevision) {
                PipelineRevision pipelineRevision = (PipelineRevision) revision;
                Stages latestStages = latestRunStagesForRevsion(pipelineRevision);
                pipelineRevision.addStages(latestStages);
            }
        }
    }
}
Also used : Revision(com.thoughtworks.go.domain.valuestreammap.Revision) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) Node(com.thoughtworks.go.domain.valuestreammap.Node) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) Stages(com.thoughtworks.go.domain.Stages)

Example 7 with PipelineRevision

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

the class RunStagesPopulatorTest method shouldPopulateOnlyLatestRunOfEachStageForEachPipelineNode.

@Test
public void shouldPopulateOnlyLatestRunOfEachStageForEachPipelineNode() throws Exception {
    /*
            git --> p1 --> p2 --> p3
         */
    CaseInsensitiveString p2 = new CaseInsensitiveString("p2");
    CaseInsensitiveString p1 = new CaseInsensitiveString("p1");
    CaseInsensitiveString p3 = new CaseInsensitiveString("p3");
    ValueStreamMap graph = new ValueStreamMap(p2, new PipelineRevision(p2.toString(), 1, ""));
    graph.addUpstreamNode(new PipelineDependencyNode(p1, p1.toString()), new PipelineRevision(p1.toString(), 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.toString()), p2);
    p3_node.addRevision(new PipelineRevision(p3.toString(), 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.toString(), 1, "s1_p1", 2, "sample", new Date());
    stagesForP1_1.add(latestStage);
    when(stageDao.findAllStagesFor(p1.toString(), 1)).thenReturn(stagesForP1_1);
    when(stageDao.findAllStagesFor(p2.toString(), 1)).thenReturn(stagesForP2_1);
    when(stageDao.findAllStagesFor(p3.toString(), 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.jupiter.api.Test)

Example 8 with PipelineRevision

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

the class LevelAssignmentTest method shouldAssignLevelsForDownstreamNodesOfCurrentPipeline.

@Test
public void shouldAssignLevelsForDownstreamNodesOfCurrentPipeline() throws Exception {
    /*
                ---> p1 ----
               /            \
    	git --> p ----------> p3
              \            /
               ---> p2 ----
    	*/
    CaseInsensitiveString current = new CaseInsensitiveString("p");
    CaseInsensitiveString p1name = new CaseInsensitiveString("p1");
    CaseInsensitiveString p2name = new CaseInsensitiveString("p2");
    CaseInsensitiveString p3name = new CaseInsensitiveString("p3");
    Node p1 = new PipelineDependencyNode(p1name, p1name.toString());
    Node p2 = new PipelineDependencyNode(p2name, p2name.toString());
    Node p3 = new PipelineDependencyNode(p3name, p3name.toString());
    Node gitNode = new SCMDependencyNode("git", "g", "git");
    ValueStreamMap valueStreamMap = new ValueStreamMap(current, new PipelineRevision(current.toString(), 1, "1"));
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("trunk"), new CaseInsensitiveString("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) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.jupiter.api.Test)

Example 9 with PipelineRevision

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

the class RunStagesPopulatorTest method shouldPopulateStageDetailsForNodesInGraph.

@Test
public void shouldPopulateStageDetailsForNodesInGraph() throws Exception {
    /*
        * git---> p1 ---> p3
        * |      v      ^
        * +---> p2 -----+
        * **/
    CaseInsensitiveString p3 = new CaseInsensitiveString("p3");
    CaseInsensitiveString p1 = new CaseInsensitiveString("p1");
    CaseInsensitiveString p2 = new CaseInsensitiveString("p2");
    ValueStreamMap graph = new ValueStreamMap(p3, new PipelineRevision(p3.toString(), 1, "labelp3-1"));
    graph.addUpstreamNode(new PipelineDependencyNode(p1, p1.toString()), new PipelineRevision(p1.toString(), 1, "labelp1-1"), p3);
    graph.addUpstreamNode(new PipelineDependencyNode(p2, p2.toString()), new PipelineRevision(p2.toString(), 1, "labelp2-1"), p3);
    graph.addUpstreamNode(new PipelineDependencyNode(p1, p1.toString()), new PipelineRevision(p1.toString(), 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.toString(), 1)).thenReturn(stagesForP1_1);
    when(stageDao.findAllStagesFor(p1.toString(), 2)).thenReturn(stagesForP1_2);
    when(stageDao.findAllStagesFor(p2.toString(), 1)).thenReturn(stagesForP2_1);
    when(stageDao.findAllStagesFor(p3.toString(), 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.jupiter.api.Test)

Aggregations

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