Search in sources :

Example 66 with MaterialRevisions

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

the class FaninDependencyResolutionTest method shouldResolveDiamondDependencyWithPackageMaterial.

@Test
public void shouldResolveDiamondDependencyWithPackageMaterial() {
    /*
            +---> P1 ---+
            |           v
           pkg1         P3
            |           ^
            +--> P2 ----+
        */
    int i = 1;
    PackageMaterial pkg1 = MaterialsMother.packageMaterial();
    u.addPackageDefinition((PackageMaterialConfig) pkg1.config());
    String[] pkg_revs = { "pkg1-1", "pkg1-2" };
    u.checkinInOrder(pkg1, u.d(i++), pkg_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(pkg1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(pkg1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1), u.m(p2));
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "pkg1-1");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "pkg1-1");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "pkg1-2");
    MaterialRevisions given = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_2));
    MaterialRevisions expected = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_1));
    assertThat(getRevisionsBasedOnDependencies(p3, goConfigDao.load(), given), is(expected));
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 67 with MaterialRevisions

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

the class FaninDependencyResolutionTest method shouldPickTheRightRevisionsWhenMaterialIsRemovedAndPutBack.

@Test
public void shouldPickTheRightRevisionsWhenMaterialIsRemovedAndPutBack() {
    GitMaterial git1 = u.wf(new GitMaterial("git1-url"), "git-folder1");
    GitMaterial git2 = u.wf(new GitMaterial("git2-url"), "git-folder2");
    GitMaterial git3 = u.wf(new GitMaterial("git3-url"), "git-folder3");
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git1), u.m(git2));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(git2));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p1), u.m(p2), u.m(git1));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p3), u.m(git2));
    u.checkinInOrder(git1, "git1_1");
    u.checkinInOrder(git2, "git2_1");
    String p1_1 = u.runAndPass(p1, "git1_1", "git2_1");
    String p2_1 = u.runAndPass(p2, "git2_1");
    String p3_1 = u.runAndPass(p3, p1_1, p2_1, "git1_1");
    String p4_1 = u.runAndPass(p4, p3_1, "git2_1");
    u.checkinInOrder(git1, "git1_2");
    u.checkinInOrder(git2, "git2_2");
    String p1_2 = u.runAndPass(p1, "git1_2", "git2_2");
    String p2_2 = u.runAndPass(p2, "git2_2");
    String p3_2 = u.runAndPass(p3, p1_2, p2_2, "git1_2");
    String p4_2 = u.runAndPass(p4, p3_2, "git2_2");
    configHelper.setMaterialConfigForPipeline("P2", git3.config());
    CruiseConfig cruiseConfig = goConfigDao.load();
    p2 = new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("P2")), p2.material);
    u.checkinInOrder(git1, "git1_3");
    u.checkinInOrder(git2, "git2_3");
    u.checkinInOrder(git3, "git3_1");
    String p1_3 = u.runAndPass(p1, "git1_3", "git2_3");
    String p2_3 = u.runAndPass(p2, "git3_1");
    String p3_3 = u.runAndPass(p3, p1_3, p2_3, "git1_3");
    // check wat happens to p4
    MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
    MaterialRevisions expected = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
    assertThat(finalRevisions, is(expected));
    // bring back git2 in p2
    configHelper.setMaterialConfigForPipeline("P2", git2.config());
    cruiseConfig = goConfigDao.load();
    p2 = new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("P2")), p2.material);
    // check wat happend to p4
    given = u.mrs(u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3));
    expected = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
    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) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 68 with MaterialRevisions

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

the class FaninDependencyResolutionTest method shouldRestoreMaterialNamesBasedOnMaterialConfig.

