You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2016/06/23 05:50:47 UTC

[1/2] jclouds git commit: Use in-memory payload for testPutBlobParallel

Repository: jclouds
Updated Branches:
  refs/heads/master d197a9e0c -> 45bcc3ce2


Use in-memory payload for testPutBlobParallel

Also simplify parts of the test.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/45bcc3ce
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/45bcc3ce
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/45bcc3ce

Branch: refs/heads/master
Commit: 45bcc3ce226ec2150e893491f2e8046780377e76
Parents: de04c69
Author: Andrew Gaul <ga...@apache.org>
Authored: Wed Jun 22 22:49:11 2016 -0700
Committer: Andrew Gaul <ga...@apache.org>
Committed: Wed Jun 22 22:50:22 2016 -0700

----------------------------------------------------------------------
 .../internal/BaseBlobIntegrationTest.java       | 26 +++++++-------------
 1 file changed, 9 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/45bcc3ce/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java
----------------------------------------------------------------------
diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java
index 86b2e8b..608ed49 100644
--- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java
+++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java
@@ -43,8 +43,6 @@ import java.util.Random;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.ws.rs.core.MediaType;
 
@@ -119,33 +117,28 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
     * http://groups.google.com/group/jclouds/browse_thread/thread/4a7c8d58530b287f
     */
    @Test(groups = { "integration", "live" })
