Search in sources :

Example 61 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldTriggerWithRevisions_inDay3_whenSharedMaterialIsNotAvailableInDay2.

@Test
public void shouldTriggerWithRevisions_inDay3_whenSharedMaterialIsNotAvailableInDay2() throws Exception {
    /**
     * day 1.
     * git -------> P1--------+
     *   \                    |
     *    \                   |
     *     \                  v
     *      -----> P2 -----> P3
     *
     * day 2.
     * git -------> P1--------+
     *                        |
     *                        |
     *                        v
     * svn -------> P2 -----> P3
     *
     * day 3.
     * git -------> P1--------+
     *   \                    |
     *    \                   |
     *     \                  v
     *      -----> P2 -----> P3
     */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    String[] git_revs = { "g1", "g2", "g3" };
    u.checkinInOrder(git, git_revs);
    SvnMaterial svn = u.wf(new SvnMaterial("svn", "username", "password", false), "folder2");
    String[] svn_revs = { "s1" };
    u.checkinInOrder(svn, svn_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(p1), u.m(p2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    // day 1:
    String p1_1 = u.runAndPass(p1, "g1");
    String p2_1 = u.runAndPass(p2, "g1");
    String p3_1 = u.runAndPass(p3, p1_1, p2_1);
    // day 2:
    configHelper.setMaterialConfigForPipeline("P2", svn.config());
    cruiseConfig = goConfigDao.load();
    String p1_2 = u.runAndPass(p1, "g2");
    String p2_2 = u.runAndPass(new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("P2")), p2.material), "s1");
    String p3_2 = u.runAndPass(p3, p1_2, p2_2);
    // day 3:
    configHelper.setMaterialConfigForPipeline("P2", git.config());
    cruiseConfig = goConfigDao.load();
    String p1_3 = u.runAndPass(p1, "g2");
    String p2_3 = u.runAndPass(p2, "g2");
    MaterialRevisions given = u.mrs(u.mr(p1, true, p1_3), u.mr(p2, false, p2_3));
    assertThat(getRevisionsBasedOnDependencies(p3, cruiseConfig, given), is(given));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 62 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldAddAllSharedMaterialsDeeperInTheGraph_whenCurrentPipelineHasDirectDependencyOnScmMaterial.

@Test
public void shouldAddAllSharedMaterialsDeeperInTheGraph_whenCurrentPipelineHasDirectDependencyOnScmMaterial() {
    GitMaterial git = u.wf(new GitMaterial("git1"), "folder1");
    String[] git_revs1 = { "g11", "g12" };
    u.checkinInOrder(git, git_revs1);
    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, "g11");
    String p2_1 = u.runAndPass(p2, p1_1);
    String p3_1 = u.runAndPass(p3, p2_1);
    String p4_1 = u.runAndPass(p4, p3_1);
    MaterialRevisions given = u.mrs(u.mr(git, true, "g11"), u.mr(p4, true, p4_1));
    MaterialRevisions expected = u.mrs(u.mr(git, true, "g11"), u.mr(p4, true, p4_1));
    assertThat(getRevisionsBasedOnDependencies(p5, cruiseConfig, given), is(expected));
    String p1_2 = u.runAndPass(p1, "g12");
    String p2_2 = u.runAndPass(p2, p1_2);
    String p3_2 = u.runAndPass(p3, p2_2);
    given = u.mrs(u.mr(git, true, "g12"), u.mr(p4, false, p4_1));
    expected = u.mrs(u.mr(git, false, "g11"), u.mr(p4, false, p4_1));
    assertThat(getRevisionsBasedOnDependencies(p5, 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 63 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldResolveSimpleDiamondWithMultipleScmRevisionsThatHasTriggeredTheUpstreamPipeline.

@Test
public void shouldResolveSimpleDiamondWithMultipleScmRevisionsThatHasTriggeredTheUpstreamPipeline() {
    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.runAndPassWithGivenMDUTimestampAndRevisionObjects(p1, u.d(i++), u.rs("g12", "g13"));
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_2), u.mr(git1, true, "g12", "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 64 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldContinueBackTrackingFromItsLastKnownPositionAndNotFromTheBeginning.

@Test(timeout = 10 * 1000)
@ExpectedException(NoCompatibleUpstreamRevisionsException.class)
public void shouldContinueBackTrackingFromItsLastKnownPositionAndNotFromTheBeginning() {
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder1");
    String[] git_revs1 = { "g11", "g12", "g13" };
    u.checkinInOrder(git1, u.d(i++), git_revs1);
    GitMaterial git2 = u.wf(new GitMaterial("git2"), "folder2");
    String[] git_revs2 = { "g21", "g22", "g23" };
    u.checkinInOrder(git2, u.d(i++), git_revs2);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1), u.m(git2));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(git1), u.m(git2));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1), u.m(p2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11", "g21");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g12", "g21");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g11", "g23");
    MaterialRevisions given = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_2));
    assertThat(getRevisionsBasedOnDependencies(p3, 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) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 65 with GitMaterial

use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldResolveDependenciesAcrossSeveralLevelsOfLinearRelations.

@Test
public void shouldResolveDependenciesAcrossSeveralLevelsOfLinearRelations() {
    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)

Aggregations

GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)146 Test (org.junit.Test)137 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)70 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)55 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)31 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)20 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)13 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 Modification (com.thoughtworks.go.domain.materials.Modification)11 File (java.io.File)11 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)10 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)10 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)9 Material (com.thoughtworks.go.domain.materials.Material)8 Materials (com.thoughtworks.go.config.materials.Materials)7