[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/buddyreplication ...

Manik Surtani msurtani at jboss.com
Tue Sep 12 06:36:26 EDT 2006


  User: msurtani
  Date: 06/09/12 06:36:26

  Modified:    tests/functional/org/jboss/cache/buddyreplication   
                        BuddyGroupAssignmentTest.java
                        BuddyPoolBroadcastTest.java
                        BuddyReplicationContentTest.java
  Log:
  Added more logging to help debug concurrency errors
  
  Revision  Changes    Path
  1.11      +92 -96    JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BuddyGroupAssignmentTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- BuddyGroupAssignmentTest.java	6 Sep 2006 15:30:57 -0000	1.10
  +++ BuddyGroupAssignmentTest.java	12 Sep 2006 10:36:25 -0000	1.11
  @@ -6,6 +6,8 @@
    */
   package org.jboss.cache.buddyreplication;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -16,18 +18,35 @@
    */
   public class BuddyGroupAssignmentTest extends BuddyReplicationTestsBase
   {
  +   private TreeCache[] caches;
  +   private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
   
  -   public void testSingleBuddy() throws Exception
  +   protected void setUp() throws Exception
      {
  -      TreeCache[] caches = createCaches(3, false);
  +      log.debug("Starting setUp()");
  +      super.setUp();
  +      log.debug("Finishing setUp()");
  +   }
   
  -      for (int i = 0; i < caches.length; i++)
  +   protected void tearDown() throws Exception
         {
  -         printBuddyGroup(caches[i]);
  +      super.tearDown();
  +      log.debug("Starting tearDown()");
  +      cleanup(caches);
  +      log.debug("Finishing tearDown()");
         }
   
  -      try
  +
  +   public void testSingleBuddy() throws Exception
  +   {
  +      log.debug("Running testSingleBuddy");
  +      caches = createCaches(3, false);
  +
  +      for (TreeCache cache : caches)
         {
  +         printBuddyGroup(cache);
  +      }
  +
            System.out.println("*** Testing cache 0:");
            assertIsBuddy(caches[0], caches[1], true);
            System.out.println("*** Testing cache 1:");
  @@ -35,18 +54,12 @@
            System.out.println("*** Testing cache 2:");
            assertIsBuddy(caches[2], caches[0], true);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void test2Buddies() throws Exception
      {
  +      log.debug("Running test2Buddies");
         TreeCache[] caches = createCaches(2, 3, false);
   
  -      try
  -      {
            System.out.println("*** Testing cache 0");
            assertIsBuddy(caches[0], caches[1], false);
            assertIsBuddy(caches[0], caches[2], false);
  @@ -57,18 +70,12 @@
            assertIsBuddy(caches[2], caches[1], false);
            assertIsBuddy(caches[2], caches[0], false);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void testRemovalFromClusterSingleBuddy() throws Exception
      {
  +      log.debug("Running testRemovalFromClusterSingleBuddy");
         TreeCache[] caches = createCaches(3, false);
   
  -      try
  -      {
            System.out.println("*** Testing cache 0");
            assertIsBuddy(caches[0], caches[1], true);
            System.out.println("*** Testing cache 1");
  @@ -90,19 +97,13 @@
            System.out.println("*** Completed successfully ***");
            assertNoLocks(caches);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void testRemovalFromCluster2Buddies() throws Exception
      {
  +      log.debug("Running testRemovalFromCluster2Buddies");
         TreeCache[] caches = createCaches(2, 4, false);
         assertNoLocks(caches);
   
  -      try
  -      {
            System.out.println("*** Testing cache 0");
            assertIsBuddy(caches[0], caches[1], false);
            assertIsBuddy(caches[0], caches[2], false);
  @@ -134,9 +135,4 @@
            assertIsBuddy(caches[3], caches[2], false);
            assertNoLocks(caches);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   }
  
  
  
  1.14      +87 -95    JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BuddyPoolBroadcastTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- BuddyPoolBroadcastTest.java	6 Sep 2006 15:30:57 -0000	1.13
  +++ BuddyPoolBroadcastTest.java	12 Sep 2006 10:36:26 -0000	1.14
  @@ -7,6 +7,8 @@
   package org.jboss.cache.buddyreplication;
   
   import EDU.oswego.cs.dl.util.concurrent.Latch;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -19,6 +21,10 @@
    */
   public class BuddyPoolBroadcastTest extends BuddyReplicationTestsBase
   {
  +
  +   private TreeCache[] caches;
  +   private Log log = LogFactory.getLog(BuddyPoolBroadcastTest.class);
  +
      private void checkConsistentPoolState(TreeCache[] caches)
      {
         for (int i = 0; i < caches.length; i++)
  @@ -29,39 +35,49 @@
               if (i != j)
               {
                  Map groupMap2 = caches[j].getBuddyManager().buddyPool;
  -               for (int k = 0; k < caches.length; k++)
  +               for (TreeCache cache : caches)
                  {
  -                  assertEquals("Comparing contents of cache " + (i + 1) + " pool map with cache " + (j + 1), groupMap.get(caches[k]), groupMap2.get(caches[k]));
  +                  assertEquals("Comparing contents of cache " + (i + 1) + " pool map with cache " + (j + 1), groupMap.get(cache), groupMap2.get(cache));
                  }
               }
            }
         }
      }
   
  -   public void test2CachesWithPoolNames() throws Exception
  +
  +   protected void setUp() throws Exception
      {
  -      TreeCache[] caches = createCaches(2, true);
  +      log.debug("Starting setUp()");
  +      super.setUp();
  +      log.debug("Finishing setUp()");
  +   }
   
  -      try
  +   protected void tearDown() throws Exception
         {
  +      log.debug("Starting tearDown()");
  +      super.tearDown();
  +      cleanup(caches);
  +      log.debug("Finishing tearDown()");
  +   }
  +
  +
  +   public void test2CachesWithPoolNames() throws Exception
  +   {
  +      log.debug("Running test2CachesWithPoolNames");
  +      caches = createCaches(2, true);
  +
            BuddyManager m = caches[0].getBuddyManager();
            Map groupMap = m.buddyPool;
   
            assertEquals("A", groupMap.get(caches[0].getLocalAddress()));
            assertEquals("B", groupMap.get(caches[1].getLocalAddress()));
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void test3CachesWithPoolNames() throws Exception
      {
  -      TreeCache[] caches = createCaches(3, true);
  +      log.debug("Running test3CachesWithPoolNames");
  +      caches = createCaches(3, true);
   
  -      try
  -      {
            BuddyManager m = caches[0].getBuddyManager();
            Map groupMap = m.buddyPool;
   
  @@ -69,18 +85,12 @@
            assertEquals("B", groupMap.get(caches[1].getLocalAddress()));
            assertEquals("C", groupMap.get(caches[2].getLocalAddress()));
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void testBuddyPoolSync() throws Exception
      {
  -      TreeCache[] caches = createCaches(3, true);
  +      log.debug("Running testBuddyPoolSync");
  +      caches = createCaches(3, true);
   
  -      try
  -      {
            Map map = caches[0].getBuddyManager().buddyPool;
   
            // first test the values
  @@ -91,18 +101,12 @@
            // now test against each other
            checkConsistentPoolState(caches);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void testChangingBuddyPoolMembership() throws Exception
      {
  -      TreeCache[] caches = createCaches(3, true);
  +      log.debug("Running testChangingBuddyPoolMembership");
  +      caches = createCaches(3, true);
   
  -      try
  -      {
            Map map = caches[0].getBuddyManager().buddyPool;
   
            // first test the values
  @@ -127,18 +131,12 @@
            // now test against each other
            checkConsistentPoolState(caches);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void testConcurrency() throws Exception
      {
  +      log.debug("Running testConcurrency");
         int numCaches = 10;
  -      TreeCache[] caches = new TreeCache[numCaches];
  -      try
  -      {
  +      caches = new TreeCache[numCaches];
            Latch latch = new Latch();
            CacheStarter[] starters = new CacheStarter[numCaches];
   
  @@ -166,12 +164,6 @@
   
            checkConsistentPoolState(caches);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -
  -   }
   
      public class CacheStarter extends Thread
      {
  
  
  
  1.11      +101 -122  JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BuddyReplicationContentTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- BuddyReplicationContentTest.java	6 Sep 2006 15:30:57 -0000	1.10
  +++ BuddyReplicationContentTest.java	12 Sep 2006 10:36:26 -0000	1.11
  @@ -6,6 +6,8 @@
    */
   package org.jboss.cache.buddyreplication;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -18,10 +20,13 @@
   {
      private String key = "key";
      private String value = "value";
  +   private TreeCache[] caches;
  +   private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
  +
   
      private void assertNoStaleLocks(TreeCache[] caches)
      {
  -      for (int i = 0; i < caches.length; i++) assertNoStaleLocks(caches[i]);
  +      for (TreeCache cache : caches) assertNoStaleLocks(cache);
      }
   
      private void assertNoStaleLocks(TreeCache cache)
  @@ -31,10 +36,9 @@
   
      public void testSimplePut() throws Exception
      {
  -      TreeCache[] caches = createCaches(3, false);
  +      log.debug("Running testSimplePut");
  +      caches = createCaches(3, false);
   
  -      try
  -      {
            String fqn = "/test";
            String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress()) + fqn;
   
  @@ -57,18 +61,12 @@
   
            assertNoStaleLocks(caches);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void testPutAndRemove() throws Exception
      {
  -      TreeCache[] caches = createCaches(3, false);
  +      log.debug("Running testPutAndRemove");
  +      caches = createCaches(3, false);
   
  -      try
  -      {
            String fqn = "/test";
            String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress()) + fqn;
   
  @@ -106,21 +104,13 @@
            assertNull("Should be null", caches[2].get(backupFqn, key));
   
            assertNoStaleLocks(caches);
  -
  -      }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -
      }
   
      public void testPutAndRemove2() throws Exception
      {
  -      TreeCache[] caches = createCaches(2, 4, false);
  +      log.debug("Running testPutAndRemove2");
  +      caches = createCaches(2, 4, false);
   
  -      try
  -      {
            String fqn = "/test";
            String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress()) + fqn;
   
  @@ -161,15 +151,11 @@
   
            assertNoStaleLocks(caches);
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   
      public void testBuddyJoin() throws Exception
      {
  -      TreeCache[] caches = createCaches(2, false);
  +      log.debug("Running testBuddyJoin");
  +      caches = createCaches(2, false);
         TreeCache cache2 = null;
   
         try
  @@ -231,16 +217,14 @@
         finally
         {
            if (cache2 != null) cache2.stop();
  -         cleanup(caches);
         }
      }
   
      public void testCompleteStateSurvival() throws Exception
      {
  -      TreeCache[] caches = null;
  +      log.debug("Running testCompleteStateSurvival");
  +      caches = null;
   
  -      try
  -      {
            caches = createCaches(3, false, true);
            caches[0].put("/0", "key", "value");
            caches[1].put("/1", "key", "value");
  @@ -270,9 +254,4 @@
            assertEquals("value", caches[1].get("/1", "key"));
            assertEquals("value", caches[2].get("/2", "key"));
         }
  -      finally
  -      {
  -         cleanup(caches);
  -      }
  -   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list