Author: manik.surtani(a)jboss.com
Date: 2008-01-04 12:32:54 -0500 (Fri, 04 Jan 2008)
New Revision: 4988
Added:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
Log:
Added test to ensure proper cleanup after gravitation
Added:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-01-04
17:32:54 UTC (rev 4988)
@@ -0,0 +1,55 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.util.CachePrinter;
+import org.testng.annotations.Test;
+
+/**
+ * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
+ * @since 2.1.0
+ */
+@Test(groups = "functional")
+public class GravitationCleanupTest extends BuddyReplicationTestsBase
+{
+ Fqn fqn = Fqn.fromString("/a/b/c");
+ Object key = "key", value = "value";
+
+ public void testStaleRegionOnDataOwner() throws Exception
+ {
+ caches = createCaches(1, 2, false, true, false);
+
+ // add some stuff on the primary
+ CacheSPI dataOwner = caches.get(0);
+ CacheSPI buddy = caches.get(1);
+
+ dataOwner.put(fqn, key, value);
+
+ System.out.println("dataOwner: " +
CachePrinter.printCacheLockingInfo(dataOwner));
+ System.out.println("buddy: " +
CachePrinter.printCacheLockingInfo(buddy));
+
+ assert dataOwner.peek(fqn, false) != null : "Should have data";
+ assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+
+ assert buddy.peek(fqn, false) == null : "Should not have data";
+ assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert buddy.peek(BuddyManager.getBackupFqn(dataOwner.getLocalAddress(), fqn),
false) != null : "Should have backup data";
+
+ // now do a gravitate call.
+ assert buddy.get(fqn, key).equals(value) : "Data should have
gravitated!";
+
+ System.out.println("dataOwner: " +
CachePrinter.printCacheLockingInfo(dataOwner));
+ System.out.println("buddy: " +
CachePrinter.printCacheLockingInfo(buddy));
+
+ assert buddy.peek(fqn, false) != null : "Should have data";
+ assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+
+ assert dataOwner.peek(fqn, false) == null : "Should not have data";
+ assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert dataOwner.peek(BuddyManager.getBackupFqn(buddy.getLocalAddress(), fqn),
false) != null : "Should have backup data";
+ }
+}
Show replies by date