From 5f43dbb6fae02af7b5454d68b4b2311c92ddae85 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 8 Apr 2011 15:03:14 -0700 Subject: [PATCH] updated tests to include containercount parameter --- .../BaseBlobStoreIntegrationTest.java | 95 ++++++++++--------- providers/aws-s3/pom.xml | 5 + providers/eucalyptus-partnercloud-s3/pom.xml | 5 + 3 files changed, 58 insertions(+), 47 deletions(-) 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 8738e8105e..3b73bb29f3 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 @@ -65,19 +65,20 @@ public class BaseBlobStoreIntegrationTest { protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple"); protected Map fiveStrings = ImmutableMap.of("one", String.format(XML_STRING_FORMAT, "apple"), "two", - String.format(XML_STRING_FORMAT, "bear"), "three", String.format(XML_STRING_FORMAT, "candy"), "four", - String.format(XML_STRING_FORMAT, "dogma"), "five", String.format(XML_STRING_FORMAT, "emma")); + String.format(XML_STRING_FORMAT, "bear"), "three", String.format(XML_STRING_FORMAT, "candy"), "four", + String.format(XML_STRING_FORMAT, "dogma"), "five", String.format(XML_STRING_FORMAT, "emma")); - protected Map fiveStringsUnderPath = ImmutableMap.of("path/1", String.format(XML_STRING_FORMAT, - "apple"), "path/2", String.format(XML_STRING_FORMAT, "bear"), "path/3", String.format(XML_STRING_FORMAT, - "candy"), "path/4", String.format(XML_STRING_FORMAT, "dogma"), "path/5", String.format(XML_STRING_FORMAT, - "emma")); + protected Map fiveStringsUnderPath = ImmutableMap.of("path/1", + String.format(XML_STRING_FORMAT, "apple"), "path/2", String.format(XML_STRING_FORMAT, "bear"), "path/3", + String.format(XML_STRING_FORMAT, "candy"), "path/4", String.format(XML_STRING_FORMAT, "dogma"), "path/5", + String.format(XML_STRING_FORMAT, "emma")); public static long INCONSISTENCY_WINDOW = 10000; protected static volatile AtomicInteger containerIndex = new AtomicInteger(0); protected volatile BlobStoreContext context; - protected static volatile int containerCount = 10; + protected static volatile int containerCount = Integer.parseInt(System.getProperty("test.blobstore.container-count", + "10")); public static final String CONTAINER_PREFIX = System.getProperty("user.name") + "-blobstore"; /** * two test groups integration and live. @@ -95,7 +96,7 @@ public class BaseBlobStoreIntegrationTest { @SuppressWarnings("unchecked") private BlobStoreContext getCloudResources(ITestContext testContext) throws ClassNotFoundException, - InstantiationException, IllegalAccessException, Exception { + InstantiationException, IllegalAccessException, Exception { String initializerClass = checkNotNull(System.getProperty("test.initializer"), "test.initializer"); Class clazz = (Class) Class.forName(initializerClass); BaseTestInitializer initializer = clazz.newInstance(); @@ -128,7 +129,7 @@ public class BaseBlobStoreIntegrationTest { private static volatile boolean initialized = false; protected void createContainersSharedByAllThreads(BlobStoreContext context, ITestContext testContext) - throws Exception { + throws Exception { while (!initialized) { synchronized (BaseBlobStoreIntegrationTest.class) { if (!initialized) { @@ -179,12 +180,12 @@ public class BaseBlobStoreIntegrationTest { try { for (int i = 0; i < 2; i++) { Iterable testContainers = Iterables.filter(context.getBlobStore().list(), - new Predicate() { - public boolean apply(StorageMetadata input) { - return (input.getType() == StorageType.CONTAINER || input.getType() == StorageType.FOLDER) - && input.getName().startsWith(CONTAINER_PREFIX.toLowerCase()); - } - }); + new Predicate() { + public boolean apply(StorageMetadata input) { + return (input.getType() == StorageType.CONTAINER || input.getType() == StorageType.FOLDER) + && input.getName().startsWith(CONTAINER_PREFIX.toLowerCase()); + } + }); for (StorageMetadata container : testContainers) { deleteContainerOrWarnIfUnable(context, container.getName()); } @@ -205,7 +206,7 @@ public class BaseBlobStoreIntegrationTest { * we will try up to the inconsistency window to see if the assertion completes. */ protected static void assertConsistencyAware(BlobStoreContext context, Runnable assertion) - throws InterruptedException { + throws InterruptedException { if (context.getConsistencyModel() == ConsistencyModel.STRICT) { assertion.run(); return; @@ -231,7 +232,7 @@ public class BaseBlobStoreIntegrationTest { } protected static void createContainerAndEnsureEmpty(BlobStoreContext context, final String containerName) - throws InterruptedException { + throws InterruptedException { context.getBlobStore().createContainerInLocation(null, containerName); if (context.getConsistencyModel() == ConsistencyModel.EVENTUAL) Thread.sleep(1000); @@ -253,8 +254,8 @@ public class BaseBlobStoreIntegrationTest { protected void add5BlobsUnderPathAnd5UnderRootToContainer(String sourceContainer) { for (Entry entry : Iterables.concat(fiveStrings.entrySet(), fiveStringsUnderPath.entrySet())) { - Blob sourceObject = context.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue()).contentType( - "text/xml").build(); + Blob sourceObject = context.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue()) + .contentType("text/xml").build(); addBlobToContainer(sourceContainer, sourceObject); } } @@ -284,35 +285,14 @@ public class BaseBlobStoreIntegrationTest { } protected void assertConsistencyAwareContainerSize(final String containerName, final int count) - throws InterruptedException { + throws InterruptedException { assertConsistencyAware(new Runnable() { public void run() { try { assert context.getBlobStore().countBlobs(containerName) == count : String.format( - "expected only %d values in %s: %s", count, containerName, ImmutableSet.copyOf(Iterables - .transform(context.getBlobStore().list(containerName), - new Function() { - - public String apply(StorageMetadata from) { - return from.getName(); - } - - }))); - } catch (Exception e) { - Throwables.propagateIfPossible(e); - } - } - }); - } - - protected void assertConsistencyAwareBlobExists(final String containerName, final String name) - throws InterruptedException { - assertConsistencyAware(new Runnable() { - public void run() { - try { - assert context.getBlobStore().blobExists(containerName, name) : String.format( - "could not find %s in %s: %s", name, containerName, ImmutableSet.copyOf(Iterables.transform( - context.getBlobStore().list(containerName), new Function() { + "expected only %d values in %s: %s", count, containerName, ImmutableSet.copyOf(Iterables + .transform(context.getBlobStore().list(containerName), + new Function() { public String apply(StorageMetadata from) { return from.getName(); @@ -326,13 +306,34 @@ public class BaseBlobStoreIntegrationTest { }); } + protected void assertConsistencyAwareBlobExists(final String containerName, final String name) + throws InterruptedException { + assertConsistencyAware(new Runnable() { + public void run() { + try { + assert context.getBlobStore().blobExists(containerName, name) : String.format( + "could not find %s in %s: %s", name, containerName, ImmutableSet.copyOf(Iterables.transform( + context.getBlobStore().list(containerName), new Function() { + + public String apply(StorageMetadata from) { + return from.getName(); + } + + }))); + } catch (Exception e) { + Throwables.propagateIfPossible(e); + } + } + }); + } + protected void assertConsistencyAwareBlobDoesntExist(final String containerName, final String name) - throws InterruptedException { + throws InterruptedException { assertConsistencyAware(new Runnable() { public void run() { try { assert !context.getBlobStore().blobExists(containerName, name) : String.format("found %s in %s", name, - containerName); + containerName); } catch (Exception e) { Throwables.propagateIfPossible(e); } @@ -386,7 +387,7 @@ public class BaseBlobStoreIntegrationTest { public void run() { try { assert !context.getBlobStore().containerExists(containerName) : "container " + containerName - + " still exists"; + + " still exists"; } catch (Exception e) { propagateIfPossible(e); } diff --git a/providers/aws-s3/pom.xml b/providers/aws-s3/pom.xml index a46eb1c36f..30edbe413e 100644 --- a/providers/aws-s3/pom.xml +++ b/providers/aws-s3/pom.xml @@ -40,6 +40,7 @@ 2006-03-01 ${test.aws.identity} ${test.aws.credential} + 25 @@ -150,6 +151,10 @@ jclouds.blobstore.httpstream.md5 ${jclouds.blobstore.httpstream.md5} + + test.blobstore.container-count + ${test.blobstore.container-count} + diff --git a/providers/eucalyptus-partnercloud-s3/pom.xml b/providers/eucalyptus-partnercloud-s3/pom.xml index 51dceb4970..f27ed56f13 100644 --- a/providers/eucalyptus-partnercloud-s3/pom.xml +++ b/providers/eucalyptus-partnercloud-s3/pom.xml @@ -40,6 +40,7 @@ 2006-03-01 FIXME_IDENTITY FIXME_CREDENTIAL + 15 @@ -136,6 +137,10 @@ jclouds.blobstore.httpstream.md5 ${jclouds.blobstore.httpstream.md5} + + test.blobstore.container-count + ${test.blobstore.container-count} +