From 73d9fa5340478e6b5b62c9c0de9c600329e0ab5e Mon Sep 17 00:00:00 2001 From: Roman Coedo Date: Sat, 12 Jul 2014 12:28:23 +0200 Subject: [PATCH] JCLOUDS-457: Test groups and improvements Test groups have been added. Also, the live tests were refactored to reduce the number of RPCs. --- apis/glacier/pom.xml | 63 ++++++++++++++++-- .../glacier/GlacierClientLiveTest.java | 66 +++++++++---------- .../glacier/GlacierClientLongLiveTest.java | 38 +++++++++++ .../glacier/GlacierClientMockTest.java | 2 +- apis/glacier/src/test/resources/testng.xml | 34 ++++++++++ 5 files changed, 159 insertions(+), 44 deletions(-) create mode 100644 apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java create mode 100644 apis/glacier/src/test/resources/testng.xml diff --git a/apis/glacier/pom.xml b/apis/glacier/pom.xml index efe6722831..fc35eab1ef 100644 --- a/apis/glacier/pom.xml +++ b/apis/glacier/pom.xml @@ -17,7 +17,8 @@ limitations under the License. --> - + 4.0.0 org.apache.jclouds.labs @@ -42,9 +43,9 @@ org.jclouds.glacier*;version="${project.version}" - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${project.version}", - * + org.jclouds.labs*;version="${project.version}", + org.jclouds*;version="${project.version}", + * @@ -115,9 +116,58 @@ test + + src/test/resources/testng.xml + + live + livelong - ${jclouds.blobstore.httpstream.url} - ${jclouds.blobstore.httpstream.md5} + + ${jclouds.blobstore.httpstream.url} + + + ${jclouds.blobstore.httpstream.md5} + + ${test.glacier.endpoint} + ${test.glacier.api-version} + ${test.glacier.build-version} + ${test.glacier.identity} + ${test.glacier.credential} + + + + + + + + + + long + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + src/test/resources/testng.xml + + live + liveshort + + + ${jclouds.blobstore.httpstream.url} + + + ${jclouds.blobstore.httpstream.md5} + ${test.glacier.endpoint} ${test.glacier.api-version} ${test.glacier.build-version} @@ -132,5 +182,4 @@ - diff --git a/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java b/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java index dc2fdd62a2..472146f368 100644 --- a/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientLiveTest.java +++ b/apis/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{ - - public GlacierClientLiveTest() { - this.provider = "glacier"; - } +@Test(groups = {"live", "liveshort"}) +public class GlacierClientLiveTest extends BaseApiLiveTest { 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{ 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(); diff --git a/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java b/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientLongLiveTest.java new file mode 100644 index 0000000000..e851f72e67 --- /dev/null +++ b/apis/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{ + + public GlacierClientLongLiveTest() { + this.provider = "glacier"; + } + + @Test + public void testApi() throws Exception { + assertThat(api).isNotNull(); + } +} diff --git a/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java b/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java index 9ae400ad0b..b53771b7f4 100644 --- a/apis/glacier/src/test/java/org/jclouds/glacier/GlacierClientMockTest.java +++ b/apis/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"; diff --git a/apis/glacier/src/test/resources/testng.xml b/apis/glacier/src/test/resources/testng.xml new file mode 100644 index 0000000000..1c1e34c96e --- /dev/null +++ b/apis/glacier/src/test/resources/testng.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +