Repository: jclouds Updated Branches: refs/heads/master b2ced53e1 -> 9dc85ecaa
JCLOUDS-1281: Improve Swift DLO tests Add DynamicLargeObjectApiLiveTest to Rackspace Cloud Files suite and use correct regionId so that tests pass. Also remove duplicative test. Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/9dc85eca Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/9dc85eca Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/9dc85eca Branch: refs/heads/master Commit: 9dc85ecaabb23bdc0b1d6b3b6650f22673631203 Parents: eaf3c77 Author: Andrew Gaul <[email protected]> Authored: Tue Nov 7 09:41:11 2017 -0800 Committer: Andrew Gaul <[email protected]> Committed: Tue Nov 7 10:50:10 2017 -0800 ---------------------------------------------------------------------- .../features/DynamicLargeObjectApiLiveTest.java | 102 +++++++------------ ...CloudFilesDynamicLargeObjectApiLiveTest.java | 31 ++++++ ...oudFilesUKDynamicLargeObjectApiLiveTest.java | 31 ++++++ ...oudFilesUSDynamicLargeObjectApiLiveTest.java | 31 ++++++ 4 files changed, 128 insertions(+), 67 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/9dc85eca/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApiLiveTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApiLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApiLiveTest.java index aaf37d3..87a2f7e 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApiLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApiLiveTest.java @@ -20,91 +20,70 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.jclouds.io.Payloads.newByteSourcePayload; import static org.testng.Assert.assertNotNull; -import java.io.IOException; - -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.domain.Blob; -import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext; -import org.jclouds.openstack.swift.v1.domain.ObjectList; import org.jclouds.openstack.swift.v1.domain.SwiftObject; import org.jclouds.openstack.swift.v1.internal.BaseSwiftApiLiveTest; -import org.jclouds.openstack.swift.v1.options.ListContainerOptions; import org.jclouds.utils.TestUtils; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteSource; @Test(groups = "live", testName = "DynamicLargeObjectApiLiveTest", singleThreaded = true) public class DynamicLargeObjectApiLiveTest extends BaseSwiftApiLiveTest { - private String defaultName = getClass().getSimpleName(); + private String containerName = getClass().getSimpleName(); private static final ByteSource megOf1s = TestUtils.randomByteSource().slice(0, 1024 * 1024); private static final ByteSource megOf2s = TestUtils.randomByteSource().slice(0, 1024 * 1024); private String objectName = "myObject"; + private String name = "foo"; - @Test - public void testReplaceManifest() throws Exception { + @Override + @BeforeClass(groups = "live") + public void setup() { + super.setup(); for (String regionId : regions) { - assertReplaceManifest(regionId, defaultName); - uploadLargeFile(regionId); + getApi().getContainerApi(regionId).create(containerName); } } - @SuppressWarnings("deprecation") - @Test - public void uploadLargeFile(String regionId) throws IOException, InterruptedException { - long total_size = 0; - RegionScopedBlobStoreContext ctx = RegionScopedBlobStoreContext.class.cast(view); - BlobStore blobStore = ctx.getBlobStore(); - String defaultContainerName = getContainerName(); - // configure the blobstore to use multipart uploading of the file - for (int partNumber = 0; partNumber < 3; partNumber++) { - String objName = String.format("%s/%s/%s", objectName, "dlo", partNumber); - String data = "data" + partNumber; - ByteSource payload = ByteSource.wrap(data.getBytes(Charsets.UTF_8)); - Blob blob = blobStore.blobBuilder(objName) - .payload(payload) - .build(); - String etag = blobStore.putBlob(defaultContainerName, blob); - assertNotNull(etag); - total_size += data.length(); + @AfterClass(groups = "live") + public void tearDown() { + for (String regionId : regions) { + deleteAllObjectsInContainer(regionId, containerName); + getApi().getContainerApi(regionId).deleteIfEmpty(containerName); } - getApi().getDynamicLargeObjectApi(regionId, defaultContainerName).putManifest(objectName, - ImmutableMap.of("myfoo", "Bar")); - SwiftObject bigObject = getApi().getObjectApi(regionId, defaultContainerName).get(objectName); - assertThat(bigObject.getETag()).isEqualTo("54bc1337d7a51660c40db39759cc1944"); - assertThat(bigObject.getPayload().getContentMetadata().getContentLength()).isEqualTo(total_size); - assertThat(getApi().getContainerApi(regionId).get(defaultContainerName).getObjectCount()).isEqualTo(Long.valueOf(4)); } @SuppressWarnings("deprecation") - protected void assertReplaceManifest(String regionId, String name) throws InterruptedException { - String containerName = getContainerName(); - ObjectApi objectApi = getApi().getObjectApi(regionId, containerName); + @Test + protected void assertReplaceManifest() throws Exception { + for (String regionId : regions) { + ObjectApi objectApi = getApi().getObjectApi(regionId, containerName); - String etag1s = objectApi.put(name + "/1", newByteSourcePayload(megOf1s)); - awaitConsistency(); - assertMegabyteAndETagMatches(regionId, containerName, name + "/1", etag1s); + String etag1s = objectApi.put(name + "/1", newByteSourcePayload(megOf1s)); + awaitConsistency(); + assertMegabyteAndETagMatches(regionId, containerName, name + "/1", etag1s); - String etag2s = objectApi.put(name + "/2", newByteSourcePayload(megOf2s)); - awaitConsistency(); - assertMegabyteAndETagMatches(regionId, containerName, name + "/2", etag2s); + String etag2s = objectApi.put(name + "/2", newByteSourcePayload(megOf2s)); + awaitConsistency(); + assertMegabyteAndETagMatches(regionId, containerName, name + "/2", etag2s); - awaitConsistency(); - String etagOfEtags = getApi().getDynamicLargeObjectApi(regionId, containerName).putManifest(name, - ImmutableMap.of("myfoo", "Bar")); + awaitConsistency(); + String etagOfEtags = getApi().getDynamicLargeObjectApi(regionId, containerName).putManifest(name, + ImmutableMap.of("myfoo", "Bar")); - assertNotNull(etagOfEtags); + assertNotNull(etagOfEtags); - awaitConsistency(); + awaitConsistency(); - SwiftObject bigObject = getApi().getObjectApi(regionId, containerName).get(name); - assertThat(bigObject.getPayload().getContentMetadata().getContentLength()).isEqualTo(Long.valueOf(2 * 1024L * 1024L)); - assertThat(bigObject.getMetadata()).isEqualTo(ImmutableMap.of("myfoo", "Bar")); - // segments are visible - assertThat(getApi().getContainerApi(regionId).get(containerName).getObjectCount()).isEqualTo(Long.valueOf(3)); + SwiftObject bigObject = getApi().getObjectApi(regionId, containerName).get(name); + assertThat(bigObject.getPayload().getContentMetadata().getContentLength()).isEqualTo(Long.valueOf(2 * 1024L * 1024L)); + assertThat(bigObject.getMetadata()).isEqualTo(ImmutableMap.of("myfoo", "Bar")); + // segments are visible + assertThat(getApi().getContainerApi(regionId).get(containerName).getObjectCount()).isEqualTo(Long.valueOf(3)); + } } protected void assertMegabyteAndETagMatches(String regionId, String containerName, String name, String etag1s) { @@ -112,15 +91,4 @@ public class DynamicLargeObjectApiLiveTest extends BaseSwiftApiLiveTest { assertThat(object1s.getETag()).isEqualTo(etag1s); assertThat(object1s.getPayload().getContentMetadata().getContentLength()).isEqualTo(Long.valueOf(1024L * 1024L)); } - - protected void deleteAllObjectsInContainerDLO(String regionId, final String containerName) { - ObjectList objects = getApi().getObjectApi(regionId, containerName).list(new ListContainerOptions()); - if (objects == null) { - return; - } - for (SwiftObject object : objects) { - String name = containerName + "/" + object.getName(); - getApi().getObjectApi(regionId, containerName).delete(name); - } - } } http://git-wip-us.apache.org/repos/asf/jclouds/blob/9dc85eca/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesDynamicLargeObjectApiLiveTest.java ---------------------------------------------------------------------- diff --git a/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesDynamicLargeObjectApiLiveTest.java b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesDynamicLargeObjectApiLiveTest.java new file mode 100644 index 0000000..f68c90b --- /dev/null +++ b/apis/rackspace-cloudfiles/src/test/java/org/jclouds/rackspace/cloudfiles/v1/features/CloudFilesDynamicLargeObjectApiLiveTest.java @@ -0,0 +1,31 @@ +/* + * 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.rackspace.cloudfiles.v1.features; + +import org.jclouds.openstack.swift.v1.features.DynamicLargeObjectApiLiveTest; +import org.testng.annotations.Test; + +/** + * Tests the live behavior of the OpenStack Object Storage {@link DynamicLargeObjectApi} + * via the {@link CloudFilesApi}. + */ +@Test(groups = "live", testName = "CloudFilesDynamicLargeObjectApiLiveTest") +public class CloudFilesDynamicLargeObjectApiLiveTest extends DynamicLargeObjectApiLiveTest { + public CloudFilesDynamicLargeObjectApiLiveTest() { + provider = "rackspace-cloudfiles"; + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/9dc85eca/providers/rackspace-cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/uk/features/CloudFilesUKDynamicLargeObjectApiLiveTest.java ---------------------------------------------------------------------- diff --git a/providers/rackspace-cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/uk/features/CloudFilesUKDynamicLargeObjectApiLiveTest.java b/providers/rackspace-cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/uk/features/CloudFilesUKDynamicLargeObjectApiLiveTest.java new file mode 100644 index 0000000..2f02501 --- /dev/null +++ b/providers/rackspace-cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/uk/features/CloudFilesUKDynamicLargeObjectApiLiveTest.java @@ -0,0 +1,31 @@ +/* + * 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.rackspace.cloudfiles.uk.features; + +import org.jclouds.rackspace.cloudfiles.v1.features.CloudFilesDynamicLargeObjectApiLiveTest; +import org.testng.annotations.Test; + +/** + * Tests the live behavior of the OpenStack Object Storage {@link DynamicLargeObjectApi} + * via the {@link CloudFilesApi}. + */ +@Test(groups = "live", testName = "CloudFilesUKDynamicLargeObjectApiLiveTest") +public final class CloudFilesUKDynamicLargeObjectApiLiveTest extends CloudFilesDynamicLargeObjectApiLiveTest { + public CloudFilesUKDynamicLargeObjectApiLiveTest() { + provider = "rackspace-cloudfiles-uk"; + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/9dc85eca/providers/rackspace-cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/us/features/CloudFilesUSDynamicLargeObjectApiLiveTest.java ---------------------------------------------------------------------- diff --git a/providers/rackspace-cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/us/features/CloudFilesUSDynamicLargeObjectApiLiveTest.java b/providers/rackspace-cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/us/features/CloudFilesUSDynamicLargeObjectApiLiveTest.java new file mode 100644 index 0000000..93b820d --- /dev/null +++ b/providers/rackspace-cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/us/features/CloudFilesUSDynamicLargeObjectApiLiveTest.java @@ -0,0 +1,31 @@ +/* + * 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.rackspace.cloudfiles.us.features; + +import org.jclouds.rackspace.cloudfiles.v1.features.CloudFilesDynamicLargeObjectApiLiveTest; +import org.testng.annotations.Test; + +/** + * Tests the live behavior of the OpenStack Object Storage {@link DynamicLargeObjectApi} + * via the {@link CloudFilesApi}. + */ +@Test(groups = "live", testName = "CloudFilesUSDynamicLargeObjectApiLiveTest") +public final class CloudFilesUSDynamicLargeObjectApiLiveTest extends CloudFilesDynamicLargeObjectApiLiveTest { + public CloudFilesUSDynamicLargeObjectApiLiveTest() { + provider = "rackspace-cloudfiles-us"; + } +}
