use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldResolveWithModifiedStageDefinitionOfRootNode.
@Test
public void shouldResolveWithModifiedStageDefinitionOfRootNode() throws Exception {
/**
* git -------+
* | |
* | |
* v v
* P1 -----> P2
*/
GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
String[] git_revs = { "g1", "g2" };
int i = 0;
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(p1), u.m(git));
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
setMaxBackTrackLimit(2);
for (int j = 1; j <= maxBackTrackLimit() + 1; j++) {
u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1, "g1");
}
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2");
p2 = u.changeStagenameForToPipeline("P2", "s", "new-stage");
CruiseConfig cruiseConfig = goConfigDao.load();
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_2), u.mr(git, true, "g2"));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p2, cruiseConfig, given);
assertThat(finalRevisions, is(given));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldComputeRevisionCorrectlyWhen_MoreThan1UpstreamPipelineHasMinimumRevision.
@Test
public void shouldComputeRevisionCorrectlyWhen_MoreThan1UpstreamPipelineHasMinimumRevision() throws Exception {
/* +----------
/-->P1---\ v
git------> P3 -> P4
\-->P2--/ ^
+----------
*/
GitMaterial git = u.wf(new GitMaterial("git"), "f");
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), u.m(git));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p1), u.m(p2), u.m(p3));
int i = 0;
u.checkinInOrder(git, u.d(i++), "g0");
String p1_1 = u.runAndPass(p1, "g0");
String p2_1 = u.runAndPass(p2, "g0");
String p3_1 = u.runAndPass(p3, p1_1, p2_1, "g0");
String p4_1 = u.runAndPass(p4, p1_1, p2_1, p3_1);
u.checkinInOrder(git, u.d(i++), "g1");
String p1_2 = u.runAndPass(p1, "g1");
u.checkinInOrder(git, u.d(i++), "g2");
String p2_2 = u.runAndPass(p2, "g2");
String p3_2 = u.runAndPass(p3, p1_2, p2_2, "g2");
u.checkinInOrder(git, u.d(i++), "g3");
String p1_3 = u.runAndPass(p1, "g3");
String p2_3 = u.runAndPass(p2, "g3");
String p3_3 = u.runAndPass(p3, p1_3, p2_3, "g3");
String p4_2 = u.runAndPass(p4, p1_3, p2_3, p3_3);
String p2_4 = u.runAndPass(p2, "g1");
String p3_4 = u.runAndPass(p3, p1_2, p2_4, "g1");
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_3), u.mr(p2, true, p2_4), u.mr(p3, true, p3_4));
MaterialRevisions expected = u.mrs(u.mr(p1, true, p1_2), u.mr(p2, true, p2_4), u.mr(p3, true, p3_4));
MaterialRevisions revisionsBasedOnDependencies = getRevisionsBasedOnDependencies(p4, goConfigDao.load(), given);
assertThat(revisionsBasedOnDependencies, is(expected));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldResolveWithNoPassedBuildOfRootNode.
@Test
public void shouldResolveWithNoPassedBuildOfRootNode() throws Exception {
/**
* git -------+
* | |
* | |
* v v
* P1 -----> P2
*/
GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
String[] git_revs = { "g1" };
int i = 0;
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(p1), u.m(git));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
setMaxBackTrackLimit(2);
for (int j = 1; j <= maxBackTrackLimit() + 1; j++) {
u.runAndFail(p2, u.d(i++), p1_1, "g1");
}
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_1), u.mr(git, true, "g1"));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p2, cruiseConfig, given);
assertThat(finalRevisions, is(given));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class AutoBuildIntegrationTest method shouldCreateBuildCauseOnMaterialConfigChange.
@Test
public void shouldCreateBuildCauseOnMaterialConfigChange() throws Exception {
// down_pipe <- svn
// ^ /
// | / => down_pipe <- up_pipe <- svn
// up_pipe
//
SvnMaterial svn = scheduleUtil.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
String[] svn_revs = { "s1" };
scheduleUtil.checkinInOrder(svn, svn_revs);
ScheduleTestUtil.AddedPipeline up_pipe = scheduleUtil.saveConfigWith("up_pipe", scheduleUtil.m(svn));
ScheduleTestUtil.AddedPipeline down_pipe = scheduleUtil.saveConfigWith("down_pipe", scheduleUtil.m(svn), scheduleUtil.m(up_pipe));
String up_pipe_1 = scheduleUtil.runAndPass(up_pipe, "s1");
pipelineTimeline.update();
String down_pipe_1 = scheduleUtil.runAndPass(down_pipe, "s1", up_pipe_1);
pipelineTimeline.update();
down_pipe.config.removeMaterialConfig(svn.config());
CruiseConfig currentConfig = goConfigService.getCurrentConfig();
currentConfig.pipelineConfigByName(new CaseInsensitiveString("down_pipe")).removeMaterialConfig(svn.config());
configHelper.writeConfigFile(currentConfig);
goConfigDao.load();
MaterialRevisions given = scheduleUtil.mrs(scheduleUtil.mr(up_pipe, true, up_pipe_1));
MaterialRevisions expected = scheduleUtil.mrs(scheduleUtil.mr(up_pipe, true, up_pipe_1));
AutoBuild autoBuildType = new AutoBuild(goConfigService, pipelineService, "down_pipe", systemEnvironment, materialChecker);
assertThat(autoBuildType.onModifications(given, true, null).getMaterialRevisions(), is(expected));
}
use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldChooseTheAppropriateRevisionsOfAllMaterials_inAComplexMultipleDiamondDependencySituation_withDependencyMaterialsNotResolvingStrictly.
@Test
public void shouldChooseTheAppropriateRevisionsOfAllMaterials_inAComplexMultipleDiamondDependencySituation_withDependencyMaterialsNotResolvingStrictly() throws Exception {
/**
* +-----------------------------+
* | hg---------->P4 |
* | |\ | |
* | | \ | |
* | | \----\ | |
* | V \ | |
* | /----> P3 ------\\ | |
* | / \\ | |
* | / \V| |
* |/ V V |
* svn -----> P1 ---------> P6 <-+---+
* \ | ^ ^ |
* \ | / | |
* \ V / | |
* \---> P2-------/ | |
* # ^ | |
* | | |
* git----------->P5<-----git2
*/
int i = 1;
SvnMaterial svn = u.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
String[] svn_revs = { "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10" };
u.checkinInOrder(svn, u.d(i++), svn_revs);
HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder2");
String[] hg_revs = { "h1", "h2", "h3", "h4", "h5", "h6", "h7" };
u.checkinInOrder(hg, u.d(i++), hg_revs);
GitMaterial git1 = u.wf(new GitMaterial("git-1"), "folder3");
u.checkinInOrder(git1, u.d(i++), "g1-1", "g1-2", "g1-3", "g1-4", "g1-5", "g1-6");
GitMaterial git2 = u.wf(new GitMaterial("git-2"), "folder4");
String[] git2_revs = { "g2-1", "g2-2", "g2-3", "g2-4", "g2-5", "g2-6", "g2-7", "g2-8" };
u.checkinInOrder(git2, u.d(i++), git2_revs);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(svn));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(p1), u.m(svn), u.m(git1));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(svn), u.m(hg));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(hg));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("P5", u.m(git1), u.m(git2));
ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("P6", u.m(svn), u.m(p4), u.m(hg), u.m(p3), u.m(p1), u.m(p2), u.m(p5), u.m(git2));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s1");
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s2");
String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s3");
String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s4");
String p1_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s6");
String p1_6 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "s8");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1, "s1", "g1-2");
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2, "s2", "g1-3");
String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_4, "s5", "g1-5");
String p2_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_5, "s6", "g1-6");
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s1", "h1");
String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s2", "h3");
String p3_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s3", "h5");
String p3_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "s7", "h6");
String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h1");
String p4_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h3");
String p4_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h6");
String p4_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), "h7");
String p5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), "g1-2", "g2-2");
String p5_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), "g1-3", "g2-3");
String p5_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), "g1-6", "g2-5");
MaterialRevisions given = u.mrs(u.mr(rel(git2, p6), true, git2_revs), u.mr(rel(p5, p6), false, p5_3), u.mr(rel(p2, p6), false, p2_4), u.mr(rel(p1, p6), true, p1_6), u.mr(rel(p3, p6), false, p3_4), u.mr(rel(hg, p6), false, hg_revs), u.mr(rel(p4, p6), false, p4_4), u.mr(rel(svn, p6), true, svn_revs));
MaterialRevisions expected = u.mrs(u.mr(rel(git2, p6), true, "g2-3"), u.mr(rel(p5, p6), false, p5_2), u.mr(rel(p2, p6), false, p2_2), u.mr(rel(p1, p6), false, p1_2), u.mr(rel(p3, p6), false, p3_2), u.mr(rel(hg, p6), false, "h3"), u.mr(rel(p4, p6), false, p4_2), u.mr(rel(svn, p6), true, "s2"));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p6, cruiseConfig, given);
assertThat(finalRevisions, is(expected));
}
Aggregations