-   public void testPutFileParallel() throws InterruptedException, IOException, TimeoutException {
-
-      File payloadFile = File.createTempFile("testPutFileParallel", "png");
-      createTestInput(32 * 1024).copyTo(Files.asByteSink(payloadFile));
-
-      final Payload testPayload = Payloads.newFilePayload(payloadFile);
-      final HashCode md5 = hashAndClose(testPayload.openStream(), md5());
+   public void testPutBlobParallel() throws Exception {
+      final ByteSource expected = createTestInput(32 * 1024);
+      final Payload testPayload = Payloads.newByteSourcePayload(expected);
       testPayload.getContentMetadata().setContentType("image/png");
 
-      final AtomicInteger blobCount = new AtomicInteger();
       final String container = getContainerName();
       try {
          Map<Integer, ListenableFuture<?>> responses = Maps.newHashMap();
          for (int i = 0; i < 3; i++) {
-
+            final String name = String.valueOf(i);
             responses.put(i, this.exec.submit(new Callable<Void>() {
 
                @Override
                public Void call() throws Exception {
-                  String name = blobCount.incrementAndGet() + "";
-                  Blob blob = view.getBlobStore().blobBuilder(name).payload(testPayload).build();
+                  Blob blob = view.getBlobStore().blobBuilder(name).payload(testPayload).contentLength(expected.size()).build();
                   view.getBlobStore().putBlob(container, blob);
+
                   assertConsistencyAwareBlobExists(container, name);
-                  blob = view.getBlobStore().getBlob(container, name);
 
-                  assertEquals(hashAndClose(blob.getPayload().openStream(), md5()), md5,
-                           String.format("md5 didn't match on %s/%s", container, name));
+                  blob = view.getBlobStore().getBlob(container, name);
+                  byte[] actual = ByteStreams2.toByteArrayAndClose(blob.getPayload().openStream());
+                  assertThat(actual).isEqualTo(expected.read());
 
                   view.getBlobStore().removeBlob(container, name);
                   assertConsistencyAwareBlobDoesntExist(container, name);
@@ -159,7 +152,6 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
          assert exceptions.size() == 0 : exceptions;
 
       } finally {
-         payloadFile.delete();
          returnContainer(container);
       }
    }


[2/2] jclouds git commit: Consistently name test container names

Posted by ga...@apache.org.
Consistently name test container names

Previously jclouds allocated the initial container pool as
$USERNAME-blobstore-1, 2, etc. and subsequent containers with
$USERNAME-blobstore-$RANDOM.  Use only the former instead.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/de04c691
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/de04c691
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/de04c691

Branch: refs/heads/master
Commit: de04c69141d3d4ff5990038a5da47c3f11471452
Parents: d197a9e
Author: Andrew Gaul <ga...@apache.org>
Authored: Thu Jul 9 14:32:33 2015 -0700
Committer: Andrew Gaul <ga...@apache.org>
Committed: Wed Jun 22 22:50:22 2016 -0700

----------------------------------------------------------------------
 .../integration/internal/BaseBlobStoreIntegrationTest.java  | 5 ++---
 .../java/org/jclouds/azureblob/AzureBlobClientLiveTest.java | 9 +++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/de04c691/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java
----------------------------------------------------------------------
diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java
index b96389f..7aae5a4 100644
--- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java
+++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java
@@ -22,7 +22,6 @@ import static org.jclouds.reflect.Reflection2.typeToken;
 import static org.testng.Assert.assertEquals;
 
 import java.io.IOException;
-import java.security.SecureRandom;
 import java.util.Date;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -82,7 +81,7 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest<BlobStoreCont
          String.format(XML_STRING_FORMAT, "emma"));
 
    public static long INCONSISTENCY_WINDOW = 10000;
-   protected static volatile AtomicInteger containerIndex = new AtomicInteger(0);
+   protected static final AtomicInteger containerIndex = new AtomicInteger(0);
 
    protected static volatile int containerCount = Integer.parseInt(System.getProperty("test.blobstore.container-count",
          "10"));
@@ -514,7 +513,7 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest<BlobStoreCont
             deleteContainerOrWarnIfUnable(view, container);
          }
       });
-      String newScratchContainer = CONTAINER_PREFIX + new SecureRandom().nextLong();
+      String newScratchContainer = CONTAINER_PREFIX + containerIndex.incrementAndGet();
       System.err.printf("*** allocated new container %s...%n", newScratchContainer);
       return newScratchContainer;
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de04c691/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java
index 61f2320..07f1944 100644
--- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java
+++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java
@@ -94,7 +94,8 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest {
    public void testCreateContainer() throws Exception {
       boolean created = false;
       while (!created) {
-         privateContainer = CONTAINER_PREFIX + new SecureRandom().nextInt();
+         // testListOwnedContainers requires a unique prefix
+         privateContainer = CONTAINER_PREFIX + "unique-" + containerIndex.incrementAndGet();
          try {
             created = getApi().createContainer(privateContainer, withMetadata(ImmutableMultimap.of("foo", "bar")));
          } catch (UndeclaredThrowableException e) {
@@ -118,7 +119,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest {
    public void testCreatePublicContainer() throws Exception {
       boolean created = false;
       while (!created) {
-         publicContainer = CONTAINER_PREFIX + new SecureRandom().nextInt();
+         publicContainer = CONTAINER_PREFIX + containerIndex.incrementAndGet();
          try {
             created = getApi().createContainer(publicContainer, withPublicAccess(PublicAccess.BLOB));
          } catch (UndeclaredThrowableException e) {
@@ -342,7 +343,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest {
 
    @Test(timeOut = 5 * 60 * 1000)
    public void testBlockOperations() throws Exception {
-      String blockContainer = CONTAINER_PREFIX + new SecureRandom().nextInt();
+      String blockContainer = CONTAINER_PREFIX + containerIndex.incrementAndGet();
       String blockBlob = "myblockblob-" + new SecureRandom().nextInt();
       String A = "A";
       String B = "B";
@@ -380,7 +381,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest {
    @Test
    public void testGetSetACL() throws Exception {
       AzureBlobClient client = getApi();
-      String blockContainer = CONTAINER_PREFIX + new SecureRandom().nextInt();
+      String blockContainer = CONTAINER_PREFIX + containerIndex.incrementAndGet();
       client.createContainer(blockContainer);
       try {
          assertThat(client.getPublicAccessForContainer(blockContainer)).isEqualTo(PublicAccess.PRIVATE);