Search in sources :

Example 21 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ValueStreamMapServiceTest method currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision.

@Test
public void currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision() {
    /*
                            /-> P1 -- \
                        git            -> p3
                            \-> P2 -- /
         */
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    Modification rev1 = ModificationsMother.oneModifiedFile("rev1");
    Modification rev2 = ModificationsMother.oneModifiedFile("rev2");
    Modification rev3 = ModificationsMother.oneModifiedFile("rev3");
    BuildCause p1buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3, rev2, rev1));
    BuildCause p2buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3));
    BuildCause p3buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1), dependencyMaterial("p2", 1)), new ArrayList<>(), new ArrayList<>());
    when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
    when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
    when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
    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())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
    assertNull(graph.getCurrentPipeline().getViewType());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 22 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldPopulateRevisionsForUpstreamPipelines.

@Test
public void shouldPopulateRevisionsForUpstreamPipelines() {
    /*
        * git---> p1 ---> p3
        * |      v      ^
        * +---> p2 -----+
        * **/
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    BuildCause p3buildCause = createBuildCause(asList("p1", "p2"), new ArrayList<>());
    BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 2)), asList(git), ModificationsMother.multipleModificationList(0));
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
    Modifications modifications = p1buildCause.getMaterialRevisions().getMaterialRevision(0).getModifications();
    when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
    when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
    when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
    when(pipelineService.buildCauseFor("p1", 2)).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())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
    VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"), new PipelineRevision("p1", 2, "LABEL-p1-2"));
    VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-p2-1"));
    VSMTestHelper.assertNodeHasRevisions(graph, "p3", new PipelineRevision("p3", 1, "LABEL-P3"));
    VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, modifications));
    verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 23 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel.

@Test
public void shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel() throws Exception {
    /*
        * +-------------+
        * |             v
        * g---->p1---->p2 ---> p3
        *        |             ^
        *        -------------+
        *
        * */
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    String p1 = "p1";
    String p2 = "p2";
    String p3 = "p3";
    BuildCause p3buildCause = createBuildCause(asList(p1, p2), new ArrayList<>());
    BuildCause p2buildCause = createBuildCause(asList(p1), asList(git));
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
    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, new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name())));
    PipelineConfig p3Config = PipelineConfigMother.pipelineConfig(p3, new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "p3-label", p3buildCause));
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(p3, 1, user, result);
    List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
    assertThat(graph.getCurrentPipeline().getName(), is(p3));
    assertThat(nodesAtEachLevel.size(), is(4));
    List<Node> firstLevel = nodesAtEachLevel.get(0);
    assertThat(firstLevel.size(), is(1));
    assertLayerHasNode(firstLevel, git.getDisplayName(), git.getFingerprint(), p1);
    List<Node> secondLevel = nodesAtEachLevel.get(1);
    assertThat(secondLevel.size(), is(2));
    assertLayerHasNode(secondLevel, p1, p1, p2);
    assertLayerHasDummyNodeWithDependents(secondLevel, p2);
    List<Node> thirdLevel = nodesAtEachLevel.get(2);
    assertThat(thirdLevel.size(), is(2));
    assertLayerHasNode(thirdLevel, p2, p2, p3);
    assertLayerHasDummyNodeWithDependents(thirdLevel, p3);
    List<Node> fourthLevel = nodesAtEachLevel.get(3);
    assertThat(fourthLevel.size(), is(1));
    assertLayerHasNode(fourthLevel, p3, p3);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Arrays.asList(java.util.Arrays.asList) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 24 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldGetPipelineDependencyGraphForAPipelineWithNoCrossLevelDependencies.

@Test
public void shouldGetPipelineDependencyGraphForAPipelineWithNoCrossLevelDependencies() {
    /*
        * svn => P1
        * */
    String pipeline = "P1";
    int counter = 1;
    BuildCause buildCause = PipelineMother.pipeline(pipeline, new Stage()).getBuildCause();
    MaterialConfig material = buildCause.getMaterialRevisions().getMaterialRevision(0).getMaterial().config();
    when(pipelineService.buildCauseFor(pipeline, counter)).thenReturn(buildCause);
    PipelineConfig p1Config = PipelineConfigMother.pipelineConfig(pipeline, new MaterialConfigs(material));
    when(goConfigService.currentCruiseConfig()).thenReturn(new BasicCruiseConfig(new BasicPipelineConfigs(p1Config)));
    when(pipelineService.findPipelineByCounterOrLabel(pipeline, "1")).thenReturn(new Pipeline(pipeline, "p1-label", buildCause));
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(pipeline, counter, user, result);
    List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
    assertThat(graph.getCurrentPipeline().getName(), is(pipeline));
    assertThat(nodesAtEachLevel.size(), is(2));
    List<Node> firstLevel = nodesAtEachLevel.get(0);
    assertThat(firstLevel.size(), is(1));
    assertNode(-1, firstLevel.get(0), material.getDisplayName(), material.getFingerprint(), 0, pipeline);
    List<Node> secondLevel = nodesAtEachLevel.get(1);
    assertThat(secondLevel.size(), is(1));
    assertNode(0, secondLevel.get(0), pipeline, pipeline, 0);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Arrays.asList(java.util.Arrays.asList) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) Test(org.junit.Test)

Example 25 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldPushAllAncestorsLeftByOneWhenMovingImmediateParentToLeftOfANode.

@Test
public void shouldPushAllAncestorsLeftByOneWhenMovingImmediateParentToLeftOfANode() {
    /*
        * g1 -> P1--->X------>P2
        *        \             ^
        *          \           |
        *            V         |
        *       g2-->P3-------+
        *
        */
    String p1 = "p1";
    String p2 = "p2";
    String p3 = "p3";
    GitMaterial g1 = new GitMaterial("g1");
    GitMaterial g2 = new GitMaterial("g2");
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(g1));
    BuildCause p3buildCause = createBuildCause(asList(p1), asList(g2));
    BuildCause p2buildCause = createBuildCause(asList(p1, p3), Arrays.<GitMaterial>asList());
    when(pipelineService.buildCauseFor(p1, 1)).thenReturn(p1buildCause);
    when(pipelineService.buildCauseFor(p2, 1)).thenReturn(p2buildCause);
    when(pipelineService.buildCauseFor(p3, 1)).thenReturn(p3buildCause);
    PipelineConfig p1Config = PipelineConfigMother.pipelineConfig(p1, new MaterialConfigs(g1.config()));
    PipelineConfig p3Config = PipelineConfigMother.pipelineConfig(p3, new MaterialConfigs(g2.config(), new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name())));
    PipelineConfig p2Config = PipelineConfigMother.pipelineConfig(p2, new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p3Config.name(), p3Config.getFirstStageConfig().name())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(pipelineService.findPipelineByCounterOrLabel(p2, "1")).thenReturn(new Pipeline(p2, "p2-label", p2buildCause));
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(p2, 1, user, result);
    List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
    assertThat(nodesAtEachLevel.size(), is(4));
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint());
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, p1, g2.getFingerprint());
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 1, p3);
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 0, p2);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Arrays.asList(java.util.Arrays.asList) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Aggregations

BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)142 Test (org.junit.Test)108 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)35 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)30 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)27 TimeProvider (com.thoughtworks.go.util.TimeProvider)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Modification (com.thoughtworks.go.domain.materials.Modification)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)15 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)14 Date (java.util.Date)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)10 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)10 Username (com.thoughtworks.go.server.domain.Username)10