use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineWithTwoStages method scheduleAndCompleteFollowingStages.
protected void scheduleAndCompleteFollowingStages(Pipeline pipeline, JobResult result) {
Stage ft = new InstanceFactory().createStageInstance(ftStage(), new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
ft.setOrderId(pipeline.getFirstStage().getOrderId() + 1);
dbHelper.getStageDao().saveWithJobs(pipeline, ft);
dbHelper.completeStage(ft, result);
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class ArtifactPropertiesGeneratorRepositoryIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
dbHelper.onSetUp();
PipelineConfig pipelineConfig = PipelineMother.withSingleStageWithMaterials(PIPELINE_NAME, STAGE_NAME, BuildPlanMother.withBuildPlans(JOB_NAME, OTHER_JOB_NAME));
DefaultSchedulingContext schedulingContext = new DefaultSchedulingContext(DEFAULT_APPROVED_BY);
Pipeline savedPipeline = instanceFactory.createPipelineInstance(pipelineConfig, modifySomeFiles(pipelineConfig), schedulingContext, "md5-test", new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(savedPipeline);
Stage savedStage = savedPipeline.getFirstStage();
stageId = savedStage.getId();
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class ArtifactPlanRepositoryIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
dbHelper.onSetUp();
PipelineConfig pipelineConfig = PipelineMother.withSingleStageWithMaterials(PIPELINE_NAME, STAGE_NAME, BuildPlanMother.withBuildPlans(JOB_NAME, OTHER_JOB_NAME));
DefaultSchedulingContext schedulingContext = new DefaultSchedulingContext(DEFAULT_APPROVED_BY);
Pipeline savedPipeline = instanceFactory.createPipelineInstance(pipelineConfig, modifySomeFiles(pipelineConfig), schedulingContext, "md5-test", new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(savedPipeline);
Stage savedStage = savedPipeline.getFirstStage();
stageId = savedStage.getId();
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldLogWithInfoIfPipelineISScheduled.
@Test
public void shouldLogWithInfoIfPipelineISScheduled() throws Exception {
try (LogFixture logging = logFixtureFor(PipelineScheduleQueue.class, Level.DEBUG)) {
JobConfigs jobConfigs = new JobConfigs();
Resources resources = new Resources(new Resource("resource1"));
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"), resources, artifactPlans, generators);
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);
configFileEditor.addPipeline(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stage.name()));
BuildCause cause = modifySomeFiles(pipelineConfig, ModificationsMother.nextRevision());
saveRev(cause);
queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
assertThat(logging.getLog(), containsString("[Pipeline Schedule] Successfully scheduled pipeline test-pipeline, buildCause:[ModificationBuildCause: triggered by " + cause.getMaterialRevisions().latestRevision() + "]"));
}
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class PipelineScheduleQueueIntegrationTest method shouldCreateMultipleJobsIfRunMultipleInstanceIsSet.
@Test
public void shouldCreateMultipleJobsIfRunMultipleInstanceIsSet() throws Exception {
JobConfigs jobConfigs = new JobConfigs();
ArtifactPropertiesGenerators generators = new ArtifactPropertiesGenerators();
generators.add(new ArtifactPropertiesGenerator("property-name", "artifact-path", "artifact-xpath"));
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test-job"), new Resources(), new ArtifactPlans(), generators);
jobConfig.setRunInstanceCount(3);
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.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.size(), is(3));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("test-job", 1)))));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("test-job", 2)))));
assertThat(plans.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("test-job", 3)))));
}
Aggregations