updated tests to include containercount parameter

This commit is contained in:
Adrian Cole 2011-04-08 15:03:14 -07:00
parent b7e2f606c7
commit 5f43dbb6fa
3 changed files with 58 additions and 47 deletions

View File

@ -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.
@ -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<BaseTestInitializer> clazz = (Class<BaseTestInitializer>) 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<? 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());
}
@ -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<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);
}
}
@ -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<StorageMetadata, String>() {
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<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();
@ -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<StorageMetadata, String>() {
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);
}

View File

@ -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 -->
@ -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>

View File

@ -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>
@ -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>