Search in sources :

Example 76 with DependencyMaterial

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

the class ChangesetServiceIntegrationTest method shouldReturnModsForRangeOfInstancesOfAnUpstreamPipeline.

@Test
public void shouldReturnModsForRangeOfInstancesOfAnUpstreamPipeline() {
    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 upstreams
    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);
    List<MaterialRevision> revisionsForUpstream4 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream4, git);
    Pipeline upstreamFour = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream4);
    // Schedule downstream
    List<MaterialRevision> revisionsForDownstream2 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForDownstream2, hg);
    dbHelper.addDependencyRevisionModification(revisionsForDownstream2, dependencyMaterial, upstreamFour, upstreamThree, upstreamTwo);
    Pipeline downstreamTwo = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForDownstream2);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), downstreamTwo.getCounter(), downstreamTwo.getCounter(), username, result, true, false);
    List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForUpstream2, revisionsForUpstream3, revisionsForUpstream4, revisionsForDownstream2);
    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 77 with DependencyMaterial

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

the class ChangesetServiceIntegrationTest method shouldFilterOutMaterialRevisionsThatTheUserIsNotAuthorizedToView.

@Test
public void shouldFilterOutMaterialRevisionsThatTheUserIsNotAuthorizedToView() throws Exception {
    configHelper.enableSecurity();
    configHelper.addAdmins("Yogi");
    Username otherUser = new Username(new CaseInsensitiveString("otherUser"));
    Username user = new Username(new CaseInsensitiveString("user"));
    SvnMaterial svn = MaterialsMother.svnMaterial("http://svn");
    PipelineConfig grandFatherPipeline = configHelper.addPipelineWithGroup("unauthorizedGroup", "granpa", new MaterialConfigs(svn.config()), "stage", "job");
    configHelper.setViewPermissionForGroup("unauthorizedGroup", CaseInsensitiveString.str(otherUser.getUsername()));
    DependencyMaterial parentDependencyMaterial = MaterialsMother.dependencyMaterial("granpa", "stage");
    PipelineConfig upstreamPipeline = configHelper.addPipeline("upstream", "stage", new MaterialConfigs(git.config(), parentDependencyMaterial.config()), "job");
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial("upstream", "stage");
    PipelineConfig downstream = configHelper.addPipeline("downstream", "stage", dependencyMaterial.config(), "job");
    // Schedule grandfather
    List<MaterialRevision> revisionsForGrandfather1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForGrandfather1, svn);
    Pipeline grandFatherOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(user), grandFatherPipeline, revisionsForGrandfather1);
    // Schedule upstream
    List<MaterialRevision> revisionsForUpstream1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream1, git);
    dbHelper.addDependencyRevisionModification(revisionsForUpstream1, parentDependencyMaterial, grandFatherOne);
    Pipeline upstreamOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(user), upstreamPipeline, revisionsForUpstream1);
    // Schedule downstream
    List<MaterialRevision> revisionsForDownstream = new ArrayList<>();
    dbHelper.addDependencyRevisionModification(revisionsForDownstream, dependencyMaterial, upstreamOne);
    Pipeline pipelineDownstream = dbHelper.checkinRevisionsToBuild(new ManualBuild(user), downstream, revisionsForDownstream);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> actual = changesetService.revisionsBetween(pipelineDownstream.getName(), pipelineDownstream.getCounter(), pipelineDownstream.getCounter(), user, result, true, false);
    List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForUpstream1, revisionsForDownstream);
    assertMaterialRevisions(expectedRevisions, actual);
    assertThat(result.isSuccessful(), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) 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 78 with DependencyMaterial

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

the class ChangesetServiceIntegrationTest method shouldNotFilterOutMaterialRevisionsAtThePointInTheDependencyIfMingleConfigDoesNotMatchWithParent.

