added more filename tests and loosened timeouts

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1948 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-10-07 21:09:51 +00:00
parent e93a081d9e
commit c228add243
2 changed files with 29 additions and 27 deletions

View File

@ -75,12 +75,12 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
DateTime after = new DateTime().plusSeconds(1); DateTime after = new DateTime().plusSeconds(1);
context.getBlobStore().getBlob(containerName, key, ifModifiedSince(before)).get(10, context.getBlobStore().getBlob(containerName, key, ifModifiedSince(before)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
try { try {
context.getBlobStore().getBlob(containerName, key, ifModifiedSince(after)).get(10, context.getBlobStore().getBlob(containerName, key, ifModifiedSince(after)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
} catch (ExecutionException e) { } catch (ExecutionException e) {
@ -111,12 +111,12 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
DateTime after = new DateTime().plusSeconds(1); DateTime after = new DateTime().plusSeconds(1);
context.getBlobStore().getBlob(containerName, key, ifUnmodifiedSince(after)).get(10, context.getBlobStore().getBlob(containerName, key, ifUnmodifiedSince(after)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
try { try {
context.getBlobStore().getBlob(containerName, key, ifUnmodifiedSince(before)).get(10, context.getBlobStore().getBlob(containerName, key, ifUnmodifiedSince(before)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
} catch (ExecutionException e) { } catch (ExecutionException e) {
@ -144,12 +144,12 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
context.getBlobStore().getBlob(containerName, key, ifETagMatches(goodETag)).get(10, context.getBlobStore().getBlob(containerName, key, ifETagMatches(goodETag)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
try { try {
context.getBlobStore().getBlob(containerName, key, ifETagMatches(badETag)).get(10, context.getBlobStore().getBlob(containerName, key, ifETagMatches(badETag)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
} catch (ExecutionException e) { } catch (ExecutionException e) {
@ -177,12 +177,12 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
context.getBlobStore().getBlob(containerName, key, ifETagDoesntMatch(badETag)).get(10, context.getBlobStore().getBlob(containerName, key, ifETagDoesntMatch(badETag)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
try { try {
context.getBlobStore().getBlob(containerName, key, ifETagDoesntMatch(goodETag)).get(10, context.getBlobStore().getBlob(containerName, key, ifETagDoesntMatch(goodETag)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
validateContent(containerName, key); validateContent(containerName, key);
} catch (ExecutionException e) { } catch (ExecutionException e) {
@ -207,13 +207,13 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
String key = "apples"; String key = "apples";
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
B object1 = context.getBlobStore().getBlob(containerName, key, range(0, 5)).get(10, B object1 = context.getBlobStore().getBlob(containerName, key, range(0, 5)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
assertEquals(BlobStoreUtils.getContentAsStringAndClose(object1), TEST_STRING.substring(0, assertEquals(BlobStoreUtils.getContentAsStringAndClose(object1), TEST_STRING.substring(0,
6)); 6));
B object2 = context.getBlobStore().getBlob(containerName, key, B object2 = context.getBlobStore().getBlob(containerName, key,
range(6, TEST_STRING.length())).get(10, TimeUnit.SECONDS); range(6, TEST_STRING.length())).get(15, TimeUnit.SECONDS);
assertEquals(BlobStoreUtils.getContentAsStringAndClose(object2), TEST_STRING.substring(6, assertEquals(BlobStoreUtils.getContentAsStringAndClose(object2), TEST_STRING.substring(6,
TEST_STRING.length())); TEST_STRING.length()));
} finally { } finally {
@ -231,7 +231,7 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
B object = context.getBlobStore().getBlob(containerName, key, B object = context.getBlobStore().getBlob(containerName, key,
range(0, 5).range(6, TEST_STRING.length())).get(10, TimeUnit.SECONDS); range(0, 5).range(6, TEST_STRING.length())).get(15, TimeUnit.SECONDS);
assertEquals(BlobStoreUtils.getContentAsStringAndClose(object), TEST_STRING); assertEquals(BlobStoreUtils.getContentAsStringAndClose(object), TEST_STRING);
} finally { } finally {
@ -248,7 +248,7 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
String key = "apples"; String key = "apples";
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
B object = context.getBlobStore().getBlob(containerName, key, tail(5)).get(10, B object = context.getBlobStore().getBlob(containerName, key, tail(5)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
assertEquals(BlobStoreUtils.getContentAsStringAndClose(object), TEST_STRING assertEquals(BlobStoreUtils.getContentAsStringAndClose(object), TEST_STRING
.substring(TEST_STRING.length() - 5)); .substring(TEST_STRING.length() - 5));
@ -267,7 +267,7 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
String key = "apples"; String key = "apples";
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
B object = context.getBlobStore().getBlob(containerName, key, startAt(5)).get(10, B object = context.getBlobStore().getBlob(containerName, key, startAt(5)).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
assertEquals(BlobStoreUtils.getContentAsStringAndClose(object), TEST_STRING.substring(5, assertEquals(BlobStoreUtils.getContentAsStringAndClose(object), TEST_STRING.substring(5,
TEST_STRING.length())); TEST_STRING.length()));
@ -289,7 +289,7 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
String containerName = getContainerName(); String containerName = getContainerName();
String key = "test"; String key = "test";
try { try {
context.getBlobStore().removeBlob(containerName, key).get(10, TimeUnit.SECONDS); context.getBlobStore().removeBlob(containerName, key).get(15, TimeUnit.SECONDS);
} finally { } finally {
returnContainer(containerName); returnContainer(containerName);
} }
@ -297,7 +297,9 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
@DataProvider(name = "delete") @DataProvider(name = "delete")
public Object[][] createData() { public Object[][] createData() {
return new Object[][] { { "sp ace" }, { "qu?stion" }, { "unic¿de" }, { "path/" } }; return new Object[][] { { "normal" }, { "sp ace" }, { "qu?stion" }, { "unic¿de" },
{ "path/foo" }, { "colon:" }, { "asteri*k" }, { "quote\"" }, { "{great<r}" },
{ "lesst>en" }, { "p|pe" } };
} }
@Test(groups = { "integration", "live" }, dataProvider = "delete") @Test(groups = { "integration", "live" }, dataProvider = "delete")
@ -305,7 +307,7 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
String containerName = getContainerName(); String containerName = getContainerName();
try { try {
addBlobToContainer(containerName, key); addBlobToContainer(containerName, key);
context.getBlobStore().removeBlob(containerName, key).get(10, TimeUnit.SECONDS); context.getBlobStore().removeBlob(containerName, key).get(15, TimeUnit.SECONDS);
assertContainerEmptyDeleting(containerName, key); assertContainerEmptyDeleting(containerName, key);
} finally { } finally {
returnContainer(containerName); returnContainer(containerName);
@ -314,7 +316,7 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
private void assertContainerEmptyDeleting(String containerName, String key) private void assertContainerEmptyDeleting(String containerName, String key)
throws InterruptedException, ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
SortedSet<M> listing = context.getBlobStore().listBlobs(containerName).get(10, SortedSet<M> listing = context.getBlobStore().listBlobs(containerName).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
assertEquals(listing.size(), 0, String.format( assertEquals(listing.size(), 0, String.format(
"deleting %s, we still have %s left in container %s, using encoding %s", key, "deleting %s, we still have %s left in container %s, using encoding %s", key,
@ -324,7 +326,7 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
@Test(groups = { "integration", "live" }) @Test(groups = { "integration", "live" })
public void deleteObjectNoContainer() throws Exception { public void deleteObjectNoContainer() throws Exception {
try { try {
context.getBlobStore().removeBlob("donb", "test").get(10, TimeUnit.SECONDS); context.getBlobStore().removeBlob("donb", "test").get(15, TimeUnit.SECONDS);
} catch (ExecutionException e) { } catch (ExecutionException e) {
assert (e.getCause() instanceof HttpResponseException || e.getCause() instanceof ContainerNotFoundException); assert (e.getCause() instanceof HttpResponseException || e.getCause() instanceof ContainerNotFoundException);
if (e.getCause() instanceof HttpResponseException) if (e.getCause() instanceof HttpResponseException)
@ -353,13 +355,13 @@ public class BaseBlobIntegrationTest<S, C extends ContainerMetadata, M extends B
} }
String containerName = getContainerName(); String containerName = getContainerName();
try { try {
assertNotNull(context.getBlobStore().putBlob(containerName, object).get(10, assertNotNull(context.getBlobStore().putBlob(containerName, object).get(30,
TimeUnit.SECONDS)); TimeUnit.SECONDS));
object = context.getBlobStore().getBlob(containerName, object.getKey()).get(10, object = context.getBlobStore().getBlob(containerName, object.getKey()).get(30,
TimeUnit.SECONDS); TimeUnit.SECONDS);
String returnedString = BlobStoreUtils.getContentAsStringAndClose(object); String returnedString = BlobStoreUtils.getContentAsStringAndClose(object);
assertEquals(returnedString, realObject); assertEquals(returnedString, realObject);
assertEquals(context.getBlobStore().listBlobs(containerName).get(10, TimeUnit.SECONDS) assertEquals(context.getBlobStore().listBlobs(containerName).get(15, TimeUnit.SECONDS)
.size(), 1); .size(), 1);
} finally { } finally {
returnContainer(containerName); returnContainer(containerName);

View File

@ -214,14 +214,14 @@ public class BaseBlobStoreIntegrationTest<S, C extends ContainerMetadata, M exte
*/ */
protected static void assertEventually(Runnable assertion) throws InterruptedException { protected static void assertEventually(Runnable assertion) throws InterruptedException {
AssertionError error = null; AssertionError error = null;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 30; i++) {
try { try {
assertion.run(); assertion.run();
return; return;
} catch (AssertionError e) { } catch (AssertionError e) {
error = e; error = e;
} }
Thread.sleep(INCONSISTENCY_WINDOW / 10); Thread.sleep(INCONSISTENCY_WINDOW / 30);
} }
if (error != null) if (error != null)
throw error; throw error;
@ -249,13 +249,13 @@ public class BaseBlobStoreIntegrationTest<S, C extends ContainerMetadata, M exte
protected void addBlobToContainer(String sourceContainer, B object) throws InterruptedException, protected void addBlobToContainer(String sourceContainer, B object) throws InterruptedException,
ExecutionException, TimeoutException, IOException { ExecutionException, TimeoutException, IOException {
context.getBlobStore().putBlob(sourceContainer, object).get(10, TimeUnit.SECONDS); context.getBlobStore().putBlob(sourceContainer, object).get(30, TimeUnit.SECONDS);
} }
protected B validateContent(String sourceContainer, String key) throws InterruptedException, protected B validateContent(String sourceContainer, String key) throws InterruptedException,
ExecutionException, TimeoutException, IOException { ExecutionException, TimeoutException, IOException {
assertEventuallyContainerSize(sourceContainer, 1); assertEventuallyContainerSize(sourceContainer, 1);
B newObject = context.getBlobStore().getBlob(sourceContainer, key).get(10, TimeUnit.SECONDS); B newObject = context.getBlobStore().getBlob(sourceContainer, key).get(30, TimeUnit.SECONDS);
assert newObject != null; assert newObject != null;
assertEquals(BlobStoreUtils.getContentAsStringAndClose(newObject), TEST_STRING); assertEquals(BlobStoreUtils.getContentAsStringAndClose(newObject), TEST_STRING);
return newObject; return newObject;
@ -266,7 +266,7 @@ public class BaseBlobStoreIntegrationTest<S, C extends ContainerMetadata, M exte
assertEventually(new Runnable() { assertEventually(new Runnable() {
public void run() { public void run() {
try { try {
assertEquals(context.getBlobStore().listBlobs(containerName).get(10, assertEquals(context.getBlobStore().listBlobs(containerName).get(30,
TimeUnit.SECONDS).size(), count); TimeUnit.SECONDS).size(), count);
} catch (Exception e) { } catch (Exception e) {
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e); Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
@ -361,7 +361,7 @@ public class BaseBlobStoreIntegrationTest<S, C extends ContainerMetadata, M exte
final String name) throws InterruptedException, ExecutionException, TimeoutException { final String name) throws InterruptedException, ExecutionException, TimeoutException {
if (context.getBlobStore().containerExists(name)) { if (context.getBlobStore().containerExists(name)) {
System.err.printf("*** deleting container %s...%n", name); System.err.printf("*** deleting container %s...%n", name);
context.getBlobStore().deleteContainer(name).get(10, TimeUnit.SECONDS); context.getBlobStore().deleteContainer(name).get(30, TimeUnit.SECONDS);
assertEventually(new Runnable() { assertEventually(new Runnable() {
public void run() { public void run() {
try { try {