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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations