mirror of https://github.com/apache/jclouds.git
replay bucket listing before re-attempting clearing the bucket
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1479 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
dd1863f7ff
commit
344cf6a3a7
|
@ -67,7 +67,7 @@ import com.google.inject.Module;
|
||||||
|
|
||||||
public class S3IntegrationTest {
|
public class S3IntegrationTest {
|
||||||
protected static final String TEST_STRING = "<apples><apple name=\"fuji\"></apple> </apples>";
|
protected static final String TEST_STRING = "<apples><apple name=\"fuji\"></apple> </apples>";
|
||||||
public static long INCONSISTENCY_WINDOW = 2000;
|
public static long INCONSISTENCY_WINDOW = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Due to eventual consistency, bucket commands may not return correctly immediately. Hence, we
|
* Due to eventual consistency, bucket commands may not return correctly immediately. Hence, we
|
||||||
|
@ -300,12 +300,7 @@ public class S3IntegrationTest {
|
||||||
public void setUpBuckets(ITestContext context) throws Exception {
|
public void setUpBuckets(ITestContext context) throws Exception {
|
||||||
synchronized (bucketNames) {
|
synchronized (bucketNames) {
|
||||||
if (bucketNames.peek() == null) {
|
if (bucketNames.peek() == null) {
|
||||||
// try twice to delete everything
|
|
||||||
try {
|
|
||||||
deleteEverything();
|
deleteEverything();
|
||||||
} catch (AssertionError e) {
|
|
||||||
deleteEverything();
|
|
||||||
}
|
|
||||||
for (; bucketIndex < bucketCount; bucketIndex++) {
|
for (; bucketIndex < bucketCount; bucketIndex++) {
|
||||||
String bucketName = bucketPrefix + bucketIndex;
|
String bucketName = bucketPrefix + bucketIndex;
|
||||||
try {
|
try {
|
||||||
|
@ -351,15 +346,17 @@ public class S3IntegrationTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove any objects in a bucket, leaving it empty.
|
* Remove any objects in a bucket, leaving it empty.
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @throws InterruptedException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
*/
|
*/
|
||||||
protected void emptyBucket(String name) throws InterruptedException, ExecutionException,
|
protected void emptyBucket(final String name) throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
if (client.bucketExists(name).get(10, TimeUnit.SECONDS)) {
|
if (client.bucketExists(name).get(10, TimeUnit.SECONDS)) {
|
||||||
|
// This can fail to be zero length because of stale bucket lists. Ex. client.listBucket()
|
||||||
|
// could return 9 keys, when there are 10. When all the deletions finish, one entry would
|
||||||
|
// be left in this case. Instead of failing, we will attempt this entire bucket deletion
|
||||||
|
// operation multiple times to ensure we can acheive a zero length bucket.
|
||||||
|
assertEventually(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
List<Future<Boolean>> results = new ArrayList<Future<Boolean>>();
|
List<Future<Boolean>> results = new ArrayList<Future<Boolean>>();
|
||||||
|
|
||||||
S3Bucket bucket = client.listBucket(name).get(10, TimeUnit.SECONDS);
|
S3Bucket bucket = client.listBucket(name).get(10, TimeUnit.SECONDS);
|
||||||
|
@ -371,8 +368,14 @@ public class S3IntegrationTest {
|
||||||
iterator.next().get(10, TimeUnit.SECONDS);
|
iterator.next().get(10, TimeUnit.SECONDS);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
assertEventuallyBucketEmpty(name);
|
assertEventuallyBucketEmpty(name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String createScratchBucketInEU() throws InterruptedException, ExecutionException,
|
protected String createScratchBucketInEU() throws InterruptedException, ExecutionException,
|
||||||
|
|
Loading…
Reference in New Issue