Search in sources :

Example 1 with Subversion

use of com.thoughtworks.go.domain.materials.svn.Subversion in project gocd by gocd.

the class MaterialExpansionServiceCachingTest method shouldCacheSvnMaterialCheckExternalCommand.

@Test
public void shouldCacheSvnMaterialCheckExternalCommand() {
    SvnMaterialConfig svnMaterialConfig = svnMaterialConfig(svnRepo.projectRepositoryUrl(), "mainRepo");
    MaterialConfigs materialConfigs = new MaterialConfigs();
    String cacheKey = (MaterialExpansionService.class + "_cacheKeyForSvnMaterialCheckExternalCommand_" + svnMaterialConfig.getFingerprint()).intern();
    Subversion svn = (SvnCommand) goCache.get(cacheKey);
    assertNull(svn);
    materialExpansionService.expandForScheduling(svnMaterialConfig, materialConfigs);
    svn = (SvnCommand) goCache.get(cacheKey);
    assertNotNull(svn);
    assertThat(svn.getUrl().forCommandline(), is(svnMaterialConfig.getUrl()));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) Subversion(com.thoughtworks.go.domain.materials.svn.Subversion) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)

Example 2 with Subversion

use of com.thoughtworks.go.domain.materials.svn.Subversion in project gocd by gocd.

the class MaterialExpansionService method svn.

private Subversion svn(SvnMaterialConfig svnMaterialConfig) {
    String cacheKey = cacheKeyForSubversionMaterialCommand(svnMaterialConfig.getFingerprint());
    Subversion svnLazyLoaded = (SvnCommand) goCache.get(cacheKey);
    if (svnLazyLoaded == null || !svnLazyLoaded.getUrl().forCommandline().equals(svnMaterialConfig.getUrl())) {
        synchronized (cacheKey) {
            svnLazyLoaded = (SvnCommand) goCache.get(cacheKey);
            if (svnLazyLoaded == null || !svnLazyLoaded.getUrl().forCommandline().equals(svnMaterialConfig.getUrl())) {
                svnLazyLoaded = new SvnCommand(svnMaterialConfig.getFingerprint(), svnMaterialConfig.getUrl(), svnMaterialConfig.getUserName(), svnMaterialConfig.getPassword(), svnMaterialConfig.isCheckExternals());
                goCache.put(cacheKeyForSubversionMaterialCommand(svnMaterialConfig.getFingerprint()), svnLazyLoaded);
            }
        }
    }
    return svnLazyLoaded;
}
Also used : Subversion(com.thoughtworks.go.domain.materials.svn.Subversion) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand)

Example 3 with Subversion

use of com.thoughtworks.go.domain.materials.svn.Subversion in project gocd by gocd.

the class PipelineSchedulerIntegrationTest method setup.

@Before
public void setup() throws Exception {
    cruise = new Username(new CaseInsensitiveString("cruise"));
    dbHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    configHelper.onSetUp();
    repository = new SvnCommand(null, testRepo.projectRepositoryUrl());
    configHelper.addPipeline(PIPELINE_MINGLE, DEV_STAGE, repository, "unit", "functional");
    configHelper.addStageToPipeline(PIPELINE_MINGLE, FT_STAGE);
    Subversion wrongRepository = new SvnCommand(null, "wrongurl");
    configHelper.addPipeline(PIPELINE_EVOLVE, DEV_STAGE, wrongRepository, "unit", "functional");
    goConfigService.forceNotifyListeners();
    serverHealthService.removeAllLogs();
    goCache.clear();
}
Also used : Username(com.thoughtworks.go.server.domain.Username) Subversion(com.thoughtworks.go.domain.materials.svn.Subversion) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 4 with Subversion

use of com.thoughtworks.go.domain.materials.svn.Subversion in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationTest method should_NOT_markAsChangedWhenMaterialIsReIntroducedWithSameRevisionsToPipeline.

@Test
public void should_NOT_markAsChangedWhenMaterialIsReIntroducedWithSameRevisionsToPipeline() throws Exception {
    SvnMaterial svn1 = SvnMaterial.createSvnMaterialWithMock(repository);
    svn1.setFolder("another_repo");
    mingleConfig = configHelper.replaceMaterialForPipeline(MINGLE_PIPELINE_NAME, svn1.config());
    runAndPassWith(svn1, "foo.c", svnRepository);
    SvnTestRepo svn2Repository = new SvnTestRepo(temporaryFolder);
    Subversion repository2 = new SvnCommand(null, svn2Repository.projectRepositoryUrl());
    SvnMaterial svn2 = SvnMaterial.createSvnMaterialWithMock(repository2);
    svn2.setFolder("boulder");
    checkinFile(svn2, "bar.c", svn2Repository);
    mingleConfig = configHelper.addMaterialToPipeline(MINGLE_PIPELINE_NAME, svn2.config());
    scheduleHelper.autoSchedulePipelinesWithRealMaterials(MINGLE_PIPELINE_NAME);
    assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
    BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
    verifyChanged(svn2, mingleBuildCause, true);
    // this should not have changed, as foo.c was already built in the previous instance
    verifyChanged(svn1, mingleBuildCause, false);
    runAndPass(mingleBuildCause.getMaterialRevisions());
    mingleConfig = configHelper.replaceMaterialForPipeline(MINGLE_PIPELINE_NAME, svn1.config());
    scheduleHelper.autoSchedulePipelinesWithRealMaterials(MINGLE_PIPELINE_NAME);
    assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
    mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
    // this should not have changed, as foo.c was already built in the previous instance
    verifyChanged(svn1, mingleBuildCause, false);
    runAndPassWith(svn1, "baz.c", svnRepository);
    mingleConfig = configHelper.addMaterialToPipeline(MINGLE_PIPELINE_NAME, svn2.config());
    checkinFile(svn1, "quux.c", svnRepository);
    scheduleHelper.autoSchedulePipelinesWithRealMaterials(MINGLE_PIPELINE_NAME);
    assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
    mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
    verifyChanged(svn2, mingleBuildCause, false);
    verifyChanged(svn1, mingleBuildCause, true);
}
Also used : Subversion(com.thoughtworks.go.domain.materials.svn.Subversion) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Aggregations

Subversion (com.thoughtworks.go.domain.materials.svn.Subversion)4 SvnCommand (com.thoughtworks.go.domain.materials.svn.SvnCommand)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)1 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)1 Username (com.thoughtworks.go.server.domain.Username)1 Test (org.junit.Test)1