Search in sources :

Example 36 with HgMaterial

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();
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial)

Example 37 with HgMaterial

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()));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HibernateCallback(org.springframework.orm.hibernate3.HibernateCallback) Matchers.containsString(org.hamcrest.Matchers.containsString) SQLQuery(org.hibernate.SQLQuery) Session(org.hibernate.Session) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 38 with HgMaterial

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<>());
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfigMother.createPipelineConfig(com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 39 with HgMaterial

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();
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfigMother.createPipelineConfig(com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 40 with HgMaterial

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)));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfigMother.createPipelineConfig(com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) DateTime(org.joda.time.DateTime) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)121 Test (org.junit.Test)107 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)34 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)29 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)23 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)15 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)10 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 Date (java.util.Date)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)9 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)8 Pagination (com.thoughtworks.go.server.util.Pagination)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)6 Modification (com.thoughtworks.go.domain.materials.Modification)6 File (java.io.File)6