You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2015/07/28 01:19:44 UTC
[21/50] [abbrv] incubator-geode git commit: GEODE-108: Fix up
HAInterestPart*DUnitTests
GEODE-108: Fix up HAInterestPart*DUnitTests
Reformat, fix timeouts, reduce interval for checking asynchronous
criteria. Move tearDown2 up by setUp. Null out static fields during
closeCache so other dunit JVMs don't leak Cache/DS instances. Remove
sleep call. Add @SuppressWarning and @Override annotations. Use
addExpectedExceptions to fix suspect string failures (including the
one that Jenkins hit). Fix typos.
Add JUnit 4 TestCase for testing these tests together in isolation.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/a336e81c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a336e81c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a336e81c
Branch: refs/heads/feature/GEODE-77
Commit: a336e81c2fe7666f8e866d3d22f58adcd4a01c18
Parents: a1abe19
Author: Kirk Lund <kl...@pivotal.io>
Authored: Wed Jul 15 11:11:36 2015 -0700
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Fri Jul 17 11:01:06 2015 -0700
----------------------------------------------------------------------
.../cache/tier/sockets/HAInterestBaseTest.java | 1435 ++++++++----------
.../sockets/HAInterestDistributedTestCase.java | 15 +
.../tier/sockets/HAInterestPart1DUnitTest.java | 210 ++-
.../tier/sockets/HAInterestPart2DUnitTest.java | 506 +++---
4 files changed, 981 insertions(+), 1185 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a336e81c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestBaseTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestBaseTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestBaseTest.java
index cce74ff..9aafaed 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestBaseTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestBaseTest.java
@@ -35,6 +35,7 @@ import dunit.DistributedTestCase;
import dunit.Host;
import dunit.VM;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -43,56 +44,48 @@ import java.util.Set;
/**
* Tests Interest Registration Functionality
- *
*/
-public class HAInterestBaseTest extends DistributedTestCase
-{
- private static int MAX_WAIT = 60000;
- protected static Cache cache = null;
- protected static PoolImpl pool = null ;
- protected static Connection conn = null ;
-
- protected static int PORT1 ;
- protected static int PORT2 ;
- protected static int PORT3 ;
-
+@SuppressWarnings({"deprecation", "rawtypes", "serial", "unchecked"})
+public class HAInterestBaseTest extends DistributedTestCase {
+
+ protected static final int TIMEOUT_MILLIS = 60 * 1000;
+ protected static final int INTERVAL_MILLIS = 10;
+
+ protected static final String REGION_NAME = "HAInterestBaseTest_region";
+
protected static final String k1 = "k1";
protected static final String k2 = "k2";
-
protected static final String client_k1 = "client-k1";
protected static final String client_k2 = "client-k2";
-
protected static final String server_k1 = "server-k1";
protected static final String server_k2 = "server-k2";
-
protected static final String server_k1_updated = "server_k1_updated";
- // To verify the beforeInterestRegistration is called or not
- protected static boolean isBeforeRegistrationCallbackCalled = false;
+ protected static Cache cache = null;
+ protected static PoolImpl pool = null;
+ protected static Connection conn = null;
- // To verify the beforeInterestRecoeryCallbackCalled is called or not
- protected static boolean isBeforeInterestRecoveryCallbackCalled = false;
+ protected static int PORT1;
+ protected static int PORT2;
+ protected static int PORT3;
- //To verify the afterInterestRegistration is called or not
+ protected static boolean isBeforeRegistrationCallbackCalled = false;
+ protected static boolean isBeforeInterestRecoveryCallbackCalled = false;
protected static boolean isAfterRegistrationCallbackCalled = false;
-
- protected static final String REGION_NAME = "HAInterestBaseTest_region";
-
- protected static Host host = null ;
-
+ protected static Host host = null;
protected static VM server1 = null;
protected static VM server2 = null;
protected static VM server3 = null;
+
protected volatile static boolean exceptionOccured = false;
- /** constructor */
public HAInterestBaseTest(String name) {
super(name);
}
- public void setUp() throws Exception
- {
+ @Override
+ public void setUp() throws Exception {
super.setUp();
host = Host.getHost(0);
server1 = host.getVM(0);
@@ -100,16 +93,45 @@ public class HAInterestBaseTest extends DistributedTestCase
server3 = host.getVM(2);
CacheServerTestUtil.disableShufflingOfEndpoints();
// start servers first
- PORT1 = ((Integer) server1.invoke(HAInterestBaseTest.class, "createServerCache")).intValue();
- PORT2 = ((Integer) server2.invoke(HAInterestBaseTest.class, "createServerCache")).intValue();
- PORT3 = ((Integer) server3.invoke(HAInterestBaseTest.class, "createServerCache")).intValue();
+ PORT1 = ((Integer) server1.invoke(HAInterestBaseTest.class, "createServerCache")).intValue();
+ PORT2 = ((Integer) server2.invoke(HAInterestBaseTest.class, "createServerCache")).intValue();
+ PORT3 = ((Integer) server3.invoke(HAInterestBaseTest.class, "createServerCache")).intValue();
exceptionOccured = false;
-
+ addExpectedException("java.net.ConnectException: Connection refused: connect");
}
+ @Override
+ public void tearDown2() throws Exception {
+ // close the clients first
+ closeCache();
+
+ // then close the servers
+ server1.invoke(HAInterestBaseTest.class, "closeCache");
+ server2.invoke(HAInterestBaseTest.class, "closeCache");
+ server3.invoke(HAInterestBaseTest.class, "closeCache");
+ CacheServerTestUtil.resetDisableShufflingOfEndpointsFlag();
+ }
+ public static void closeCache() {
+ PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = false;
+ PoolImpl.BEFORE_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = false;
+ PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
+ PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
+ HAInterestBaseTest.isAfterRegistrationCallbackCalled = false;
+ HAInterestBaseTest.isBeforeInterestRecoveryCallbackCalled = false;
+ HAInterestBaseTest.isBeforeRegistrationCallbackCalled = false;
+ if (cache != null && !cache.isClosed()) {
+ cache.close();
+ cache.getDistributedSystem().disconnect();
+ }
+ cache = null;
+ pool = null;
+ conn = null;
+ }
+
/**
* Return the current primary waiting for a primary to exist.
+ *
* @since 5.7
*/
public static VM getPrimaryVM() {
@@ -117,13 +139,14 @@ public class HAInterestBaseTest extends DistributedTestCase
}
/**
- * Return the current primary waiting for a primary to exist and for it
- * not to be the oldPrimary (if oldPrimary is NOT null).
+ * Return the current primary waiting for a primary to exist and for it not to
+ * be the oldPrimary (if oldPrimary is NOT null).
+ *
* @since 5.7
*/
public static VM getPrimaryVM(final VM oldPrimary) {
WaitCriterion wc = new WaitCriterion() {
- String excuse;
+ @Override
public boolean done() {
int primaryPort = pool.getPrimaryPort();
if (primaryPort == -1) {
@@ -136,22 +159,24 @@ public class HAInterestBaseTest extends DistributedTestCase
}
return false;
}
+ @Override
public String description() {
- return excuse;
+ return "waiting for primary";
}
};
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
int primaryPort = pool.getPrimaryPort();
assertTrue(primaryPort != -1);
VM currentPrimary = getServerVM(primaryPort);
assertTrue(currentPrimary != oldPrimary);
return currentPrimary;
}
-
+
public static VM getBackupVM() {
return getBackupVM(null);
}
+
public static VM getBackupVM(VM stoppedBackup) {
VM currentPrimary = getPrimaryVM(null);
if (currentPrimary != server2 && server2 != stoppedBackup) {
@@ -161,16 +186,14 @@ public class HAInterestBaseTest extends DistributedTestCase
} else if (currentPrimary != server1 && server1 != stoppedBackup) {
return server1;
} else {
- fail("expected currentPrimary " + currentPrimary + " to be "
- + server1 + ", or "
- + server2 + ", or "
- + server3);
+ fail("expected currentPrimary " + currentPrimary + " to be " + server1 + ", or " + server2 + ", or " + server3);
return null;
}
}
/**
* Given a server vm (server1, server2, or server3) return its port.
+ *
* @since 5.7
*/
public static int getServerPort(VM vm) {
@@ -181,17 +204,14 @@ public class HAInterestBaseTest extends DistributedTestCase
} else if (vm == server3) {
return PORT3;
} else {
- fail("expected vm " + vm + " to be "
- + server1
- + ", or "
- + server2
- + ", or "
- + server3);
+ fail("expected vm " + vm + " to be " + server1 + ", or " + server2 + ", or " + server3);
return -1;
}
}
+
/**
* Given a server port (PORT1, PORT2, or PORT3) return its vm.
+ *
* @since 5.7
*/
public static VM getServerVM(int port) {
@@ -202,833 +222,650 @@ public class HAInterestBaseTest extends DistributedTestCase
} else if (port == PORT3) {
return server3;
} else {
- fail("expected port " + port + " to be "
- + PORT1
- + ", or "
- + PORT2
- + ", or "
- + PORT3);
+ fail("expected port " + port + " to be " + PORT1 + ", or " + PORT2 + ", or " + PORT3);
return null;
}
}
-
- public static void verifyRefreshedEntriesFromServer()
- {
+
+ public static void verifyRefreshedEntriesFromServer() {
final Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r1);
-
+
WaitCriterion wc = new WaitCriterion() {
- String excuse;
+ @Override
public boolean done() {
Region.Entry re = r1.getEntry(k1);
- if (re == null) return false;
+ if (re == null)
+ return false;
Object val = re.getValue();
return client_k1.equals(val);
}
+ @Override
public String description() {
- return excuse;
+ return "waiting for client_k1 refresh from server";
}
};
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
wc = new WaitCriterion() {
- String excuse;
+ @Override
public boolean done() {
Region.Entry re = r1.getEntry(k2);
- if (re == null) return false;
+ if (re == null)
+ return false;
Object val = re.getValue();
return client_k2.equals(val);
}
+ @Override
public String description() {
- return excuse;
+ return "waiting for client_k2 refresh from server";
}
};
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- // assertEquals(client_k1, r1.getEntry(k1).getValue());
- // assertEquals(client_k2 ,r1.getEntry(k2).getValue());
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
}
- public static void verifyDeadAndLiveServers(final int expectedDeadServers,
- final int expectedLiveServers)
-{
- WaitCriterion wc = new WaitCriterion() {
- String description;
- public boolean done() {
- return pool.getConnectedServerCount() == expectedLiveServers;
- }
- public String description() {
- return description;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
-// while (proxy.getDeadServers().size() != expectedDeadServers) { // wait until condition is met
-// assertTrue("Waited over " + maxWaitTime + "for dead servers to become : " + expectedDeadServers + " This issue can occur on Solaris as DSM thread get stuck in connectForServer() call, and hence not recovering any newly started server This may be beacuase of tcp_ip_abort_cinterval kernal level property on solaris which has 3 minutes as a default value",
-// (System.currentTimeMillis() - start) < maxWaitTime);
-// try {
-// Thread.yield();
-// synchronized(delayLock) {delayLock.wait(2000);}
-// }
-// catch (InterruptedException ie) {
-// fail("Interrupted while waiting ", ie);
-// }
-// }
-// start = System.currentTimeMillis();
-}
+ public static void verifyDeadAndLiveServers(final int expectedDeadServers, final int expectedLiveServers) {
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return pool.getConnectedServerCount() == expectedLiveServers;
+ }
+ @Override
+ public String description() {
+ return "waiting for pool.getConnectedServerCount() == expectedLiveServer";
+ }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+ }
- public static void putK1andK2()
- {
+ public static void putK1andK2() {
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(r1);
- try {
- r1.put(k1, server_k1);
- r1.put(k2, server_k2);
- }
- catch (Exception e) {
- fail("Test failed due to Exception in putK1andK2 ::" + e);
- }
+ r1.put(k1, server_k1);
+ r1.put(k2, server_k2);
}
- public static void setBridgeObserverForBeforeInterestRecoveryFailure()
- {
- PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
- BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
- public void beforeInterestRecovery()
- {
- synchronized (HAInterestBaseTest.class) {
- Thread t = new Thread (){
- public void run(){
- getBackupVM().invoke(HAInterestBaseTest.class, "startServer");
- getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
- }
- };
- t.start();
- try {
- DistributedTestCase.join(t, 30 * 1000, getLogWriter());
- }catch(Exception ignore) {
- exceptionOccured= true;
- }
- HAInterestBaseTest.isBeforeInterestRecoveryCallbackCalled = true;
- HAInterestBaseTest.class.notify();
- PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
- }
- }
- });
- }
-
-
- public static void setBridgeObserverForBeforeInterestRecovery()
- {
- PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
- BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
- public void beforeInterestRecovery()
- {
- synchronized (HAInterestBaseTest.class) {
- Thread t = new Thread (){
- public void run(){
- Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
- assertNotNull(r1);
- try {
- r1.put(k1, server_k1_updated);
- } catch (Exception e) {
- e.printStackTrace();
- fail("Test Failed due to ..."+e);
+ public static void setBridgeObserverForBeforeInterestRecoveryFailure() {
+ PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
+ BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
+ public void beforeInterestRecovery() {
+ synchronized (HAInterestBaseTest.class) {
+ Thread t = new Thread() {
+ public void run() {
+ getBackupVM().invoke(HAInterestBaseTest.class, "startServer");
+ getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
}
- }
- };
- t.start();
-
- HAInterestBaseTest.isBeforeInterestRecoveryCallbackCalled = true;
- HAInterestBaseTest.class.notify();
- PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
- }
- }
- });
- }
-
- public static void waitForBeforeInterestRecoveryCallBack()
- {
-
- assertNotNull(cache);
- synchronized (HAInterestBaseTest.class) {
- while (!isBeforeInterestRecoveryCallbackCalled) {
- try {
- HAInterestBaseTest.class.wait();
- }
- catch (InterruptedException e) {
- fail("Test failed due to InterruptedException in waitForBeforeInterstRecovery()");
- }
- }
- }
-
- }
-
-public static void setBridgeObserverForBeforeRegistration(final VM vm)
-{
- PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = true;
- BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
- public void beforeInterestRegistration()
- {
- synchronized (HAInterestBaseTest.class) {
- vm.invoke(HAInterestBaseTest.class, "startServer");
- HAInterestBaseTest.isBeforeRegistrationCallbackCalled = true;
- HAInterestBaseTest.class.notify();
- PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
+ };
+ t.start();
+ try {
+ DistributedTestCase.join(t, 30 * 1000, getLogWriter());
+ } catch (Exception ignore) {
+ exceptionOccured = true;
+ }
+ HAInterestBaseTest.isBeforeInterestRecoveryCallbackCalled = true;
+ HAInterestBaseTest.class.notify();
+ PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
+ }
}
- }
- });
-}
+ });
+ }
-public static void waitForBeforeRegistrationCallback()
-{
+ public static void setBridgeObserverForBeforeInterestRecovery() {
+ PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = true;
+ BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
+ public void beforeInterestRecovery() {
+ synchronized (HAInterestBaseTest.class) {
+ Thread t = new Thread() {
+ public void run() {
+ Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r1);
+ r1.put(k1, server_k1_updated);
+ }
+ };
+ t.start();
- assertNotNull(cache);
- synchronized (HAInterestBaseTest.class) {
- while (!isBeforeRegistrationCallbackCalled) {
- try {
- HAInterestBaseTest.class.wait();
- }
- catch (InterruptedException e) {
- fail("Test failed due to InterruptedException in waitForBeforeRegistrationCallback()");
+ HAInterestBaseTest.isBeforeInterestRecoveryCallbackCalled = true;
+ HAInterestBaseTest.class.notify();
+ PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false;
+ }
}
- }
+ });
}
-}
-public static void setBridgeObserverForAfterRegistration(final VM vm)
-{
- PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = true;
- BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
- public void afterInterestRegistration()
- {
- synchronized (HAInterestBaseTest.class) {
- vm.invoke(HAInterestBaseTest.class, "startServer");
- HAInterestBaseTest.isAfterRegistrationCallbackCalled = true;
- HAInterestBaseTest.class.notify();
- PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = false;
+ public static void waitForBeforeInterestRecoveryCallBack() throws InterruptedException {
+ assertNotNull(cache);
+ synchronized (HAInterestBaseTest.class) {
+ while (!isBeforeInterestRecoveryCallbackCalled) {
+ HAInterestBaseTest.class.wait();
}
}
- });
-}
-
-public static void waitForAfterRegistrationCallback()
-{
+ }
- assertNotNull(cache);
- if (!isAfterRegistrationCallbackCalled) {
- synchronized (HAInterestBaseTest.class) {
- while (!isAfterRegistrationCallbackCalled) {
- try {
- HAInterestBaseTest.class.wait();
- }
- catch (InterruptedException e) {
- fail("Test failed due to InterruptedException in waitForAfterRegistrationCallback()");
+ public static void setBridgeObserverForBeforeRegistration(final VM vm) {
+ PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = true;
+ BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
+ public void beforeInterestRegistration() {
+ synchronized (HAInterestBaseTest.class) {
+ vm.invoke(HAInterestBaseTest.class, "startServer");
+ HAInterestBaseTest.isBeforeRegistrationCallbackCalled = true;
+ HAInterestBaseTest.class.notify();
+ PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
}
}
- }
+ });
}
-}
-
-
-
- public static void unSetBridgeObserverForRegistrationCallback()
-{
- synchronized (HAInterestBaseTest.class) {
- PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
- PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = false ;
- HAInterestBaseTest.isBeforeRegistrationCallbackCalled = false;
- HAInterestBaseTest.isAfterRegistrationCallbackCalled = false ;
+ public static void waitForBeforeRegistrationCallback() throws InterruptedException {
+ assertNotNull(cache);
+ synchronized (HAInterestBaseTest.class) {
+ while (!isBeforeRegistrationCallbackCalled) {
+ HAInterestBaseTest.class.wait();
+ }
+ }
}
-}
- public static void verifyDispatcherIsAlive()
- {
- try {
- assertEquals("More than one BridgeServer", 1, cache.getBridgeServers()
- .size());
- WaitCriterion wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- return cache.getBridgeServers().size() == 1;
- }
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- BridgeServerImpl bs = (BridgeServerImpl)cache.getBridgeServers()
- .iterator().next();
- assertNotNull(bs);
- assertNotNull(bs.getAcceptor());
- assertNotNull(bs.getAcceptor().getCacheClientNotifier());
- final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
-
- wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- return ccn.getClientProxies().size() > 0;
- }
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- wc = new WaitCriterion() {
- String excuse;
- Iterator iter_prox;
- CacheClientProxy proxy;
- public boolean done() {
- iter_prox = ccn.getClientProxies().iterator();
- if(iter_prox.hasNext()) {
- proxy = (CacheClientProxy)iter_prox.next();
- return proxy._messageDispatcher.isAlive();
- }
- else {
- return false;
- }
+ public static void setBridgeObserverForAfterRegistration(final VM vm) {
+ PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = true;
+ BridgeObserverHolder.setInstance(new BridgeObserverAdapter() {
+ public void afterInterestRegistration() {
+ synchronized (HAInterestBaseTest.class) {
+ vm.invoke(HAInterestBaseTest.class, "startServer");
+ HAInterestBaseTest.isAfterRegistrationCallbackCalled = true;
+ HAInterestBaseTest.class.notify();
+ PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = false;
}
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
- }
- catch (Exception ex) {
- fail("while setting verifyDispatcherIsAlive " + ex);
- }
+ }
+ });
}
- public static void verifyDispatcherIsNotAlive()
- {
- try {
- WaitCriterion wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- return cache.getBridgeServers().size() == 1;
- }
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- BridgeServerImpl bs = (BridgeServerImpl)cache.getBridgeServers()
- .iterator().next();
- assertNotNull(bs);
- assertNotNull(bs.getAcceptor());
- assertNotNull(bs.getAcceptor().getCacheClientNotifier());
- final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
- wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- return ccn.getClientProxies().size() > 0;
- }
- public String description() {
- return excuse;
+ public static void waitForAfterRegistrationCallback() throws InterruptedException {
+ assertNotNull(cache);
+ if (!isAfterRegistrationCallbackCalled) {
+ synchronized (HAInterestBaseTest.class) {
+ while (!isAfterRegistrationCallbackCalled) {
+ HAInterestBaseTest.class.wait();
}
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- Iterator iter_prox = ccn.getClientProxies().iterator();
- if (iter_prox.hasNext()) {
- CacheClientProxy proxy = (CacheClientProxy)iter_prox.next();
- assertFalse("Dispatcher on secondary should not be alive",
- proxy._messageDispatcher.isAlive());
}
-
- }
- catch (Exception ex) {
- fail("while setting verifyDispatcherIsNotAlive " + ex);
}
}
+ public static void unSetBridgeObserverForRegistrationCallback() {
+ synchronized (HAInterestBaseTest.class) {
+ PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false;
+ PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = false;
+ HAInterestBaseTest.isBeforeRegistrationCallbackCalled = false;
+ HAInterestBaseTest.isAfterRegistrationCallbackCalled = false;
+ }
+ }
- public static void createEntriesK1andK2OnServer()
- {
- try {
- Region r1 = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
- assertNotNull(r1);
- if (!r1.containsKey(k1)) {
- r1.create(k1, server_k1);
- }
- if (!r1.containsKey(k2)) {
- r1.create(k2, server_k2);
- }
- assertEquals(r1.getEntry(k1).getValue(), server_k1);
- assertEquals(r1.getEntry(k2).getValue(), server_k2);
+ public static void verifyDispatcherIsAlive() {
+ assertEquals("More than one BridgeServer", 1, cache.getBridgeServers().size());
+
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return cache.getBridgeServers().size() == 1;
}
- catch (Exception ex) {
- fail("failed while createEntries()", ex);
+ @Override
+ public String description() {
+ return "waiting for cache.getBridgeServers().size() == 1";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
- public static void createEntriesK1andK2()
- {
- try {
- Region r1 = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
- assertNotNull(r1);
- if (!r1.containsKey(k1)) {
- r1.create(k1, client_k1);
- }
- if (!r1.containsKey(k2)) {
- r1.create(k2, client_k2);
- }
- assertEquals(r1.getEntry(k1).getValue(), client_k1);
- assertEquals(r1.getEntry(k2).getValue(), client_k2);
+ BridgeServerImpl bs = (BridgeServerImpl) cache.getBridgeServers().iterator().next();
+ assertNotNull(bs);
+ assertNotNull(bs.getAcceptor());
+ assertNotNull(bs.getAcceptor().getCacheClientNotifier());
+ final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
+
+ wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return ccn.getClientProxies().size() > 0;
}
- catch (Exception ex) {
- fail("failed while createEntries()", ex);
+ @Override
+ public String description() {
+ return "waiting for ccn.getClientProxies().size() > 0";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
- public static void createServerEntriesK1andK2()
- {
- try {
- Region r1 = cache.getRegion(Region.SEPARATOR+ REGION_NAME);
- assertNotNull(r1);
- if (!r1.containsKey(k1)) {
- r1.create(k1, server_k1);
- }
- if (!r1.containsKey(k2)) {
- r1.create(k2, server_k2);
+ wc = new WaitCriterion() {
+ Iterator iter_prox;
+ CacheClientProxy proxy;
+
+ @Override
+ public boolean done() {
+ iter_prox = ccn.getClientProxies().iterator();
+ if (iter_prox.hasNext()) {
+ proxy = (CacheClientProxy) iter_prox.next();
+ return proxy._messageDispatcher.isAlive();
+ } else {
+ return false;
}
- assertEquals(r1.getEntry(k1).getValue(), server_k1);
- assertEquals(r1.getEntry(k2).getValue(), server_k2);
}
- catch (Exception ex) {
- fail("failed while createEntries()", ex);
+
+ @Override
+ public String description() {
+ return "waiting for CacheClientProxy _messageDispatcher to be alive";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+ }
- public static void registerK1AndK2()
- {
- try {
- Region r = cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- List list = new ArrayList();
- list.add(k1);
- list.add(k2);
- r.registerInterest(list, InterestResultPolicy.KEYS_VALUES);
+ public static void verifyDispatcherIsNotAlive() {
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return cache.getBridgeServers().size() == 1;
}
- catch (Exception ex) {
- ex.printStackTrace();
- fail("failed while region.registerK1AndK2()", ex);
+ @Override
+ public String description() {
+ return "cache.getBridgeServers().size() == 1";
}
- }
-
- public static void reRegisterK1AndK2()
- {
- try {
- Region r = cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- List list = new ArrayList();
- list.add(k1);
- list.add(k2);
- r.registerInterest(list);
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+ BridgeServerImpl bs = (BridgeServerImpl) cache.getBridgeServers().iterator().next();
+ assertNotNull(bs);
+ assertNotNull(bs.getAcceptor());
+ assertNotNull(bs.getAcceptor().getCacheClientNotifier());
+ final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
+
+ wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return ccn.getClientProxies().size() > 0;
}
- catch (Exception ex) {
- fail("failed while region.reRegisterK1AndK2()", ex);
+ @Override
+ public String description() {
+ return "waiting for ccn.getClientProxies().size() > 0";
}
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ Iterator iter_prox = ccn.getClientProxies().iterator();
+ if (iter_prox.hasNext()) {
+ CacheClientProxy proxy = (CacheClientProxy) iter_prox.next();
+ assertFalse("Dispatcher on secondary should not be alive", proxy._messageDispatcher.isAlive());
}
+ }
- public static void startServer()
- {
- try {
- Cache c = CacheFactory.getAnyInstance();
- assertEquals("More than one BridgeServer", 1, c.getBridgeServers().size());
- BridgeServerImpl bs = (BridgeServerImpl) c.getBridgeServers().iterator().next();
- assertNotNull(bs);
- bs.start();
+ public static void createEntriesK1andK2OnServer() {
+ Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r1);
+ if (!r1.containsKey(k1)) {
+ r1.create(k1, server_k1);
}
- catch (Exception ex) {
- fail("while startServer() " + ex);
- }
+ if (!r1.containsKey(k2)) {
+ r1.create(k2, server_k2);
}
+ assertEquals(r1.getEntry(k1).getValue(), server_k1);
+ assertEquals(r1.getEntry(k2).getValue(), server_k2);
+ }
- public static void startServerAndPause()
- {
- try {
- Cache c = CacheFactory.getAnyInstance();
- assertEquals("More than one BridgeServer", 1, c.getBridgeServers().size());
- BridgeServerImpl bs = (BridgeServerImpl) c.getBridgeServers().iterator().next();
- assertNotNull(bs);
- bs.start();
- Thread.sleep(10000);
+ public static void createEntriesK1andK2() {
+ Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r1);
+ if (!r1.containsKey(k1)) {
+ r1.create(k1, client_k1);
}
- catch (Exception ex) {
- fail("while startServer() " + ex);
- }
+ if (!r1.containsKey(k2)) {
+ r1.create(k2, client_k2);
}
+ assertEquals(r1.getEntry(k1).getValue(), client_k1);
+ assertEquals(r1.getEntry(k2).getValue(), client_k2);
+ }
-
- public static void stopServer()
- {
- try {
- assertEquals("More than one BridgeServer", 1, cache.getBridgeServers().size());
- BridgeServerImpl bs = (BridgeServerImpl) cache.getBridgeServers().iterator().next();
- assertNotNull(bs);
- bs.stop();
+ public static void createServerEntriesK1andK2() {
+ Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r1);
+ if (!r1.containsKey(k1)) {
+ r1.create(k1, server_k1);
}
- catch (Exception ex) {
- fail("while setting stopServer " + ex);
- }
+ if (!r1.containsKey(k2)) {
+ r1.create(k2, server_k2);
}
+ assertEquals(r1.getEntry(k1).getValue(), server_k1);
+ assertEquals(r1.getEntry(k2).getValue(), server_k2);
+ }
+ public static void registerK1AndK2() {
+ Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ List list = new ArrayList();
+ list.add(k1);
+ list.add(k2);
+ r.registerInterest(list, InterestResultPolicy.KEYS_VALUES);
+ }
- public static void stopPrimaryAndRegisterK1AndK2AndVerifyResponse()
- {
- try {
- LocalRegion r = (LocalRegion)cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- ServerRegionProxy srp = new ServerRegionProxy(r);
+ public static void reRegisterK1AndK2() {
+ Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ List list = new ArrayList();
+ list.add(k1);
+ list.add(k2);
+ r.registerInterest(list);
+ }
- WaitCriterion wc = new WaitCriterion() {
- public boolean done() {
- return pool.getConnectedServerCount() == 3;
- }
- public String description() {
- return "connected server count never became 3";
- }
- };
- DistributedTestCase.waitForCriterion(wc, 30 * 1000, 1000, true);
-
- // close primaryEP
- getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
- List list = new ArrayList();
- list.add(k1);
- list.add(k2);
- List serverKeys = srp.registerInterest(list, InterestType.KEY,
- InterestResultPolicy.KEYS, false,
- r.getAttributes().getDataPolicy().ordinal);
- assertNotNull(serverKeys);
- List resultKeys =(List) serverKeys.get(0) ;
- assertEquals(2,resultKeys.size());
- assertTrue(resultKeys.contains(k1));
- assertTrue(resultKeys.contains(k2));
+ public static void startServer() throws IOException {
+ Cache c = CacheFactory.getAnyInstance();
+ assertEquals("More than one BridgeServer", 1, c.getBridgeServers().size());
+ BridgeServerImpl bs = (BridgeServerImpl) c.getBridgeServers().iterator().next();
+ assertNotNull(bs);
+ bs.start();
+ }
+
+ public static void stopServer() {
+ assertEquals("More than one BridgeServer", 1, cache.getBridgeServers().size());
+ BridgeServerImpl bs = (BridgeServerImpl) cache.getBridgeServers().iterator().next();
+ assertNotNull(bs);
+ bs.stop();
+ }
+ public static void stopPrimaryAndRegisterK1AndK2AndVerifyResponse() {
+ LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ ServerRegionProxy srp = new ServerRegionProxy(r);
+
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return pool.getConnectedServerCount() == 3;
}
- catch (Exception ex) {
- fail("failed while region.stopPrimaryAndRegisterK1AndK2AndVerifyResponse()", ex);
+ @Override
+ public String description() {
+ return "connected server count never became 3";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ // close primaryEP
+ getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
+ List list = new ArrayList();
+ list.add(k1);
+ list.add(k2);
+ List serverKeys = srp.registerInterest(list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
+ assertNotNull(serverKeys);
+ List resultKeys = (List) serverKeys.get(0);
+ assertEquals(2, resultKeys.size());
+ assertTrue(resultKeys.contains(k1));
+ assertTrue(resultKeys.contains(k2));
+ }
- public static void stopPrimaryAndUnregisterRegisterK1()
- {
- try {
- LocalRegion r = (LocalRegion)cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- ServerRegionProxy srp = new ServerRegionProxy(r);
+ public static void stopPrimaryAndUnregisterRegisterK1() {
+ LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ ServerRegionProxy srp = new ServerRegionProxy(r);
- WaitCriterion wc = new WaitCriterion() {
- public boolean done() {
- return pool.getConnectedServerCount() == 3;
- }
- public String description() {
- return "connected server count never became 3";
- }
- };
- DistributedTestCase.waitForCriterion(wc, 30 * 1000, 1000, true);
-
- // close primaryEP
- getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
- List list = new ArrayList();
- list.add(k1);
- srp.unregisterInterest(list, InterestType.KEY,false,false);
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return pool.getConnectedServerCount() == 3;
}
- catch (Exception ex) {
- fail("failed while region.stopPrimaryAndUnregisterRegisterK1()", ex);
+ @Override
+ public String description() {
+ return "connected server count never became 3";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
- public static void stopBothPrimaryAndSecondaryAndRegisterK1AndK2AndVerifyResponse()
- {
- try {
- LocalRegion r = (LocalRegion)cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- ServerRegionProxy srp = new ServerRegionProxy(r);
+ // close primaryEP
+ getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
+ List list = new ArrayList();
+ list.add(k1);
+ srp.unregisterInterest(list, InterestType.KEY, false, false);
+ }
- WaitCriterion wc = new WaitCriterion() {
- public boolean done() {
- return pool.getConnectedServerCount() == 3;
- }
- public String description() {
- return "connected server count never became 3";
- }
- };
- DistributedTestCase.waitForCriterion(wc, 30 * 1000, 1000, true);
-
- // close primaryEP
- VM backup = getBackupVM();
- getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
- //close secondary
- backup.invoke(HAInterestBaseTest.class, "stopServer");
- List list = new ArrayList();
- list.add(k1);
- list.add(k2);
- List serverKeys = srp.registerInterest(list, InterestType.KEY,
- InterestResultPolicy.KEYS, false,
- r.getAttributes().getDataPolicy().ordinal);
-
- assertNotNull(serverKeys);
- List resultKeys =(List) serverKeys.get(0) ;
- assertEquals(2,resultKeys.size());
- assertTrue(resultKeys.contains(k1));
- assertTrue(resultKeys.contains(k2));
- }
- catch (Exception ex) {
- fail("failed while region.stopBothPrimaryAndSecondaryAndRegisterK1AndK2AndVerifyResponse()", ex);
+ public static void stopBothPrimaryAndSecondaryAndRegisterK1AndK2AndVerifyResponse() {
+ LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ ServerRegionProxy srp = new ServerRegionProxy(r);
+
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return pool.getConnectedServerCount() == 3;
}
- }
+ @Override
+ public String description() {
+ return "connected server count never became 3";
+ }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ // close primaryEP
+ VM backup = getBackupVM();
+ getPrimaryVM().invoke(HAInterestBaseTest.class, "stopServer");
+ // close secondary
+ backup.invoke(HAInterestBaseTest.class, "stopServer");
+ List list = new ArrayList();
+ list.add(k1);
+ list.add(k2);
+ List serverKeys = srp.registerInterest(list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
+
+ assertNotNull(serverKeys);
+ List resultKeys = (List) serverKeys.get(0);
+ assertEquals(2, resultKeys.size());
+ assertTrue(resultKeys.contains(k1));
+ assertTrue(resultKeys.contains(k2));
+ }
+
/**
* returns the secondary that was stopped
*/
- public static VM stopSecondaryAndRegisterK1AndK2AndVerifyResponse()
- {
- try {
- LocalRegion r = (LocalRegion)cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- ServerRegionProxy srp = new ServerRegionProxy(r);
-
- WaitCriterion wc = new WaitCriterion() {
- public boolean done() {
- return pool.getConnectedServerCount() == 3;
- }
- public String description() {
- return "Never got three connected servers";
- }
- };
- DistributedTestCase.waitForCriterion(wc, 90 * 1000, 1000, true);
-
- // close secondary EP
- VM result = getBackupVM();
- result.invoke(HAInterestBaseTest.class, "stopServer");
- List list = new ArrayList();
- list.add(k1);
- list.add(k2);
- List serverKeys = srp.registerInterest(list, InterestType.KEY,
- InterestResultPolicy.KEYS,
- false, r.getAttributes().getDataPolicy().ordinal);
-
- assertNotNull(serverKeys);
- List resultKeys =(List) serverKeys.get(0) ;
- assertEquals(2,resultKeys.size());
- assertTrue(resultKeys.contains(k1));
- assertTrue(resultKeys.contains(k2));
- return result;
+ public static VM stopSecondaryAndRegisterK1AndK2AndVerifyResponse() {
+ LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ ServerRegionProxy srp = new ServerRegionProxy(r);
+
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return pool.getConnectedServerCount() == 3;
}
- catch (Exception ex) {
- fail("failed while region.stopSecondaryAndRegisterK1AndK2AndVerifyResponse()", ex);
- return null;
+ @Override
+ public String description() {
+ return "Never got three connected servers";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ // close secondary EP
+ VM result = getBackupVM();
+ result.invoke(HAInterestBaseTest.class, "stopServer");
+ List list = new ArrayList();
+ list.add(k1);
+ list.add(k2);
+ List serverKeys = srp.registerInterest(list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
+
+ assertNotNull(serverKeys);
+ List resultKeys = (List) serverKeys.get(0);
+ assertEquals(2, resultKeys.size());
+ assertTrue(resultKeys.contains(k1));
+ assertTrue(resultKeys.contains(k2));
+ return result;
+ }
/**
* returns the secondary that was stopped
*/
- public static VM stopSecondaryAndUNregisterK1()
- {
- try {
- LocalRegion r = (LocalRegion)cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- ServerRegionProxy srp = new ServerRegionProxy(r);
-
- WaitCriterion wc = new WaitCriterion() {
- public boolean done() {
- return pool.getConnectedServerCount() == 3;
- }
- public String description() {
- return "connected server count never became 3";
- }
- };
- DistributedTestCase.waitForCriterion(wc, 30 * 1000, 1000, true);
-
- // close secondary EP
- VM result = getBackupVM();
- result.invoke(HAInterestBaseTest.class, "stopServer");
- List list = new ArrayList();
- list.add(k1);
- srp.unregisterInterest(list, InterestType.KEY,false,false);
- return result;
+ public static VM stopSecondaryAndUNregisterK1() {
+ LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ ServerRegionProxy srp = new ServerRegionProxy(r);
+
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return pool.getConnectedServerCount() == 3;
}
- catch (Exception ex) {
- fail("failed while region.stopSecondaryAndUNregisterK1()", ex);
- return null;
+ @Override
+ public String description() {
+ return "connected server count never became 3";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ // close secondary EP
+ VM result = getBackupVM();
+ result.invoke(HAInterestBaseTest.class, "stopServer");
+ List list = new ArrayList();
+ list.add(k1);
+ srp.unregisterInterest(list, InterestType.KEY, false, false);
+ return result;
+ }
- public static void registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse()
- {
- try {
- ServerLocation primary = pool.getPrimary();
- ServerLocation secondary = (ServerLocation)pool.getRedundants().get(0);
- LocalRegion r = (LocalRegion)cache.getRegion(Region.SEPARATOR+REGION_NAME);
- assertNotNull(r);
- ServerRegionProxy srp = new ServerRegionProxy(r);
- List list = new ArrayList();
- list.add(k1);
- list.add(k2);
-
- //Primary server
- List serverKeys1 = srp.registerInterestOn(primary, list,
- InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes()
- .getDataPolicy().ordinal);
- assertNotNull(serverKeys1);
- //expect serverKeys in response from primary
- List resultKeys =(List) serverKeys1.get(0) ;
- assertEquals(2,resultKeys.size());
- assertTrue(resultKeys.contains(k1));
- assertTrue(resultKeys.contains(k2));
-
- //Secondary server
- List serverKeys2 = srp.registerInterestOn(secondary, list,
- InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes()
- .getDataPolicy().ordinal);
- // if the list is null then it is empty
- if (serverKeys2 != null) {
- // no serverKeys in response from secondary
- assertTrue(serverKeys2.isEmpty());
- }
+ public static void registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse() {
+ ServerLocation primary = pool.getPrimary();
+ ServerLocation secondary = (ServerLocation) pool.getRedundants().get(0);
+ LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
+ assertNotNull(r);
+ ServerRegionProxy srp = new ServerRegionProxy(r);
+ List list = new ArrayList();
+ list.add(k1);
+ list.add(k2);
+
+ // Primary server
+ List serverKeys1 = srp.registerInterestOn(primary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
+ assertNotNull(serverKeys1);
+ // expect serverKeys in response from primary
+ List resultKeys = (List) serverKeys1.get(0);
+ assertEquals(2, resultKeys.size());
+ assertTrue(resultKeys.contains(k1));
+ assertTrue(resultKeys.contains(k2));
+
+ // Secondary server
+ List serverKeys2 = srp.registerInterestOn(secondary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
+ // if the list is null then it is empty
+ if (serverKeys2 != null) {
+ // no serverKeys in response from secondary
+ assertTrue(serverKeys2.isEmpty());
+ }
+ }
+ public static void verifyInterestRegistration() {
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return cache.getBridgeServers().size() == 1;
+ }
+ @Override
+ public String description() {
+ return "waiting for cache.getBridgeServers().size() == 1";
+ }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+ BridgeServerImpl bs = (BridgeServerImpl) cache.getBridgeServers().iterator().next();
+ assertNotNull(bs);
+ assertNotNull(bs.getAcceptor());
+ assertNotNull(bs.getAcceptor().getCacheClientNotifier());
+ final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
+
+ wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return ccn.getClientProxies().size() > 0;
}
- catch (Exception ex) {
- fail("failed while region.registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse()", ex);
+ @Override
+ public String description() {
+ return "waiting for ccn.getClientProxies().size() > 0";
}
- }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+ Iterator iter_prox = ccn.getClientProxies().iterator();
- public static void verifyInterestRegistration()
- {
- try {
- WaitCriterion wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- return cache.getBridgeServers().size() == 1;
- }
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- BridgeServerImpl bs = (BridgeServerImpl)cache.getBridgeServers()
- .iterator().next();
- assertNotNull(bs);
- assertNotNull(bs.getAcceptor());
- assertNotNull(bs.getAcceptor().getCacheClientNotifier());
- final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
+ if (iter_prox.hasNext()) {
+ final CacheClientProxy ccp = (CacheClientProxy) iter_prox.next();
+
wc = new WaitCriterion() {
- String excuse;
+ @Override
public boolean done() {
- return ccn.getClientProxies().size() > 0;
+ Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex]
+ .getProfile(Region.SEPARATOR + REGION_NAME)
+ .getKeysOfInterestFor(ccp.getProxyID());
+ return keysMap != null && keysMap.size() == 2;
}
+ @Override
public String description() {
- return excuse;
+ return "waiting for keys of interest to include 2 keys";
}
};
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- Iterator iter_prox = ccn.getClientProxies().iterator();
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
- if (iter_prox.hasNext()) {
- final CacheClientProxy ccp =(CacheClientProxy)iter_prox.next();
- wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- Set keysMap = (Set)ccp.cils[RegisterInterestTracker.interestListIndex]
- .getProfile(Region.SEPARATOR + REGION_NAME)
- .getKeysOfInterestFor(ccp.getProxyID());
- return keysMap != null && keysMap.size() == 2;
- }
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- Set keysMap = (Set)ccp.cils[RegisterInterestTracker.interestListIndex]
- .getProfile( Region.SEPARATOR + REGION_NAME)
+ Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex].getProfile(Region.SEPARATOR + REGION_NAME)
.getKeysOfInterestFor(ccp.getProxyID());
- assertNotNull(keysMap);
- assertEquals(2, keysMap.size());
- assertTrue(keysMap.contains(k1));
- assertTrue(keysMap.contains(k2));
- }
- }
- catch (Exception ex) {
- fail("while setting verifyInterestRegistration " + ex);
+ assertNotNull(keysMap);
+ assertEquals(2, keysMap.size());
+ assertTrue(keysMap.contains(k1));
+ assertTrue(keysMap.contains(k2));
}
}
- public static void verifyInterestUNRegistration()
- {
- try {
- WaitCriterion wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- return cache.getBridgeServers().size() == 1;
- }
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
+ public static void verifyInterestUNRegistration() {
+ WaitCriterion wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return cache.getBridgeServers().size() == 1;
+ }
+ @Override
+ public String description() {
+ return "waiting for cache.getBridgeServers().size() == 1";
+ }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ BridgeServerImpl bs = (BridgeServerImpl) cache.getBridgeServers().iterator().next();
+ assertNotNull(bs);
+ assertNotNull(bs.getAcceptor());
+ assertNotNull(bs.getAcceptor().getCacheClientNotifier());
+ final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
+
+ wc = new WaitCriterion() {
+ @Override
+ public boolean done() {
+ return ccn.getClientProxies().size() > 0;
+ }
+ @Override
+ public String description() {
+ return "waiting for ccn.getClientProxies().size() > 0";
+ }
+ };
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ Iterator iter_prox = ccn.getClientProxies().iterator();
+ if (iter_prox.hasNext()) {
+ final CacheClientProxy ccp = (CacheClientProxy) iter_prox.next();
- BridgeServerImpl bs = (BridgeServerImpl)cache.getBridgeServers()
- .iterator().next();
- assertNotNull(bs);
- assertNotNull(bs.getAcceptor());
- assertNotNull(bs.getAcceptor().getCacheClientNotifier());
- final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
wc = new WaitCriterion() {
- String excuse;
+ @Override
public boolean done() {
- return ccn.getClientProxies().size() > 0;
+ Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex]
+ .getProfile(Region.SEPARATOR + REGION_NAME)
+ .getKeysOfInterestFor(ccp.getProxyID());
+ return keysMap != null;
}
+ @Override
public String description() {
- return excuse;
+ return "waiting for keys of interest to not be null";
}
};
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- Iterator iter_prox = ccn.getClientProxies().iterator();
- if (iter_prox.hasNext()) {
- final CacheClientProxy ccp =(CacheClientProxy)iter_prox.next();
- wc = new WaitCriterion() {
- String excuse;
- public boolean done() {
- Set keysMap = (Set)ccp.cils[RegisterInterestTracker.interestListIndex]
- .getProfile(Region.SEPARATOR + REGION_NAME)
- .getKeysOfInterestFor(ccp.getProxyID());
- return keysMap != null;
- }
- public String description() {
- return excuse;
- }
- };
- DistributedTestCase.waitForCriterion(wc, MAX_WAIT, 1000, true);
-
- Set keysMap = (Set)ccp.cils[RegisterInterestTracker.interestListIndex]
+ DistributedTestCase.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
+
+ Set keysMap = (Set) ccp.cils[RegisterInterestTracker.interestListIndex]
.getProfile(Region.SEPARATOR + REGION_NAME)
.getKeysOfInterestFor(ccp.getProxyID());
- assertNotNull(keysMap);
- assertEquals(1, keysMap.size());
- assertFalse(keysMap.contains(k1));
- assertTrue(keysMap.contains(k2));
- }
- }
- catch (Exception ex) {
- fail("while setting verifyInterestUNRegistration " + ex);
+ assertNotNull(keysMap);
+ assertEquals(1, keysMap.size());
+ assertFalse(keysMap.contains(k1));
+ assertTrue(keysMap.contains(k2));
}
}
- private void createCache(Properties props) throws Exception
- {
+ private void createCache(Properties props) throws Exception {
DistributedSystem ds = getSystem(props);
assertNotNull(ds);
ds.disconnect();
@@ -1037,8 +874,7 @@ public static void waitForAfterRegistrationCallback()
assertNotNull(cache);
}
- public static void createClientPoolCache(String testName,String host) throws Exception
- {
+ public static void createClientPoolCache(String testName, String host) throws Exception {
Properties props = new Properties();
props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
props.setProperty(DistributionConfig.LOCATORS_NAME, "");
@@ -1046,17 +882,18 @@ public static void waitForAfterRegistrationCallback()
CacheServerTestUtil.disableShufflingOfEndpoints();
PoolImpl p;
try {
- p = (PoolImpl)PoolManager.createFactory()
- .addServer(host, PORT1)
- .addServer(host, PORT2)
- .addServer(host, PORT3)
- .setSubscriptionEnabled(true)
- .setSubscriptionRedundancy(-1)
- .setReadTimeout(1000)
- .setPingInterval(1000)
- // retryInterval should be more so that only registerInterste thread will initiate failover
- // .setRetryInterval(20000)
- .create("HAInterestBaseTestPool");
+ p = (PoolImpl) PoolManager.createFactory()
+ .addServer(host, PORT1)
+ .addServer(host, PORT2)
+ .addServer(host, PORT3)
+ .setSubscriptionEnabled(true)
+ .setSubscriptionRedundancy(-1)
+ .setReadTimeout(1000)
+ .setPingInterval(1000)
+ // retryInterval should be more so that only registerInterste thread
+ // will initiate failover
+ // .setRetryInterval(20000)
+ .create("HAInterestBaseTestPool");
} finally {
CacheServerTestUtil.enableShufflingOfEndpoints();
}
@@ -1071,8 +908,7 @@ public static void waitForAfterRegistrationCallback()
assertNotNull(conn);
}
- public static void createClientPoolCacheWithSmallRetryInterval(String testName,String host) throws Exception
- {
+ public static void createClientPoolCacheWithSmallRetryInterval(String testName, String host) throws Exception {
Properties props = new Properties();
props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
props.setProperty(DistributionConfig.LOCATORS_NAME, "");
@@ -1080,18 +916,18 @@ public static void waitForAfterRegistrationCallback()
CacheServerTestUtil.disableShufflingOfEndpoints();
PoolImpl p;
try {
- p = (PoolImpl)PoolManager.createFactory()
- .addServer(host, PORT1)
- .addServer(host, PORT2)
- .setSubscriptionEnabled(true)
- .setSubscriptionRedundancy(-1)
- .setReadTimeout(1000)
- .setSocketBufferSize(32768)
- .setMinConnections(6)
- .setPingInterval(200)
- // .setRetryInterval(200)
- // retryAttempts 3
- .create("HAInterestBaseTestPool");
+ p = (PoolImpl) PoolManager.createFactory()
+ .addServer(host, PORT1)
+ .addServer(host, PORT2)
+ .setSubscriptionEnabled(true)
+ .setSubscriptionRedundancy(-1)
+ .setReadTimeout(1000)
+ .setSocketBufferSize(32768)
+ .setMinConnections(6)
+ .setPingInterval(200)
+ // .setRetryInterval(200)
+ // retryAttempts 3
+ .create("HAInterestBaseTestPool");
} finally {
CacheServerTestUtil.enableShufflingOfEndpoints();
}
@@ -1106,21 +942,19 @@ public static void waitForAfterRegistrationCallback()
conn = pool.acquireConnection();
assertNotNull(conn);
}
-
- public static void createClientPoolCacheConnectionToSingleServer(String testName,String hostName) throws Exception
- {
+ public static void createClientPoolCacheConnectionToSingleServer(String testName, String hostName) throws Exception {
Properties props = new Properties();
props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
props.setProperty(DistributionConfig.LOCATORS_NAME, "");
new HAInterestBaseTest("temp").createCache(props);
- PoolImpl p = (PoolImpl)PoolManager.createFactory()
- .addServer(hostName, PORT1)
- .setSubscriptionEnabled(true)
- .setSubscriptionRedundancy(-1)
- .setReadTimeout(1000)
- // .setRetryInterval(20)
- .create("HAInterestBaseTestPool");
+ PoolImpl p = (PoolImpl) PoolManager.createFactory()
+ .addServer(hostName, PORT1)
+ .setSubscriptionEnabled(true)
+ .setSubscriptionRedundancy(-1)
+ .setReadTimeout(1000)
+ // .setRetryInterval(20)
+ .create("HAInterestBaseTestPool");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setConcurrencyChecksEnabled(true);
@@ -1133,9 +967,7 @@ public static void waitForAfterRegistrationCallback()
assertNotNull(conn);
}
-
- public static Integer createServerCache() throws Exception
- {
+ public static Integer createServerCache() throws Exception {
new HAInterestBaseTest("temp").createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -1145,18 +977,16 @@ public static void waitForAfterRegistrationCallback()
cache.createRegion(REGION_NAME, factory.create());
BridgeServer server = cache.addBridgeServer();
- int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET) ;
+ int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
server.setMaximumTimeBetweenPings(180000);
// ensures updates to be sent instead of invalidations
server.setNotifyBySubscription(true);
server.start();
return new Integer(server.getPort());
-
}
- public static Integer createServerCacheWithLocalRegion() throws Exception
- {
+ public static Integer createServerCacheWithLocalRegion() throws Exception {
new HAInterestBaseTest("temp").createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
@@ -1165,45 +995,12 @@ public static void waitForAfterRegistrationCallback()
cache.createRegion(REGION_NAME, attrs);
BridgeServer server = cache.addBridgeServer();
- int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET) ;
+ int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
// ensures updates to be sent instead of invalidations
server.setNotifyBySubscription(true);
server.setMaximumTimeBetweenPings(180000);
server.start();
return new Integer(server.getPort());
-
- }
-
-
-
- public void tearDown2() throws Exception
- {
- super.tearDown2();
- // close the clients first
- closeCache();
-
- // then close the servers
- server1.invoke(HAInterestBaseTest.class, "closeCache");
- server2.invoke(HAInterestBaseTest.class, "closeCache");
- server3.invoke(HAInterestBaseTest.class, "closeCache");
- CacheServerTestUtil.resetDisableShufflingOfEndpointsFlag();
- }
-
- public static void closeCache()
- {
- PoolImpl.AFTER_REGISTER_CALLBACK_FLAG = false ;
- PoolImpl.BEFORE_PRIMARY_IDENTIFICATION_FROM_BACKUP_CALLBACK_FLAG = false ;
- PoolImpl.BEFORE_RECOVER_INTEREST_CALLBACK_FLAG = false ;
- PoolImpl.BEFORE_REGISTER_CALLBACK_FLAG = false ;
- HAInterestBaseTest.isAfterRegistrationCallbackCalled = false ;
- HAInterestBaseTest.isBeforeInterestRecoveryCallbackCalled = false ;
- HAInterestBaseTest.isBeforeRegistrationCallbackCalled = false ;
- if (cache != null && !cache.isClosed()) {
- cache.close();
- cache.getDistributedSystem().disconnect();
- }
}
}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a336e81c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestDistributedTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestDistributedTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestDistributedTestCase.java
new file mode 100755
index 0000000..82739c6
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestDistributedTestCase.java
@@ -0,0 +1,15 @@
+package com.gemstone.gemfire.internal.cache.tier.sockets;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ HAInterestPart1DUnitTest.class,
+ HAInterestPart2DUnitTest.class,
+})
+/**
+ * Suite of distributed tests for HAInterest.
+ */
+public class HAInterestDistributedTestCase {
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a336e81c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java
index f3f3608..1f48963 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java
@@ -6,28 +6,26 @@
*=========================================================================
*/
package com.gemstone.gemfire.internal.cache.tier.sockets;
+
import dunit.VM;
-public class HAInterestPart1DUnitTest extends HAInterestBaseTest
-{
+@SuppressWarnings("serial")
+public class HAInterestPart1DUnitTest extends HAInterestBaseTest {
- /** constructor */
public HAInterestPart1DUnitTest(String name) {
super(name);
}
-
/**
* Tests whether interest is registered or not on both primary and secondaries
*/
- public void testInterestRegistrationOnBothPrimaryAndSecondary()throws Exception
- {
+ public void testInterestRegistrationOnBothPrimaryAndSecondary() throws Exception {
createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
createEntriesK1andK2();
server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- //register K1 and K2
+ // register K1 and K2
registerK1AndK2();
server1.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
server2.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
@@ -35,31 +33,30 @@ public class HAInterestPart1DUnitTest extends HAInterestBaseTest
}
/**
- * Tests whether interest is registered on both primary and secondaries and verify their responses
+ * Tests whether interest is registered on both primary and secondaries and
+ * verify their responses
*/
- public void testInterestRegistrationResponseOnBothPrimaryAndSecondary()throws Exception
- {
-
+ public void testInterestRegistrationResponseOnBothPrimaryAndSecondary() throws Exception {
createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
createEntriesK1andK2();
server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- //register interst and verify response
+ // register interest and verify response
registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse();
-
}
+
/**
- * Tests whether re-registration of interest causes duplicates on server side interest map
+ * Tests whether re-registration of interest causes duplicates on server side
+ * interest map
*/
- public void testRERegistrationWillNotCreateDuplicateKeysOnServerInterstMaps() throws Exception{
-
+ public void testRERegistrationWillNotCreateDuplicateKeysOnServerInterstMaps() throws Exception {
createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
createEntriesK1andK2();
server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- //register multiple times
+ // register multiple times
reRegisterK1AndK2();
server1.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
@@ -68,31 +65,32 @@ public class HAInterestPart1DUnitTest extends HAInterestBaseTest
}
/**
- * Tests if Primary fails during interest registration should initiate failover
- * and should pick new primary and get server keys in response of registerInterest
+ * Tests if Primary fails during interest registration should initiate
+ * failover and should pick new primary and get server keys in response of
+ * registerInterest
*/
- public void testPrimaryFailureInRegisterInterest() throws Exception{
-
+ public void testPrimaryFailureInRegisterInterest() throws Exception {
createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
createEntriesK1andK2();
server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- //stop primary
+ // stop primary
VM oldPrimary = getPrimaryVM();
stopPrimaryAndRegisterK1AndK2AndVerifyResponse();
// DSM
verifyDeadAndLiveServers(1, 2);
- //new primary
+ // new primary
VM newPrimary = getPrimaryVM(oldPrimary);
newPrimary.invoke(HAInterestBaseTest.class, "verifyDispatcherIsAlive");
newPrimary.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
}
/**
- * Tests if Secondary fails during interest registration should add to dead Ep list
+ * Tests if Secondary fails during interest registration should add to dead Ep
+ * list
*/
- public void testSecondaryFailureInRegisterInterest() throws Exception{
+ public void testSecondaryFailureInRegisterInterest() throws Exception {
createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
createEntriesK1andK2();
server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
@@ -103,101 +101,101 @@ public class HAInterestPart1DUnitTest extends HAInterestBaseTest
stopSecondaryAndRegisterK1AndK2AndVerifyResponse();
verifyDeadAndLiveServers(1, 2);
- //still primary
+ // still primary
primary.invoke(HAInterestBaseTest.class, "verifyDispatcherIsAlive");
primary.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
}
+
/**
- * Tests if Primary and next primary candidate fails during interest registration
- * it should pick new primary from ep list and add these two server to dead ep list
- * and expect serverKeys as a response from registration on newly selected primary
+ * Tests if Primary and next primary candidate fails during interest
+ * registration it should pick new primary from ep list and add these two
+ * server to dead ep list and expect serverKeys as a response from
+ * registration on newly selected primary
*/
- public void testBothPrimaryAndSecondaryFailureInRegisterInterest() throws Exception{
-
- createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
- createEntriesK1andK2();
+ public void testBothPrimaryAndSecondaryFailureInRegisterInterest() throws Exception {
+ createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
+ createEntriesK1andK2();
server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- //stop server1 and server2
+ // stop server1 and server2
VM oldPrimary = getPrimaryVM();
stopBothPrimaryAndSecondaryAndRegisterK1AndK2AndVerifyResponse();
- verifyDeadAndLiveServers(2,1);
+ verifyDeadAndLiveServers(2, 1);
+ VM newPrimary = getPrimaryVM(oldPrimary);
+ newPrimary.invoke(HAInterestBaseTest.class, "verifyDispatcherIsAlive");
+ newPrimary.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
+ }
+
+ /**
+ * Tests if Primary fails during interest registration , it selects new
+ * primary from the ep list after making this ep as primary it fails , so
+ * interest registration will initiate failover on this ep as well it should
+ * pick new primary from ep list and these two server to dead ep list and
+ * expect serverKeys as a response from registration on newly selected primary
+ *
+ */
+ public void testProbablePrimaryFailureInRegisterInterest() throws Exception {
+ createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
+ createEntriesK1andK2();
+ server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
+ server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
+ server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
+
+ VM oldPrimary = getPrimaryVM();
+ stopPrimaryAndRegisterK1AndK2AndVerifyResponse();
+
+ verifyDeadAndLiveServers(1, 2);
VM newPrimary = getPrimaryVM(oldPrimary);
newPrimary.invoke(HAInterestBaseTest.class, "verifyDispatcherIsAlive");
newPrimary.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
}
- /**
- * Tests if Primary fails during interest registration , it selects new primary from the ep list
- * after making this ep as primary it fails , so interst registration will initiate failover on this ep as well
- * it should pick new primary from ep list and these two server to dead ep list
- * and expect serverKeys as a response from registration on newly selected primary
- *
- */
- public void testProbablePrimaryFailureInRegisterInterest()throws Exception{
-
- createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
- createEntriesK1andK2();
- server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2") ;
-
- VM oldPrimary = getPrimaryVM();
- stopPrimaryAndRegisterK1AndK2AndVerifyResponse();
-
- verifyDeadAndLiveServers(1,2);
- VM newPrimary = getPrimaryVM(oldPrimary);
- newPrimary.invoke(HAInterestBaseTest.class, "verifyDispatcherIsAlive");
- newPrimary.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
- }
-
- /**
- * Tests if DeadServerMonitor on detecting an EP as alive should register client ( create CCP) as welll as register IL
- */
- public void testInterstRegistrationOnRecoveredEPbyDSM() throws Exception{
-
- addExpectedException("SocketException");
-
- createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
- createEntriesK1andK2();
- registerK1AndK2();
- server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
- server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2") ;
-
- server1.invoke(HAInterestBaseTest.class, "stopServer");
- server2.invoke(HAInterestBaseTest.class, "stopServer");
- server3.invoke(HAInterestBaseTest.class, "stopServer");
- //All servers are dead at this point , no primary in the system.
- verifyDeadAndLiveServers(3, 0);
-
- // now start one of the servers
- server2.invoke(HAInterestBaseTest.class, "startServer");
- verifyDeadAndLiveServers(2, 1);
- //verify that is it primary , and dispatcher is running
- server2.invoke(HAInterestBaseTest.class, "verifyDispatcherIsAlive");
- //verify that interest is registered on this recovered EP
- server2.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
-
- // now start one more server ; this should be now secondary
- server1.invoke(HAInterestBaseTest.class, "startServer");
- verifyDeadAndLiveServers(1, 2);
-
- //verify that is it secondary , dispatcher should not be runnig
- server1.invoke(HAInterestBaseTest.class, "verifyDispatcherIsNotAlive");
- //verify that interest is registered on this recovered EP as well
- server1.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
-
- // now start one more server ; this should be now secondary
- server3.invoke(HAInterestBaseTest.class, "startServer");
- verifyDeadAndLiveServers(0, 3);
-
- //verify that is it secondary , dispatcher should not be runnig
- server3.invoke(HAInterestBaseTest.class, "verifyDispatcherIsNotAlive");
- //verify that interest is registered on this recovered EP as well
- server3.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
-
- }
+ /**
+ * Tests if DeadServerMonitor on detecting an EP as alive should register
+ * client ( create CCP) as welll as register IL
+ */
+ public void testInterstRegistrationOnRecoveredEPbyDSM() throws Exception {
+ addExpectedException("SocketException");
+
+ createClientPoolCache(this.getName(), getServerHostName(server1.getHost()));
+ createEntriesK1andK2();
+ registerK1AndK2();
+ server1.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
+ server2.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
+ server3.invoke(HAInterestBaseTest.class, "createEntriesK1andK2");
+
+ server1.invoke(HAInterestBaseTest.class, "stopServer");
+ server2.invoke(HAInterestBaseTest.class, "stopServer");
+ server3.invoke(HAInterestBaseTest.class, "stopServer");
+ // All servers are dead at this point , no primary in the system.
+ verifyDeadAndLiveServers(3, 0);
+
+ // now start one of the servers
+ server2.invoke(HAInterestBaseTest.class, "startServer");
+ verifyDeadAndLiveServers(2, 1);
+ // verify that is it primary , and dispatcher is running
+ server2.invoke(HAInterestBaseTest.class, "verifyDispatcherIsAlive");
+ // verify that interest is registered on this recovered EP
+ server2.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
+
+ // now start one more server ; this should be now secondary
+ server1.invoke(HAInterestBaseTest.class, "startServer");
+ verifyDeadAndLiveServers(1, 2);
+
+ // verify that is it secondary , dispatcher should not be runnig
+ server1.invoke(HAInterestBaseTest.class, "verifyDispatcherIsNotAlive");
+ // verify that interest is registered on this recovered EP as well
+ server1.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
+
+ // now start one more server ; this should be now secondary
+ server3.invoke(HAInterestBaseTest.class, "startServer");
+ verifyDeadAndLiveServers(0, 3);
+
+ // verify that is it secondary , dispatcher should not be runnig
+ server3.invoke(HAInterestBaseTest.class, "verifyDispatcherIsNotAlive");
+ // verify that interest is registered on this recovered EP as well
+ server3.invoke(HAInterestBaseTest.class, "verifyInterestRegistration");
+ }
}