Repository: jclouds-labs-aws
Updated Branches:
  refs/heads/master 244f50edc -> 6a8586ab0


JCLOUDS-457: Long live tests

The long live tests have been added. These tests takes several
hours and will leave traces in your AWS account.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/commit/6a8586ab
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/tree/6a8586ab
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/diff/6a8586ab

Branch: refs/heads/master
Commit: 6a8586ab0695bc055e01afb1d74e36c1ea7f9ce6
Parents: 244f50e
Author: Roman Coedo <[email protected]>
Authored: Sat Jul 12 14:08:06 2014 +0200
Committer: Andrew Gaul <[email protected]>
Committed: Thu Jul 24 04:55:53 2014 -0700

----------------------------------------------------------------------
 glacier/pom.xml                                 |  44 ++++++-
 .../org/jclouds/glacier/domain/JobMetadata.java |   4 +-
 .../glacier/GlacierClientLongLiveTest.java      | 116 ++++++++++++++++++-
 3 files changed, 156 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/6a8586ab/glacier/pom.xml
----------------------------------------------------------------------
diff --git a/glacier/pom.xml b/glacier/pom.xml
index fc35eab..b741f10 100644
--- a/glacier/pom.xml
+++ b/glacier/pom.xml
@@ -142,7 +142,7 @@
       </build>
     </profile>
     <profile>
-      <id>long</id>
+      <id>livelong</id>
       <build>
         <plugins>
           <plugin>
@@ -160,7 +160,47 @@
                     <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                   </suiteXmlFiles>
                   <groups>live</groups>
-                  <excludedGroups>liveshort</excludedGroups>
+                  <excludedGroups>liveshort, setup</excludedGroups>
+                  <systemPropertyVariables>
+                    <jclouds.blobstore.httpstream.url>
+                      ${jclouds.blobstore.httpstream.url}
+                    </jclouds.blobstore.httpstream.url>
+                    <jclouds.blobstore.httpstream.md5>
+                      ${jclouds.blobstore.httpstream.md5}
+                    </jclouds.blobstore.httpstream.md5>
+                    
<test.glacier.endpoint>${test.glacier.endpoint}</test.glacier.endpoint>
+                    
<test.glacier.api-version>${test.glacier.api-version}</test.glacier.api-version>
+                    
<test.glacier.build-version>${test.glacier.build-version}</test.glacier.build-version>
+                    
<test.glacier.identity>${test.glacier.identity}</test.glacier.identity>
+                    
<test.glacier.credential>${test.glacier.credential}</test.glacier.credential>
+                  </systemPropertyVariables>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>livelongsetup</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>integration</id>
+                <phase>integration-test</phase>
+                <goals>
+                  <goal>test</goal>
+                </goals>
+                <configuration>
+                  <suiteXmlFiles>
+                    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
+                  </suiteXmlFiles>
+                  <groups>live</groups>
+                  <excludedGroups>liveshort, longtest</excludedGroups>
                   <systemPropertyVariables>
                     <jclouds.blobstore.httpstream.url>
                       ${jclouds.blobstore.httpstream.url}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/6a8586ab/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
