Search in sources :

Example 86 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method should_NOT_triggerWithRevisionOfUpstream_whichHasRunUsingMutuallyIncompatibleRevisions.

@Test
public void should_NOT_triggerWithRevisionOfUpstream_whichHasRunUsingMutuallyIncompatibleRevisions() {
    /**
     *                   |> P4
     *                  /   ^
     *                /     |
     *              /       |
     * git -----> P1 ----> P3 (manual)
     *              \     ^
     *               \    |
     *                \   |
     *                 V  |
     *                  P2
     */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder");
    String[] git_revs = { "g1", "g2" };
    int i = 1;
    u.checkinInOrder(git, u.d(i++), git_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p1), u.m(p2));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p3), u.m(p1));
    CruiseConfig cruiseConfig = goConfigDao.load();
    int extraHours5 = i++;
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(extraHours5), "g1");
    int extraHours4 = i++;
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(extraHours4), p1_1);
    int extraHours3 = i++;
    String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(extraHours3), p1_1, p2_1);
    int extraHours2 = i++;
    String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(extraHours2), p3_1, p1_1);
    int extraHours1 = i++;
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(extraHours1), "g1");
    // p2 is running
    u.scheduleWith(p2, p1_2);
    int extraHours = i++;
    String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(extraHours), p1_2, p2_1);
    pipelineTimeline.update();
    final MaterialRevisions given = new MaterialRevisions();
    given.addRevision(u.mr(p3, true, p3_2));
    given.addRevision(u.mr(p1, true, p1_2));
    assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(given));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 87 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldResolveWhenAChainOfDependencyMaterialConstituteASharedMaterial.

@Test
public void shouldResolveWhenAChainOfDependencyMaterialConstituteASharedMaterial() {
    // +--------> P1 ------+
    // |                   |
    // |                   |
    // git                 P2
    // |                   |
    // +--------> P3<------+
    GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder-name");
    String[] git_revs1 = { "g11", "g12" };
    int i = 1;
    u.checkinInOrder(git1, u.d(i++), git_revs1);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(git1), u.m(p2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12");
    MaterialRevisions given = u.mrs(u.mr(git1, true, "g12"), u.mr(p2, false, p2_1));
    MaterialRevisions expected = u.mrs(u.mr(git1, false, "g11"), u.mr(p2, false, p2_1));
    MaterialRevisions actual = getRevisionsBasedOnDependencies(p3, cruiseConfig, given);
    assertThat(actual, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 88 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method fanInBehaviourShouldBeCorrectWhenStagesHaveDifferentNamesInGraph.

@Test
public void fanInBehaviourShouldBeCorrectWhenStagesHaveDifferentNamesInGraph() {
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
    String[] git_revs1 = { "g11", "g12" };
    u.checkinInOrder(git1, u.d(i++), git_revs1);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", "stage1", u.m(git1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", "stage2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", "stage3", u.m(p1));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", "stage4", u.m(p2), u.m(p3));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
    String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p1_1);
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_1), u.mr(p3, true, p3_1));
    assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(given));
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
    given = u.mrs(u.mr(p2, true, p2_2), u.mr(p3, false, p3_1));
    MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_1), u.mr(p3, true, p3_1));
    assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 89 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldResolveSimpleDiamondWithMultipleScmRevisionsToBeRun.

@Test
public void shouldResolveSimpleDiamondWithMultipleScmRevisionsToBeRun() {
    /*
             +---> P1 ---+
             |           v
            git         P2
             |          v
             +--------> P3
         */
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
    String[] git_revs1 = { "g11", "g12", "g13" };
    u.checkinInOrder(git1, u.d(i++), git_revs1);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p2), u.m(git1));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
    String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p2_1, "g11");
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12");
    String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g13");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_3);
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_2), u.mr(git1, true, "g13"));
    MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_2), u.mr(git1, true, "g12", "g13"));
    assertThat(getRevisionsBasedOnDependencies(p3, cruiseConfig, given), is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 90 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class UnrunStagesPopulatorTest method shouldPopulateConfiguredStagesWhenThereAreNoRevisionsForDownstream.

@Test
public void shouldPopulateConfiguredStagesWhenThereAreNoRevisionsForDownstream() throws Exception {
    /*
            p --> p1 --> p2
             \
              +-> p3
         */
    ValueStreamMap graph = new ValueStreamMap("p", revision("p", 1));
    Node p1_node = graph.addDownstreamNode(new PipelineDependencyNode("p1", "p1"), "p");
    Node p2_node = graph.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p1");
    Node p3_node = graph.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p");
    addRevisions(p1_node);
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    String group = "first";
    cruiseConfig.addPipeline(group, pipelineConfig("p"));
    cruiseConfig.addPipeline(group, pipelineConfig("p1"));
    cruiseConfig.addPipeline(group, pipelineConfig("p2"));
    cruiseConfig.addPipeline(group, pipelineConfig("p3"));
    when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
    unrunStagesPopulator.apply(graph);
    assertUnrunPipeline(p2_node, "p2");
    assertUnrunPipeline(p3_node, "p3");
}
Also used : BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Aggregations

CruiseConfig (com.thoughtworks.go.config.CruiseConfig)95 Test (org.junit.Test)77 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)35 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)33 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)32 ServerConfig (com.thoughtworks.go.config.ServerConfig)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)5 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)4 File (java.io.File)4 ConfigCache (com.thoughtworks.go.config.ConfigCache)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)3 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)3 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3