[jbosscache-commits] JBoss Cache SVN: r7206 - core/trunk/src/test/java/org/jboss/cache/integration/websession.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Nov 26 21:05:07 EST 2008


Author: bstansberry at jboss.com
Date: 2008-11-26 21:05:06 -0500 (Wed, 26 Nov 2008)
New Revision: 7206

Modified:
   core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
Log:
Add tests of more failure scenarios seen during AS soak tests

Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java	2008-11-27 02:04:28 UTC (rev 7205)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java	2008-11-27 02:05:06 UTC (rev 7206)
@@ -65,6 +65,286 @@
       return true;
    }
    
+   public void testFailoverAndImmediateInvalidate()
+   {
+      int attr = 0;
+      
+      SessionManager mgr0 = getSessionManagers().get(0);
+      SessionManager mgr1 = getSessionManagers().get(1);
+      SessionManager mgr2 = getSessionManagers().get(2);
+      SessionManager mgr3 = getSessionManagers().get(3);
+      
+      String contextHostName = mgr0.getContextHostName();
+
+      // Create the session
+      SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
+      replListener1.expectWithTx(PutDataMapCommand.class);
+      
+      Request req = new Request(mgr0, null, sas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();      
+      
+      String sessionId = sas.getSessionId();
+      assert sessionId != null : "session id is null";
+      // validate cache contents
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr0.getCache(), mgr1.getCache());
+      
+      // Modify the session
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++))); 
+      replListener1.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr0, sessionId, sas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+      
+      // Fail over; request reads the session and then modifies the session
+      GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));   
+      MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
+      ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
+      replListener0.expectWithTx(PutDataMapCommand.class); 
+      
+      req = new Request(mgr3, sessionId, mas);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();
+      
+      assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
+      Integer integer = (Integer) gas.getReadAttributes().get(KEY);
+      assert integer != null : "null attribute value";
+      assert integer.intValue() == (attr - 2) : "wrong val " + integer + " expected " + (attr -2);
+      
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr3.getCache(), mgr0.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      
+      // Invalidate the session
+      InvalidationServlet invs = new InvalidationServlet();
+      replListener0.expectWithTx(RemoveNodeCommand.class); 
+      
+      req = new Request(mgr3, sessionId, invs);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();
+
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
+   }
+   
+   public void testFailoverToOwnerAndImmediatelyInvalidate()
+   {
+      int attr = 0;
+      
+      SessionManager mgr0 = getSessionManagers().get(0);
+      SessionManager mgr1 = getSessionManagers().get(1);
+      SessionManager mgr2 = getSessionManagers().get(2);
+      SessionManager mgr3 = getSessionManagers().get(3);
+      
+      String contextHostName = mgr0.getContextHostName();
+
+      // Create the session
+      SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      ReplicationListener replListener2 = getReplicationListener(mgr2.getCache());
+      replListener2.expectWithTx(PutDataMapCommand.class);
+      
+      Request req = new Request(mgr1, null, sas);
+      req.execute();      
+      replListener2.waitForReplicationToOccur();      
+      
+      String sessionId = sas.getSessionId();
+      assert sessionId != null : "session id is null";
+      // validate cache contents
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr1.getCache(), mgr2.getCache());
+      
+      // Modify the session
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++))); 
+      replListener2.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr1, sessionId, sas);
+      req.execute();      
+      replListener2.waitForReplicationToOccur();
+      
+      // Fail over; request reads the session and then modifies the session
+      GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));   
+      MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
+      ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
+      replListener1.expectWithTx(PutDataMapCommand.class); 
+      
+      req = new Request(mgr0, sessionId, mas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+      
+      assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
+      Integer integer = (Integer) gas.getReadAttributes().get(KEY);
+      assert integer != null : "null attribute value";
+      assert integer.intValue() == (attr - 2) : "wrong val " + integer + " expected " + (attr -2);
+      
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr0.getCache(), mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      
+      // Invalidate the session
+      InvalidationServlet invs = new InvalidationServlet();
+      replListener1.expectWithTx(RemoveNodeCommand.class); 
+      
+      req = new Request(mgr0, sessionId, invs);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
+   }
+   
+   public void testFailoverAndInvalidate()
+   {
+      int attr = 0;
+      
+      SessionManager mgr0 = getSessionManagers().get(0);
+      SessionManager mgr1 = getSessionManagers().get(1);
+      SessionManager mgr2 = getSessionManagers().get(2);
+      SessionManager mgr3 = getSessionManagers().get(3);
+      
+      String contextHostName = mgr0.getContextHostName();
+
+      // Create the session
+      SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
+      replListener1.expectWithTx(PutDataMapCommand.class);
+      
+      Request req = new Request(mgr0, null, sas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();      
+      
+      String sessionId = sas.getSessionId();
+      assert sessionId != null : "session id is null";
+      // validate cache contents
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr0.getCache(), mgr1.getCache());
+      
+      // Modify the session
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++))); 
+      replListener1.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr0, sessionId, sas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+      
+      // Fail over; request reads the session and then modifies the session
+      GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));   
+      MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
+      ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
+      replListener0.expectWithTx(PutDataMapCommand.class); 
+      
+      req = new Request(mgr3, sessionId, mas);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();
+      
+      assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
+      Integer integer = (Integer) gas.getReadAttributes().get(KEY);
+      assert integer != null : "null attribute value";
+      assert integer.intValue() == (attr - 2) : "wrong val " + integer + " expected " + (attr -2);
+      
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr3.getCache(), mgr0.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      
+      // Modify the session again
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      replListener0.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr3, sessionId, sas);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();
+      
+      // Invalidate the session
+      InvalidationServlet invs = new InvalidationServlet();
+      replListener0.expectWithTx(RemoveNodeCommand.class); 
+      
+      req = new Request(mgr3, sessionId, invs);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();
+
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
+   }
+   
+   public void testFailoverToOwnerAndInvalidate()
+   {
+      int attr = 0;
+      
+      SessionManager mgr0 = getSessionManagers().get(0);
+      SessionManager mgr1 = getSessionManagers().get(1);
+      SessionManager mgr2 = getSessionManagers().get(2);
+      SessionManager mgr3 = getSessionManagers().get(3);
+      
+      String contextHostName = mgr0.getContextHostName();
+
+      // Create the session
+      SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      ReplicationListener replListener2 = getReplicationListener(mgr2.getCache());
+      replListener2.expectWithTx(PutDataMapCommand.class);
+      
+      Request req = new Request(mgr1, null, sas);
+      req.execute();      
+      replListener2.waitForReplicationToOccur();      
+      
+      String sessionId = sas.getSessionId();
+      assert sessionId != null : "session id is null";
+      // validate cache contents
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr1.getCache(), mgr2.getCache());
+      
+      // Modify the session
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++))); 
+      replListener2.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr1, sessionId, sas);
+      req.execute();      
+      replListener2.waitForReplicationToOccur();
+      
+      // Fail over; request reads the session and then modifies the session
+      GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));   
+      MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
+      ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
+      replListener1.expectWithTx(PutDataMapCommand.class); 
+      
+      req = new Request(mgr0, sessionId, mas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+      
+      assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
+      Integer integer = (Integer) gas.getReadAttributes().get(KEY);
+      assert integer != null : "null attribute value";
+      assert integer.intValue() == (attr - 2) : "wrong val " + integer + " expected " + (attr -2);
+      
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr0.getCache(), mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      
+      // Modify the session again
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      replListener1.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr0, sessionId, sas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+      
+      // Invalidate the session
+      InvalidationServlet invs = new InvalidationServlet();
+      replListener1.expectWithTx(RemoveNodeCommand.class); 
+      
+      req = new Request(mgr0, sessionId, invs);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
+   }
+   
    public void testFailoverAndFailBack()
    {
       int attr = 0;
@@ -78,7 +358,7 @@
 
       // Create the session
       SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
-      ReplicationListener replListener1 = ReplicationListener.getReplicationListener(mgr1.getCache());
+      ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
       replListener1.expectWithTx(PutDataMapCommand.class);
       
       Request req = new Request(mgr0, null, sas);
@@ -89,6 +369,8 @@
       assert sessionId != null : "session id is null";
       // validate cache contents
       BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr0.getCache(), mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
       
       // Modify the session
       sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++))); 