@Test
public void shouldRestoreMaterialNamesBasedOnMaterialConfig() throws Exception {
    /*
            g -> up   -> down
                 +-> mid -+
         */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    u.checkinInOrder(git, "g1");
    ScheduleTestUtil.AddedPipeline up = u.saveConfigWith("up", u.m(git));
    ScheduleTestUtil.MaterialDeclaration upForMid = u.m(up);
    ((DependencyMaterial) upForMid.material).setName(new CaseInsensitiveString("up-for-mid"));
    ScheduleTestUtil.AddedPipeline mid = u.saveConfigWith("mid", upForMid);
    ScheduleTestUtil.MaterialDeclaration upForDown = u.m(up);
    ((DependencyMaterial) upForDown.material).setName(new CaseInsensitiveString("up-for-down"));
    ScheduleTestUtil.AddedPipeline down = u.saveConfigWith("down", u.m(mid), upForDown);
    CruiseConfig cruiseConfig = goConfigDao.load();
    String up_1 = u.runAndPass(up, "g1");
    String mid_1 = u.runAndPass(mid, up_1);
    String down_1 = u.runAndPass(down, mid_1, up_1);
    MaterialRevisions given = u.mrs(u.mr(mid, false, mid_1), u.mr(up, false, up_1));
    MaterialRevisions revisionsBasedOnDependencies = getRevisionsBasedOnDependencies(down, cruiseConfig, given);
    for (MaterialRevision revisionsBasedOnDependency : revisionsBasedOnDependencies) {
        DependencyMaterial dependencyPipeline = (DependencyMaterial) revisionsBasedOnDependency.getMaterial();
        if (dependencyPipeline.getPipelineName().equals(new CaseInsensitiveString("up"))) {
            assertThat(dependencyPipeline.getName(), is(new CaseInsensitiveString("up-for-down")));
        }
    }
    assertThat(revisionsBasedOnDependencies, is(given));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 69 with MaterialRevisions

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

the class FaninDependencyResolutionTest method shouldFindCompatibleRevisionWhenSameMaterialHasDiffFolderNamesInGraph.

@Test
public void shouldFindCompatibleRevisionWhenSameMaterialHasDiffFolderNamesInGraph() throws Exception {
    // Second <- Svn
    // |     /
    // |   /
    // Third
    // 
    SvnMaterial svn1 = u.wf(new SvnMaterial("svn", "username", "password", false), "one");
    SvnMaterial svn2 = u.wf(new SvnMaterial("svn", "username", "password", false), "two");
    String[] svn_revs = { "s1" };
    u.checkinInOrder(svn1, svn_revs);
    ScheduleTestUtil.AddedPipeline second = u.saveConfigWith("second", u.m(svn1));
    ScheduleTestUtil.AddedPipeline third = u.saveConfigWith("third", u.m(second), u.m(svn2));
    String second_1 = u.runAndPass(second, "s1");
    MaterialRevisions given = u.mrs(u.mr(second, true, second_1), u.mr(svn2, true, "s1"));
    MaterialRevisions materialRevisions = getRevisionsBasedOnDependencies(third, goConfigDao.load(), given);
    assertThat(materialRevisions, is(given));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 70 with MaterialRevisions

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

the class FaninDependencyResolutionTest method shouldReturnPreviousBuild_sRevisionsIfOneParentFailed.

@Test
public void shouldReturnPreviousBuild_sRevisionsIfOneParentFailed() {
    // git ----------
    // |            |
    // ----- ------      |
    // |           |      |
    // v           v      |
    // P1         P2      |
    // |         |       |
    // |         |       |
    // --->P3<--        |
    // ^____________|
    GitMaterial gitMaterial = new GitMaterial("git-url");
    u.checkinInOrder(gitMaterial, "g1", "g2");
    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(p1), u.m(p2), u.m(gitMaterial));
    String p1_1 = u.runAndPass(p1, "g1");
    String p2_1 = u.runAndPass(p2, "g1");
    String p3_1 = u.runAndPass(p3, p1_1, p2_1, "g1");
    String p1_2 = u.runAndPass(p1, "g2");
    String p2_2 = u.runAndFail(p2, "g2");
    MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(gitMaterial, true, "g2"), u.mr(p1, true, p1_2), u.mr(p2, true, p2_1) });
    MaterialRevisions expected = u.mrs(new MaterialRevision[] { u.mr(gitMaterial, true, "g1"), u.mr(p1, true, p1_1), u.mr(p2, true, p2_1) });
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p3, goConfigDao.load(), 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) 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