Search in sources :

Example 11 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ScheduleServiceIntegrationTest method runAndPass.

private Pipeline runAndPass(PipelineConfig pipelineConfig, int counter) {
    BuildCause buildCause = ModificationsMother.modifySomeFiles(pipelineConfig);
    dbHelper.saveMaterials(buildCause.getMaterialRevisions());
    String pipelineName = pipelineConfig.name().toString();
    pipelineScheduleQueue.schedule(pipelineName, buildCause);
    scheduleService.autoSchedulePipelinesFromRequestBuffer();
    Pipeline pipeline = pipelineDao.findPipelineByNameAndCounter(pipelineName, counter);
    pipeline = pipelineDao.loadAssociations(pipeline, pipelineName);
    dbHelper.pass(pipeline);
    return pipeline;
}
Also used : BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 12 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class PipelineScheduleServiceTest method shouldForceStagePlanWithModificationsSinceLast.

@Test
public void shouldForceStagePlanWithModificationsSinceLast() throws Exception {
    Pipeline completedMingle = scheduleAndCompleteInitialPipelines();
    pipelineDao.loadPipeline(completedMingle.getId());
    TestingMaterial testingMaterial = new TestingMaterial();
    mingleConfig.setMaterialConfigs(new MaterialConfigs(testingMaterial.config()));
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(testingMaterial, testingMaterial.modificationsSince(null, null, subprocessExecutionContext));
    BuildCause buildCause = BuildCause.createManualForced(revisions, Username.ANONYMOUS);
    dbHelper.saveMaterials(buildCause.getMaterialRevisions());
    Pipeline forcedPipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    pipelineService.save(forcedPipeline);
    verifyMingleScheduledWithModifications();
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 13 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class PipelineScheduleServiceTest method shouldScheduleMultipleJobsWhenToBeRunMultipleInstance.

@Test
public void shouldScheduleMultipleJobsWhenToBeRunMultipleInstance() throws Exception {
    configHelper.setRunMultipleInstance(CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", 2);
    Material stubMaterial = new TestingMaterial();
    evolveConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
    BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
    dbHelper.saveMaterials(buildCause.getMaterialRevisions());
    Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY, environmentConfigService.agentsForPipeline(evolveConfig.name())), md5, new TimeProvider());
    pipelineService.save(pipeline);
    Stage instance = scheduleService.scheduleStage(pipeline, STAGE_NAME, "anyone", new ScheduleService.NewStageInstanceCreator(goConfigService), new ScheduleService.ExceptioningErrorHandler());
    JobInstances scheduledJobs = instance.getJobInstances();
    assertThat(scheduledJobs.size(), is(2));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("name", is(RunMultipleInstance.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Material(com.thoughtworks.go.domain.materials.Material) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) TestingMaterial(com.thoughtworks.go.domain.materials.TestingMaterial) Test(org.junit.Test)

Example 14 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class InstanceFactoryTest method shouldSchedulePipelineWithFirstStage.

@Test
public void shouldSchedulePipelineWithFirstStage() {
    StageConfig stageOneConfig = StageConfigMother.stageConfig("dev", BuildPlanMother.withBuildPlans("functional", "unit"));
    StageConfig stageTwoConfig = StageConfigMother.stageConfig("qa", BuildPlanMother.withBuildPlans("suiteOne", "suiteTwo"));
    MaterialConfigs materialConfigs = MaterialConfigsMother.defaultMaterialConfigs();
    PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("mingle"), materialConfigs, stageOneConfig, stageTwoConfig);
    BuildCause buildCause = BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, buildCause, new DefaultSchedulingContext("test"), "some-md5", new TimeProvider());
    assertThat(pipeline.getName(), is("mingle"));
    assertThat(pipeline.getStages().size(), is(1));
    assertThat(pipeline.getStages().get(0).getName(), is("dev"));
    assertThat(pipeline.getStages().get(0).getJobInstances().get(0).getName(), is("functional"));
}
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)

Example 15 with BuildCause

use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.

the class ValueStreamMapService method traverseUpstream.

private void traverseUpstream(String pipelineName, BuildCause buildCause, ValueStreamMap graph, List<MaterialRevision> visitedNodes) {
    for (MaterialRevision materialRevision : buildCause.getMaterialRevisions()) {
        Material material = materialRevision.getMaterial();
        if (material instanceof DependencyMaterial) {
            String upstreamPipeline = ((DependencyMaterial) material).getPipelineName().toString();
            DependencyMaterialRevision revision = (DependencyMaterialRevision) materialRevision.getRevision();
            graph.addUpstreamNode(new PipelineDependencyNode(upstreamPipeline, upstreamPipeline), new PipelineRevision(revision.getPipelineName(), revision.getPipelineCounter(), revision.getPipelineLabel()), pipelineName);
            if (visitedNodes.contains(materialRevision)) {
                continue;
            }
            visitedNodes.add(materialRevision);
            DependencyMaterialRevision dmrOfUpstreamPipeline = buildCause.getMaterialRevisions().findDependencyMaterialRevision(upstreamPipeline);
            BuildCause buildCauseForUpstreamPipeline = pipelineService.buildCauseFor(dmrOfUpstreamPipeline.getPipelineName(), dmrOfUpstreamPipeline.getPipelineCounter());
            traverseUpstream(upstreamPipeline, buildCauseForUpstreamPipeline, graph, visitedNodes);
        } else {
            graph.addUpstreamMaterialNode(new SCMDependencyNode(material.getFingerprint(), material.getUriForDisplay(), materialRevision.getMaterialType()), material.getName(), pipelineName, materialRevision);
        }
    }
}
Also used : Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Aggregations

BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)142 Test (org.junit.Test)108 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)35 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)30 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)27 TimeProvider (com.thoughtworks.go.util.TimeProvider)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Modification (com.thoughtworks.go.domain.materials.Modification)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)15 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)14 Date (java.util.Date)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)10 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)10 Username (com.thoughtworks.go.server.domain.Username)10