brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [09/11] git commit: BrooklynMavenArtifactsTest: allow retry for URL
Date Tue, 28 Oct 2014 15:37:20 GMT
BrooklynMavenArtifactsTest: allow retry for URL

- have seen response code 500 from repository.apache.org for snapshot
  builds, so retry for default timeout (30 seconds)


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/7952ae5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/7952ae5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/7952ae5f

Branch: refs/heads/master
Commit: 7952ae5ffd4bbab19e24b8efdb24429506f807bf
Parents: e9e366a
Author: Aled Sage <aled.sage@gmail.com>
Authored: Mon Oct 27 14:38:00 2014 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Oct 28 15:35:33 2014 +0000

----------------------------------------------------------------------
 .../util/BrooklynMavenArtifactsTest.java        | 25 +++++++++++++-------
 1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7952ae5f/core/src/test/java/brooklyn/util/BrooklynMavenArtifactsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/BrooklynMavenArtifactsTest.java b/core/src/test/java/brooklyn/util/BrooklynMavenArtifactsTest.java
index bb68951..d1f0ef4 100644
--- a/core/src/test/java/brooklyn/util/BrooklynMavenArtifactsTest.java
+++ b/core/src/test/java/brooklyn/util/BrooklynMavenArtifactsTest.java
@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import brooklyn.test.Asserts;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.maven.MavenArtifact;
 import brooklyn.util.maven.MavenRetriever;
@@ -77,15 +78,21 @@ public class BrooklynMavenArtifactsTest {
         checkValidArchive(release);
     }
 
-    private void checkValidArchive(String url) {
-        try {
-            byte[] bytes = Streams.readFully(ResourceUtils.create(this).getResourceFromUrl(url));
-            // confirm this follow redirects!
-            Assert.assertTrue(bytes.length > 100*1000, "download of "+url+" is suspect
("+Strings.makeSizeString(bytes.length)+")");
-            // (could also check it is a zip etc)
-        } catch (Exception e) {
-            throw Exceptions.propagate(e);
-        }
+    private void checkValidArchive(final String url) {
+        // Note have seen response code 500 from repository.apache.org, for
+        //   https://repository.apache.org/service/local/artifact/maven/redirect?r=snapshots&v=0.7.0-SNAPSHOT&g=org.apache.brooklyn&a=brooklyn-utils-common&e=jar
+        // Therefore willing to retry, rather than failing immediately.
+        Asserts.succeedsEventually(new Runnable() {
+            @Override public void run() {
+                try {
+                    byte[] bytes = Streams.readFully(ResourceUtils.create(this).getResourceFromUrl(url));
+                    // confirm this follow redirects!
+                    Assert.assertTrue(bytes.length > 100*1000, "download of "+url+" is
suspect ("+Strings.makeSizeString(bytes.length)+")");
+                    // (could also check it is a zip etc)
+                } catch (Exception e) {
+                    throw Exceptions.propagate(e);
+                }
+            }});
     }
 
 }


Mime
View raw message