mirror of https://github.com/apache/jclouds.git
Issue 64: cleaned up integration test code
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1482 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
3b72ff31df
commit
074fefc7db
|
@ -27,27 +27,22 @@ import static org.jclouds.aws.s3.commands.options.PutBucketOptions.Builder.creat
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.logging.ConsoleHandler;
|
|
||||||
import java.util.logging.Formatter;
|
|
||||||
import java.util.logging.Handler;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.jclouds.aws.s3.config.StubS3ConnectionModule;
|
import org.jclouds.aws.s3.config.StubS3ConnectionModule;
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
import org.jclouds.aws.s3.domain.S3Bucket;
|
||||||
import org.jclouds.aws.s3.domain.S3Object;
|
import org.jclouds.aws.s3.domain.S3Object;
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket.Metadata;
|
import org.jclouds.aws.s3.domain.S3Bucket.Metadata;
|
||||||
import org.jclouds.aws.s3.domain.S3Bucket.Metadata.LocationConstraint;
|
import org.jclouds.aws.s3.domain.S3Bucket.Metadata.LocationConstraint;
|
||||||
import org.jclouds.aws.s3.internal.StubS3Connection;
|
|
||||||
import org.jclouds.aws.s3.reference.S3Constants;
|
import org.jclouds.aws.s3.reference.S3Constants;
|
||||||
import org.jclouds.aws.s3.util.S3Utils;
|
import org.jclouds.aws.s3.util.S3Utils;
|
||||||
import org.jclouds.http.config.JavaUrlHttpFutureCommandClientModule;
|
import org.jclouds.http.config.JavaUrlHttpFutureCommandClientModule;
|
||||||
|
@ -66,6 +61,25 @@ 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 = 1000;
|
public static long INCONSISTENCY_WINDOW = 1000;
|
||||||
|
protected static final String sysAWSAccessKeyId = System
|
||||||
|
.getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
|
||||||
|
protected static final String sysAWSSecretAccessKey = System
|
||||||
|
.getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
|
||||||
|
protected static int bucketCount = 20;
|
||||||
|
protected static volatile int bucketIndex = 0;
|
||||||
|
|
||||||
|
protected byte[] goodMd5;
|
||||||
|
protected byte[] badMd5;
|
||||||
|
protected S3Connection client;
|
||||||
|
protected S3Context context = null;
|
||||||
|
protected boolean SANITY_CHECK_RETURNED_BUCKET_NAME = false;
|
||||||
|
private String bucketPrefix = System.getProperty("user.name") + ".s3int";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* two test groups integration and live.
|
||||||
|
*/
|
||||||
|
private static final BlockingQueue<String> bucketNames = new ArrayBlockingQueue<String>(
|
||||||
|
bucketCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -86,27 +100,10 @@ public class S3IntegrationTest {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte[] goodMd5;
|
|
||||||
protected byte[] badMd5;
|
|
||||||
|
|
||||||
protected void createBucketAndEnsureEmpty(String bucketName) throws InterruptedException,
|
protected void createBucketAndEnsureEmpty(String bucketName) throws InterruptedException,
|
||||||
ExecutionException, TimeoutException {
|
ExecutionException, TimeoutException {
|
||||||
client.putBucketIfNotExists(bucketName).get(10, TimeUnit.SECONDS);
|
client.putBucketIfNotExists(bucketName).get(10, TimeUnit.SECONDS);
|
||||||
emptyBucket(bucketName);
|
emptyBucket(bucketName);
|
||||||
assertEventuallyBucketEmpty(bucketName);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void assertEventuallyBucketEmpty(final String bucketName) throws InterruptedException {
|
|
||||||
assertEventually(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
assertEquals(client.listBucket(bucketName).get(10, TimeUnit.SECONDS).getContents()
|
|
||||||
.size(), 0, "bucket " + bucketName + "wasn't empty");
|
|
||||||
} catch (Exception e) {
|
|
||||||
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addObjectToBucket(String sourceBucket, String key) throws InterruptedException,
|
protected void addObjectToBucket(String sourceBucket, String key) throws InterruptedException,
|
||||||
|
@ -145,38 +142,6 @@ public class S3IntegrationTest {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = { "integration", "live" })
|
|
||||||
protected void enableDebug() {
|
|
||||||
if (debugEnabled()) {
|
|
||||||
Handler HANDLER = new ConsoleHandler() {
|
|
||||||
{
|
|
||||||
setLevel(Level.ALL);
|
|
||||||
setFormatter(new Formatter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(LogRecord record) {
|
|
||||||
return String.format("[%tT %-7s] [%-7s] [%s]: %s %s\n", new Date(record
|
|
||||||
.getMillis()), record.getLevel(), Thread.currentThread().getName(),
|
|
||||||
record.getLoggerName(), record.getMessage(),
|
|
||||||
record.getThrown() == null ? "" : record.getThrown());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Logger guiceLogger = Logger.getLogger("org.jclouds");
|
|
||||||
guiceLogger.addHandler(HANDLER);
|
|
||||||
guiceLogger.setLevel(Level.ALL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected S3Connection client;
|
|
||||||
protected S3Context context = null;
|
|
||||||
|
|
||||||
protected static final String sysAWSAccessKeyId = System
|
|
||||||
.getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
|
|
||||||
protected static final String sysAWSSecretAccessKey = System
|
|
||||||
.getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "integration", "live" })
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
@Parameters( { S3Constants.PROPERTY_AWS_ACCESSKEYID, S3Constants.PROPERTY_AWS_SECRETACCESSKEY })
|
@Parameters( { S3Constants.PROPERTY_AWS_ACCESSKEYID, S3Constants.PROPERTY_AWS_SECRETACCESSKEY })
|
||||||
protected void setUpCredentials(@Optional String AWSAccessKeyId,
|
protected void setUpCredentials(@Optional String AWSAccessKeyId,
|
||||||
|
@ -202,9 +167,6 @@ public class S3IntegrationTest {
|
||||||
}
|
}
|
||||||
client = context.getConnection();
|
client = context.getConnection();
|
||||||
assert client != null;
|
assert client != null;
|
||||||
|
|
||||||
SANITY_CHECK_RETURNED_BUCKET_NAME = (client instanceof StubS3Connection);
|
|
||||||
|
|
||||||
goodMd5 = S3Utils.md5(TEST_STRING);
|
goodMd5 = S3Utils.md5(TEST_STRING);
|
||||||
badMd5 = S3Utils.md5("alf");
|
badMd5 = S3Utils.md5("alf");
|
||||||
}
|
}
|
||||||
|
@ -212,6 +174,7 @@ public class S3IntegrationTest {
|
||||||
protected void createStubS3Context() {
|
protected void createStubS3Context() {
|
||||||
context = S3ContextFactory.createContext("stub", "stub").withHttpAddress("stub").withModule(
|
context = S3ContextFactory.createContext("stub", "stub").withHttpAddress("stub").withModule(
|
||||||
new StubS3ConnectionModule()).build();
|
new StubS3ConnectionModule()).build();
|
||||||
|
SANITY_CHECK_RETURNED_BUCKET_NAME = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createLiveS3Context(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
protected void createLiveS3Context(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
||||||
|
@ -221,13 +184,8 @@ public class S3IntegrationTest {
|
||||||
|
|
||||||
public String getBucketName() throws InterruptedException, ExecutionException, TimeoutException {
|
public String getBucketName() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String bucketName = bucketNames.poll(30, TimeUnit.SECONDS);
|
String bucketName = bucketNames.poll(30, TimeUnit.SECONDS);
|
||||||
// retrying as inside EC2 it may take longer to reflect the contents of a bucket.
|
|
||||||
try {
|
|
||||||
emptyBucket(bucketName);
|
|
||||||
} catch (AssertionError e) {
|
|
||||||
emptyBucket(bucketName);
|
|
||||||
}
|
|
||||||
assert bucketName != null : "unable to get a bucket for the test";
|
assert bucketName != null : "unable to get a bucket for the test";
|
||||||
|
emptyBucket(bucketName);
|
||||||
return bucketName;
|
return bucketName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +202,6 @@ public class S3IntegrationTest {
|
||||||
ExecutionException, TimeoutException {
|
ExecutionException, TimeoutException {
|
||||||
if (bucketName != null) {
|
if (bucketName != null) {
|
||||||
bucketNames.add(bucketName);
|
bucketNames.add(bucketName);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure that any returned bucket name actually exists on the server. Return of a
|
* Ensure that any returned bucket name actually exists on the server. Return of a
|
||||||
* non-existent bucket introduces subtle testing bugs, where later unrelated tests will
|
* non-existent bucket introduces subtle testing bugs, where later unrelated tests will
|
||||||
|
@ -280,17 +237,6 @@ public class S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int bucketCount = 20;
|
|
||||||
protected static volatile int bucketIndex = 0;
|
|
||||||
|
|
||||||
protected boolean SANITY_CHECK_RETURNED_BUCKET_NAME = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* two test groups integration and live.
|
|
||||||
*/
|
|
||||||
private static final BlockingQueue<String> bucketNames = new ArrayBlockingQueue<String>(
|
|
||||||
bucketCount);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are a lot of retries here mainly from experience running inside amazon EC2.
|
* There are a lot of retries here mainly from experience running inside amazon EC2.
|
||||||
*/
|
*/
|
||||||
|
@ -314,10 +260,6 @@ public class S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean debugEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected S3ContextFactory buildS3ContextFactory(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
protected S3ContextFactory buildS3ContextFactory(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
||||||
return S3ContextFactory.createContext(AWSAccessKeyId, AWSSecretAccessKey).withSaxDebug()
|
return S3ContextFactory.createContext(AWSAccessKeyId, AWSSecretAccessKey).withSaxDebug()
|
||||||
.withHttpSecure(false).withHttpPort(80);
|
.withHttpSecure(false).withHttpPort(80);
|
||||||
|
@ -327,8 +269,6 @@ public class S3IntegrationTest {
|
||||||
return new JavaUrlHttpFutureCommandClientModule();
|
return new JavaUrlHttpFutureCommandClientModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String bucketPrefix = System.getProperty("user.name") + ".s3int";
|
|
||||||
|
|
||||||
protected void deleteEverything() throws Exception {
|
protected void deleteEverything() throws Exception {
|
||||||
try {
|
try {
|
||||||
List<S3Bucket.Metadata> metadata = client.listOwnedBuckets().get(10, TimeUnit.SECONDS);
|
List<S3Bucket.Metadata> metadata = client.listOwnedBuckets().get(10, TimeUnit.SECONDS);
|
||||||
|
@ -355,8 +295,13 @@ public class S3IntegrationTest {
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
context.createInputStreamMap(name).clear();
|
Map<String, InputStream> map = context.createInputStreamMap(name);
|
||||||
assertEventuallyBucketEmpty(name);
|
Set<String> keys = map.keySet();
|
||||||
|
if (keys.size() > 0) {
|
||||||
|
map.clear();
|
||||||
|
assertEquals(map.size(), 0, String.format(
|
||||||
|
"deleting %s, we still have %s left", keys, map.keySet()));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
Utils.<RuntimeException> rethrowIfRuntimeOrSameType(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,11 +71,6 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
AWSCredentials credentials;
|
AWSCredentials credentials;
|
||||||
S3Service service;
|
S3Service service;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean debugEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* overridden only to get access to the amazon credentials used for jets3t initialization.
|
* overridden only to get access to the amazon credentials used for jets3t initialization.
|
||||||
*/
|
*/
|
||||||
|
@ -99,8 +94,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateBucketImpl() throws S3ServiceException, InterruptedException,
|
public void testCreateBucketImpl() throws S3ServiceException, InterruptedException,
|
||||||
ExecutionException, TimeoutException
|
ExecutionException, TimeoutException {
|
||||||
{
|
|
||||||
String bucketName = getScratchBucketName();
|
String bucketName = getScratchBucketName();
|
||||||
try {
|
try {
|
||||||
S3Bucket bucket = service.createBucket(new S3Bucket(bucketName));
|
S3Bucket bucket = service.createBucket(new S3Bucket(bucketName));
|
||||||
|
@ -126,19 +120,18 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||||
public void testDeleteObjectImpl() throws InterruptedException, ExecutionException,
|
public void testDeleteObjectImpl() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException, S3ServiceException, IOException
|
TimeoutException, S3ServiceException, IOException {
|
||||||
{
|
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
String objectKey = "key-testDeleteObjectImpl";
|
String objectKey = "key-testDeleteObjectImpl";
|
||||||
String objectValue = "test";
|
String objectValue = "test";
|
||||||
|
|
||||||
org.jclouds.aws.s3.domain.S3Object s3Object = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object s3Object = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
objectKey, objectValue);
|
objectKey, objectValue);
|
||||||
addObjectToBucket(bucketName, s3Object);
|
addObjectToBucket(bucketName, s3Object);
|
||||||
|
|
||||||
service.deleteObject(bucketName, objectKey);
|
service.deleteObject(bucketName, objectKey);
|
||||||
|
|
||||||
assertEquals(client.headObject(bucketName, objectKey).get(10, TimeUnit.SECONDS),
|
assertEquals(client.headObject(bucketName, objectKey).get(10, TimeUnit.SECONDS),
|
||||||
org.jclouds.aws.s3.domain.S3Object.Metadata.NOT_FOUND);
|
org.jclouds.aws.s3.domain.S3Object.Metadata.NOT_FOUND);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -148,23 +141,22 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||||
public void testGetObjectDetailsImpl() throws InterruptedException, ExecutionException,
|
public void testGetObjectDetailsImpl() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException, S3ServiceException, IOException
|
TimeoutException, S3ServiceException, IOException {
|
||||||
{
|
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
String objectKey = "key-testGetObjectDetailsImpl";
|
String objectKey = "key-testGetObjectDetailsImpl";
|
||||||
String objectValue = "test";
|
String objectValue = "test";
|
||||||
String metadataName = "metadata-name-1";
|
String metadataName = "metadata-name-1";
|
||||||
String metadataValue = "metadata-value-1";
|
String metadataValue = "metadata-value-1";
|
||||||
|
|
||||||
org.jclouds.aws.s3.domain.S3Object s3Object = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object s3Object = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
objectKey, objectValue);
|
objectKey, objectValue);
|
||||||
s3Object.getMetadata().getUserMetadata().put(S3Constants.USER_METADATA_PREFIX + metadataName,
|
s3Object.getMetadata().getUserMetadata().put(
|
||||||
metadataValue);
|
S3Constants.USER_METADATA_PREFIX + metadataName, metadataValue);
|
||||||
addObjectToBucket(bucketName, s3Object);
|
addObjectToBucket(bucketName, s3Object);
|
||||||
|
|
||||||
S3Object objectDetails = service.getObjectDetails(new S3Bucket(bucketName), objectKey);
|
S3Object objectDetails = service.getObjectDetails(new S3Bucket(bucketName), objectKey);
|
||||||
|
|
||||||
assertEquals(objectDetails.getKey(), objectKey);
|
assertEquals(objectDetails.getKey(), objectKey);
|
||||||
assertEquals(objectDetails.getContentLength(), 4);
|
assertEquals(objectDetails.getContentLength(), 4);
|
||||||
assertNull(objectDetails.getDataInputStream());
|
assertNull(objectDetails.getDataInputStream());
|
||||||
|
@ -176,29 +168,28 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||||
public void testGetObjectImpl() throws InterruptedException, ExecutionException,
|
public void testGetObjectImpl() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException, S3ServiceException, IOException
|
TimeoutException, S3ServiceException, IOException {
|
||||||
{
|
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
String objectKey = "key-testGetObjectImpl";
|
String objectKey = "key-testGetObjectImpl";
|
||||||
String objectValue = "test";
|
String objectValue = "test";
|
||||||
String metadataName = "metadata-name-2";
|
String metadataName = "metadata-name-2";
|
||||||
String metadataValue = "metadata-value-2";
|
String metadataValue = "metadata-value-2";
|
||||||
|
|
||||||
org.jclouds.aws.s3.domain.S3Object s3Object = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object s3Object = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
objectKey, objectValue);
|
objectKey, objectValue);
|
||||||
s3Object.getMetadata().getUserMetadata().put(S3Constants.USER_METADATA_PREFIX + metadataName,
|
s3Object.getMetadata().getUserMetadata().put(
|
||||||
metadataValue);
|
S3Constants.USER_METADATA_PREFIX + metadataName, metadataValue);
|
||||||
addObjectToBucket(bucketName, s3Object);
|
addObjectToBucket(bucketName, s3Object);
|
||||||
|
|
||||||
S3Object object = service.getObject(new S3Bucket(bucketName), objectKey);
|
S3Object object = service.getObject(new S3Bucket(bucketName), objectKey);
|
||||||
|
|
||||||
assertEquals(object.getKey(), objectKey);
|
assertEquals(object.getKey(), objectKey);
|
||||||
assertNotNull(object.getDataInputStream());
|
assertNotNull(object.getDataInputStream());
|
||||||
assertEquals(IOUtils.toString(object.getDataInputStream()), objectValue);
|
assertEquals(IOUtils.toString(object.getDataInputStream()), objectValue);
|
||||||
assertEquals(object.getContentLength(), objectValue.length());
|
assertEquals(object.getContentLength(), objectValue.length());
|
||||||
assertEquals(object.getMetadata(metadataName), metadataValue);
|
assertEquals(object.getMetadata(metadataName), metadataValue);
|
||||||
|
|
||||||
// TODO: Test conditional gets
|
// TODO: Test conditional gets
|
||||||
} finally {
|
} finally {
|
||||||
returnBucket(bucketName);
|
returnBucket(bucketName);
|
||||||
|
@ -207,22 +198,21 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||||
public void testListAllBucketsImpl() throws InterruptedException, ExecutionException,
|
public void testListAllBucketsImpl() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException, S3ServiceException
|
TimeoutException, S3ServiceException {
|
||||||
{
|
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
// Ensure there is at least 1 bucket in S3 account to list and compare.
|
// Ensure there is at least 1 bucket in S3 account to list and compare.
|
||||||
S3Bucket[] jsBuckets = service.listAllBuckets();
|
S3Bucket[] jsBuckets = service.listAllBuckets();
|
||||||
|
|
||||||
List<org.jclouds.aws.s3.domain.S3Bucket.Metadata> jcBuckets = client.listOwnedBuckets().get(
|
List<org.jclouds.aws.s3.domain.S3Bucket.Metadata> jcBuckets = client.listOwnedBuckets()
|
||||||
10, TimeUnit.SECONDS);
|
.get(10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
assert jsBuckets.length == jcBuckets.size();
|
assert jsBuckets.length == jcBuckets.size();
|
||||||
|
|
||||||
Iterator<org.jclouds.aws.s3.domain.S3Bucket.Metadata> jcBucketsIter = jcBuckets.iterator();
|
Iterator<org.jclouds.aws.s3.domain.S3Bucket.Metadata> jcBucketsIter = jcBuckets.iterator();
|
||||||
for (S3Bucket jsBucket : jsBuckets) {
|
for (S3Bucket jsBucket : jsBuckets) {
|
||||||
assert jcBucketsIter.hasNext();
|
assert jcBucketsIter.hasNext();
|
||||||
|
|
||||||
org.jclouds.aws.s3.domain.S3Bucket.Metadata jcBucket = jcBucketsIter.next();
|
org.jclouds.aws.s3.domain.S3Bucket.Metadata jcBucket = jcBucketsIter.next();
|
||||||
assert jsBucket.getName().equals(jcBucket.getName());
|
assert jsBucket.getName().equals(jcBucket.getName());
|
||||||
}
|
}
|
||||||
|
@ -240,9 +230,9 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
addObjectToBucket(bucketName, "item2");
|
addObjectToBucket(bucketName, "item2");
|
||||||
addObjectToBucket(bucketName, "object1");
|
addObjectToBucket(bucketName, "object1");
|
||||||
addObjectToBucket(bucketName, "object2/subobject1");
|
addObjectToBucket(bucketName, "object2/subobject1");
|
||||||
|
|
||||||
S3ObjectsChunk chunk;
|
S3ObjectsChunk chunk;
|
||||||
|
|
||||||
// Normal complete listing
|
// Normal complete listing
|
||||||
chunk = service.listObjectsChunked(bucketName, null, null, 1000, null, true);
|
chunk = service.listObjectsChunked(bucketName, null, null, 1000, null, true);
|
||||||
assertEquals(chunk.getObjects().length, 4);
|
assertEquals(chunk.getObjects().length, 4);
|
||||||
|
@ -250,7 +240,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertNull(chunk.getDelimiter());
|
assertNull(chunk.getDelimiter());
|
||||||
assertNull(chunk.getPrefix());
|
assertNull(chunk.getPrefix());
|
||||||
assertNull(chunk.getPriorLastKey());
|
assertNull(chunk.getPriorLastKey());
|
||||||
|
|
||||||
// Partial listing
|
// Partial listing
|
||||||
chunk = service.listObjectsChunked(bucketName, null, null, 2, null, false);
|
chunk = service.listObjectsChunked(bucketName, null, null, 2, null, false);
|
||||||
assertEquals(chunk.getObjects().length, 2);
|
assertEquals(chunk.getObjects().length, 2);
|
||||||
|
@ -258,7 +248,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertNull(chunk.getDelimiter());
|
assertNull(chunk.getDelimiter());
|
||||||
assertNull(chunk.getPrefix());
|
assertNull(chunk.getPrefix());
|
||||||
assertEquals(chunk.getPriorLastKey(), "item2");
|
assertEquals(chunk.getPriorLastKey(), "item2");
|
||||||
|
|
||||||
// Complete listing, in two chunks
|
// Complete listing, in two chunks
|
||||||
chunk = service.listObjectsChunked(bucketName, null, null, 2, null, true);
|
chunk = service.listObjectsChunked(bucketName, null, null, 2, null, true);
|
||||||
assertEquals(chunk.getObjects().length, 4);
|
assertEquals(chunk.getObjects().length, 4);
|
||||||
|
@ -266,7 +256,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertNull(chunk.getDelimiter());
|
assertNull(chunk.getDelimiter());
|
||||||
assertNull(chunk.getPrefix());
|
assertNull(chunk.getPrefix());
|
||||||
assertNull(chunk.getPriorLastKey());
|
assertNull(chunk.getPriorLastKey());
|
||||||
|
|
||||||
// Partial listing with marker
|
// Partial listing with marker
|
||||||
chunk = service.listObjectsChunked(bucketName, null, null, 1000, "item1/subobject2", true);
|
chunk = service.listObjectsChunked(bucketName, null, null, 1000, "item1/subobject2", true);
|
||||||
assertEquals(chunk.getObjects().length, 3);
|
assertEquals(chunk.getObjects().length, 3);
|
||||||
|
@ -274,7 +264,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertNull(chunk.getDelimiter());
|
assertNull(chunk.getDelimiter());
|
||||||
assertNull(chunk.getPrefix());
|
assertNull(chunk.getPrefix());
|
||||||
assertNull(chunk.getPriorLastKey());
|
assertNull(chunk.getPriorLastKey());
|
||||||
|
|
||||||
// Partial listing with marker
|
// Partial listing with marker
|
||||||
chunk = service.listObjectsChunked(bucketName, null, null, 1000, "object1", true);
|
chunk = service.listObjectsChunked(bucketName, null, null, 1000, "object1", true);
|
||||||
assertEquals(chunk.getObjects().length, 1);
|
assertEquals(chunk.getObjects().length, 1);
|
||||||
|
@ -282,7 +272,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertNull(chunk.getDelimiter());
|
assertNull(chunk.getDelimiter());
|
||||||
assertNull(chunk.getPrefix());
|
assertNull(chunk.getPrefix());
|
||||||
assertNull(chunk.getPriorLastKey());
|
assertNull(chunk.getPriorLastKey());
|
||||||
|
|
||||||
// Prefix test
|
// Prefix test
|
||||||
chunk = service.listObjectsChunked(bucketName, "item", null, 1000, null, true);
|
chunk = service.listObjectsChunked(bucketName, "item", null, 1000, null, true);
|
||||||
assertEquals(chunk.getObjects().length, 2);
|
assertEquals(chunk.getObjects().length, 2);
|
||||||
|
@ -290,7 +280,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertNull(chunk.getDelimiter());
|
assertNull(chunk.getDelimiter());
|
||||||
assertEquals(chunk.getPrefix(), "item");
|
assertEquals(chunk.getPrefix(), "item");
|
||||||
assertNull(chunk.getPriorLastKey());
|
assertNull(chunk.getPriorLastKey());
|
||||||
|
|
||||||
// Delimiter test
|
// Delimiter test
|
||||||
chunk = service.listObjectsChunked(bucketName, null, "/", 1000, null, true);
|
chunk = service.listObjectsChunked(bucketName, null, "/", 1000, null, true);
|
||||||
assertEquals(chunk.getObjects().length, 2);
|
assertEquals(chunk.getObjects().length, 2);
|
||||||
|
@ -298,7 +288,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertEquals(chunk.getDelimiter(), "/");
|
assertEquals(chunk.getDelimiter(), "/");
|
||||||
assertNull(chunk.getPrefix());
|
assertNull(chunk.getPrefix());
|
||||||
assertNull(chunk.getPriorLastKey());
|
assertNull(chunk.getPriorLastKey());
|
||||||
|
|
||||||
// Prefix & delimiter test
|
// Prefix & delimiter test
|
||||||
chunk = service.listObjectsChunked(bucketName, "item", "/", 1000, null, true);
|
chunk = service.listObjectsChunked(bucketName, "item", "/", 1000, null, true);
|
||||||
assertEquals(chunk.getObjects().length, 1);
|
assertEquals(chunk.getObjects().length, 1);
|
||||||
|
@ -321,29 +311,29 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
addObjectToBucket(bucketName, "item2");
|
addObjectToBucket(bucketName, "item2");
|
||||||
addObjectToBucket(bucketName, "object1");
|
addObjectToBucket(bucketName, "object1");
|
||||||
addObjectToBucket(bucketName, "object2/subobject1");
|
addObjectToBucket(bucketName, "object2/subobject1");
|
||||||
|
|
||||||
S3Object[] objects;
|
S3Object[] objects;
|
||||||
|
|
||||||
// Normal complete listing
|
// Normal complete listing
|
||||||
objects = service.listObjects(bucketName, null, null, 1000);
|
objects = service.listObjects(bucketName, null, null, 1000);
|
||||||
assertEquals(objects.length, 4);
|
assertEquals(objects.length, 4);
|
||||||
|
|
||||||
// Complete listing, in two chunks
|
// Complete listing, in two chunks
|
||||||
objects = service.listObjects(bucketName, null, null, 2);
|
objects = service.listObjects(bucketName, null, null, 2);
|
||||||
assertEquals(objects.length, 4);
|
assertEquals(objects.length, 4);
|
||||||
assertEquals(objects[0].getKey(), "item1/subobject2");
|
assertEquals(objects[0].getKey(), "item1/subobject2");
|
||||||
assertEquals(objects[3].getKey(), "object2/subobject1");
|
assertEquals(objects[3].getKey(), "object2/subobject1");
|
||||||
|
|
||||||
// Prefix test
|
// Prefix test
|
||||||
objects = service.listObjects(bucketName, "item", null, 1000);
|
objects = service.listObjects(bucketName, "item", null, 1000);
|
||||||
assertEquals(objects.length, 2);
|
assertEquals(objects.length, 2);
|
||||||
|
|
||||||
// Delimiter test
|
// Delimiter test
|
||||||
objects = service.listObjects(bucketName, null, "/", 1000);
|
objects = service.listObjects(bucketName, null, "/", 1000);
|
||||||
assertEquals(objects.length, 2);
|
assertEquals(objects.length, 2);
|
||||||
assertEquals(objects[0].getKey(), "item2");
|
assertEquals(objects[0].getKey(), "item2");
|
||||||
assertEquals(objects[1].getKey(), "object1");
|
assertEquals(objects[1].getKey(), "object1");
|
||||||
|
|
||||||
// Prefix & delimiter test
|
// Prefix & delimiter test
|
||||||
objects = service.listObjects(bucketName, "item", "/", 1000);
|
objects = service.listObjects(bucketName, "item", "/", 1000);
|
||||||
assertEquals(objects.length, 1);
|
assertEquals(objects.length, 1);
|
||||||
|
@ -359,10 +349,10 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
String objectKey = "putObject";
|
String objectKey = "putObject";
|
||||||
|
|
||||||
S3Object requestObject, jsResultObject;
|
S3Object requestObject, jsResultObject;
|
||||||
org.jclouds.aws.s3.domain.S3Object jcObject;
|
org.jclouds.aws.s3.domain.S3Object jcObject;
|
||||||
|
|
||||||
// Upload empty object
|
// Upload empty object
|
||||||
requestObject = new S3Object(objectKey);
|
requestObject = new S3Object(objectKey);
|
||||||
jsResultObject = service.putObject(new S3Bucket(bucketName), requestObject);
|
jsResultObject = service.putObject(new S3Bucket(bucketName), requestObject);
|
||||||
|
@ -373,7 +363,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertEquals(jsResultObject.getKey(), requestObject.getKey());
|
assertEquals(jsResultObject.getKey(), requestObject.getKey());
|
||||||
assertEquals(jsResultObject.getContentLength(), 0);
|
assertEquals(jsResultObject.getContentLength(), 0);
|
||||||
assertEquals(jsResultObject.getContentType(), ContentTypes.BINARY);
|
assertEquals(jsResultObject.getContentType(), ContentTypes.BINARY);
|
||||||
|
|
||||||
// Upload unicode-named object
|
// Upload unicode-named object
|
||||||
requestObject = new S3Object("Ÿn’<EFBFBD>˜dŽ-object");
|
requestObject = new S3Object("Ÿn’<EFBFBD>˜dŽ-object");
|
||||||
jsResultObject = service.putObject(new S3Bucket(bucketName), requestObject);
|
jsResultObject = service.putObject(new S3Bucket(bucketName), requestObject);
|
||||||
|
@ -384,7 +374,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertEquals(jsResultObject.getKey(), requestObject.getKey());
|
assertEquals(jsResultObject.getKey(), requestObject.getKey());
|
||||||
assertEquals(jsResultObject.getContentLength(), 0);
|
assertEquals(jsResultObject.getContentLength(), 0);
|
||||||
assertEquals(jsResultObject.getContentType(), ContentTypes.BINARY);
|
assertEquals(jsResultObject.getContentType(), ContentTypes.BINARY);
|
||||||
|
|
||||||
// Upload string object
|
// Upload string object
|
||||||
String data = "This is my Ÿn’<6E>˜dŽ data";
|
String data = "This is my Ÿn’<6E>˜dŽ data";
|
||||||
requestObject = new S3Object(objectKey, data);
|
requestObject = new S3Object(objectKey, data);
|
||||||
|
@ -394,7 +384,7 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertTrue(jcObject.getMetadata().getContentType().startsWith("text/plain"));
|
assertTrue(jcObject.getMetadata().getContentType().startsWith("text/plain"));
|
||||||
assertEquals(jsResultObject.getContentLength(), data.getBytes("UTF-8").length);
|
assertEquals(jsResultObject.getContentLength(), data.getBytes("UTF-8").length);
|
||||||
assertTrue(jsResultObject.getContentType().startsWith("text/plain"));
|
assertTrue(jsResultObject.getContentType().startsWith("text/plain"));
|
||||||
|
|
||||||
// Upload object with metadata
|
// Upload object with metadata
|
||||||
requestObject = new S3Object(objectKey);
|
requestObject = new S3Object(objectKey);
|
||||||
requestObject.addMetadata(S3Constants.USER_METADATA_PREFIX + "my-metadata-1", "value-1");
|
requestObject.addMetadata(S3Constants.USER_METADATA_PREFIX + "my-metadata-1", "value-1");
|
||||||
|
@ -402,9 +392,9 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
jcObject = client.getObject(bucketName, objectKey).get(10, TimeUnit.SECONDS);
|
jcObject = client.getObject(bucketName, objectKey).get(10, TimeUnit.SECONDS);
|
||||||
assertEquals(Iterables.getLast(jcObject.getMetadata().getUserMetadata().get(
|
assertEquals(Iterables.getLast(jcObject.getMetadata().getUserMetadata().get(
|
||||||
S3Constants.USER_METADATA_PREFIX + "my-metadata-1")), "value-1");
|
S3Constants.USER_METADATA_PREFIX + "my-metadata-1")), "value-1");
|
||||||
assertEquals(jsResultObject.getMetadata(S3Constants.USER_METADATA_PREFIX + "my-metadata-1"),
|
assertEquals(jsResultObject
|
||||||
"value-1");
|
.getMetadata(S3Constants.USER_METADATA_PREFIX + "my-metadata-1"), "value-1");
|
||||||
|
|
||||||
// Upload object with public-read ACL
|
// Upload object with public-read ACL
|
||||||
requestObject = new S3Object(objectKey);
|
requestObject = new S3Object(objectKey);
|
||||||
requestObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
|
requestObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
|
||||||
|
@ -413,12 +403,12 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
// TODO: No way yet to get/lookup ACL from jClouds object
|
// TODO: No way yet to get/lookup ACL from jClouds object
|
||||||
// assertEquals(jcObject.getAcl(), CannedAccessPolicy.PUBLIC_READ);
|
// assertEquals(jcObject.getAcl(), CannedAccessPolicy.PUBLIC_READ);
|
||||||
assertEquals(jsResultObject.getAcl(), AccessControlList.REST_CANNED_PUBLIC_READ);
|
assertEquals(jsResultObject.getAcl(), AccessControlList.REST_CANNED_PUBLIC_READ);
|
||||||
|
|
||||||
// TODO : Any way to test a URL lookup that works for live and stub testing?
|
// TODO : Any way to test a URL lookup that works for live and stub testing?
|
||||||
// URL publicUrl = new URL(
|
// URL publicUrl = new URL(
|
||||||
// "http://" + bucketName + ".s3.amazonaws.com:80/" + requestObject.getKey());
|
// "http://" + bucketName + ".s3.amazonaws.com:80/" + requestObject.getKey());
|
||||||
// assertEquals(((HttpURLConnection) publicUrl.openConnection()).getResponseCode(), 200);
|
// assertEquals(((HttpURLConnection) publicUrl.openConnection()).getResponseCode(), 200);
|
||||||
|
|
||||||
// Upload object and check MD5
|
// Upload object and check MD5
|
||||||
requestObject = new S3Object(objectKey);
|
requestObject = new S3Object(objectKey);
|
||||||
data = "Here is some d‡tˆ for you";
|
data = "Here is some d‡tˆ for you";
|
||||||
|
@ -445,21 +435,21 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
String metadataName = "metadata-name";
|
String metadataName = "metadata-name";
|
||||||
String sourceMetadataValue = "souce-metadata-value";
|
String sourceMetadataValue = "souce-metadata-value";
|
||||||
String destinationMetadataValue = "destination-metadata-value";
|
String destinationMetadataValue = "destination-metadata-value";
|
||||||
|
|
||||||
org.jclouds.aws.s3.domain.S3Object sourceObject = new org.jclouds.aws.s3.domain.S3Object(
|
org.jclouds.aws.s3.domain.S3Object sourceObject = new org.jclouds.aws.s3.domain.S3Object(
|
||||||
sourceObjectKey, data);
|
sourceObjectKey, data);
|
||||||
sourceObject.getMetadata().getUserMetadata().put(
|
sourceObject.getMetadata().getUserMetadata().put(
|
||||||
S3Constants.USER_METADATA_PREFIX + metadataName, sourceMetadataValue);
|
S3Constants.USER_METADATA_PREFIX + metadataName, sourceMetadataValue);
|
||||||
addObjectToBucket(bucketName, sourceObject);
|
addObjectToBucket(bucketName, sourceObject);
|
||||||
|
|
||||||
S3Object destinationObject;
|
S3Object destinationObject;
|
||||||
Map copyResult;
|
Map copyResult;
|
||||||
org.jclouds.aws.s3.domain.S3Object jcDestinationObject;
|
org.jclouds.aws.s3.domain.S3Object jcDestinationObject;
|
||||||
|
|
||||||
// Copy with metadata and ACL retained
|
// Copy with metadata and ACL retained
|
||||||
destinationObject = new S3Object(destinationObjectKey);
|
destinationObject = new S3Object(destinationObjectKey);
|
||||||
copyResult = service.copyObject(bucketName, sourceObjectKey, bucketName, destinationObject,
|
copyResult = service.copyObject(bucketName, sourceObjectKey, bucketName,
|
||||||
false);
|
destinationObject, false);
|
||||||
jcDestinationObject = client.getObject(bucketName, destinationObject.getKey()).get(10,
|
jcDestinationObject = client.getObject(bucketName, destinationObject.getKey()).get(10,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
assertEquals(jcDestinationObject.getKey(), destinationObjectKey);
|
assertEquals(jcDestinationObject.getKey(), destinationObjectKey);
|
||||||
|
@ -468,25 +458,25 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
||||||
assertEquals(copyResult.get("ETag"), S3Utils.toHexString(jcDestinationObject.getMetadata()
|
assertEquals(copyResult.get("ETag"), S3Utils.toHexString(jcDestinationObject.getMetadata()
|
||||||
.getMd5()));
|
.getMd5()));
|
||||||
// TODO: Test destination ACL is unchanged (ie private)
|
// TODO: Test destination ACL is unchanged (ie private)
|
||||||
|
|
||||||
// Copy with metadata replaced
|
// Copy with metadata replaced
|
||||||
destinationObject = new S3Object(destinationObjectKey);
|
destinationObject = new S3Object(destinationObjectKey);
|
||||||
destinationObject.addMetadata(S3Constants.USER_METADATA_PREFIX + metadataName,
|
destinationObject.addMetadata(S3Constants.USER_METADATA_PREFIX + metadataName,
|
||||||
destinationMetadataValue);
|
destinationMetadataValue);
|
||||||
copyResult = service.copyObject(bucketName, sourceObjectKey, bucketName, destinationObject,
|
copyResult = service.copyObject(bucketName, sourceObjectKey, bucketName,
|
||||||
true);
|
destinationObject, true);
|
||||||
jcDestinationObject = client.getObject(bucketName, destinationObject.getKey()).get(10,
|
jcDestinationObject = client.getObject(bucketName, destinationObject.getKey()).get(10,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
assertEquals(Iterators.getLast(jcDestinationObject.getMetadata().getUserMetadata().get(
|
assertEquals(Iterators.getLast(jcDestinationObject.getMetadata().getUserMetadata().get(
|
||||||
S3Constants.USER_METADATA_PREFIX + metadataName).iterator()),
|
S3Constants.USER_METADATA_PREFIX + metadataName).iterator()),
|
||||||
destinationMetadataValue);
|
destinationMetadataValue);
|
||||||
// TODO: Test destination ACL is unchanged (ie private)
|
// TODO: Test destination ACL is unchanged (ie private)
|
||||||
|
|
||||||
// Copy with ACL modified
|
// Copy with ACL modified
|
||||||
destinationObject = new S3Object(destinationObjectKey);
|
destinationObject = new S3Object(destinationObjectKey);
|
||||||
destinationObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
|
destinationObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
|
||||||
copyResult = service.copyObject(bucketName, sourceObjectKey, bucketName, destinationObject,
|
copyResult = service.copyObject(bucketName, sourceObjectKey, bucketName,
|
||||||
false);
|
destinationObject, false);
|
||||||
jcDestinationObject = client.getObject(bucketName, destinationObject.getKey()).get(10,
|
jcDestinationObject = client.getObject(bucketName, destinationObject.getKey()).get(10,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
// TODO: Test destination ACL is changed (ie public-read)
|
// TODO: Test destination ACL is changed (ie public-read)
|
||||||
|
|
|
@ -30,19 +30,13 @@ import org.jclouds.aws.s3.suncloud.xml.config.SunCloudS3ParserModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This performs the same test as {@link S3ConnectionLiveTest}, except using Sun Cloud
|
* This performs the same test as {@link S3ConnectionLiveTest}, except using Sun Cloud Storage.
|
||||||
* Storage.
|
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(enabled = false, groups = { "live" }, testName = "s3.suncloud.SunCloudS3ConnectionLiveTest")
|
@Test(enabled = false, groups = { "live" }, testName = "s3.suncloud.SunCloudS3ConnectionLiveTest")
|
||||||
public class SunCloudS3ConnectionLiveTest extends S3ConnectionLiveTest {
|
public class SunCloudS3ConnectionLiveTest extends S3ConnectionLiveTest {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean debugEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected S3ContextFactory buildS3ContextFactory(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
protected S3ContextFactory buildS3ContextFactory(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
||||||
return S3ContextFactory.createContext(AWSAccessKeyId, AWSSecretAccessKey).withModules(
|
return S3ContextFactory.createContext(AWSAccessKeyId, AWSSecretAccessKey).withModules(
|
||||||
|
|
|
@ -49,16 +49,9 @@ import com.google.inject.Provider;
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live" })
|
@Test(groups = { "live" })
|
||||||
public abstract class BasePerformance extends S3IntegrationTest {
|
public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
@Override
|
|
||||||
protected boolean debugEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int timeoutSeconds = 10;
|
protected int timeoutSeconds = 10;
|
||||||
protected int loopCount = 100;
|
protected int loopCount = 100;
|
||||||
|
|
||||||
protected ExecutorService exec;
|
protected ExecutorService exec;
|
||||||
|
|
||||||
protected CompletionService<Boolean> completer;
|
protected CompletionService<Boolean> completer;
|
||||||
|
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
|
@ -74,13 +67,13 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
exec = null;
|
exec = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutBytesSerialEU() throws Exception {
|
public void testPutBytesSerialEU() throws Exception {
|
||||||
String euBucketName = createScratchBucketInEU();
|
String euBucketName = createScratchBucketInEU();
|
||||||
doSerial(new PutBytesCallable(euBucketName), loopCount / 10);
|
doSerial(new PutBytesCallable(euBucketName), loopCount / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutBytesParallelEU() throws InterruptedException, ExecutionException,
|
public void testPutBytesParallelEU() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
String euBucketName = createScratchBucketInEU();
|
String euBucketName = createScratchBucketInEU();
|
||||||
|
@ -91,7 +84,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutBytesSerial() throws Exception {
|
public void testPutBytesSerial() throws Exception {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
|
@ -101,7 +94,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutBytesParallel() throws InterruptedException, ExecutionException,
|
public void testPutBytesParallel() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
|
@ -112,7 +105,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutFileSerial() throws Exception {
|
public void testPutFileSerial() throws Exception {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
|
@ -122,7 +115,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutFileParallel() throws InterruptedException, ExecutionException,
|
public void testPutFileParallel() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
|
@ -133,7 +126,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutInputStreamSerial() throws Exception {
|
public void testPutInputStreamSerial() throws Exception {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
|
@ -143,7 +136,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutInputStreamParallel() throws InterruptedException, ExecutionException,
|
public void testPutInputStreamParallel() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
|
@ -154,7 +147,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutStringSerial() throws Exception {
|
public void testPutStringSerial() throws Exception {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
try {
|
try {
|
||||||
|
@ -164,7 +157,7 @@ public abstract class BasePerformance extends S3IntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test
|
||||||
public void testPutStringParallel() throws InterruptedException, ExecutionException,
|
public void testPutStringParallel() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
String bucketName = getBucketName();
|
String bucketName = getBucketName();
|
||||||
|
|
Loading…
Reference in New Issue