Search in sources :

Example 86 with PipelineConfig

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

the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt.

@Test
public void hasPipelineEverRunWithIsFalseWhenThereAreNewerModificationsThatHaveNotBeenBuilt() {
    HgMaterial hgMaterial = MaterialsMother.hgMaterial("hgUrl", "dest");
    MaterialRevision materialRevision = saveOneScmModification(hgMaterial, "user", "file");
    PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial.config()), "dev");
    MaterialRevisions materialRevisions = new MaterialRevisions(materialRevision);
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    pipelineSqlMapDao.save(pipeline);
    MaterialRevision notBuiltRevision = saveOneScmModification(hgMaterial, "user", "file2");
    MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(hgMaterial, notBuiltRevision.getLatestModification()));
    assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(false));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 87 with PipelineConfig

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

the class PipelineServiceTriangleDependencyTest method shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged.

@Test
public void shouldNotGetTheRevisionsFromUpStreamPipelineIfTheDependencyMaterialHasNotChanged() throws Exception {
    MaterialRevisions expected = createHgMaterialWithMultipleRevisions(1L, first);
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    expected.addRevision(up1Revision);
    MaterialRevisions actual = createHgMaterialWithMultipleRevisions(1L, third);
    actual.addRevision(up1Revision);
    up1Revision.markAsNotChanged();
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", actual.getMaterials().get(0).config(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", expected.getMaterials().get(0).config());
    when(pipelineDao.findBuildCauseOfPipelineByNameAndCounter("up1", 1)).thenReturn(BuildCause.createManualForced(expected, new Username(str("loser"))));
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(actual));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 88 with PipelineConfig

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

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline.

@Test
public void shouldGetTheRevisionsForDependencyMaterialFromUpStreamPipeline() throws Exception {
    Date modifiedTime = new Date();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(dependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
    expected.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(changedDependencyMaterialRevision("up1", 1, "label", "stage", 1, modifiedTime));
    actual.addRevision(dependencyMaterialRevision("common", 4, "label", "first", 1, modifiedTime));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", new DependencyMaterialConfig(new CaseInsensitiveString("common"), new CaseInsensitiveString("first")));
    PipelineConfig common = createPipelineConfigWithMaterialConfig("common", MaterialConfigsMother.hgMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    MaterialRevisions upStreamPipelinesRevisions = new MaterialRevisions();
    upStreamPipelinesRevisions.addRevision(dependencyMaterialRevision("common", 3, "label", "first", 1, modifiedTime));
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(upStreamPipelinesRevisions);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1, new PipelineConfigDependencyGraph(common)));
    MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(dependencyGraph, actual);
    assertThat(finalRevisions, is(expected));
    for (int i = 0; i < expected.numberOfRevisions(); i++) {
        assertTrue(finalRevisions.getMaterialRevision(i) == actual.getMaterialRevision(i));
    }
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 89 with PipelineConfig

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

the class PipelineServiceTriangleDependencyTest method shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial.

@Test
public void shouldGetTheRevisionsFromTheUpStreamPipelineFor2SameMaterial() throws Exception {
    MaterialRevision up1Revision = dependencyMaterialRevision("up1", 1, "label", "stage", 1, new Date());
    up1Revision.markAsChanged();
    MaterialRevisions expected = new MaterialRevisions();
    expected.addRevision(up1Revision);
    expected.addAll(createHgMaterialWithMultipleRevisions(1L, first));
    expected.addAll(createSvnMaterialWithMultipleRevisions(2L, first));
    MaterialRevisions actual = new MaterialRevisions();
    actual.addRevision(up1Revision);
    actual.addAll(createHgMaterialWithMultipleRevisions(1L, third));
    actual.addAll(createSvnMaterialWithMultipleRevisions(2L, third));
    PipelineConfig current = createPipelineConfigWithMaterialConfig("current", new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    PipelineConfig up1 = createPipelineConfigWithMaterialConfig("up1", MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    Pipeline pipeline = PipelineMother.passedPipelineInstance("up1", "stage", "job");
    pipeline.setId(10);
    when(pipelineDao.findPipelineByNameAndCounter("up1", 1)).thenReturn(pipeline);
    when(materialRepository.findMaterialRevisionsForPipeline(10)).thenReturn(expected);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(up1));
    assertThat(service.getRevisionsBasedOnDependencies(dependencyGraph, actual), is(expected));
}
Also used : PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ModificationsMother.dependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.dependencyMaterialRevision) ModificationsMother.changedDependencyMaterialRevision(com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 90 with PipelineConfig

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

the class BuildCauseTest method shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger.

@Test
public void shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger() {
    SvnMaterial material = MaterialsMother.svnMaterial();
    MaterialConfig materialConfig = material.config();
    MaterialRevisions first = new MaterialRevisions(new MaterialRevision(material, oneModifiedFile("revision1")));
    BuildCause buildCause = BuildCause.createWithModifications(first, "");
    buildCause.setMaterialRevisions(first);
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build");
    pipelineConfig.materialConfigs().clear();
    pipelineConfig.materialConfigs().add(materialConfig);
    pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "plug"), "revision2"));
    try {
        buildCause.assertPipelineConfigAndMaterialRevisionMatch(pipelineConfig);
    } catch (BuildCauseOutOfDateException ex) {
        // good
        return;
    }
    fail("should have thrown");
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) BuildCauseOutOfDateException(com.thoughtworks.go.domain.buildcause.BuildCauseOutOfDateException) 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