Search in sources :

Example 66 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineConfigSaveValidationContextTest method shouldGetDependencyMaterialsForPipelines.

@Test
public void shouldGetDependencyMaterialsForPipelines() {
    BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("p1", "p2", "p3");
    PipelineConfig p2 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p2"));
    p2.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p1"), new CaseInsensitiveString("stage")));
    PipelineConfig p3 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p3"));
    p3.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p2"), new CaseInsensitiveString("stage")));
    PipelineConfigSaveValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig);
    assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("p1")).getDependencies().isEmpty(), is(true));
    assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("p2")).getDependencies(), contains(new Node.DependencyNode(new CaseInsensitiveString("p1"), new CaseInsensitiveString("stage"))));
    assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("p3")).getDependencies(), contains(new Node.DependencyNode(new CaseInsensitiveString("p2"), new CaseInsensitiveString("stage"))));
    assertThat(context.getDependencyMaterialsFor(new CaseInsensitiveString("junk")).getDependencies().isEmpty(), is(true));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 67 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineTemplateConfigTest method shouldValidateTemplateJobsUsedInDownstreamPipelines.

@Test
public void shouldValidateTemplateJobsUsedInDownstreamPipelines() {
    JobConfig jobConfigWithExecTask = new JobConfig(new CaseInsensitiveString("defaultJob"));
    jobConfigWithExecTask.addTask(new ExecTask("ls", "l", "server/config"));
    JobConfigs jobConfigs = new JobConfigs(jobConfigWithExecTask);
    JobConfig jobConfigWithFetchTask = new JobConfig(new CaseInsensitiveString("fetchJob"));
    jobConfigWithFetchTask.addTask(new FetchTask(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("non-existent-job"), "src", "dest"));
    JobConfigs jobConfigsForDownstream = new JobConfigs(jobConfigWithFetchTask);
    StageConfig stageConfig = StageConfigMother.custom("stage", jobConfigs);
    PipelineTemplateConfig template = PipelineTemplateConfigMother.createTemplate("template", stageConfig);
    PipelineConfig upstreamPipelineUsingTemplate = PipelineConfigMother.pipelineConfigWithTemplate("pipeline", "template");
    upstreamPipelineUsingTemplate.usingTemplate(template);
    // Pipeline and stage of upstreamPipelineUsingTemplate
    MaterialConfig dependency = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"));
    PipelineConfig downStreamPipeline = PipelineConfigMother.pipelineConfig("downstreamPipeline", new MaterialConfigs(dependency), jobConfigsForDownstream);
    BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
    cruiseConfig.addTemplate(template);
    cruiseConfig.addPipelineWithoutValidation("group", upstreamPipelineUsingTemplate);
    cruiseConfig.addPipelineWithoutValidation("group", downStreamPipeline);
    template.validateTree(ConfigSaveValidationContext.forChain(cruiseConfig), cruiseConfig, false);
    assertThat(template.errors().getAllOn("base"), is(Arrays.asList("\"downstreamPipeline :: mingle :: fetchJob\" tries to fetch artifact from job \"pipeline :: stage :: non-existent-job\" which does not exist.")));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 68 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineTemplateConfigTest method shouldValidateTemplateStageUsedInDownstreamPipelines.

@Test
public void shouldValidateTemplateStageUsedInDownstreamPipelines() {
    JobConfig jobConfigWithExecTask = new JobConfig(new CaseInsensitiveString("defaultJob"));
    jobConfigWithExecTask.addTask(new ExecTask("ls", "l", "server/config"));
    JobConfigs jobConfigs = new JobConfigs(jobConfigWithExecTask);
    StageConfig stageConfig = StageConfigMother.custom("stage", jobConfigs);
    PipelineTemplateConfig template = PipelineTemplateConfigMother.createTemplate("template", stageConfig);
    PipelineConfig upstreamPipelineUsingTemplate = PipelineConfigMother.pipelineConfigWithTemplate("pipeline", "template");
    upstreamPipelineUsingTemplate.usingTemplate(template);
    // Pipeline and stage of upstreamPipelineUsingTemplate
    MaterialConfig dependency = new DependencyMaterialConfig(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("non-existent-stage"));
    PipelineConfig downStreamPipeline = PipelineConfigMother.pipelineConfig("downstreamPipeline", new MaterialConfigs(dependency));
    BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
    cruiseConfig.addTemplate(template);
    cruiseConfig.addPipelineWithoutValidation("group", upstreamPipelineUsingTemplate);
    cruiseConfig.addPipelineWithoutValidation("group", downStreamPipeline);
    template.validateTree(ConfigSaveValidationContext.forChain(cruiseConfig), cruiseConfig, false);
    assertThat(template.errors().getAllOn("base"), is(Arrays.asList("Stage with name 'non-existent-stage' does not exist on pipeline 'pipeline', it is being referred to from pipeline 'downstreamPipeline' (cruise-config.xml)")));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 69 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldAllowToDependOnPipelineDefinedInConfigRepository_WhenInConfigRepository.

@Test
public void shouldAllowToDependOnPipelineDefinedInConfigRepository_WhenInConfigRepository() throws Exception {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
    PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
    goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
    pipeline1.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://mysvn", false), "myplugin"), "123"));
    pipeline2.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://othersvn", false), "myplugin"), "2222"));
    pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
    assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
    pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
    DependencyMaterialConfig dep = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
    assertThat(dep.errors().isEmpty(), is(true));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 70 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldAllowToDependOnPipelineDefinedInFile_WhenInFile.

@Test
public void shouldAllowToDependOnPipelineDefinedInFile_WhenInFile() throws Exception {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
    PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
    goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
    pipeline1.setOrigin(new FileConfigOrigin());
    pipeline2.setOrigin(new FileConfigOrigin());
    pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
    assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
    pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
    DependencyMaterialConfig dep = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
    assertThat(dep.errors().isEmpty(), is(true));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)135 Test (org.junit.Test)106 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)21 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)15 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)14 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)11 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)10 Date (java.util.Date)10 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)9 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)8 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 Pipeline (com.thoughtworks.go.domain.Pipeline)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)8 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)7 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)7 ModificationsMother.changedDependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision)7