use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_whileComputingCompatibleRevisions.
@Test
public void shouldPrefer_combinationThatBringsLatestPossibleRevisionsOfMostMaterials_whileComputingCompatibleRevisions() throws Exception {
/**
* +------ git ------+
* | | |
* | | |
* v v v
* P1 P2 P3
* | | |
* | | |
* +-----> P4 <------+
*/
GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
String[] git_revs = { "g1", "g2", "g3", "g4" };
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(git));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(git));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p2), u.m(p1), u.m(p3));
CruiseConfig cruiseConfig = goConfigDao.load();
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g1");
String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2", "g3");
String p1_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
String p1_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g2");
String p1_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g4");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g1");
String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
String p2_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g3");
String p2_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g4");
// latest
String p2_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g2");
// Does this honour schedule order?
String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g1");
String p3_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g2");
String p3_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
String p3_4 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g3");
String p3_5 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), "g4");
MaterialRevisions given = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, true, p1_5), u.mr(p3, false, p3_5));
MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_5), u.mr(p1, false, p1_4), u.mr(p3, false, p3_2));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
assertThat(finalRevisions, is(expected));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldChooseTheRevisionFromSecondInAComplexSituation.
@Test
public void shouldChooseTheRevisionFromSecondInAComplexSituation() throws Exception {
// hg -> First git
// | \ |
// | Third <- Second
// | | /
// | | /
// +------> Last
//
HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
String[] hg_revs = { "h1", "h2" };
u.checkinInOrder(hg, hg_revs);
GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
String[] git_revs = { "g1", "g2" };
u.checkinInOrder(git, git_revs);
ScheduleTestUtil.AddedPipeline first = u.saveConfigWith("first", u.m(hg));
ScheduleTestUtil.AddedPipeline second = u.saveConfigWith("second", u.m(git));
ScheduleTestUtil.AddedPipeline third = u.saveConfigWith("third", u.m(first), u.m(second));
ScheduleTestUtil.AddedPipeline last = u.saveConfigWith("last", u.m(hg), u.m(second), u.m(third));
String first_1 = u.runAndPass(first, "h1");
String second_1 = u.runAndPass(second, "g1");
String second_2 = u.runAndPass(second, "g1");
String second_3 = u.runAndPass(second, "g2");
String second_4 = u.runAndPass(second, "g2");
String third_1 = u.runAndPass(third, first_1, second_2);
String third_2 = u.runAndPass(third, first_1, second_2);
String third_3 = u.runAndPass(third, first_1, second_2);
MaterialRevisions given = u.mrs(u.mr(hg, true, hg_revs), u.mr(second, true, second_4), u.mr(third, true, third_3));
MaterialRevisions expected = u.mrs(u.mr(hg, true, "h1"), u.mr(second, true, second_2), u.mr(third, true, third_3));
MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("last"));
assertThat(finalRevisions, is(expected));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class AutoTriggerDependencyResolutionTest method shouldResolveTriangleDependency.
/* TRIANGLE TEST BEGIN */
@Test
public void shouldResolveTriangleDependency() throws Exception {
GitMaterial git = new GitMaterial("git");
String[] git_revs = { "g1" };
u.checkinInOrder(git, git_revs);
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(git));
ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
ScheduleTestUtil.AddedPipeline p6 = u.saveConfigWith("p6", u.m(p4), u.m(p5));
String p4_1 = u.runAndPass(p4, "g1");
String p4_2 = u.runAndPass(p4, "g1");
String p5_1 = u.runAndPass(p5, p4_2);
String p4_3 = u.runAndPass(p4, "g1");
String p4_4 = u.runAndPass(p4, "g1");
PipelineConfigDependencyGraph graph = new PipelineConfigDependencyGraph(p6.config, new PipelineConfigDependencyGraph(p5.config), new PipelineConfigDependencyGraph(p4.config));
MaterialRevisions given = u.mrs(u.mr(p4, true, p4_4), u.mr(p5, true, p5_1));
MaterialRevisions expected = u.mrs(u.mr(p4, true, p4_2), u.mr(p5, true, p5_1));
assertThat(pipelineService.getRevisionsBasedOnDependencies(graph, given), is(expected));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitMultipleMaterialsTest method shouldIgnoreDestinationFolderWhenCloningMaterialWhenServerSide.
@Test
public void shouldIgnoreDestinationFolderWhenCloningMaterialWhenServerSide() throws Exception {
GitMaterial material1 = repo.createMaterial("dest1");
MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext(true));
assertThat(new File(pipelineDir, "dest1").exists(), is(false));
assertThat(new File(pipelineDir, ".git").exists(), is(true));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialAgentFactoryTest method shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace.
@Test
public void shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace() throws IOException {
String agentUuid = "uuid-01783738";
File workingDirectory = temporaryFolder.newFolder();
MaterialAgentFactory factory = new MaterialAgentFactory(new ProcessOutputStreamConsumer(new DevNull(), new DevNull()), workingDirectory, new AgentIdentifier("host", "1.1.1.1", agentUuid), packageRepositoryExtension, scmExtension);
GitMaterial gitMaterial = new GitMaterial("http://foo", "master", "dest_folder");
MaterialAgent agent = factory.createAgent(new MaterialRevision(gitMaterial));
assertThat(agent, is(instanceOf(AbstractMaterialAgent.class)));
SubprocessExecutionContext execCtx = (SubprocessExecutionContext) ReflectionUtil.getField(agent, "execCtx");
assertThat(execCtx.getProcessNamespace("fingerprint"), is(CachedDigestUtils.sha256Hex(String.format("%s%s%s", "fingerprint", agentUuid, gitMaterial.workingdir(workingDirectory)))));
}
Aggregations