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));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs 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));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt.
@Test
public void hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt() {
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);
MaterialRevision notBuiltRevision = saveOneScmModification(hgMaterial, "user", "file2");
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, notBuiltRevision.getLatestModification()));
assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(false));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldCreateJobsMatchingRealAgentsIfRunOnAllAgentsIsSet.
@Test
public void shouldCreateJobsMatchingRealAgentsIfRunOnAllAgentsIsSet() throws Exception {
JobConfigs jobConfigs = new JobConfigs();
ArtifactPlans artifactPlans = new ArtifactPlans();
ArtifactPropertiesGenerators generators = new ArtifactPropertiesGenerators();
generators.add(new ArtifactPropertiesGenerator("property-name", "artifact-path", "artifact-xpath"));
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test-job"), new Resources(), artifactPlans, 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));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class DeletePackageRepositoryCommandTest method shouldNotDeletePackageRepositoryIfItIsUsedAsAMaterialInPipeline.
@Test
public void shouldNotDeletePackageRepositoryIfItIsUsedAsAMaterialInPipeline() throws Exception {
PackageDefinition pkg = new PackageDefinition();
pkg.setId("pkg");
packageRepository.addPackage(pkg);
PackageMaterialConfig packageMaterial = new PackageMaterialConfig("pkg");
PipelineConfig pipeline = new PipelineConfig();
pipeline.setMaterialConfigs(new MaterialConfigs(packageMaterial));
cruiseConfig.addPipeline("first", pipeline);
assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
assertThat(cruiseConfig.getPackageRepositories().find(repoId), is(packageRepository));
DeletePackageRepositoryCommand command = new DeletePackageRepositoryCommand(goConfigService, packageRepository, currentUser, result);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
}
Aggregations