use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class ValueStreamMapPerformanceTest method setupVSM.
private CruiseConfig setupVSM(int numberOfDownstreamPipelines) {
HgMaterial hg = new HgMaterial("hgurl", "folder");
String hg_revs = "hg1";
u.checkinInOrder(hg, hg_revs);
ScheduleTestUtil.AddedPipeline up = u.saveConfigWith("u", new ScheduleTestUtil.MaterialDeclaration(hg, "dest"));
String up_r = u.runAndPass(up, hg_revs);
ScheduleTestUtil.AddedPipeline previouslyCreatedPipeline = up;
String previousRun = up_r;
for (int i = 0; i < numberOfDownstreamPipelines; i++) {
DependencyMaterial dep = new DependencyMaterial(previouslyCreatedPipeline.config.name(), previouslyCreatedPipeline.config.get(0).name());
ScheduleTestUtil.AddedPipeline d = u.saveConfigWith("d" + i, new ScheduleTestUtil.MaterialDeclaration(dep, "random"));
String currentRun = u.runAndPass(d, previousRun);
previouslyCreatedPipeline = d;
previousRun = currentRun;
}
return goConfigDao.load();
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MaterialRepositoryWithH2IntegrationTest method materialFingerprintShouldUseTheHashAlgoritmInMigration47.
@Test
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void materialFingerprintShouldUseTheHashAlgoritmInMigration47() throws Exception {
final HgMaterial material = new HgMaterial("url", null);
byte[] fingerprint = (byte[]) repo.getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
String pattern = format("'type=%s%surl=%s'", material.getType(), AbstractMaterial.FINGERPRINT_DELIMITER, material.getUrl());
SQLQuery query = session.createSQLQuery(format("CALL HASH('SHA256', STRINGTOUTF8(%s), 1)", pattern));
return query.uniqueResult();
}
});
assertThat(Hex.encodeHexString(fingerprint), is(material.getFingerprint()));
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldReturnEarliestPMRFor1Material.
@Test
public void shouldReturnEarliestPMRFor1Material() throws Exception {
HgMaterial hgmaterial = MaterialsMother.hgMaterial("first");
PipelineConfig pipelineConfig = createPipelineConfig(PIPELINE_NAME, "stage", "job");
pipelineConfig.setMaterialConfigs(new MaterialConfigs(hgmaterial.config()));
DateTime date = new DateTime(1984, 12, 23, 0, 0, 0, 0);
long firstId = createPipeline(hgmaterial, pipelineConfig, 1, oneModifiedFile("3", date.plusDays(2).toDate()), oneModifiedFile("2", date.plusDays(2).toDate()), oneModifiedFile("1", date.plusDays(3).toDate()));
long secondId = createPipeline(hgmaterial, pipelineConfig, 2, oneModifiedFile("5", date.plusDays(1).toDate()), oneModifiedFile("4", date.toDate()));
PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
ArrayList<PipelineTimelineEntry> entries = new ArrayList<>();
pipelineRepository.updatePipelineTimeline(pipelineTimeline, entries);
assertThat(pipelineTimeline.getEntriesFor(PIPELINE_NAME).size(), is(2));
assertThat(entries.size(), is(2));
assertThat(entries, hasItem(expected(firstId, Collections.singletonMap(hgmaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(2).toDate(), "123", hgmaterial.getFingerprint(), 10))), 1)));
assertThat(entries, hasItem(expected(secondId, Collections.singletonMap(hgmaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(1).toDate(), "12", hgmaterial.getFingerprint(), 8))), 2)));
assertThat(pipelineTimeline.getEntriesFor(PIPELINE_NAME), hasItem(expected(firstId, Collections.singletonMap(hgmaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(2).toDate(), "123", hgmaterial.getFingerprint(), 10))), 1)));
assertThat(pipelineTimeline.getEntriesFor(PIPELINE_NAME), hasItem(expected(secondId, Collections.singletonMap(hgmaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(1).toDate(), "12", hgmaterial.getFingerprint(), 8))), 2)));
assertThat(pipelineTimeline.maximumId(), is(secondId));
long thirdId = createPipeline(hgmaterial, pipelineConfig, 3, oneModifiedFile("30", date.plusDays(10).toDate()));
pipelineRepository.updatePipelineTimeline(pipelineTimeline, new ArrayList<>());
assertThat(pipelineTimeline.getEntriesFor(PIPELINE_NAME).size(), is(3));
assertThat(pipelineTimeline.getEntriesFor(PIPELINE_NAME), hasItem(expected(thirdId, Collections.singletonMap(hgmaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(10).toDate(), "1234", hgmaterial.getFingerprint(), 12))), 3)));
assertThat(pipelineTimeline.maximumId(), is(thirdId));
assertThat(pipelineSqlMapDao.pipelineByIdWithMods(firstId).getNaturalOrder(), is(1.0));
assertThat(pipelineSqlMapDao.pipelineByIdWithMods(secondId).getNaturalOrder(), is(0.5));
assertThat(pipelineSqlMapDao.pipelineByIdWithMods(thirdId).getNaturalOrder(), is(2.0));
PipelineTimeline pipelineTimeline2 = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
pipelineRepository.updatePipelineTimeline(pipelineTimeline2, new ArrayList<>());
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldAddExistingPipelinesToTimelineForNewTimeline.
@Test
public void shouldAddExistingPipelinesToTimelineForNewTimeline() {
HgMaterial hgmaterial = MaterialsMother.hgMaterial(UUID.randomUUID().toString());
PipelineConfig pipelineConfig = createPipelineConfig(PIPELINE_NAME, "stage", "job");
pipelineConfig.setMaterialConfigs(new MaterialConfigs(hgmaterial.config()));
DateTime date = new DateTime(1984, 12, 23, 0, 0, 0, 0);
long firstId = createPipeline(hgmaterial, pipelineConfig, 1, oneModifiedFile("3", date.plusDays(2).toDate()), oneModifiedFile("2", date.plusDays(2).toDate()), oneModifiedFile("1", date.plusDays(3).toDate()));
long secondId = createPipeline(hgmaterial, pipelineConfig, 2, oneModifiedFile("5", date.plusDays(1).toDate()), oneModifiedFile("4", date.toDate()));
PipelineTimeline mods = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
mods.update();
assertThat(pipelineSqlMapDao.pipelineByIdWithMods(firstId).getNaturalOrder(), is(1.0));
assertThat(pipelineSqlMapDao.pipelineByIdWithMods(secondId).getNaturalOrder(), is(0.5));
PipelineTimeline modsAfterReboot = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
modsAfterReboot.update();
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldReturnEarliestPMRForMultipleMaterial.
@Test
public void shouldReturnEarliestPMRForMultipleMaterial() throws Exception {
final HgMaterial hgmaterial = MaterialsMother.hgMaterial("first");
final SvnMaterial svnMaterial = MaterialsMother.svnMaterial();
PipelineConfig pipelineConfig = createPipelineConfig(PIPELINE_NAME, "stage", "job");
pipelineConfig.setMaterialConfigs(new MaterialConfigs(hgmaterial.config(), svnMaterial.config()));
final DateTime date = new DateTime(1984, 12, 23, 0, 0, 0, 0);
long first = save(pipelineConfig, 1, 1.0, new MaterialRevision(hgmaterial, oneModifiedFile("13", date.plusDays(2).toDate()), oneModifiedFile("12", date.plusDays(2).toDate()), oneModifiedFile("11", date.plusDays(3).toDate())), new MaterialRevision(svnMaterial, oneModifiedFile("23", date.plusDays(6).toDate()), oneModifiedFile("22", date.plusDays(2).toDate()), oneModifiedFile("21", date.plusDays(2).toDate())));
long second = save(pipelineConfig, 2, 0.0, new MaterialRevision(hgmaterial, oneModifiedFile("15", date.plusDays(3).toDate()), oneModifiedFile("14", date.plusDays(2).toDate())), new MaterialRevision(svnMaterial, oneModifiedFile("25", date.plusDays(5).toDate())));
PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
pipelineRepository.updatePipelineTimeline(pipelineTimeline, new ArrayList<>());
Collection<PipelineTimelineEntry> modifications = pipelineTimeline.getEntriesFor(PIPELINE_NAME);
assertThat(modifications.size(), is(2));
assertThat(modifications, hasItem(expected(first, new HashMap<String, List<PipelineTimelineEntry.Revision>>() {
{
put(hgmaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(2).toDate(), "123", hgmaterial.getFingerprint(), 8)));
put(svnMaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(6).toDate(), "456", svnMaterial.getFingerprint(), 12)));
}
}, 1)));
assertThat(modifications, hasItem(expected(second, new HashMap<String, List<PipelineTimelineEntry.Revision>>() {
{
put(hgmaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(3).toDate(), "234", hgmaterial.getFingerprint(), 9)));
put(svnMaterial.getFingerprint(), a(new PipelineTimelineEntry.Revision(date.plusDays(5).toDate(), "345", svnMaterial.getFingerprint(), 10)));
}
}, 2)));
}
Aggregations