use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class ResourcesTest method shouldValidateTree.
@Test
public void shouldValidateTree() {
Resource resource1 = new Resource("a#");
Resource resource2 = new Resource("b");
Resources resources = new Resources(resource1, resource2);
resources.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new PipelineConfig()));
assertThat(resource1.errors().size(), is(1));
assertThat(resource1.errors().firstError(), is(String.format("Resource name 'a#' is not valid. Valid names much match '%s'", Resource.VALID_REGEX)));
assertThat(resource2.errors().isEmpty(), is(true));
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class BuildCauseProducerService method autoSchedulePipeline.
public void autoSchedulePipeline(String pipelineName, ServerHealthStateOperationResult result, long trackingId) {
schedulingPerformanceLogger.autoSchedulePipelineStart(trackingId, pipelineName);
try {
PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
newProduceBuildCause(pipelineConfig, new AutoBuild(goConfigService, pipelineService, pipelineName, systemEnvironment, materialChecker, serverHealthService), result, trackingId);
} finally {
schedulingPerformanceLogger.autoSchedulePipelineFinish(trackingId, pipelineName);
}
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldNotScheduleAnyNewPipelineWhenErrorHappens.
@Test
public void shouldNotScheduleAnyNewPipelineWhenErrorHappens() throws Exception {
String stageName = "invalidStageName";
PipelineConfig invalidPipeline = configHelper.addPipelineWithInvalidMaterial("invalidPipeline", stageName);
int beforeScheduling = pipelineDao.count(CaseInsensitiveString.str(invalidPipeline.name()));
autoSchedulePipelines();
int afterScheduling = pipelineDao.count(CaseInsensitiveString.str(invalidPipeline.name()));
assertThat(beforeScheduling, is(afterScheduling));
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class GoDashboardServiceTest method shouldUpdateCacheForPipelineGivenItsConfig.
@Test
public void shouldUpdateCacheForPipelineGivenItsConfig() throws Exception {
PipelineConfig pipelineConfig = configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1", "job1");
PipelineConfigs groupConfig = config.findGroup("group1");
GoDashboardPipeline pipeline = pipeline("pipeline1");
when(goConfigService.findGroupByPipeline(new CaseInsensitiveString("pipeline1"))).thenReturn(groupConfig);
when(dashboardCurrentStateLoader.pipelineFor(pipelineConfig, groupConfig)).thenReturn(pipeline);
service.updateCacheForPipeline(pipelineConfig);
verify(cache).put(pipeline);
}
use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.
the class BuildAssignmentServiceTest method shouldNotMatchAnElasticJobToAnElasticAgentOnlyIfThePluginIdMatches.
@Test
public void shouldNotMatchAnElasticJobToAnElasticAgentOnlyIfThePluginIdMatches() {
PipelineConfig pipelineWithElasticJob = PipelineConfigMother.pipelineWithElasticJob(elasticProfileId1);
JobPlan jobPlan1 = new InstanceFactory().createJobPlan(pipelineWithElasticJob.first().getJobs().first(), schedulingContext);
jobPlans.add(jobPlan1);
when(elasticAgentPluginService.shouldAssignWork(elasticAgentInstance.elasticAgentMetadata(), "", jobPlan1.getElasticProfile(), null)).thenReturn(false);
buildAssignmentService.onTimer();
JobPlan matchingJob = buildAssignmentService.findMatchingJob(elasticAgentInstance);
assertThat(matchingJob, is(nullValue()));
assertThat(buildAssignmentService.jobPlans().size(), is(1));
}
Aggregations