use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldNotTriggerPipelineWhenItHasAlreadyRunWithPeggedRevisions_WithFanInOff.
@Test
public void shouldNotTriggerPipelineWhenItHasAlreadyRunWithPeggedRevisions_WithFanInOff() throws Exception {
// p1 <- SVN
// | /
// v v
// p2 <- git
SystemEnvironment env = mock(SystemEnvironment.class);
when(env.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
SvnMaterial svn = u.wf(new SvnMaterial("url", "username", "password", false), "folder1");
u.checkinInOrder(svn, "s1", "s2");
GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
u.checkinFile(git, "g1", new File("some_file.txt"), ModifiedAction.modified);
u.checkinFile(git, "g2", new File("some_new_file.txt"), ModifiedAction.modified);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(svn));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1), u.m(svn), u.m(git));
String p1_1 = u.runAndPass(p1, "s1");
String p2_1 = u.runAndPass(p2, p1_1, "s1", "g1");
String p2_2 = u.runAndPass(p2, p1_1, "s1", "g2");
MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, true, "s2"), u.mr(git, true, "g2") });
MaterialRevisions previousRevisions = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, false, "s1"), u.mr(git, false, "g2") });
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p2.config.name().toString(), env, materialChecker, serverHealthService);
pipelineTimeline.update();
BuildCause buildCause = autoBuild.onModifications(given, false, previousRevisions);
assertThat(buildCause, is(nullValue()));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method should_NOT_triggerWithRevisionOfUpstream_whichHasRunUsingMutuallyIncompatibleRevisions.
@Test
public void should_NOT_triggerWithRevisionOfUpstream_whichHasRunUsingMutuallyIncompatibleRevisions() {
/**
* |> P4
* / ^
* / |
* / |
* git -----> P1 ----> P3 (manual)
* \ ^
* \ |
* \ |
* V |
* P2
*/
GitMaterial git = u.wf(new GitMaterial("git"), "folder");
String[] git_revs = { "g1", "g2" };
int i = 1;
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));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p3), u.m(p1));
CruiseConfig cruiseConfig = goConfigDao.load();
int extraHours5 = i++;
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(extraHours5), "g1");
int extraHours4 = i++;
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(extraHours4), p1_1);
int extraHours3 = i++;
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(extraHours3), p1_1, p2_1);
int extraHours2 = i++;
String p4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p4, u.d(extraHours2), p3_1, p1_1);
int extraHours1 = i++;
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(extraHours1), "g1");
//p2 is running
u.scheduleWith(p2, p1_2);
int extraHours = i++;
String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(extraHours), p1_2, p2_1);
pipelineTimeline.update();
final MaterialRevisions given = new MaterialRevisions();
given.addRevision(u.mr(p3, true, p3_2));
given.addRevision(u.mr(p1, true, p1_2));
assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(given));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method fanInBehaviourShouldBeCorrectWhenStagesHaveDifferentNamesInGraph.
@Test
public void fanInBehaviourShouldBeCorrectWhenStagesHaveDifferentNamesInGraph() {
int i = 1;
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
String[] git_revs1 = { "g11", "g12" };
u.checkinInOrder(git1, u.d(i++), git_revs1);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", "stage1", u.m(git1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", "stage2", u.m(p1));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", "stage3", u.m(p1));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", "stage4", u.m(p2), u.m(p3));
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++), p1_1);
MaterialRevisions given = u.mrs(u.mr(p2, true, p2_1), u.mr(p3, true, p3_1));
assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(given));
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12");
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
given = u.mrs(u.mr(p2, true, p2_2), u.mr(p3, false, p3_1));
MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_1), u.mr(p3, true, p3_1));
assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(expected));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldTwistFaninBehaviourWithDifferentConfiguration.
@Test
public void shouldTwistFaninBehaviourWithDifferentConfiguration() {
int i = 1;
GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder1");
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 c1 = u.saveConfigWith("c1", u.m(git1), u.m(git2));
ScheduleTestUtil.AddedPipeline c2 = u.saveConfigWith("c2", u.m(git1));
ScheduleTestUtil.AddedPipeline c3 = u.saveConfigWith("c3", u.m(git1), u.m(c1), u.m(c2));
ScheduleTestUtil.AddedPipeline c4 = u.saveConfigWith("c4", u.m(c1), u.m(c2), u.m(c3));
ScheduleTestUtil.AddedPipeline c5 = u.saveConfigWith("c5", u.m(git2));
ScheduleTestUtil.AddedPipeline c6 = u.saveConfigWith("c6", u.m(git1), u.m(c1), u.m(c4), u.m(c5));
CruiseConfig cruiseConfig = goConfigDao.load();
String c1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c1, u.d(i++), "g11", "g21");
String c2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c2, u.d(i++), "g11");
String c3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c3, u.d(i++), "g11", c1_1, c2_1);
String c4_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c4, u.d(i++), c1_1, c2_1, c3_1);
String c5_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c5, u.d(i++), "g21");
String c6_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c6, u.d(i++), "g11", c1_1, c4_1, c5_1);
String c1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c1, u.d(i++), "g11", "g22");
String c5_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c5, u.d(i++), "g22");
String c4_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(c4, u.d(i++), c1_2, c2_1, c3_1);
MaterialRevisions given = u.mrs(u.mr(git1, false, "g11"), u.mr(c1, true, c1_2), u.mr(c4, true, c4_2), u.mr(c5, true, c5_2));
MaterialRevisions expected = u.mrs(u.mr(git1, false, "g11"), u.mr(c1, true, c1_1), u.mr(c4, true, c4_1), u.mr(c5, true, c5_1));
MaterialRevisions actual = getRevisionsBasedOnDependencies(c6, cruiseConfig, given);
assertThat(actual, is(expected));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldTriggerPipelineWhenThereAreNoNewChangesButMaterialIsRemoved_WithFanInOff.
@Test
public void shouldTriggerPipelineWhenThereAreNoNewChangesButMaterialIsRemoved_WithFanInOff() throws Exception {
// p1 <- SVN
// | /
// v v
// p2 <- git
SystemEnvironment env = mock(SystemEnvironment.class);
when(env.enforceRevisionCompatibilityWithUpstream()).thenReturn(false);
SvnMaterial svn = u.wf(new SvnMaterial("url", "username", "password", false), "folder1");
u.checkinInOrder(svn, "s1", "s2");
GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
u.checkinInOrder(git, "g1", "g2");
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(svn));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1), u.m(svn), u.m(git));
String p1_1 = u.runAndPass(p1, "s1");
String p2_1 = u.runAndPass(p2, p1_1, "s1", "g1");
configHelper.setMaterialConfigForPipeline("p2", u.m(p1).materialConfig(), u.m(svn).materialConfig());
p2 = new ScheduleTestUtil.AddedPipeline(goConfigService.currentCruiseConfig().pipelineConfigByName(new CaseInsensitiveString("p2")), p2.material);
MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, true, "s1") });
MaterialRevisions previousRevisions = u.mrs(new MaterialRevision[] { u.mr(p1, false, p1_1), u.mr(svn, true, "s1") });
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, p2.config.name().toString(), env, materialChecker, serverHealthService);
pipelineTimeline.update();
BuildCause buildCause = autoBuild.onModifications(given, true, previousRevisions);
assertThat(buildCause, is(notNullValue()));
assertThat(buildCause.getMaterialRevisions(), is(given));
}
Aggregations