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 2016/01/23 22:49:21 UTC
jclouds git commit: Avoid sleeping in signed URL tests
Repository: jclouds
Updated Branches:
refs/heads/master b2c0786fc -> b50c518f7
Avoid sleeping in signed URL tests
Also bump expiration to a consistent 60 seconds.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/b50c518f
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/b50c518f
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/b50c518f
Branch: refs/heads/master
Commit: b50c518f7e063fb6a3f624f1065fabd22ce0f9c9
Parents: b2c0786
Author: Andrew Gaul <ga...@apache.org>
Authored: Thu Jan 21 18:46:27 2016 -0800
Committer: Andrew Gaul <ga...@apache.org>
Committed: Sat Jan 23 13:48:43 2016 -0800
----------------------------------------------------------------------
.../internal/BaseBlobSignerLiveTest.java | 57 +++++++++++++++-----
1 file changed, 45 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b50c518f/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java
----------------------------------------------------------------------
diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java
index 5332c23..080ed9e 100644
--- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java
+++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java
@@ -41,6 +41,9 @@ import com.google.common.util.concurrent.Uninterruptibles;
*/
@Test(groups = {"live"})
public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
+ protected int getSignedUrlTimeout() {
+ return 60;
+ }
@Test
public void testSignGetUrl() throws Exception {
@@ -82,20 +85,35 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
public void testSignGetUrlWithTime() throws InterruptedException, IOException {
String name = "hello";
String text = "fooooooooooooooooooooooo";
- int timeout = 10;
Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
String container = getContainerName();
try {
view.getBlobStore().putBlob(container, blob);
assertConsistencyAwareContainerSize(container, 1);
- HttpRequest request = view.getSigner().signGetBlob(container, name, timeout);
-
+ HttpRequest request = view.getSigner().signGetBlob(container, name, getSignedUrlTimeout());
assertEquals(request.getFilters().size(), 0);
- Uninterruptibles.sleepUninterruptibly(timeout / 2, TimeUnit.SECONDS);
assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream()), text);
+ } catch (UnsupportedOperationException ignore) {
+ throw new SkipException("signGetUrl with a time limit is not supported on " + provider);
+ } finally {
+ returnContainer(container);
+ }
+ }
+
+ @Test
+ public void testSignGetUrlWithTimeExpired() throws InterruptedException, IOException {
+ String name = "hello";
+ String text = "fooooooooooooooooooooooo";
+
+ Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
+ String container = getContainerName();
+ try {
+ view.getBlobStore().putBlob(container, blob);
+ assertConsistencyAwareContainerSize(container, 1);
+ HttpRequest request = view.getSigner().signGetBlob(container, name, -getSignedUrlTimeout());
+ assertEquals(request.getFilters().size(), 0);
- TimeUnit.SECONDS.sleep(2 * timeout);
try {
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream());
fail("Temporary URL did not expire as expected");
@@ -129,26 +147,41 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
public void testSignPutUrlWithTime() throws Exception {
String name = "hello";
String text = "fooooooooooooooooooooooo";
- int timeout = 30;
Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
String container = getContainerName();
try {
- HttpRequest request = view.getSigner().signPutBlob(container, blob, timeout);
+ HttpRequest request = view.getSigner().signPutBlob(container, blob, getSignedUrlTimeout());
assertEquals(request.getFilters().size(), 0);
// Strip Expect: 100-continue to make actual responses visible, since
// Java 7+ will throw a ProtocolException instead of setting the response code:
// http://www.docjar.com/html/api/sun/net/www/protocol/http/HttpURLConnection.java.html#1021
request = request.toBuilder().removeHeader(EXPECT).build();
- Uninterruptibles.sleepUninterruptibly(timeout / 2, TimeUnit.SECONDS);
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream());
- assertConsistencyAwareContainerSize(container, 1);
+ } catch (UnsupportedOperationException ignore) {
+ throw new SkipException("signPutUrl with a time limit is not supported on " + provider);
+ } finally {
+ returnContainer(container);
+ }
+ }
+
+ @Test
+ public void testSignPutUrlWithTimeExpired() throws Exception {
+ String name = "hello";
+ String text = "fooooooooooooooooooooooo";
- view.getBlobStore().removeBlob(container, name);
- assertConsistencyAwareContainerSize(container, 0);
+ Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
+ String container = getContainerName();
+ try {
+ HttpRequest request = view.getSigner().signPutBlob(container, blob, -getSignedUrlTimeout());
+ assertEquals(request.getFilters().size(), 0);
+
+ // Strip Expect: 100-continue to make actual responses visible, since
+ // Java 7+ will throw a ProtocolException instead of setting the response code:
+ // http://www.docjar.com/html/api/sun/net/www/protocol/http/HttpURLConnection.java.html#1021
+ request = request.toBuilder().removeHeader(EXPECT).build();
- TimeUnit.SECONDS.sleep(2 * timeout);
try {
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().openStream());
fail("Temporary URL did not expire as expected");