Search in sources :

Example 81 with CruiseConfig

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

the class AutoTriggerDependencyResolutionTest method shouldResolveSimpleDiamond.

@Test
public void shouldResolveSimpleDiamond() {
    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", u.m(git1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", 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 82 with CruiseConfig

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

the class AutoTriggerDependencyResolutionTest method shouldResolveWhenAChainOfDependencyMaterialConstituteASharedMaterial_withAnUnrelatedMaterial.

@Test
public void shouldResolveWhenAChainOfDependencyMaterialConstituteASharedMaterial_withAnUnrelatedMaterial() {
    // hg---> P0 ---+
    // |
    // +--------> P1 ------+
    // |                   |
    // |                   v
    // git                 P2
    // |                   |
    // +--------> P3 <-----+
    HgMaterial hg = u.wf(new HgMaterial("hg1", null), "folder1");
    String[] hg_revs = { "h11", "h12" };
    int i = 1;
    u.checkinInOrder(hg, u.d(i++), hg_revs);
    GitMaterial git = u.wf(new GitMaterial("git1"), "folder2");
    String[] git_revs1 = { "g11", "g12" };
    u.checkinInOrder(git, u.d(i++), git_revs1);
    ScheduleTestUtil.AddedPipeline p0 = u.saveConfigWith("p0", u.m(hg));
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git), u.m(p0));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(git), u.m(p2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p0_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p0, u.d(i++), "h11");
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11", p0_1);
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
    String p0_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p0, u.d(i++), "h12");
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12", p0_2);
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
    MaterialRevisions given = u.mrs(u.mr(git, true, "g12"), u.mr(p2, false, p2_2));
    MaterialRevisions expected = u.mrs(u.mr(git, false, "g12"), u.mr(p2, false, p2_2));
    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) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 83 with CruiseConfig

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

the class AutoTriggerDependencyResolutionTest method shouldResolveDependenciesAcrossSeveralLevelsOfLinearRelations_withNamesThatManifestDirtyGlobalStorageProblem.

@Test
public void shouldResolveDependenciesAcrossSeveralLevelsOfLinearRelations_withNamesThatManifestDirtyGlobalStorageProblem() {
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    String[] git_revs = { "g1", "g2" };
    u.checkinInOrder(git, 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(p2));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p3));
    ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(git), u.m(p4));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPass(p1, "g1");
    String p2_1 = u.runAndPass(p2, p1_1);
    String p3_1 = u.runAndPass(p3, p2_1);
    String p4_1 = u.runAndPass(p4, p3_1);
    String p1_2 = u.runAndPass(p1, "g2");
    String p2_2 = u.runAndPass(p2, p1_2);
    MaterialRevisions given = u.mrs(u.mr(git, true, git_revs), u.mr(p4, true, p4_1));
    MaterialRevisions expected = u.mrs(u.mr(git, true, "g1"), u.mr(p4, true, p4_1));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("p5"));
    assertThat(finalRevisions, 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) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 84 with CruiseConfig

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

the class AutoTriggerDependencyResolutionTest method shouldPrefer_materialRevisionThatChangedLast_over_anyMaterialRevisionsThatAreChanged_butAreOlder_whileComputingCompatibleRevisions.

@Test
public void shouldPrefer_materialRevisionThatChangedLast_over_anyMaterialRevisionsThatAreChanged_butAreOlder_whileComputingCompatibleRevisions() throws Exception {
    /**
     *      +------ git ------+
     *      |        |        |
     *      |        |        |
     *      v        v        v
     *      P1      P2       P3
     *      |        |        |
     *      |        |        |
     *      +-----> P4 <------+
     */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    String[] git_revs = { "g1", "g2", "g3", "g4" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(git));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(git));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p2), u.m(p1), u.m(p3));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPass(p1, "g1");
    String p1_2 = u.runAndPass(p1, "g2", "g3");
    String p1_3 = u.runAndPass(p1, "g4");
    String p1_4 = u.runAndPass(p1, "g2");
    String p1_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(2), "g4");
    String p2_1 = u.runAndPass(p2, "g1");
    String p2_2 = u.runAndPass(p2, "g2");
    String p2_3 = u.runAndPass(p2, "g3");
    String p2_4 = u.runAndPass(p2, "g4");
    // latest
    String p2_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(3), "g2");
    String p3_1 = u.runAndPass(p3, "g1");
    String p3_2 = u.runAndPass(p3, "g2");
    String p3_3 = u.runAndPass(p3, "g3");
    String p3_4 = u.runAndPass(p3, "g3");
    String p3_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(1), "g4");
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, true, p1_5), u.mr(p3, false, p3_5));
    MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, false, p1_4), u.mr(p3, false, p3_2));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
    assertThat(finalRevisions, 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 85 with CruiseConfig

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

the class AutoTriggerDependencyResolutionTest method fanInBehaviourShouldBeCorrectWhenStagesHaveBeenRenamedInHistory.

@Test
public void fanInBehaviourShouldBeCorrectWhenStagesHaveBeenRenamedInHistory() {
    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));
    p1.config.add(0, StageConfigMother.manualStage("renamed_stage"));
    configHelper.writeConfigFile(cruiseConfig);
    cruiseConfig = goConfigDao.load();
    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)

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