JCLOUDS-457: Test groups and improvements

Test groups have been added. Also, the live tests were
refactored to reduce the number of RPCs.
This commit is contained in:
Roman Coedo 2014-07-12 12:28:23 +02:00 committed by Andrew Gaul
parent ff83778fb7
commit 73d9fa5340
5 changed files with 159 additions and 44 deletions

View File

@ -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>

View File

@ -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();

View File

@ -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();
}
}

View File

@ -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";

View File

@ -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>