summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.server.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-03-22 19:11:06 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2016-03-22 19:11:08 -0400
commit09810d013c8366f3f174438e8537d397b158906a (patch)
treed47ae38f58b7863086eed5c3f8e10ecded333e0b /org.eclipse.jgit.lfs.server.test
parentb601e88738945b3861b99283173e31daf924227d (diff)
parentb72fc2b4942d45f4e8317821be0c3eb470b1688f (diff)
downloadjgit-09810d013c8366f3f174438e8537d397b158906a.tar.gz
jgit-09810d013c8366f3f174438e8537d397b158906a.zip
Merge "Make the FileLfsRepository thread safe"
Diffstat (limited to 'org.eclipse.jgit.lfs.server.test')
-rw-r--r--org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java
index 35bf09b0c1..1fb91bd29d 100644
--- a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java
+++ b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java
@@ -51,6 +51,13 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.lfs.lib.AnyLongObjectId;
import org.eclipse.jgit.lfs.lib.LongObjectId;
@@ -98,4 +105,36 @@ public class UploadTest extends LfsServerTest {
assertEquals("expected object length " + Files.size(f), Files.size(f),
repository.getSize(id));
}
+
+ @Test
+ public void testParallelUploads() throws Exception {
+ int count = 10;
+ List<Path> paths = new ArrayList<>(count);
+
+ for (int i = 0; i < count; i++) {
+ Path f = Paths.get(getTempDirectory().toString(),
+ "largeRandomFile_" + i);
+ createPseudoRandomContentFile(f, 1 * MiB);
+ paths.add(f);
+ }
+
+ final CyclicBarrier barrier = new CyclicBarrier(count);
+
+ ExecutorService e = Executors.newFixedThreadPool(count);
+ try {
+ for (final Path p : paths) {
+ e.submit(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ barrier.await();
+ putContent(p);
+ return null;
+ }
+ });
+ }
+ } finally {
+ e.shutdown();
+ e.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
+ }
+ }
}