Search in sources :

Example 61 with MaterialConfigs

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

the class PipelineRepositoryIntegrationTest method shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations.

@Test
public void shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations() {
    ScheduleTestUtil u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git"), "folder1");
    u.checkinInOrder(git1, "g1");
    GitMaterial git2 = u.wf(new GitMaterial("git"), "folder2");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("P", u.m(git1), u.m(git2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    u.checkinInOrder(git1, u.d(i++), "g2");
    u.runAndPass(p, "g1", "g2");
    u.runAndPass(p, "g2", "g1");
    PipelineTimeline timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    timeline.updateTimelineOnInit();
    List<PipelineTimelineEntry> timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
    assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
    assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
    List<PipelineTimelineEntry.Revision> flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g1"));
    assertThat(flyweightsRevs.get(1).revision, is("g2"));
    assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
    assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g2"));
    assertThat(flyweightsRevs.get(1).revision, is("g1"));
    MaterialConfigs materials = CLONER.deepClone(p.config.materialConfigs());
    Collections.reverse(materials);
    configHelper.setMaterialConfigForPipeline("P", materials.toArray(new MaterialConfig[0]));
    goConfigDao.load();
    timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    timeline.updateTimelineOnInit();
    timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
    assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
    assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g1"));
    assertThat(flyweightsRevs.get(1).revision, is("g2"));
    assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
    assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g2"));
    assertThat(flyweightsRevs.get(1).revision, is("g1"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.Test)

Example 62 with MaterialConfigs

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

the class PipelineScheduleQueueIntegrationTest method shouldCreateJobsMatchingRealAgentsIfRunOnAllAgentsIsSet.

@Test
public void shouldCreateJobsMatchingRealAgentsIfRunOnAllAgentsIsSet() {
    JobConfigs jobConfigs = new JobConfigs();
    ArtifactConfigs artifactConfigs = new ArtifactConfigs();
    ArtifactPropertiesConfig generators = new ArtifactPropertiesConfig();
    generators.add(new ArtifactPropertyConfig("property-name", "artifact-path", "artifact-xpath"));
    JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test-job"), new ResourceConfigs(), artifactConfigs, generators);
    jobConfig.setRunOnAllAgents(true);
    jobConfigs.add(jobConfig);
    StageConfig stage = new StageConfig(new CaseInsensitiveString("test-stage"), jobConfigs);
    MaterialConfigs materialConfigs = new MaterialConfigs(MaterialConfigsMother.dependencyMaterialConfig());
    PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("test-pipeline"), materialConfigs, stage);
    BuildCause cause = modifySomeFiles(pipelineConfig, ModificationsMother.nextRevision());
    saveRev(cause);
    configFileEditor.addAgent("localhost", "uuid1");
    configFileEditor.addAgent("localhost", "uuid2");
    configFileEditor.addAgent("localhost", "uuid3");
    configFileEditor.addAgentToEnvironment("env", "uuid1");
    configFileEditor.addPipeline(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stage.name()));
    queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), configFileEditor.currentConfig().agents()), "md5-test", new TimeProvider());
    List<JobPlan> plans = jobService.orderedScheduledBuilds();
    assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("test-job", 1)))));
    assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("test-job", 2)))));
    assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("test-job", 3)))));
    assertThat(plans.size(), is(3));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 63 with MaterialConfigs

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

the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWith_shouldCacheResultsForPipelineNameMaterialIdAndModificationId.

@Test
public void hasPipelineEverRunWith_shouldCacheResultsForPipelineNameMaterialIdAndModificationId() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial("hgUrl", "dest");
    MaterialRevision materialRevision = saveOneScmModification(hgMaterial, "user", "file");
    PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial.config()), "dev");
    MaterialRevisions materialRevisions = new MaterialRevisions(materialRevision);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    GoCache spyGoCache = spy(goCache);
    when(spyGoCache.get(any(String.class))).thenCallRealMethod();
    Mockito.doCallRealMethod().when(spyGoCache).put(any(String.class), any(Object.class));
    repo = new MaterialRepository(sessionFactory, spyGoCache, 2, transactionSynchronizationManager, materialConfigConverter, materialExpansionService, databaseStrategy);
    pipelineSqlMapDao.save(pipeline);
    MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, materialRevision.getLatestModification()));
    assertThat("should hit the db and cache it", repo.hasPipelineEverRunWith("mingle", revisions), is(true));
    assertThat("should have cached the result on the previous call", repo.hasPipelineEverRunWith("mingle", revisions), is(true));
    verify(spyGoCache, times(1)).put(any(String.class), eq(Boolean.TRUE));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) GoCache(com.thoughtworks.go.server.cache.GoCache) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 64 with MaterialConfigs

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

the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWith.

@Test
public void hasPipelineEverRunWith() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial("hgUrl", "dest");
    MaterialRevision materialRevision = saveOneScmModification(hgMaterial, "user", "file");
    PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial.config()), "dev");
    MaterialRevisions materialRevisions = new MaterialRevisions(materialRevision);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    pipelineSqlMapDao.save(pipeline);
    MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, materialRevision.getLatestModification()));
    assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 65 with MaterialConfigs

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

the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsAndMultipleRuns.

@Test
public void hasPipelineEverRunWithMultipleMaterialsAndMultipleRuns() {
    HgMaterial hgMaterial1 = MaterialsMother.hgMaterial("hgUrl", "dest");
    MaterialRevision hgMaterialRevision1 = saveOneScmModification(hgMaterial1, "user", "file");
    DependencyMaterial depMaterial1 = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
    MaterialRevision depMaterialRevision1 = saveOneDependencyModification(depMaterial1, "blahPipeline/1/blahStage/1");
    PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial1.config(), depMaterial1.config()), "dev");
    MaterialRevisions materialRevisions1 = new MaterialRevisions(hgMaterialRevision1, depMaterialRevision1);
    pipelineSqlMapDao.save(instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions1, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
    HgMaterial hgMaterial2 = MaterialsMother.hgMaterial("hgUrl", "dest");
    MaterialRevision hgMaterialRevision2 = saveOneScmModification(hgMaterial2, "user", "file");
    DependencyMaterial depMaterial2 = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
    MaterialRevision depMaterialRevision2 = saveOneDependencyModification(depMaterial2, "blahPipeline/2/blahStage/1");
    PipelineConfig pipelineConfig2 = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial2.config(), depMaterial2.config()), "dev");
    MaterialRevisions materialRevisions2 = new MaterialRevisions(hgMaterialRevision2, depMaterialRevision2);
    savePipeline(instanceFactory.createPipelineInstance(pipelineConfig2, BuildCause.createManualForced(materialRevisions2, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
    MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(depMaterial1, depMaterialRevision1.getLatestModification()), new MaterialRevision(hgMaterial2, hgMaterialRevision2.getLatestModification()));
    assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)218 Test (org.junit.Test)158 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)35 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)33 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)32 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)32 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)25 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)25 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)25 TimeProvider (com.thoughtworks.go.util.TimeProvider)25 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)21 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)14 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)14 Material (com.thoughtworks.go.domain.materials.Material)14 Materials (com.thoughtworks.go.config.materials.Materials)12