----------------------------------------------------------------------
diff --git a/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java 
b/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
index 6dfc5eb..1e67df8 100644
--- a/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
+++ b/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
@@ -70,7 +70,7 @@ public class JobMetadata {
          @Nullable String archiveSHA256TreeHash, boolean completed, @Nullable 
Date completionDate, Date creationDate,
          @Nullable Long inventorySizeInBytes, @Nullable String jobDescription, 
String jobId,
          @Nullable String retrievalByteRange, @Nullable String sha256TreeHash, 
@Nullable String snsTopic,
-         String statusCode, String statusMessage, String vaultArn,
+         String statusCode, @Nullable String statusMessage, String vaultArn,
          @Nullable InventoryRetrievalParameters parameters) {
       super();
       this.action = checkNotNull(action, "action");
@@ -87,7 +87,7 @@ public class JobMetadata {
       this.sha256TreeHash = sha256TreeHash;
       this.snsTopic = snsTopic;
       this.statusCode = JobStatus.fromString(checkNotNull(statusCode, 
"statusCode"));
-      this.statusMessage = checkNotNull(statusMessage, "statusMessage");
+      this.statusMessage = statusMessage;
       this.vaultArn = checkNotNull(vaultArn, "vaultArn");
       this.parameters = parameters;
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/6a8586ab/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java
----------------------------------------------------------------------
diff --git 
a/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java 
b/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java
index e851f72..1ab4939 100644
--- a/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java
+++ b/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java
@@ -17,22 +17,130 @@
 package org.jclouds.glacier;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.jclouds.glacier.util.TestUtils.MiB;
+import static org.jclouds.glacier.util.TestUtils.buildData;
+import static org.jclouds.glacier.util.TestUtils.buildPayload;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.TimeUnit;
 
 import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.glacier.domain.ArchiveRetrievalJobRequest;
+import org.jclouds.glacier.domain.InventoryRetrievalJobRequest;
+import org.jclouds.glacier.domain.JobMetadata;
+import org.jclouds.glacier.domain.JobStatus;
+import org.jclouds.glacier.domain.VaultMetadata;
+import org.jclouds.glacier.util.ContentRange;
 import org.testng.annotations.Test;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.hash.HashCode;
+import com.google.common.io.Closer;
+
 /**
  * Long live test for Glacier.
  */
-@Test(groups = {"live", "livelong"})
 public class GlacierClientLongLiveTest extends BaseApiLiveTest<GlacierClient>{
 
+   private static final long PART_SIZE = 1;
+   private static final long INITIAL_WAIT = TimeUnit.HOURS.toMillis(3);
+   private static final long TIME_BETWEEN_POLLS = 
TimeUnit.MINUTES.toMillis(15);
+   private static final String VAULT_NAME = "JCLOUDS_LIVE_TESTS";
+   private static final String ARCHIVE_DESCRIPTION = "test archive";
+
+   private String archiveId = null;
+   private String archiveRetrievalJob = null;
+   private String inventoryRetrievalJob = null;
+
    public GlacierClientLongLiveTest() {
       this.provider = "glacier";
    }
 
-   @Test
-   public void testApi() throws Exception {
-      assertThat(api).isNotNull();
+   @Test(groups = {"live", "livelong", "setup"})
+   public void testSetVault() throws Exception {
+      api.createVault(VAULT_NAME);
+      api.uploadArchive(VAULT_NAME, buildPayload(1 * MiB), 
ARCHIVE_DESCRIPTION);
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"})
+   public void testUploadArchive() {
+      String archiveId = api.uploadArchive(VAULT_NAME, buildPayload(1 * MiB));
+      assertThat(api.deleteArchive(VAULT_NAME, archiveId)).isTrue();
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"})
+   public void testCompleteMultipartUpload() {
+      String uploadId = api.initiateMultipartUpload(VAULT_NAME, PART_SIZE);
+      ImmutableMap.Builder<Integer, HashCode> hashes = ImmutableMap.builder();
+      hashes.put(0, api.uploadPart(VAULT_NAME, uploadId, 
ContentRange.fromPartNumber(0, PART_SIZE),
+            buildPayload(PART_SIZE * MiB)));
+      hashes.put(1, api.uploadPart(VAULT_NAME, uploadId, 
ContentRange.fromPartNumber(1, PART_SIZE),
+            buildPayload(PART_SIZE * MiB)));
+      archiveId = api.completeMultipartUpload(VAULT_NAME, uploadId, 
hashes.build(), PART_SIZE * 2 * MiB);
+      assertThat(archiveId).isNotNull();
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
{"testUploadArchive", "testCompleteMultipartUpload"})
+   public void testInitiateJob() {
+      ArchiveRetrievalJobRequest archiveRetrieval = 
ArchiveRetrievalJobRequest.builder().archiveId(archiveId).build();
+      InventoryRetrievalJobRequest inventoryRetrieval = 
InventoryRetrievalJobRequest.builder().build();
+      archiveRetrievalJob = api.initiateJob(VAULT_NAME, archiveRetrieval);
+      inventoryRetrievalJob = api.initiateJob(VAULT_NAME, inventoryRetrieval);
+      assertThat(archiveRetrievalJob).isNotNull();
+      assertThat(inventoryRetrievalJob).isNotNull();
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
{"testInitiateJob"})
+   public void testDescribeJob() {
+      VaultMetadata vaultMetadata = api.describeVault(VAULT_NAME);
+
+      JobMetadata archiveRetrievalMetadata = api.describeJob(VAULT_NAME, 
archiveRetrievalJob);
+      assertThat(archiveRetrievalMetadata.getArchiveId()).isEqualTo(archiveId);
+      
assertThat(archiveRetrievalMetadata.getJobId()).isEqualTo(archiveRetrievalJob);
+      
assertThat(archiveRetrievalMetadata.getVaultArn()).isEqualTo(vaultMetadata.getVaultARN());
+
+      JobMetadata inventoryRetrievalMetadata = api.describeJob(VAULT_NAME, 
inventoryRetrievalJob);
+      
assertThat(inventoryRetrievalMetadata.getJobId()).isEqualTo(inventoryRetrievalJob);
+      
assertThat(inventoryRetrievalMetadata.getVaultArn()).isEqualTo(vaultMetadata.getVaultARN());
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
{"testInitiateJob"})
+   public void testListJobs() {
+         
assertThat(api.listJobs(VAULT_NAME)).extracting("jobId").contains(inventoryRetrievalJob,
 archiveRetrievalJob);
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
{"testInitiateJob", "testDescribeJob", "testListJobs"})
+   public void testWaitForSucceed() throws InterruptedException {
+      Thread.sleep(INITIAL_WAIT);
+      while (api.describeJob(VAULT_NAME, archiveRetrievalJob).getStatusCode() 
== JobStatus.IN_PROGRESS ||
+            api.describeJob(VAULT_NAME, inventoryRetrievalJob).getStatusCode() 
== JobStatus.IN_PROGRESS) {
+         Thread.sleep(TIME_BETWEEN_POLLS);
+      }
+      assertThat(api.describeJob(VAULT_NAME, 
archiveRetrievalJob).getStatusCode()).isEqualTo(JobStatus.SUCCEEDED);
+      assertThat(api.describeJob(VAULT_NAME, 
inventoryRetrievalJob).getStatusCode()).isEqualTo(JobStatus.SUCCEEDED);
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
{"testWaitForSucceed"})
+   public void testGetJobOutput() throws IOException {
+      Closer closer = Closer.create();
+      try {
+         InputStream inputStream = 
closer.register(api.getJobOutput(VAULT_NAME, archiveRetrievalJob).openStream());
+         InputStream expectedInputStream = closer.register(buildData(PART_SIZE 
* 2 * MiB).openStream());
+         assertThat(inputStream).hasContentEqualTo(expectedInputStream);
+      } finally {
+         closer.close();
+      }
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
{"testWaitForSucceed"})
+   public void testGetInventoryRetrievalOutput() throws InterruptedException {
+      assertThat(api.getInventoryRetrievalOutput(VAULT_NAME, 
inventoryRetrievalJob))
+            .extracting("description").contains(ARCHIVE_DESCRIPTION);
+   }
+
+   @Test(groups = {"live", "livelong", "longtest"}, dependsOnMethods = 
{"testGetJobOutput"})
+   public void testDeleteArchive() throws Exception {
+      assertThat(api.deleteArchive(VAULT_NAME, archiveId)).isTrue();
    }
 }

Reply via email to