Search in sources :

Example 66 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class ChangesetServiceIntegrationTest method shouldGetModificationsFrom1To1.

@Test
public void shouldGetModificationsFrom1To1() {
    Username loser = new Username(new CaseInsensitiveString("loser"));
    ManualBuild build = new ManualBuild(loser);
    Date checkinTime = new Date();
    Modification hgCommit1 = checkinWithComment("abcd", "#4518 - foo", checkinTime);
    Modification gitCommit1 = checkinWithComment("1234", "#3750 - agent index", checkinTime);
    Pipeline pipelineOne = dbHelper.checkinRevisionsToBuild(build, pipelineConfigWithTwoMaterials, dbHelper.addRevisionsWithModifications(hg, hgCommit1), dbHelper.addRevisionsWithModifications(git, gitCommit1));
    List<MaterialRevision> expectedRevisions = Arrays.asList(new MaterialRevision(hg, hgCommit1), new MaterialRevision(git, gitCommit1));
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> revisions = changesetService.revisionsBetween("foo", pipelineOne.getCounter(), pipelineOne.getCounter(), loser, result, true, false);
    assertMaterialRevisions(expectedRevisions, revisions);
    assertThat(result.isSuccessful(), is(true));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineMaterialRevision(com.thoughtworks.go.domain.PipelineMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 67 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class ChangesetServiceIntegrationTest method shouldGetModificationsFrom0To1.

@Test
public void shouldGetModificationsFrom0To1() {
    Username loser = new Username(new CaseInsensitiveString("loser"));
    ManualBuild build = new ManualBuild(loser);
    Date checkinTime = new Date();
    Modification hgCommit1 = checkinWithComment("abcd", "#4518 - foo", checkinTime);
    Modification gitCommit1 = checkinWithComment("1234", "#3750 - agent index", checkinTime);
    Pipeline pipelineOne = dbHelper.checkinRevisionsToBuild(build, pipelineConfigWithTwoMaterials, dbHelper.addRevisionsWithModifications(hg, hgCommit1), dbHelper.addRevisionsWithModifications(git, gitCommit1));
    List<MaterialRevision> expectedRevisions = Arrays.asList(new MaterialRevision(hg, hgCommit1), new MaterialRevision(git, gitCommit1));
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> revisions = changesetService.revisionsBetween("foo", 0, pipelineOne.getCounter(), loser, result, true, false);
    assertMaterialRevisions(expectedRevisions, revisions);
    assertThat(result.isSuccessful(), is(true));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineMaterialRevision(com.thoughtworks.go.domain.PipelineMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 68 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class ChangesetServiceIntegrationTest method shouldReturnModsOfItsOwnAndAnUpstreamPipelineForTheGivenPipelineCounters.

@Test
public void shouldReturnModsOfItsOwnAndAnUpstreamPipelineForTheGivenPipelineCounters() {
    PipelineConfig upstreamPipeline = configHelper.addPipeline("upstream", "stage", git.config(), "job");
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial("upstream", "stage");
    pipelineConfigWithTwoMaterials.addMaterialConfig(dependencyMaterial.config());
    pipelineConfigWithTwoMaterials.removeMaterialConfig(git.config());
    Username username = new Username(new CaseInsensitiveString("user1"));
    // Schedule upstream
    List<MaterialRevision> revisionsForUpstream1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream1, git);
    Pipeline upstreamOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream1);
    // Schedule downstream
    List<MaterialRevision> revisionsForPipeline1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForPipeline1, hg);
    dbHelper.addDependencyRevisionModification(revisionsForPipeline1, dependencyMaterial, upstreamOne);
    Pipeline pipelineOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForPipeline1);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), pipelineOne.getCounter(), pipelineOne.getCounter(), username, result, true, false);
    List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForUpstream1, revisionsForPipeline1);
    assertMaterialRevisions(expectedRevisions, actual);
    assertThat(result.isSuccessful(), is(true));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) PipelineMaterialRevision(com.thoughtworks.go.domain.PipelineMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 69 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class ChangesetServiceIntegrationTest method shouldReturn_SCMMods_AcrossParentStageFailures_WithFailuresNextToFrom.

@Test
public void shouldReturn_SCMMods_AcrossParentStageFailures_WithFailuresNextToFrom() {
    PipelineConfig upstreamPipeline = configHelper.addPipeline("upstream", "stage", git.config(), "job");
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial("upstream", "stage");
    pipelineConfigWithTwoMaterials.addMaterialConfig(dependencyMaterial.config());
    pipelineConfigWithTwoMaterials.removeMaterialConfig(git.config());
    Username username = new Username(new CaseInsensitiveString("user1"));
    // Schedule first of upstream
    List<MaterialRevision> revisionsForUpstream1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream1, git);
    Pipeline upstreamOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream1);
    // Schedule downstream
    List<MaterialRevision> revisionsForDownstream1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForDownstream1, hg);
    dbHelper.addDependencyRevisionModification(revisionsForDownstream1, dependencyMaterial, upstreamOne);
    Pipeline downstreamOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForDownstream1);
    // Schedule multiple upstream, but no corresponding downstream, because upstream stage failed(may be?)
    List<MaterialRevision> revisionsForUpstream2 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream2, git);
    Pipeline upstreamTwo = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream2);
    List<MaterialRevision> revisionsForUpstream3 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream3, git);
    Pipeline upstreamThree = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream3);
    // Schedule upstream again(upstream stage starts passing once again)
    List<MaterialRevision> revisionsForUpstream4 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream4, git);
    Pipeline upstreamFour = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream4);
    // Schedule downstream for comparision
    List<MaterialRevision> revisionsForDownstream2 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForDownstream2, hg);
    dbHelper.addDependencyRevisionModification(revisionsForDownstream2, dependencyMaterial, upstreamFour);
    Pipeline downstreamTwo = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForDownstream2);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), downstreamOne.getCounter(), downstreamTwo.getCounter(), username, result, true, false);
    List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForUpstream2, revisionsForUpstream3, revisionsForUpstream4, revisionsForDownstream2);
    assertMaterialRevisions(expectedRevisions, actual);
    assertThat(result.isSuccessful(), is(true));
    actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), downstreamTwo.getCounter(), downstreamTwo.getCounter(), username, result, true, // same to and from
    false);
    assertMaterialRevisions(expectedRevisions, actual);
    assertThat(result.isSuccessful(), is(true));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) PipelineMaterialRevision(com.thoughtworks.go.domain.PipelineMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 70 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class FaninDependencyResolutionTest method shouldPickTheRightRevisionsWhenMaterialIsRemovedAndPutBack.

@Test
public void shouldPickTheRightRevisionsWhenMaterialIsRemovedAndPutBack() {
    GitMaterial git1 = u.wf(new GitMaterial("git1-url"), "git-folder1");
    GitMaterial git2 = u.wf(new GitMaterial("git2-url"), "git-folder2");
    GitMaterial git3 = u.wf(new GitMaterial("git3-url"), "git-folder3");
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("P1", u.m(git1), u.m(git2));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("P2", u.m(git2));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("P3", u.m(p1), u.m(p2), u.m(git1));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("P4", u.m(p3), u.m(git2));
    u.checkinInOrder(git1, "git1_1");
    u.checkinInOrder(git2, "git2_1");
    String p1_1 = u.runAndPass(p1, "git1_1", "git2_1");
    String p2_1 = u.runAndPass(p2, "git2_1");
    String p3_1 = u.runAndPass(p3, p1_1, p2_1, "git1_1");
    String p4_1 = u.runAndPass(p4, p3_1, "git2_1");
    u.checkinInOrder(git1, "git1_2");
    u.checkinInOrder(git2, "git2_2");
    String p1_2 = u.runAndPass(p1, "git1_2", "git2_2");
    String p2_2 = u.runAndPass(p2, "git2_2");
    String p3_2 = u.runAndPass(p3, p1_2, p2_2, "git1_2");
    String p4_2 = u.runAndPass(p4, p3_2, "git2_2");
    configHelper.setMaterialConfigForPipeline("P2", git3.config());
    CruiseConfig cruiseConfig = goConfigDao.load();
    p2 = new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("P2")), p2.material);
    u.checkinInOrder(git1, "git1_3");
    u.checkinInOrder(git2, "git2_3");
    u.checkinInOrder(git3, "git3_1");
    String p1_3 = u.runAndPass(p1, "git1_3", "git2_3");
    String p2_3 = u.runAndPass(p2, "git3_1");
    String p3_3 = u.runAndPass(p3, p1_3, p2_3, "git1_3");
    // check wat happens to p4
    MaterialRevisions given = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
    MaterialRevisions expected = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
    assertThat(finalRevisions, is(expected));
    // bring back git2 in p2
    configHelper.setMaterialConfigForPipeline("P2", git2.config());
    cruiseConfig = goConfigDao.load();
    p2 = new ScheduleTestUtil.AddedPipeline(cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("P2")), p2.material);
    // check wat happend to p4
    given = u.mrs(u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3));
    expected = u.mrs(new MaterialRevision[] { u.mr(git2, true, "git2_3"), u.mr(p3, true, p3_3) });
    finalRevisions = getRevisionsBasedOnDependencies(p4, cruiseConfig, given);
    assertThat(finalRevisions, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)185 Test (org.junit.Test)141 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)72 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)68 Modification (com.thoughtworks.go.domain.materials.Modification)65 Date (java.util.Date)50 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)31 Pipeline (com.thoughtworks.go.domain.Pipeline)29 Username (com.thoughtworks.go.server.domain.Username)27 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 File (java.io.File)17 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)16 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16