Search in sources :

Example 46 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class MaterialExpansionServiceTest method shouldExpandMaterialConfigsForScheduling.

@Test
public void shouldExpandMaterialConfigsForScheduling() {
    PipelineConfig pipelineConfig = new PipelineConfig();
    HgMaterialConfig hg = MaterialConfigsMother.hgMaterialConfig();
    pipelineConfig.addMaterialConfig(hg);
    MaterialConfigs materialConfigs = materialExpansionService.expandMaterialConfigsForScheduling(pipelineConfig.materialConfigs());
    assertThat(materialConfigs.size(), is(1));
    assertThat(materialConfigs.get(0), is(hg));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)

Example 47 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class FetchArtifactViewHelperTest method setUp.

/**
 *  PIPELINES                                          +           TEMPLATE
 *                                                     +
 * random_other                                        +
 * [mingle]                                            +
 *                                                     +           template-1
 * random_pipeline                                     +            [1, 2, 3]
 * [mingle]<---------------------------|               +
 *                                     |               +
 * uppest                              |               +
 * [1, 2, 3]                           |               +           template-2
 *     ^                               |               +            [1, 2]
 *     |                               |               +
 * upper                               |               +
 * [1, 2, 3]                           |               +
 *     ^<--------------------------|   |               +
 *     |                           |   |               +
 * downer                          |   |               +
 * [1, 2, 3]                       |   |               +
 *     ^<----------------------|   |   |               +
 *     |                       |   |   |               +
 * downest                    downest_wmp              +
 * [1, 2, 3]                    [1, 2, 3]              +
 *                                                     +
 */
@Before
public void setUp() {
    initMocks(this);
    when(systemEnvironment.isFetchArtifactTemplateAutoSuggestEnabled()).thenReturn(true);
    when(systemEnvironment.get(SystemEnvironment.FETCH_ARTIFACT_AUTO_SUGGEST)).thenReturn(true);
    PipelineConfig random = PipelineConfigMother.pipelineConfig("random_pipeline");
    JobConfigs randomJobs = random.getStage(new CaseInsensitiveString("mingle")).getJobs();
    randomJobs.add(new JobConfig("mingle_job"));
    PipelineConfig uppest = PipelineConfigMother.createPipelineConfig("uppest", "uppest_stage_1", "uppest_job_1", "uppest_job_1a");
    uppest.add(StageConfigMother.custom("uppest_stage_2", "uppest_job_2"));
    uppest.add(StageConfigMother.custom("uppest_stage_3", "uppest_job_3"));
    PipelineConfig upper = PipelineConfigMother.createPipelineConfig("upper", "upper_stage_1", "upper_job_1", "upper_job_1a");
    upper.add(StageConfigMother.custom("upper_stage_2", "upper_job_2"));
    upper.add(StageConfigMother.custom("upper_stage_3", "upper_job_3"));
    upper.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("uppest_stage_2")));
    PipelineConfig downer = PipelineConfigMother.createPipelineConfig("downer", "downer_stage_1", "downer_job_1", "downer_job_1a");
    downer.add(StageConfigMother.custom("downer_stage_2", "downer_job_2"));
    downer.add(StageConfigMother.custom("downer_stage_3", "downer_job_3"));
    downer.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("upper"), new CaseInsensitiveString("upper_stage_2")));
    PipelineConfig downest = PipelineConfigMother.createPipelineConfig("downest", "downest_stage_1", "downest_job_1", "downest_job_1a");
    downest.add(StageConfigMother.custom("downest_stage_2", "downest_job_2"));
    downest.add(StageConfigMother.custom("downest_stage_3", "downest_job_3"));
    downest.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("downer"), new CaseInsensitiveString("downer_stage_2")));
    PipelineConfig downestWithMultiplePaths = PipelineConfigMother.createPipelineConfig("downest_wmp", "downest_wmp_stage_1", "downest_wmp_job_1", "downest_wmp_job_1a");
    downestWithMultiplePaths.add(StageConfigMother.custom("downest_wmp_stage_2", "downest_wmp_job_2"));
    downestWithMultiplePaths.add(StageConfigMother.custom("downest_wmp_stage_3", "downest_wmp_job_3"));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("downer"), new CaseInsensitiveString("downer_stage_2")));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("upper"), new CaseInsensitiveString("upper_stage_2")));
    downestWithMultiplePaths.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("random_pipeline"), new CaseInsensitiveString("mingle")));
    PipelineConfig randomOther = PipelineConfigMother.pipelineConfig("randomOther_pipeline");
    JobConfigs randomOtherJobs = randomOther.getStage(new CaseInsensitiveString("mingle")).getJobs();
    randomOtherJobs.add(new JobConfig("mingle_job_from_other_pipeline"));
    TemplatesConfig templates = new TemplatesConfig(new PipelineTemplateConfig(new CaseInsensitiveString("template-1"), StageConfigMother.custom("t1-stage-1", "t1-job-1", "t1-job-1a"), StageConfigMother.custom("t1-stage-2", "t1-job-2"), StageConfigMother.custom("t1-stage-3", "t1-job-3")), new PipelineTemplateConfig(new CaseInsensitiveString("template-2"), StageConfigMother.custom("t2-stage-1", "t2-job-1", "t2-job-1a"), StageConfigMother.custom("t2-stage-2", "t2-job-2")));
    cruiseConfig = configWith(uppest, upper, downer, downest, downestWithMultiplePaths, random, randomOther);
    cruiseConfig.setTemplates(templates);
}
Also used : TemplatesConfig(com.thoughtworks.go.config.TemplatesConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) JobConfig(com.thoughtworks.go.config.JobConfig) Before(org.junit.Before)