@Test
public void shouldNotFilterOutMaterialRevisionsAtThePointInTheDependencyIfMingleConfigDoesNotMatchWithParent() throws Exception {
    Username user = new Username(new CaseInsensitiveString("user"));
    SvnMaterial svn = MaterialsMother.svnMaterial("http://svn");
    PipelineConfig grandFatherPipeline = configHelper.addPipelineWithGroup("unauthorizedGroup", "granpa", new MaterialConfigs(svn.config()), new MingleConfig("https://granpa-mingle", "go"), "stage", "job");
    configHelper.setViewPermissionForGroup("unauthorizedGroup", CaseInsensitiveString.str(user.getUsername()));
    DependencyMaterial parentDependencyMaterial = MaterialsMother.dependencyMaterial("granpa", "stage");
    PipelineConfig upstreamPipeline = configHelper.addPipeline("upstream", "stage", new MaterialConfigs(git.config(), parentDependencyMaterial.config()), "job");
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial("upstream", "stage");
    PipelineConfig downstream = configHelper.addPipeline("downstream", "stage", dependencyMaterial.config(), new MingleConfig("https://downstream-mingle", "go"), "job");
    // Schedule grandfather
    List<MaterialRevision> revisionsForGrandfather1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForGrandfather1, svn);
    Pipeline grandFatherOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(user), grandFatherPipeline, revisionsForGrandfather1);
    // Schedule upstream
    List<MaterialRevision> revisionsForUpstream1 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream1, git);
    dbHelper.addDependencyRevisionModification(revisionsForUpstream1, parentDependencyMaterial, grandFatherOne);
    Pipeline upstreamOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(user), upstreamPipeline, revisionsForUpstream1);
    // Schedule downstream
    List<MaterialRevision> revisionsForDownstream = new ArrayList<>();
    dbHelper.addDependencyRevisionModification(revisionsForDownstream, dependencyMaterial, upstreamOne);
    Pipeline pipelineDownstream = dbHelper.checkinRevisionsToBuild(new ManualBuild(user), downstream, revisionsForDownstream);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> actual = changesetService.revisionsBetween(pipelineDownstream.getName(), pipelineDownstream.getCounter(), pipelineDownstream.getCounter(), user, result, true, false);
    List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForGrandfather1, revisionsForUpstream1, revisionsForDownstream);
    assertMaterialRevisions(expectedRevisions, actual);
    assertThat(result.isSuccessful(), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Pipeline(com.thoughtworks.go.domain.Pipeline) 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) Test(org.junit.Test)

Example 79 with DependencyMaterial

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

the class ChangesetServiceIntegrationTest method shouldNotReturnAMaterialWhenNothingHasChangedInIt.

@Test
public void shouldNotReturnAMaterialWhenNothingHasChangedInIt() {
    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 second upstream
    List<MaterialRevision> revisionsForUpstream2 = new ArrayList<>();
    addRevisionWith2Mods(revisionsForUpstream2, git);
    List<MaterialRevision> expectedGitRevision = revisionsForUpstream2;
    Pipeline upstreamTwo = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream2);
    // Schedule second downstream
    List<MaterialRevision> up2Rev = dbHelper.addDependencyRevisionModification(revisionsForDownstream1, dependencyMaterial, upstreamTwo);
    // Using the same hg revision.
    Pipeline downstreamTwo = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForDownstream1);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MaterialRevision> actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), downstreamOne.getCounter(), downstreamTwo.getCounter(), username, result, true, false);
    // Should not contain the hg revision that has not changed
    List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForUpstream2, up2Rev);
    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 80 with DependencyMaterial

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

the class FanInPerformanceTest method shouldTestFanInForMesh.

@Test(timeout = 240000)
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void shouldTestFanInForMesh() throws Exception {
    int numberOfNodesPerLevel = 10;
    int numberOfLevels = 10;
    int numberOfInstancesForUpstream = 1;
    ScmMaterial svn = u.wf((ScmMaterial) MaterialsMother.defaultMaterials().get(0), "folder1");
    String[] svn_revs = { "svn_1" };
    u.checkinInOrder(svn, svn_revs);
    PipelineConfig upstreamConfig = graphGenerator.createPipelineWithInstances("upstream", new ArrayList<>(), numberOfInstancesForUpstream);
    PipelineConfig currentConfig = graphGenerator.createMesh(upstreamConfig, "current", "up", numberOfInstancesForUpstream, numberOfNodesPerLevel, numberOfLevels);
    List<MaterialRevision> revisions = new ArrayList<>();
    revisions.add(u.mr(svn, true, "svn_1"));
    for (int i = 1; i <= numberOfNodesPerLevel; i++) {
        String pipelineName = String.format("pipeline_%s_%d_%d", "up", numberOfLevels, i);
        revisions.add(u.mr(new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString("stage")), true, pipelineName + "/1/stage/1"));
    }
    MaterialRevisions given = new MaterialRevisions(revisions);
    long start = System.currentTimeMillis();
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(currentConfig.name(), configHelper.currentConfig(), given);
    long timeTaken = (System.currentTimeMillis() - start) / 1000;
    assertThat(String.format("Fan-in took %ds. Should have finished in 10s.", timeTaken), timeTaken, Matchers.lessThan(10l));
    assertThat(finalRevisions, is(given));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) ArrayList(java.util.ArrayList) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Aggregations

DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)97 Test (org.junit.Test)75 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)64 Modification (com.thoughtworks.go.domain.materials.Modification)30 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)29 Date (java.util.Date)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)17 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)16 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)15 Stage (com.thoughtworks.go.domain.Stage)14 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 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)10 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