You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/07/15 12:02:08 UTC

git commit: JCLOUDS-457: Test groups and improvements

Repository: jclouds-labs-aws
Updated Branches:
  refs/heads/master 1af587923 -> 67e8c7211


JCLOUDS-457: Test groups and improvements

Test groups have been added. Also, the live tests were
refactored to reduce the number of RPCs.


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/67e8c721
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/tree/67e8c721
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/diff/67e8c721

Branch: refs/heads/master
Commit: 67e8c721175de34ae7c9af761b4af5a4e3f6a919
Parents: 1af5879
Author: Roman Coedo <ro...@gmail.com>
Authored: Sat Jul 12 12:28:23 2014 +0200
Committer: Andrew Gaul <ga...@apache.org>
Committed: Tue Jul 15 03:01:42 2014 -0700

----------------------------------------------------------------------
 glacier/pom.xml                                 | 63 ++++++++++++++++---
 .../jclouds/glacier/GlacierClientLiveTest.java  | 66 +++++++++-----------
 .../glacier/GlacierClientLongLiveTest.java      | 38 +++++++++++
 .../jclouds/glacier/GlacierClientMockTest.java  |  2 +-
 glacier/src/test/resources/testng.xml           | 34 ++++++++++
 5 files changed, 159 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/67e8c721/glacier/pom.xml
----------------------------------------------------------------------
diff --git a/glacier/pom.xml b/glacier/pom.xml
index efe6722..fc35eab 100644
--- a/glacier/pom.xml
+++ b/glacier/pom.xml
@@ -17,7 +17,8 @@
     limitations under the License.
 
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.jclouds.labs</groupId>
@@ -42,9 +43,9 @@
 
     <jclouds.osgi.export>org.jclouds.glacier*;version="${project.version}"</jclouds.osgi.export>
     <jclouds.osgi.import>
-        org.jclouds.labs*;version="${project.version}",
-        org.jclouds*;version="${project.version}",
-        *
+      org.jclouds.labs*;version="${project.version}",
+      org.jclouds*;version="${project.version}",
+      *
     </jclouds.osgi.import>
   </properties>
 
@@ -115,9 +116,58 @@
                   <goal>test</goal>
                 </goals>
                 <configuration>
+                  <suiteXmlFiles>
+                    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
+                  </suiteXmlFiles>
+                  <groups>live</groups>
+                  <excludedGroups>livelong</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>
+                    <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>long</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</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>
@@ -132,5 +182,4 @@
       </build>
     </profile>
   </profiles>
-
 </project>

http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/67e8c721/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java
----------------------------------------------------------------------
diff --git a/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java b/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java
index dc2fdd6..472146f 100644
--- a/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java
+++ b/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java
@@ -28,42 +28,42 @@ import org.jclouds.glacier.util.ContentRange;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.hash.HashCode;
 
 /**
  * Live test for Glacier.
  */
