use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method findModificationsSince_shouldHandleConcurrentModificationToCache.
@Test
public void findModificationsSince_shouldHandleConcurrentModificationToCache() throws InterruptedException {
final SvnMaterial svn = MaterialsMother.svnMaterial();
final MaterialRevision first = saveOneScmModification(svn, "user1", "file1");
final MaterialRevision second = saveOneScmModification(svn, "user2", "file2");
final MaterialRevision third = saveOneScmModification(svn, "user2", "file3");
repo = new MaterialRepository(sessionFactory, goCache = new GoCache(goCache) {
@Override
public Object get(String key) {
Object value = super.get(key);
// sleep so we can have multiple threads enter the critical section
TestUtils.sleepQuietly(200);
return value;
}
}, 200, transactionSynchronizationManager, materialConfigConverter, materialExpansionService, databaseStrategy);
Thread thread1 = new Thread(new Runnable() {
public void run() {
repo.findModificationsSince(svn, first);
}
});
thread1.start();
TestUtils.sleepQuietly(50);
Thread thread2 = new Thread(new Runnable() {
public void run() {
repo.findModificationsSince(svn, second);
}
});
thread2.start();
thread1.join();
thread2.join();
assertThat(repo.cachedModifications(repo.findMaterialInstance(svn)).size(), is(3));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method findModificationsSince_shouldCacheResults.
@Test
public void findModificationsSince_shouldCacheResults() {
SvnMaterial material = MaterialsMother.svnMaterial();
MaterialRevision zero = saveOneScmModification(material, "user1", "file1");
MaterialRevision first = saveOneScmModification(material, "user1", "file1");
MaterialRevision second = saveOneScmModification(material, "user2", "file2");
MaterialRevision third = saveOneScmModification(material, "user2", "file2");
repo.findModificationsSince(material, first);
HibernateTemplate mockTemplate = mock(HibernateTemplate.class);
repo.setHibernateTemplate(mockTemplate);
List<Modification> modifications = repo.findModificationsSince(material, first);
assertThat(modifications.size(), is(2));
assertEquals(third.getLatestModification(), modifications.get(0));
assertEquals(second.getLatestModification(), modifications.get(1));
verifyNoMoreInteractions(mockTemplate);
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial 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.config.materials.svn.SvnMaterial 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.config.materials.svn.SvnMaterial 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