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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations