use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class JobStatusListenerTest method setUp.
@Before
public void setUp() throws Exception {
goCache.clear();
dbHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao);
configHelper.onSetUp();
PipelineConfig pipelineConfig = withSingleStageWithMaterials(PIPELINE_NAME, STAGE_NAME, withBuildPlans(JOB_NAME));
configHelper.addPipeline(PIPELINE_NAME, STAGE_NAME);
savedPipeline = scheduleHelper.schedule(pipelineConfig, BuildCause.createWithModifications(modifyOneFile(pipelineConfig), ""), GoConstants.DEFAULT_APPROVED_BY);
JobInstance job = savedPipeline.getStages().first().getJobInstances().first();
job.setAgentUuid(UUID);
mockery = new ClassMockery();
stageStatusTopic = mockery.mock(StageStatusTopic.class);
}
use of com.thoughtworks.go.config.PipelineConfig 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));
}
use of com.thoughtworks.go.config.PipelineConfig 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));
}
use of com.thoughtworks.go.config.PipelineConfig 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));
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsInPeggedRevisionsCase.
@Test
public void hasPipelineEverRunWithMultipleMaterialsInPeggedRevisionsCase() {
HgMaterial firstMaterial = MaterialsMother.hgMaterial("first", "dest");
MaterialRevision first1 = saveOneScmModification("first1", firstMaterial, "user", "file", "comment");
MaterialRevision first2 = saveOneScmModification("first2", firstMaterial, "user", "file", "comment");
HgMaterial secondMaterial = MaterialsMother.hgMaterial("second", "dest");
MaterialRevision second1 = saveOneScmModification("second1", secondMaterial, "user", "file", "comment");
MaterialRevision second2 = saveOneScmModification("second2", secondMaterial, "user", "file", "comment");
MaterialRevisions firstRun = new MaterialRevisions(first1, second2);
MaterialRevisions secondRun = new MaterialRevisions(first2, second1);
PipelineConfig config = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(firstMaterial.config(), secondMaterial.config()), "dev");
savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(firstRun, "Pavan"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(secondRun, "Shilpa-who-gets-along-well-with-her"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
assertThat(repo.hasPipelineEverRunWith("mingle", new MaterialRevisions(first2, second2)), is(true));
}
Aggregations