@@ -102,7 +384,7 @@
       GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
       sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));   
       MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
-      ReplicationListener replListener0 = ReplicationListener.getReplicationListener(mgr0.getCache());
+      ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
       replListener0.expectWithTx(PutDataMapCommand.class); 
       
       req = new Request(mgr3, sessionId, mas);
@@ -116,6 +398,7 @@
       
       BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr3.getCache(), mgr0.getCache());
       BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
       
       // Modify the session again
       sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
@@ -142,6 +425,7 @@
       
       BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr0.getCache(), mgr1.getCache());
       BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
       
       // Invalidate the session
       InvalidationServlet invs = new InvalidationServlet();
@@ -155,5 +439,77 @@
       BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
       BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
       BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
+      
+      gas = new GetAttributesServlet(Collections.singleton(KEY));
+      req = new Request(mgr0, sessionId, gas);
+      assert gas.getReadAttributes().get(KEY) == null : "session not cleaned up";
    }
+   
+   public void testInvalidateOnFailoverToBackup()
+   {
+      int attr = 0;
+      
+      SessionManager mgr0 = getSessionManagers().get(0);
+      SessionManager mgr1 = getSessionManagers().get(1);
+      SessionManager mgr2 = getSessionManagers().get(2);
+      SessionManager mgr3 = getSessionManagers().get(3);
+      
+      String contextHostName = mgr0.getContextHostName();
+
+      // Create the session
+      SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
+      replListener0.expectWithTx(PutDataMapCommand.class);
+      
+      Request req = new Request(mgr3, null, sas);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();      
+      
+      String sessionId = sas.getSessionId();
+      assert sessionId != null : "session id is null";
+      // validate cache contents
+      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr3.getCache(), mgr0.getCache());
+      
+      // Modify the session
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++))); 
+      replListener0.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr3, sessionId, sas);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();      
+      
+      // Passivate the session
+      mgr0.passivate(sessionId);
+      mgr1.passivate(sessionId);
+      mgr2.passivate(sessionId);
+      mgr3.passivate(sessionId);   
+      
+      // Reactivate the session
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++))); 
+      replListener0.expectWithTx(PutDataMapCommand.class);
+      
+      req = new Request(mgr3, sessionId, sas);
+      req.execute();      
+      replListener0.waitForReplicationToOccur();      
+      
+      // Invalidate the session
+      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
+      InvalidationServlet invs = new InvalidationServlet();
+      MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
+      ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
+      replListener1.expectWithTx(PutDataMapCommand.class, RemoveNodeCommand.class); 
+      
+      req = new Request(mgr0, sessionId, mas);
+      req.execute();      
+      replListener1.waitForReplicationToOccur();
+
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
+      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
+      
+      GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
+      req = new Request(mgr0, sessionId, gas);
+      assert gas.getReadAttributes().get(KEY) == null : "session not cleaned up";
+   }
 }




More information about the jbosscache-commits mailing list