brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/8] brooklyn-server git commit: Fix integration tests in brooklyn-core
Date Fri, 11 Nov 2016 09:50:17 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master dff428e52 -> 1caa48ff2


Fix integration tests in brooklyn-core


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

Branch: refs/heads/master
Commit: b714516a57eabf4ef50d41ae8c3de9f5b93ffdc8
Parents: 70f2950
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Mon Nov 7 19:13:00 2016 +0200
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Thu Nov 10 18:06:45 2016 +0200

----------------------------------------------------------------------
 .../geo/external-ip-address-resolvers.txt       |  3 ++-
 .../entity/RecordingSensorEventListener.java    |  4 ++++
 .../brooklyn/enricher/stock/EnrichersTest.java  | 22 +++++++++++++-------
 .../java/org/apache/brooklyn/test/Asserts.java  |  4 +++-
 .../util/javalang/MemoryUsageTrackerTest.java   |  1 +
 5 files changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b714516a/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
b/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
index 693114a..c51b394 100644
--- a/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
+++ b/core/src/main/resources/org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt
@@ -18,7 +18,8 @@
 http://jsonip.com/
 http://myip.dnsomatic.com/
 http://checkip.dyndns.org/
-http://wtfismyip.com/text
+# Uses Let's Encrypt certificate supported only in Java 8u101+
+# https://wtfismyip.com/text
 http://whatismyip.akamai.com/
 http://myip.wampdeveloper.com/
 http://icanhazip.com/

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b714516a/core/src/test/java/org/apache/brooklyn/core/entity/RecordingSensorEventListener.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/RecordingSensorEventListener.java
b/core/src/test/java/org/apache/brooklyn/core/entity/RecordingSensorEventListener.java
index f5384b2..e0c4ed0 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/RecordingSensorEventListener.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/RecordingSensorEventListener.java
@@ -126,4 +126,8 @@ public class RecordingSensorEventListener<T> implements SensorEventListener<T>,
         }
     }
 
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + "[size=" + getEvents().size() + "; events=" +
getEvents() + "]";
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b714516a/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java b/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
index e20664b..4e6c87e 100644
--- a/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
+++ b/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
@@ -18,6 +18,9 @@
  */
 package org.apache.brooklyn.enricher.stock;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
 import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
@@ -185,7 +188,7 @@ public class EnrichersTest extends BrooklynAppUnitTestSupport {
     }
 
     @Test(groups="Integration") // because takes a second
-    public void testTransformingRespectsUnchangedButWillRepublish() {
+    public void testTransformingRespectsUnchangedButWillRepublish() throws Exception {
         RecordingSensorEventListener<String> record = new RecordingSensorEventListener<>();
         app.getManagementContext().getSubscriptionManager().subscribe(entity, STR2, record);
         
@@ -197,21 +200,26 @@ public class EnrichersTest extends BrooklynAppUnitTestSupport {
                             return ("ignoredval".equals(input)) ? Entities.UNCHANGED : input;
                         }})
                 .build());
-        Asserts.assertThat(record.getEvents(), CollectionFunctionals.sizeEquals(0));
+        // check notifyOfInitialValue (set in Transformer) is null
+        Asserts.eventually(Suppliers.ofInstance(record), CollectionFunctionals.sizeEquals(1));
+        SensorEvent<String> initialEvent = Iterables.getOnlyElement(record);
+        assertEquals(initialEvent.getSensor(), STR2);
+        assertNull(initialEvent.getValue());
 
         entity.sensors().set(STR1, "myval");
-        Asserts.eventually(Suppliers.ofInstance(record), CollectionFunctionals.sizeEquals(1));
-        EntityAsserts.assertAttributeEquals(entity, STR2, "myval");
+        Asserts.eventually(Suppliers.ofInstance(record), CollectionFunctionals.sizeEquals(2));
+        EntityAsserts.assertAttributeEqualsEventually(entity, STR2, "myval");
 
         entity.sensors().set(STR1, "ignoredval");
         EntityAsserts.assertAttributeEqualsContinually(entity, STR2, "myval");
 
         entity.sensors().set(STR1, "myval2");
-        Asserts.eventually(Suppliers.ofInstance(record), CollectionFunctionals.sizeEquals(2));
-        EntityAsserts.assertAttributeEquals(entity, STR2, "myval2");
+        Asserts.eventually(Suppliers.ofInstance(record), CollectionFunctionals.sizeEquals(3));
+        EntityAsserts.assertAttributeEqualsEventually(entity, STR2, "myval2");
 
         entity.sensors().set(STR1, "myval2");
-        entity.sensors().set(STR1, "myval2");
+        // Duplicate values still trigger change events
+        // entity.sensors().set(STR1, "myval2");
         entity.sensors().set(STR1, "myval3");
         Asserts.eventually(Suppliers.ofInstance(record), CollectionFunctionals.sizeEquals(5));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b714516a/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java b/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java
index 21a1b53..a4717e2 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java
@@ -951,6 +951,7 @@ public class Asserts {
                     }
                     lastException = null;
                 } catch(Throwable e) {
+                    Exceptions.propagateIfInterrupt(e);
                     lastException = e;
                     if (log.isTraceEnabled()) log.trace("Attempt {} after {} ms: {}", new
Object[] {attempt, System.currentTimeMillis() - startTime, e.getMessage()});
                     if (abortOnException) throw e;
@@ -966,10 +967,11 @@ public class Asserts {
                 throw lastException;
             throw fail("invalid results; last was: "+result);
         } catch (Throwable t) {
+            Exceptions.propagateIfInterrupt(t);
             if (logException) log.info("failed succeeds-eventually, "+attempt+" attempts,
"+
                     (System.currentTimeMillis()-startTime)+"ms elapsed "+
                     "(rethrowing): "+t);
-            throw Exceptions.propagateAnnotated("failed succeeds-eventually, "+attempt+"
attempts, "+
+            throw new AssertionError("failed succeeds-eventually, "+attempt+" attempts, "+
                 (System.currentTimeMillis()-startTime)+"ms elapsed: "+Exceptions.collapseText(t),
t);
         }
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b714516a/utils/common/src/test/java/org/apache/brooklyn/util/javalang/MemoryUsageTrackerTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/javalang/MemoryUsageTrackerTest.java
b/utils/common/src/test/java/org/apache/brooklyn/util/javalang/MemoryUsageTrackerTest.java
index f5b61dc..e80f08d 100644
--- a/utils/common/src/test/java/org/apache/brooklyn/util/javalang/MemoryUsageTrackerTest.java
+++ b/utils/common/src/test/java/org/apache/brooklyn/util/javalang/MemoryUsageTrackerTest.java
@@ -102,6 +102,7 @@ public class MemoryUsageTrackerTest {
             if (containsAbsent(dump)) break;
         }
         int cleared = countAbsents(dump);
+        assertTrue(cleared > 0, "No soft references cleared after trying to allocate all
available memory");
         LOG.info("First soft reference cleared after "+dump.size()+" 1M blocks created; "+cleared+"
of them cleared; memory just before collected is "+beforeCollectedMemory);
         
         // Expect the soft references to only have been collected when most of the JVM's
memory 


Mime
View raw message