use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldAddAllSharedMaterialsDeeperInTheGraph.
@Test
public void shouldAddAllSharedMaterialsDeeperInTheGraph() {
GitMaterial git = u.wf(new GitMaterial("git1"), "folder1");
int i = 0;
String[] git_revs1 = { "g11", "g12" };
u.checkinInOrder(git, u.d(i++), git_revs1);
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));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p3));
ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4));
ScheduleTestUtil.AddedPipeline p7 = u.saveConfigWith("p7", u.m(p5), u.m(p6));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g11");
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p1_1);
String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(i++), p2_1);
String p5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p5, u.d(i++), p3_1);
String p6_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p6, u.d(i++), p4_1);
MaterialRevisions given = u.mrs(u.mr(p5, true, p5_1), u.mr(p6, true, p6_1));
MaterialRevisions expected = u.mrs(u.mr(p5, true, p5_1), u.mr(p6, true, p6_1));
assertThat(getRevisionsBasedOnDependencies(p7, cruiseConfig, given), is(expected));
String p1_2 = u.runAndPass(p1, "g12");
String p3_2 = u.runAndPass(p3, p1_2);
String p5_2 = u.runAndPass(p5, p3_2);
given = u.mrs(u.mr(p5, true, p5_2), u.mr(p6, true, p6_1));
assertThat(getRevisionsBasedOnDependencies(p7, cruiseConfig, given), is(expected));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldNotTriggerWithRevisions_ForWhichCurrentlyTheMaterialConfigurationIsDifferent.
@Test
public void shouldNotTriggerWithRevisions_ForWhichCurrentlyTheMaterialConfigurationIsDifferent() throws Exception {
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder1");
int i = 1;
String[] git_revs1 = { "g11" };
u.checkinInOrder(git1, u.d(i++), git_revs1);
GitMaterial git2 = u.wf(new GitMaterial("git2"), "folder2");
String[] git_revs2 = { "g21", "g22" };
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();
// day 1:
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11", "g21");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g11", "g21");
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p1_1, p2_1);
// day 2:
configHelper.setMaterialConfigForPipeline("P2", git1.config());
cruiseConfig = goConfigDao.load();
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i), "g11", "g22");
ScheduleTestUtil.AddedPipeline new_p2 = new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("p2")), p2.material);
u.scheduleWith(new_p2, "g11");
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_2), u.mr(new_p2, false, p2_1));
try {
assertThat(getRevisionsBasedOnDependencies(p3, cruiseConfig, given), is(nullValue()));
fail("Should have failed. There is no compatiable revision as material configuration has changed for p2");
} catch (NoCompatibleUpstreamRevisionsException e) {
assertThat(e.getMessage(), is("Failed resolution of pipeline p3 : Cause : No valid revisions found for the upstream dependency: DependencyMaterialConfig{pipelineName='p2', stageName='s'}"));
}
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method should_NOT_flip_flop_betweenTwoSetsOfAutoTriggerRevisionCombinations.
@Test
public void should_NOT_flip_flop_betweenTwoSetsOfAutoTriggerRevisionCombinations() {
/**
* git ---> P1
* | \ |
* | \ |
* | \ |
* | \ |
* V V V
* P2 ---> P3
*/
GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
String[] git_revs = { "g1" };
u.checkinInOrder(git, 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(p1), u.m(p2), u.m(git));
CruiseConfig cruiseConfig = goConfigDao.load();
// i counts hour, increments everytime,
int i = 0;
// important because we find auto-trigger compatible revision combinations based on time
// (and this is what the twist test that reproduced the bug first time was using)
int extraHours18 = i++;
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(extraHours18), "g1");
int extraHours17 = i++;
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(extraHours17), "g1");
int extraHours16 = i++;
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(extraHours16), p1_1, p2_1, "g1");
int extraHours15 = i++;
u.checkinInOrder(git, u.d(extraHours15), "g2");
int extraHours14 = i++;
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(extraHours14), "g2");
int extraHours13 = i++;
u.checkinInOrder(git, u.d(extraHours13), "g3");
int extraHours12 = i++;
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(extraHours12), "g3");
int extraHours11 = i++;
u.checkinInOrder(git, u.d(extraHours11), "g4");
int extraHours10 = i++;
String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionObjects(p2, u.d(extraHours10), u.rs("g3", "g4"));
int extraHours9 = i++;
u.checkinInOrder(git, u.d(extraHours9), "g5");
int extraHours8 = i++;
String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionObjects(p1, u.d(extraHours8), u.rs("g4", "g5"));
int extraHours7 = i++;
String p2_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(extraHours7), "g5");
int extraHours6 = i++;
List<String> revsForP1 = u.revisions(p1_3);
List<String> revsForP2 = u.revisions(p2_4);
List<String> revsForGit = u.revisions("g2", "g3", "g4", "g5");
String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionObjects(p3, u.d(extraHours6), u.getRevisionsForMaterials(revsForP1, revsForP2, revsForGit));
int extraHours5 = i++;
u.checkinInOrder(git, u.d(extraHours5), "g6");
int extraHours4 = i++;
String p2_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(extraHours4), "g6");
int extraHours3 = i++;
u.checkinInOrder(git, u.d(extraHours3), "g7");
int extraHours2 = i++;
String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionObjects(p1, u.d(extraHours2), u.rs("g6", "g7"));
int extraHours1 = i++;
String p2_6 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(extraHours1), "g3");
int extraHours = i++;
String p3_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(extraHours), p1_2, p2_6, "g3");
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_4), u.mr(p2, false, p2_6), u.mr(git, true, "g7"));
MaterialRevisions previous = u.mrs(new MaterialRevision[] { u.mr(p1, true, p1_2), u.mr(p2, false, p2_6), u.mr(git, true, "g3") });
pipelineTimeline.update();
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, "P3", systemEnvironment, materialChecker);
assertThat(autoBuild.onModifications(given, false, previous), nullValue());
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldPrefer_NewModifications_Over_OldModifications_whenFindingCompatibleRevisions.
@Test
public void shouldPrefer_NewModifications_Over_OldModifications_whenFindingCompatibleRevisions() throws Exception {
/**
* git -------> P1--------+
* | |
* | |
* v v
* P2 -----> P3
*/
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));
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++), "g1");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
MaterialRevisions given = u.mrs(u.mr(p2, true, p2_3), u.mr(u.mw(p1), false, p1_2));
MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_3), u.mr(u.mw(p1), false, p1_2));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p3, cruiseConfig, given);
assertThat(finalRevisions, is(expected));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldOutputCorrectScmRevisionsForBuildCausePopup.
@Test
public void shouldOutputCorrectScmRevisionsForBuildCausePopup() {
int i = 1;
GitMaterial git = u.wf(new GitMaterial("git"), "folder");
String[] git_revs1 = { "g11", "g12", "g13", "g14", "g15" };
u.checkinInOrder(git, u.d(i++), git_revs1);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(git), u.m(p1));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g12", p1_2);
String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g13");
String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g14");
MaterialRevisions given = u.mrs(u.mr(p1, true, p1_4), u.mr(git, true, "g15"));
MaterialRevisions expected = u.mrs(u.mr(p1, true, p1_4), u.mr(git, true, "g13", "g14"));
assertThat(getRevisionsBasedOnDependencies(p2, cruiseConfig, given), is(expected));
}
Aggregations