brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [1/2] brooklyn-server git commit: Fix non-deterministic DefaultCOnnectivityResolverTest
Date Tue, 23 May 2017 13:29:51 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 2bb8572f4 -> 377454ed8


Fix non-deterministic DefaultCOnnectivityResolverTest

Was failing on apache Jenkins sometimes, due to a 1ms timeout!
Increased this to 100ms, which still feels low (but unfortunately
The test will take a minimum of `Math.min(timeout, gracePeriod)`.

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2952ea1d
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2952ea1d
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2952ea1d

Branch: refs/heads/master
Commit: 2952ea1d8ace5ed5eb4058f3ef1280c8dd8160d6
Parents: 2bb8572
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue May 23 11:09:03 2017 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue May 23 11:09:03 2017 +0100

----------------------------------------------------------------------
 .../jclouds/DefaultConnectivityResolverTest.java     | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2952ea1d/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/DefaultConnectivityResolverTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/DefaultConnectivityResolverTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/DefaultConnectivityResolverTest.java
index 6088c54..6e7d8b0 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/DefaultConnectivityResolverTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/DefaultConnectivityResolverTest.java
@@ -151,7 +151,7 @@ public class DefaultConnectivityResolverTest extends AbstractJcloudsStubbedUnitT
                 JcloudsLocationConfig.WAIT_FOR_SSHABLE, "1ms",
                 JcloudsLocationConfig.POLL_FOR_FIRST_REACHABLE_ADDRESS, "1ms",
                 JcloudsLocation.CUSTOM_CREDENTIALS, credential));
-        ConnectivityResolverOptions options = newResolveOptionsForIps(reachableIps).build();
+        ConnectivityResolverOptions options = newResolveOptionsForIps(reachableIps, Duration.millis(100)).build();
 
         // Chooses authorisedHostAndPort when credentials are tested.
         DefaultConnectivityResolver customizer = new DefaultConnectivityResolver(ImmutableMap.of(
@@ -193,7 +193,7 @@ public class DefaultConnectivityResolverTest extends AbstractJcloudsStubbedUnitT
         initNodeCreatorAndJcloudsLocation(newNodeCreator(), ImmutableMap.of(
                 JcloudsLocationConfig.CONNECTIVITY_RESOLVER, customizer));
 
-        ConnectivityResolverOptions options = newResolveOptionsForIps(reachableIps).build();
+        ConnectivityResolverOptions options = newResolveOptionsForIps(reachableIps, Duration.millis(100)).build();
         ConfigBag configBag = ConfigBag.newInstance();
 
         ManagementAddressResolveResult result = customizer.resolve(jcloudsLocation, newNodeMetadata(),
configBag, options);
@@ -222,7 +222,7 @@ public class DefaultConnectivityResolverTest extends AbstractJcloudsStubbedUnitT
         initNodeCreatorAndJcloudsLocation(newNodeCreator(), ImmutableMap.of(
                 JcloudsLocationConfig.CONNECTIVITY_RESOLVER, customizer));
 
-        ConnectivityResolverOptions options = newResolveOptionsForIps(reachableIps).build();
+        ConnectivityResolverOptions options = newResolveOptionsForIps(reachableIps, Duration.ONE_MILLISECOND).build();
         ConfigBag configBag = ConfigBag.newInstance();
         customizer.resolve(jcloudsLocation, newNodeMetadata(), configBag, options);
     }
@@ -232,9 +232,14 @@ public class DefaultConnectivityResolverTest extends AbstractJcloudsStubbedUnitT
                 .initialCredentials(credential);
     }
     
-    private ConnectivityResolverOptions.Builder newResolveOptionsForIps(Set<HostAndPort>
reachableIps) {
+    private ConnectivityResolverOptions.Builder newResolveOptionsForIps(Set<HostAndPort>
reachableIps, Duration timeout) {
+        // It's important to not use a tiny timeout (e.g. 1ms) if you expect it to succeed,

+        // because that can fail on apache jenkins. We execute the check in a background
+        // thread, and then wait for this timeout for it to succeed. On a slow machine, we

+        // might not have finished executing the predicate, so might abort. 
+        // (see `ReachableSocketFinder.tryReachable()`, and its use of `timeout`).
         return newResolveOptions().
-            pollForReachableAddresses(Predicates.in(reachableIps), Duration.millis(1), true);
+            pollForReachableAddresses(Predicates.in(reachableIps), timeout, true);
     }
 
     private NodeMetadata newNodeMetadata() {


Mime
View raw message