Example 48 with PipelineConfig

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

Example 49 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class BuildAssignmentServiceTest method shouldMatchAnElasticJobToAnElasticAgentOnlyIfThePluginAgreesToTheAssignmentWhenMultipleElasticJobsRequiringTheSamePluginAreScheduled.

@Test
public void shouldMatchAnElasticJobToAnElasticAgentOnlyIfThePluginAgreesToTheAssignmentWhenMultipleElasticJobsRequiringTheSamePluginAreScheduled() {
    PipelineConfig pipelineWith2ElasticJobs = PipelineConfigMother.pipelineWithElasticJob(elasticProfileId1, elasticProfileId2);
    JobPlan jobPlan1 = new InstanceFactory().createJobPlan(pipelineWith2ElasticJobs.first().getJobs().first(), schedulingContext);
    JobPlan jobPlan2 = new InstanceFactory().createJobPlan(pipelineWith2ElasticJobs.first().getJobs().last(), schedulingContext);
    jobPlans.add(jobPlan1);
    jobPlans.add(jobPlan2);
    when(elasticAgentPluginService.shouldAssignWork(elasticAgentInstance.elasticAgentMetadata(), "", jobPlan1.getElasticProfile(), jobPlan1.getIdentifier())).thenReturn(false);
    when(elasticAgentPluginService.shouldAssignWork(elasticAgentInstance.elasticAgentMetadata(), "", jobPlan2.getElasticProfile(), jobPlan2.getIdentifier())).thenReturn(true);
    buildAssignmentService.onTimer();
    JobPlan matchingJob = buildAssignmentService.findMatchingJob(elasticAgentInstance);
    assertThat(matchingJob, is(jobPlan2));
    assertThat(buildAssignmentService.jobPlans().size(), is(1));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Test(org.junit.Test)

Example 50 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class BuildAssignmentServiceTest method shouldMatchAnElasticJobToAnElasticAgentOnlyIfThePluginAgreesToTheAssignment.

@Test
public void shouldMatchAnElasticJobToAnElasticAgentOnlyIfThePluginAgreesToTheAssignment() {
    PipelineConfig pipelineWithElasticJob = PipelineConfigMother.pipelineWithElasticJob(elasticProfileId1);
    JobPlan jobPlan = new InstanceFactory().createJobPlan(pipelineWithElasticJob.first().getJobs().first(), schedulingContext);
    jobPlans.add(jobPlan);
    when(elasticAgentPluginService.shouldAssignWork(elasticAgentInstance.elasticAgentMetadata(), "", jobPlan.getElasticProfile(), jobPlan.getIdentifier())).thenReturn(true);
    buildAssignmentService.onTimer();
    JobPlan matchingJob = buildAssignmentService.findMatchingJob(elasticAgentInstance);
    assertThat(matchingJob, is(jobPlan));
    assertThat(buildAssignmentService.jobPlans().size(), is(0));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Test(org.junit.Test)

Aggregations

PipelineConfig (com.thoughtworks.go.config.PipelineConfig)186 Test (org.junit.Test)129 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)76 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)32 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)19 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)17 TimeProvider (com.thoughtworks.go.util.TimeProvider)16 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)15 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)13 Pipeline (com.thoughtworks.go.domain.Pipeline)13 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)13 Date (java.util.Date)13 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)12 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)12 StageConfig (com.thoughtworks.go.config.StageConfig)11 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)11 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)11 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)11 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)9 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)9