Skip to content

Commit

Permalink
updated tests to include containercount parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cole committed Apr 8, 2011
1 parent b7e2f60 commit 5f43dbb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 37 deletions.
Expand Up @@ -65,19 +65,20 @@ public class BaseBlobStoreIntegrationTest {
protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple");

protected Map<String, String> 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<String, String> 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<String, String> 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.
Expand All @@ -95,7 +96,7 @@ public void setUpResourcesForAllThreads(ITestContext testContext) throws Excepti

@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<BaseTestInitializer> clazz = (Class<BaseTestInitializer>) Class.forName(initializerClass);
BaseTestInitializer initializer = clazz.newInstance();
Expand Down Expand Up @@ -128,7 +129,7 @@ protected void tearDownClient() throws Exception {
private static volatile boolean initialized = false;

protected void createContainersSharedByAllThreads(BlobStoreContext context, ITestContext testContext)
throws Exception {
throws Exception {
while (!initialized) {
synchronized (BaseBlobStoreIntegrationTest.class) {
if (!initialized) {
Expand Down Expand Up @@ -179,12 +180,12 @@ protected static void deleteEverything(final BlobStoreContext context) throws Ex
try {
for (int i = 0; i < 2; i++) {
Iterable<? extends StorageMetadata> testContainers = Iterables.filter(context.getBlobStore().list(),
new Predicate<StorageMetadata>() {
public boolean apply(StorageMetadata input) {
return (input.getType() == StorageType.CONTAINER || input.getType() == StorageType.FOLDER)
&& input.getName().startsWith(CONTAINER_PREFIX.toLowerCase());
}
});
new Predicate<StorageMetadata>() {
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());
}
Expand All @@ -205,7 +206,7 @@ public boolean apply(StorageMetadata input) {
* 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;
Expand All @@ -231,7 +232,7 @@ protected void assertConsistencyAware(Runnable assertion) throws InterruptedExce
}

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);
Expand All @@ -253,8 +254,8 @@ protected String addBlobToContainer(String sourceContainer, String key, String p

protected void add5BlobsUnderPathAnd5UnderRootToContainer(String sourceContainer) {
for (Entry<String, String> 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);
}
}
Expand Down Expand Up @@ -284,20 +285,20 @@ protected Blob validateContent(String container, String name) throws Interrupted
}

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<StorageMetadata, String>() {
"expected only %d values in %s: %s", count, containerName, ImmutableSet.copyOf(Iterables
.transform(context.getBlobStore().list(containerName),
new Function<StorageMetadata, String>() {

public String apply(StorageMetadata from) {
return from.getName();
}
public String apply(StorageMetadata from) {
return from.getName();
}

})));
})));
} catch (Exception e) {
Throwables.propagateIfPossible(e);
}
Expand All @@ -306,19 +307,19 @@ public String apply(StorageMetadata from) {
}

protected void assertConsistencyAwareBlobExists(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(
"could not find %s in %s: %s", name, containerName, ImmutableSet.copyOf(Iterables.transform(
context.getBlobStore().list(containerName), new Function<StorageMetadata, String>() {
"could not find %s in %s: %s", name, containerName, ImmutableSet.copyOf(Iterables.transform(
context.getBlobStore().list(containerName), new Function<StorageMetadata, String>() {

public String apply(StorageMetadata from) {
return from.getName();
}
public String apply(StorageMetadata from) {
return from.getName();
}

})));
})));
} catch (Exception e) {
Throwables.propagateIfPossible(e);
}
Expand All @@ -327,12 +328,12 @@ public String apply(StorageMetadata from) {
}

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);
}
Expand Down Expand Up @@ -386,7 +387,7 @@ protected void assertNotExists(final String containerName) throws InterruptedExc
public void run() {
try {
assert !context.getBlobStore().containerExists(containerName) : "container " + containerName
+ " still exists";
+ " still exists";
} catch (Exception e) {
propagateIfPossible(e);
}
Expand Down
5 changes: 5 additions & 0 deletions providers/aws-s3/pom.xml
Expand Up @@ -40,6 +40,7 @@
<test.aws-s3.apiversion>2006-03-01</test.aws-s3.apiversion>
<test.aws-s3.identity>${test.aws.identity}</test.aws-s3.identity>
<test.aws-s3.credential>${test.aws.credential}</test.aws-s3.credential>
<test.blobstore.container-count>25</test.blobstore.container-count>
</properties>

<!-- temporary -->
Expand Down Expand Up @@ -150,6 +151,10 @@
<name>jclouds.blobstore.httpstream.md5</name>
<value>${jclouds.blobstore.httpstream.md5}</value>
</property>
<property>
<name>test.blobstore.container-count</name>
<value>${test.blobstore.container-count}</value>
</property>
</systemProperties>
</configuration>
</execution>
Expand Down
5 changes: 5 additions & 0 deletions providers/eucalyptus-partnercloud-s3/pom.xml
Expand Up @@ -40,6 +40,7 @@
<test.eucalyptus-partnercloud-s3.apiversion>2006-03-01</test.eucalyptus-partnercloud-s3.apiversion>
<test.eucalyptus-partnercloud-s3.identity>FIXME_IDENTITY</test.eucalyptus-partnercloud-s3.identity>
<test.eucalyptus-partnercloud-s3.credential>FIXME_CREDENTIAL</test.eucalyptus-partnercloud-s3.credential>
<test.blobstore.container-count>15</test.blobstore.container-count>
</properties>

<dependencies>
Expand Down Expand Up @@ -136,6 +137,10 @@
<name>jclouds.blobstore.httpstream.md5</name>
<value>${jclouds.blobstore.httpstream.md5}</value>
</property>
<property>
<name>test.blobstore.container-count</name>
<value>${test.blobstore.container-count}</value>
</property>
</systemProperties>
</configuration>
</execution>
Expand Down

0 comments on commit 5f43dbb

Please sign in to comment.