Search in sources :

Example 96 with TimeProvider

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);
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) Stage(com.thoughtworks.go.domain.Stage) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 97 with TimeProvider

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();
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Stage(com.thoughtworks.go.domain.Stage) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext) Pipeline(com.thoughtworks.go.domain.Pipeline) Before(org.junit.Before)

Example 98 with TimeProvider

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();
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Before(org.junit.Before)

Example 99 with TimeProvider

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() + "]"));
    }
}
Also used : LogFixture(com.thoughtworks.go.util.LogFixture) 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 100 with TimeProvider

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)))));
}
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)

Aggregations

TimeProvider (com.thoughtworks.go.util.TimeProvider)137 Test (org.junit.Test)91 Date (java.util.Date)23 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)22 DateTime (org.joda.time.DateTime)17 GoConfigRevision (com.thoughtworks.go.domain.GoConfigRevision)13 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)11 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)11 Before (org.junit.Before)11 Username (com.thoughtworks.go.server.domain.Username)10 Pipeline (com.thoughtworks.go.domain.Pipeline)9 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)9 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)8 Stage (com.thoughtworks.go.domain.Stage)7 TransactionStatus (org.springframework.transaction.TransactionStatus)7 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)6 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)6 Material (com.thoughtworks.go.domain.materials.Material)5 TestingMaterial (com.thoughtworks.go.domain.materials.TestingMaterial)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5