use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialDatabaseUpdaterIntegrationTest method shouldNotThrowUpWhenSameMaterialIsBeingUpdatedByMultipleThreads.
@Test
public void shouldNotThrowUpWhenSameMaterialIsBeingUpdatedByMultipleThreads() throws Exception {
final ScmMaterial material = new GitMaterial(testRepo.projectRepositoryUrl());
final List<Exception> threadOneExceptions = new ArrayList();
final List<Exception> threadTwoExceptions = new ArrayList();
Thread updateThread1 = new Thread() {
@Override
public void run() {
try {
updater.updateMaterial(material);
} catch (Exception e) {
threadOneExceptions.add(e);
}
}
};
Thread updateThread2 = new Thread() {
@Override
public void run() {
try {
updater.updateMaterial(material);
} catch (Exception e) {
threadTwoExceptions.add(e);
}
}
};
updateThread1.start();
updateThread2.start();
updateThread1.join();
updateThread2.join();
if (!threadOneExceptions.isEmpty()) {
throw threadOneExceptions.get(0);
}
if (!threadTwoExceptions.isEmpty()) {
throw threadTwoExceptions.get(0);
}
assertThat("transaction template executeWithExceptionHandling should be invoked only once", transactionTemplateWithInvocationCount.invocationCount, is(1));
}
use of com.thoughtworks.go.config.materials.ScmMaterial 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));
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialRevisions method updateToCommand.
public BuildCommand updateToCommand(String baseDir) {
List<BuildCommand> commands = new ArrayList<>();
for (MaterialRevision revision : revisions) {
Material material = revision.getMaterial();
if (material instanceof ScmMaterial) {
if (material instanceof GitMaterial) {
GitMaterialUpdater updater = new GitMaterialUpdater((GitMaterial) material);
commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
} else {
commands.add(BuildCommand.fail("%s Material is not supported for new build command agent", material.getTypeForDisplay()));
}
}
}
return BuildCommand.compose(commands);
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldPersistMaterialsWithRealPassword.
@Test
public void shouldPersistMaterialsWithRealPassword() throws SQLException {
MaterialRevisions materialRevisions = new MaterialRevisions();
addRevision(materialRevisions, MaterialsMother.svnMaterial("http://username:password@localhost"));
addRevision(materialRevisions, MaterialsMother.hgMaterial("http://username:password@localhost"));
addRevision(materialRevisions, new GitMaterial("git://username:password@localhost"));
addRevision(materialRevisions, new P4Material("localhost:1666", "view"));
BuildCause buildCause = BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS);
Pipeline pipeline = new Pipeline("Test", buildCause);
save(pipeline);
Pipeline loaded = pipelineDao.mostRecentPipeline("Test");
Materials materials = loaded.getMaterials();
for (Material material : materials) {
assertThat(((ScmMaterial) material).getUrl(), not(containsString("******")));
}
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class SCMDependencyNodeTest method addMaterialRevisionShouldNotAllowDuplicates.
@Test
public void addMaterialRevisionShouldNotAllowDuplicates() {
ScmMaterial gitMaterial = MaterialsMother.gitMaterial("/url/for/repo");
List<Modification> modifications = ModificationsMother.multipleModificationList();
SCMDependencyNode node = new SCMDependencyNode("nodeID", "nodeName", "GIT");
node.addMaterialRevision(new MaterialRevision(gitMaterial, modifications));
node.addMaterialRevision(new MaterialRevision(gitMaterial, modifications));
assertThat(node.getMaterialRevisions().size(), is(1));
}
Aggregations