Search in sources :

Example 21 with DependencyMaterial

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

the class MaterialRevisionTest method shouldDetectOldestAndLatestDependencyRevision.

@Test
public void shouldDetectOldestAndLatestDependencyRevision() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("stage"));
    MaterialRevision materialRevision = new MaterialRevision(dependencyMaterial, new Modification(new Date(), "upstream/3/stage/1", "1.3-3", null), new Modification(new Date(), "upstream/2/stage/1", "1.3-2", null));
    assertThat(materialRevision.getOldestRevision(), is(DependencyMaterialRevision.create("upstream/2/stage/1", "1.3-2")));
    assertThat(materialRevision.getRevision(), is(DependencyMaterialRevision.create("upstream/3/stage/1", "1.3-3")));
}
Also used : DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 22 with DependencyMaterial

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

the class GraphGenerator method createInstances.

private void createInstances(int numberOfInstances, List<PipelineConfig> previousNodes, PipelineConfig pipelineConfig) {
    for (int k = 1; k <= numberOfInstances; k++) {
        List<String> previousRevisions = new ArrayList<>();
        previousRevisions.add("svn_1");
        int instanceCount = previousNodes.size() == 1 ? 1 : k;
        for (int x = 0; x < previousNodes.size(); x++) {
            previousRevisions.add(String.format("%s/%d/stage/1", previousNodes.get(x).name().toString(), instanceCount));
        }
        scheduleUtil.runAndPass(new ScheduleTestUtil.AddedPipeline(pipelineConfig, new DependencyMaterial(pipelineConfig.name(), new CaseInsensitiveString("stage"))), previousRevisions.toArray(new String[previousRevisions.size()]));
    }
}
Also used : ArrayList(java.util.ArrayList) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 23 with DependencyMaterial

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

the class FaninDependencyResolutionTest method shouldRestoreMaterialNamesBasedOnMaterialConfig.

@Test
public void shouldRestoreMaterialNamesBasedOnMaterialConfig() throws Exception {
    /*
            g -> up   -> down
                 +-> mid -+
         */
    GitMaterial git = u.wf(new GitMaterial("git"), "folder1");
    u.checkinInOrder(git, "g1");
    ScheduleTestUtil.AddedPipeline up = u.saveConfigWith("up", u.m(git));
    ScheduleTestUtil.MaterialDeclaration upForMid = u.m(up);
    ((DependencyMaterial) upForMid.material).setName(new CaseInsensitiveString("up-for-mid"));
    ScheduleTestUtil.AddedPipeline mid = u.saveConfigWith("mid", upForMid);
    ScheduleTestUtil.MaterialDeclaration upForDown = u.m(up);
    ((DependencyMaterial) upForDown.material).setName(new CaseInsensitiveString("up-for-down"));
    ScheduleTestUtil.AddedPipeline down = u.saveConfigWith("down", u.m(mid), upForDown);
    CruiseConfig cruiseConfig = goConfigDao.load();
    String up_1 = u.runAndPass(up, "g1");
    String mid_1 = u.runAndPass(mid, up_1);
    String down_1 = u.runAndPass(down, mid_1, up_1);
    MaterialRevisions given = u.mrs(u.mr(mid, false, mid_1), u.mr(up, false, up_1));
    MaterialRevisions revisionsBasedOnDependencies = getRevisionsBasedOnDependencies(down, cruiseConfig, given);
    for (MaterialRevision revisionsBasedOnDependency : revisionsBasedOnDependencies) {
        DependencyMaterial dependencyPipeline = (DependencyMaterial) revisionsBasedOnDependency.getMaterial();
        if (dependencyPipeline.getPipelineName().equals(new CaseInsensitiveString("up"))) {
            assertThat(dependencyPipeline.getName(), is(new CaseInsensitiveString("up-for-down")));
        }
    }
    assertThat(revisionsBasedOnDependencies, is(given));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 24 with DependencyMaterial

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial 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 25 with DependencyMaterial

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial 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)

Aggregations

DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)96 Test (org.junit.Test)75 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)30 Modification (com.thoughtworks.go.domain.materials.Modification)30 Date (java.util.Date)24 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)18 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)16 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)15 Stage (com.thoughtworks.go.domain.Stage)14 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Materials (com.thoughtworks.go.config.materials.Materials)12 Username (com.thoughtworks.go.server.domain.Username)12 Pipeline (com.thoughtworks.go.domain.Pipeline)11 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)11 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)10 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)9