Search in sources :

Example 86 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldIgnoreUpstreamPipelineWhenThereIsNothingInCommon.

@Test
public void shouldIgnoreUpstreamPipelineWhenThereIsNothingInCommon() throws Exception {
    SvnMaterial svn = u.wf(new SvnMaterial("url", "username", "password", false), "folder1");
    String[] svn_revs = { "s1", "s2" };
    int i = 1;
    u.checkinInOrder(svn, u.d(i++), svn_revs);
    HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder2");
    String[] hg_revs = { "hg1", "hg2", "hg3" };
    u.checkinInOrder(hg, u.d(i++), hg_revs);
    ScheduleTestUtil.AddedPipeline up0 = u.saveConfigWith("up0", u.m(hg));
    ScheduleTestUtil.AddedPipeline up1 = u.saveConfigWith("up1", u.m(up0));
    ScheduleTestUtil.AddedPipeline current = u.saveConfigWith("current", u.m(up0), u.m(up1), u.m(svn));
    String up0_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg1", "hg2", "hg3");
    String up0_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg1", "hg2", "hg3");
    String up1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i++), up0_1);
    MaterialRevisions given = u.mrs(u.mr(up0, true, up0_2), u.mr(up1, false, up1_1), u.mr(svn, true, "s1", "s2"));
    MaterialRevisions expected = u.mrs(u.mr(up0, true, up0_2), u.mr(up1, false, up1_1), u.mr(svn, true, "s2"));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("current"));
    assertThat(finalRevisions, is(expected));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 87 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldGetOnlyLatestScmRevisionOnFirstRun.

@Test
public void shouldGetOnlyLatestScmRevisionOnFirstRun() {
    GitMaterial gitMaterial = new GitMaterial("git-url", null, "dest-folder");
    u.checkinInOrder(gitMaterial, "git-1", "git-2", "git-3");
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(gitMaterial));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(gitMaterial));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(gitMaterial), u.m(p1), u.m(p2));
    String p1_1 = u.runAndPass(p1, "git-3");
    String p2_1 = u.runAndPass(p2, "git-3");
    MaterialRevisions given = u.mrs(u.mr(gitMaterial, true, "git-3"), u.mr(p1, false, p1_1), u.mr(p2, false, p2_1));
    MaterialRevisions expected = u.mrs(u.mr(gitMaterial, true, "git-3"), u.mr(p1, false, p1_1), u.mr(p2, false, p2_1));
    assertThat(getRevisionsBasedOnDependencies(p3, goConfigDao.load(), 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) Test(org.junit.Test)

Example 88 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependencyViaAutoBuild.

@Test
public void shouldResolveTriangleDependencyViaAutoBuild() throws Exception {
    SystemEnvironment env = mock(SystemEnvironment.class);
    when(env.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
    int i = 0;
    GitMaterial git = new GitMaterial("git");
    String[] git_revs = { "g1" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
    ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
    ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
    String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
    String p4_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
    String p5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), p4_2);
    String p4_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "g1");
    String p4_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i), "g1");
    MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
    MaterialRevisions expected = u.mrs(u.mr(p4, false, p4_2), u.mr(p5, false, p5_1));
    AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p6.config.name().toString(), env, materialChecker);
    pipelineTimeline.update();
    BuildCause buildCause = autoBuild.onModifications(given, false, null);
    assertThat(buildCause.getMaterialRevisions(), is(expected));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 89 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldChooseTheRevisionFromThirdWhenBothThirdAndSecondAreModified.

@Test
public void shouldChooseTheRevisionFromThirdWhenBothThirdAndSecondAreModified() throws Exception {
    // Third <- Second <-- SVN
    // |      |
    // v      v
    // Last
    SvnMaterial svn = u.wf(new SvnMaterial("url", "username", "password", false), "folder1");
    String[] svn_revs = { "s1", "s2" };
    int i = 1;
    u.checkinInOrder(svn, u.d(i++), svn_revs);
    ScheduleTestUtil.AddedPipeline second = u.saveConfigWith("second", u.m(svn));
    ScheduleTestUtil.AddedPipeline third = u.saveConfigWith("third", u.m(second));
    ScheduleTestUtil.AddedPipeline last = u.saveConfigWith("last", u.m(second), u.m(third));
    String second_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(second, u.d(i++), "s1");
    String second_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(second, u.d(i++), "s1");
    String second_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(second, u.d(i++), "s1");
    String second_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(second, u.d(i++), "s2");
    String third_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(third, u.d(i++), second_1);
    String third_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(third, u.d(i++), second_1);
    String third_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(third, u.d(i++), second_2);
    MaterialRevisions given = u.mrs(u.mr(third, true, third_3), u.mr(second, true, second_4));
    MaterialRevisions expected = u.mrs(u.mr(third, true, third_3), u.mr(second, true, second_3));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("last"));
    assertThat(finalRevisions, is(expected));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 90 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_whileComputingCompatibleRevisions.

@Test
public void shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_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" };
    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(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.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2", "g3");
    String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
    String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2");
    String p1_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g1");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
    String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g3");
    String p2_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g4");
    // latest
    String p2_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
    // Does this honour schedule order?
    String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g1");
    String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g2");
    String p3_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
    String p3_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
    String p3_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "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)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)212 Test (org.junit.Test)166 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)111 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)68 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)38 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)33 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)31 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 Materials (com.thoughtworks.go.config.materials.Materials)27 Pipeline (com.thoughtworks.go.domain.Pipeline)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 File (java.io.File)12