Search in sources :

Example 56 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildCauseProducerServiceConfigRepoIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    hgRepo = new HgTestRepo("testHgRepo", temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    materialConfig = hgRepo.materialConfig();
    configHelper.addConfigRepo(new ConfigRepoConfig(materialConfig, "gocd-xml"));
    logger = mock(MDUPerformanceLogger.class);
    TestingEmailSender emailSender = new TestingEmailSender();
    SystemDiskSpaceChecker mockDiskSpaceChecker = Mockito.mock(SystemDiskSpaceChecker.class);
    StageService stageService = mock(StageService.class);
    ConfigDbStateRepository configDbStateRepository = mock(ConfigDbStateRepository.class);
    goDiskSpaceMonitor = new GoDiskSpaceMonitor(goConfigService, systemEnvironment, serverHealthService, emailSender, mockDiskSpaceChecker, mock(ArtifactsService.class), stageService, configDbStateRepository);
    goDiskSpaceMonitor.initialize();
    worker = new MaterialUpdateListener(configTopic, materialDatabaseUpdater, logger, goDiskSpaceMonitor);
    xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
    configTestRepo = new ConfigTestRepo(hgRepo, xmlWriter);
    this.material = (HgMaterial) materialConfigConverter.toMaterial(materialConfig);
    pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
    pipelineConfig.materialConfigs().clear();
    pipelineConfig.materialConfigs().add(materialConfig);
    PIPELINE_NAME = CaseInsensitiveString.str(pipelineConfig.name());
    configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
    materialUpdateService.updateMaterial(material);
    // time for messages to pass through all services
    waitForMaterialNotInProgress();
    pipelineConfig = goConfigService.pipelineConfigNamed(pipelineConfig.name());
    pipelineScheduleQueue.clear();
    // check test setup
    Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs());
    MaterialRevisions peggedRevisions = new MaterialRevisions();
    firstRevisions = materialChecker.findLatestRevisions(peggedRevisions, materials);
    assertThat(firstRevisions.isMissingModifications(), is(false));
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) GoDiskSpaceMonitor(com.thoughtworks.go.server.cronjob.GoDiskSpaceMonitor) HgTestRepo(com.thoughtworks.go.helper.HgTestRepo) ConfigTestRepo(com.thoughtworks.go.helper.ConfigTestRepo) Before(org.junit.Before)

Example 57 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal.

@Test
public void shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal() throws Exception {
    SvnTestRepoWithExternal repo = new SvnTestRepoWithExternal(temporaryFolder);
    repositoryForMaterial(repo);
    prepareAPipelineWithHistory();
    checkInFiles("foo");
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    materialDatabaseUpdater.updateMaterial(svnMaterial);
    buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
    assertThat(result.canContinue(), is(true));
    BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(CaseInsensitiveString.str(mingleConfig.name()));
    MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
    assertThat(materialRevisions.getRevisions().size(), is(2));
    Materials materials = materialRevisions.getMaterials();
    assertThat(materials.size(), is(2));
    assertThat(materials.get(0), is(svnMaterial));
    SvnMaterial external = (SvnMaterial) materials.get(1);
    assertThat(external.getUrl(), is(repo.externalRepositoryUrl()));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 58 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModifications.

@Test
public void shouldCreateBuildCauseWithModifications() throws Exception {
    repositoryForMaterial(new SvnTestRepo(temporaryFolder));
    prepareAPipelineWithHistory();
    checkInFiles("foo");
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    materialDatabaseUpdater.updateMaterial(svnMaterial);
    buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
    assertThat(result.canContinue(), is(true));
    BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(CaseInsensitiveString.str(mingleConfig.name()));
    MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
    assertThat(materialRevisions.getRevisions().size(), is(1));
    Materials materials = materialRevisions.getMaterials();
    assertThat(materials.size(), is(1));
    assertThat(materials.get(0), is(svnMaterial));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 59 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldPersistMaterialsWithRealPassword.

@Test
public void shouldPersistMaterialsWithRealPassword() {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    addRevision(materialRevisions, MaterialsMother.svnMaterial("http://username:password@localhost"));
    addRevision(materialRevisions, MaterialsMother.hgMaterial("http://username:password@localhost"));
    addRevision(materialRevisions, new GitMaterial("git://username:password@localhost"));
    addRevision(materialRevisions, new P4Material("localhost:1666", "view"));
    BuildCause buildCause = BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS);
    Pipeline pipeline = new Pipeline("Test", buildCause);
    save(pipeline);
    Pipeline loaded = pipelineDao.mostRecentPipeline("Test");
    Materials materials = loaded.getMaterials();
    for (Material material : materials) {
        assertThat(((ScmMaterial) material).getUrl(), not(containsString("******")));
    }
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Materials(com.thoughtworks.go.config.materials.Materials) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 60 with Materials

use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.

the class MaterialRevisionBuilder method depInstance.

public Tuple depInstance(String pipelineName, int counter, Date modifiedTime, Tuple... buildCause) {
    String key = key(pipelineName, counter, modifiedTime);
    if (!instanceToRevision.containsKey(key)) {
        if (buildCause.length == 0) {
            throw new RuntimeException("Cannot create instance without a buildcause. You can retrive it without buildcause once it has been created");
        }
        DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(STAGE_NAME));
        DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, counter, "label", STAGE_NAME, 1);
        instanceToRevision.put(key, revision.convert(material, modifiedTime));
        final long id = getNextId();
        org.mockito.Mockito.when(pipelineDao.findPipelineByNameAndCounter(pipelineName, counter)).thenReturn(pipeline(id));
        org.mockito.Mockito.when(materialRepository.findMaterialRevisionsForPipeline(id)).thenReturn(buildCauseOfThisPipeline(buildCause));
    }
    MaterialRevision materialRevision = instanceToRevision.get(key);
    Materials materials = new Materials();
    for (MaterialRevision revision : buildCauseOfThisPipeline(buildCause)) {
        materials.add(revision.getMaterial());
    }
    PipelineConfig config = new PipelineConfig(new CaseInsensitiveString(pipelineName), materials.convertToConfigs(), new StageConfig(new CaseInsensitiveString(STAGE_NAME), new JobConfigs()));
    return new Tuple(new PipelineConfigDependencyGraph(config, dependencyGraphsFor(buildCause)), materialRevision);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)63 Test (org.junit.Test)47 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)27 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)17 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)13 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)12 Material (com.thoughtworks.go.domain.materials.Material)11 Modification (com.thoughtworks.go.domain.materials.Modification)11 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)10 TimeProvider (com.thoughtworks.go.util.TimeProvider)10 File (java.io.File)10 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)9 Date (java.util.Date)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5