-@Test(groups = { "integration", "live" })
-public class GlacierClientLiveTest extends BaseApiLiveTest<GlacierClient>{
-
-   public GlacierClientLiveTest() {
-      this.provider = "glacier";
-   }
+@Test(groups = {"live", "liveshort"})
+public class GlacierClientLiveTest extends BaseApiLiveTest<GlacierClient> {
 
    private final String VAULT_NAME1 = UUID.randomUUID().toString();
    private final String VAULT_NAME2 = UUID.randomUUID().toString();
    private final String VAULT_NAME3 = UUID.randomUUID().toString();
 
-   @Test(groups = { "integration", "live" })
+   public GlacierClientLiveTest() {
+      this.provider = "glacier";
+   }
+
+   @Test
    public void testDeleteVaultIfEmptyOrNotFound() throws Exception {
       assertThat(api.deleteVault(UUID.randomUUID().toString())).isTrue();
    }
 
-   @Test(groups = { "integration", "live" })
+   @Test
    public void testDescribeNonExistentVault() throws Exception {
       assertThat(api.describeVault(UUID.randomUUID().toString())).isNull();
    }
 
-   @Test(groups = { "integration", "live" })
+   @Test
    public void testCreateVault() throws Exception {
-      String path = api.createVault(VAULT_NAME1).toString();
-      api.createVault(VAULT_NAME2);
-      api.createVault(VAULT_NAME3);
-      assertThat(path)
+      assertThat(api.createVault(VAULT_NAME1).toString())
             .contains("https://glacier.us-east-1.amazonaws.com/")
             .contains("/vaults/" + VAULT_NAME1);
+      api.createVault(VAULT_NAME2);
+      api.createVault(VAULT_NAME3);
    }
 
-   @Test(groups = { "integration", "live" }, dependsOnMethods = { "testCreateVault" })
+   @Test(dependsOnMethods = {"testCreateVault"})
    public void testListAndDescribeVaults() throws Exception {
       PaginatedVaultCollection vaults = api.listVaults();
       assertThat(vaults).containsAll(ImmutableList.of(
@@ -72,39 +72,33 @@ public class GlacierClientLiveTest extends BaseApiLiveTest<GlacierClient>{
             api.describeVault(VAULT_NAME3)));
    }
 
-   @Test(groups = { "integration", "live" }, dependsOnMethods = { "testCreateVault" })
-   public void testListMultipartUploadsWithEmptyList() throws Exception {
+   @Test(dependsOnMethods = {"testCreateVault"})
+   public void testListMultipartUploadWithEmptyList() throws Exception {
       assertThat(api.listMultipartUploads(VAULT_NAME1)).isEmpty();
    }
 
-   @Test(groups = { "integration", "live" }, dependsOnMethods = { "testListMultipartUploadsWithEmptyList" })
-   public void testInitiateAndAbortMultipartUpload() throws Exception {
-      String uploadId = api.initiateMultipartUpload(VAULT_NAME1, 8);
-      try {
-         assertThat(uploadId).isNotNull();
-      } finally {
-         api.abortMultipartUpload(VAULT_NAME1, uploadId);
-      }
-   }
-
-   @Test(groups = { "integration", "live" }, dependsOnMethods = { "testInitiateAndAbortMultipartUpload" })
-   public void testListMultipartUploads() throws Exception {
+   @Test(dependsOnMethods = {"testListMultipartUploadWithEmptyList"})
+   public void testInitiateListAndAbortMultipartUpload() throws Exception {
       long partSizeInMb = 1;
       String uploadId = api.initiateMultipartUpload(VAULT_NAME1, partSizeInMb);
       try {
-         assertThat(api.uploadPart(VAULT_NAME1, uploadId,
-                 ContentRange.fromPartNumber(0, partSizeInMb), buildPayload(partSizeInMb * MiB))).isNotNull();
          assertThat(api.listMultipartUploads(VAULT_NAME1)).extracting("multipartUploadId").contains(uploadId);
-         assertThat(api.abortMultipartUpload(VAULT_NAME1, uploadId)).isTrue();
+
+         HashCode part1 = api.uploadPart(VAULT_NAME1, uploadId,
+               ContentRange.fromPartNumber(0, partSizeInMb), buildPayload(partSizeInMb * MiB));
+         HashCode part2 = api.uploadPart(VAULT_NAME1, uploadId,
+               ContentRange.fromPartNumber(1, partSizeInMb), buildPayload(partSizeInMb * MiB));
+         assertThat(part1).isNotNull();
+         assertThat(part2).isNotNull();
+         assertThat(api.listParts(VAULT_NAME1, uploadId)).extracting("treeHash").containsExactly(part1, part2);
       } finally {
-         api.abortMultipartUpload(VAULT_NAME1, uploadId);
+         assertThat(api.abortMultipartUpload(VAULT_NAME1, uploadId)).isTrue();
       }
    }
 
-   @Test(groups = { "integration", "live" },
-         dependsOnMethods = { "testListAndDescribeVaults", "testListMultipartUploadsWithEmptyList",
-         "testInitiateAndAbortMultipartUpload", "testListMultipartUploads" })
-   public void testDeleteVault() throws Exception {
+   @Test(dependsOnMethods = {"testListAndDescribeVaults", "testListMultipartUploadWithEmptyList",
+         "testInitiateListAndAbortMultipartUpload"})
+   public void testDeleteVaultAndArchive() throws Exception {
       assertThat(api.deleteVault(VAULT_NAME1)).isTrue();
       assertThat(api.deleteVault(VAULT_NAME2)).isTrue();
       assertThat(api.deleteVault(VAULT_NAME3)).isTrue();

http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/67e8c721/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
new file mode 100644
index 0000000..e851f72
--- /dev/null
+++ b/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.glacier;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Long live test for Glacier.
+ */
+@Test(groups = {"live", "livelong"})
+public class GlacierClientLongLiveTest extends BaseApiLiveTest<GlacierClient>{
+
+   public GlacierClientLongLiveTest() {
+      this.provider = "glacier";
+   }
+
+   @Test
+   public void testApi() throws Exception {
+      assertThat(api).isNotNull();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/67e8c721/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java
----------------------------------------------------------------------
diff --git a/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java b/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java
index 9ae400a..b53771b 100644
--- a/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java
+++ b/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java
@@ -71,7 +71,7 @@ import com.squareup.okhttp.mockwebserver.RecordedRequest;
 /**
  * Mock test for Glacier.
  */
-@Test(singleThreaded = true)
+@Test(singleThreaded = true, groups = {"mock"})
 public class GlacierClientMockTest {
 
    private static final String REQUEST_ID = "AAABZpJrTyioDC_HsOmHae8EZp_uBSJr6cnGOLKp_XJCl-Q";

http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/67e8c721/glacier/src/test/resources/testng.xml
----------------------------------------------------------------------
diff --git a/glacier/src/test/resources/testng.xml b/glacier/src/test/resources/testng.xml
new file mode 100644
index 0000000..1c1e34c
--- /dev/null
+++ b/glacier/src/test/resources/testng.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+<suite name="tests">
+  <test name="livelong">
+    <groups>
+      <run>
+        <include name="livelong" />
+      </run>
+    </groups>
+    <classes>
+      <class name="org.jclouds.glacier.GlacierClientLongLiveTest" />
+    </classes>
+  </test>
+  <test name="mock">
+    <groups>
+      <run>
+        <include name="mock" />
+      </run>
+    </groups>
+    <classes>
+      <class name="org.jclouds.glacier.GlacierClientMockTest" />
+    </classes>
+  </test>
+  <test name="liveshort">
+    <groups>
+      <run>
+        <include name="liveshort" />
+      </run>
+    </groups>
+    <classes>
+      <class name="org.jclouds.glacier.GlacierClientLiveTest" />
+    </classes>
+  </test>
+</suite>