brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [7/8] brooklyn-server git commit: Code tidy for test BrooklynMementoPersisterInMemorySize
Date Tue, 09 Aug 2016 19:44:41 GMT
Code tidy for test BrooklynMementoPersisterInMemorySize

And increase persistPeriod to decrease risk of failure on jenkins


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

Branch: refs/heads/master
Commit: 3d5833d17c2ca8033b9e794817dd0a8b73dbd33c
Parents: 3e1171f
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Aug 9 18:15:56 2016 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Aug 9 18:18:45 2016 +0100

----------------------------------------------------------------------
 ...ntoPersisterInMemorySizeIntegrationTest.java | 42 ++++++++++++++------
 ...essPersisterInMemorySizeIntegrationTest.java |  5 +--
 2 files changed, 31 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d5833d1/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
index fff4cf6..873370e 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
@@ -18,9 +18,6 @@
  */
 package org.apache.brooklyn.core.mgmt.persist;
 
-import java.io.IOException;
-import java.util.concurrent.TimeoutException;
-
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.mgmt.persist.ListeningObjectStore.RecordingTransactionListener;
@@ -29,6 +26,8 @@ import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.brooklyn.util.time.Duration;
 import org.apache.brooklyn.util.time.Time;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -36,6 +35,16 @@ import org.testng.annotations.Test;
 @Test
 public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends BrooklynMementoPersisterTestFixture
{
 
+    // TODO If you decrease persistPeriod to 1ms (from 100ms) then
+    //   SoftwareProcessPersisterInMemorySizeIntegrationTest.testPersistenceVolumeFastNoTrigger
+    // will fail: "Phase one recorded 234239 bytes, 123 files".
+    // It fails non-deterministically on Apache Jenkins (with 100ms persistPeriod) because
that 
+    // machine can be very slow sometimes.
+    // Increased persistPeriod to 250ms to improve chances of it working on jenkins, but
really we
+    // need to revisit how this test is written!
+    
+    private static final Logger LOG = LoggerFactory.getLogger(BrooklynMementoPersisterInMemorySizeIntegrationTest.class);
+
     protected static int pass1MaxFiles = 30;
     protected static int pass1MaxKb = 30;
     protected static int pass2MaxFiles = 40;
@@ -48,36 +57,43 @@ public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends
Brookly
         recorder = new RecordingTransactionListener("in-mem-test-"+Identifiers.makeRandomId(4));
         return RebindTestUtils.managementContextBuilder(classLoader, 
             new ListeningObjectStore(new InMemoryObjectStore(), recorder))
-            .persistPeriod(Duration.millis(100)).buildStarted();
+            .persistPeriod(Duration.millis(250)).buildStarted();
     }
     
-    public void testPersistenceVolumeFast() throws IOException, TimeoutException, InterruptedException
{
+    @Test
+    public void testPersistenceVolumeFast() throws Exception {
         doTestPersistenceVolume(false, true);
     }
+    
     @Test(groups="Integration",invocationCount=20)
-    public void testPersistenceVolumeFastManyTimes() throws IOException, TimeoutException,
InterruptedException {
+    public void testPersistenceVolumeFastManyTimes() throws Exception {
         doTestPersistenceVolume(false, true);
     }
+    
     @Test(groups="Integration")
-    public void testPersistenceVolumeWaiting() throws IOException, TimeoutException, InterruptedException
{
+    public void testPersistenceVolumeWaiting() throws Exception {
         // by waiting we ensure there aren't extra writes going on
         doTestPersistenceVolume(true, true);
     }
-    public void testPersistenceVolumeFastNoTrigger() throws IOException, TimeoutException,
InterruptedException {
+    
+    @Test
+    public void testPersistenceVolumeFastNoTrigger() throws Exception {
         doTestPersistenceVolume(false, false);
     }
+    
     @Test(groups="Integration",invocationCount=20)
-    public void testPersistenceVolumeFastNoTriggerManyTimes() throws IOException, TimeoutException,
InterruptedException {
+    public void testPersistenceVolumeFastNoTriggerManyTimes() throws Exception {
         doTestPersistenceVolume(false, false);
     }
     
-    protected void doTestPersistenceVolume(boolean forceDelay, boolean canTrigger) throws
IOException, TimeoutException, InterruptedException {
+    protected void doTestPersistenceVolume(boolean forceDelay, boolean canTrigger) throws
Exception {
         if (forceDelay) Time.sleep(Duration.FIVE_SECONDS);
         else recorder.blockUntilDataWrittenExceeds(512, Duration.FIVE_SECONDS);
         localManagementContext.getRebindManager().waitForPendingComplete(Duration.FIVE_SECONDS,
canTrigger);
         
         long out1 = recorder.getBytesOut();
         int filesOut1 = recorder.getCountDataOut();
+        LOG.info("Phase one recorded "+out1+" bytes, "+filesOut1+" files");
         Assert.assertTrue(out1>512, "should have written at least 0.5k, only wrote "+out1);
         Assert.assertTrue(out1<pass1MaxKb*1000, "should have written less than " + pass1MaxKb
+ "k, wrote "+out1);
         Assert.assertTrue(filesOut1<pass1MaxFiles, "should have written fewer than " +
pass1MaxFiles + " files, wrote "+filesOut1);
@@ -88,8 +104,9 @@ public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends
Brookly
         localManagementContext.getRebindManager().waitForPendingComplete(Duration.FIVE_SECONDS,
canTrigger);
         
         long out2 = recorder.getBytesOut();
-        Assert.assertTrue(out2-out1>10, "should have written more data");
         int filesOut2 = recorder.getCountDataOut();
+        LOG.info("Phase two recorded "+out2+" bytes, "+filesOut2+" files");
+        Assert.assertTrue(out2-out1>10, "should have written more data");
         Assert.assertTrue(filesOut2>filesOut1, "should have written more files");
         
         Assert.assertTrue(out2<pass2MaxKb*1000, "should have written less than " + pass2MaxKb
+ "k, wrote "+out2);
@@ -101,8 +118,9 @@ public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends
Brookly
         localManagementContext.getRebindManager().waitForPendingComplete(Duration.FIVE_SECONDS,
canTrigger);
 
         long out3 = recorder.getBytesOut();
-        Assert.assertTrue(out3-out2 > pass3MaxKb, "should have written " + pass3MaxKb
+ "k more data, only wrote "+out3+" compared with "+out2);
         int filesOut3 = recorder.getCountDataOut();
+        LOG.info("Phase three recorded "+out3+" bytes, "+filesOut3+" files");
+        Assert.assertTrue(out3-out2 > pass3MaxKb, "should have written " + pass3MaxKb
+ "k more data, only wrote "+out3+" compared with "+out2);
         Assert.assertTrue(filesOut3>filesOut2, "should have written more files");
     }
     

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d5833d1/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessPersisterInMemorySizeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessPersisterInMemorySizeIntegrationTest.java
b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessPersisterInMemorySizeIntegrationTest.java
index 0d53a08..91f8221 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessPersisterInMemorySizeIntegrationTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessPersisterInMemorySizeIntegrationTest.java
@@ -18,9 +18,6 @@
  */
 package org.apache.brooklyn.entity.software.base;
 
-import java.io.IOException;
-import java.util.concurrent.TimeoutException;
-
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterInMemorySizeIntegrationTest;
 import org.testng.annotations.BeforeMethod;
@@ -49,7 +46,7 @@ public class SoftwareProcessPersisterInMemorySizeIntegrationTest extends
Brookly
     }
 
     // to allow selection for running in IDE
-    public void testPersistenceVolumeFast() throws IOException, TimeoutException, InterruptedException
{
+    public void testPersistenceVolumeFast() throws Exception {
         super.testPersistenceVolumeFast();
     }
 


Mime
View raw message