[jboss-cvs] JBossAS SVN: r61876 - branches/Branch_4_0/testsuite/src/main/org/jboss/test/ha/singleton/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 29 21:48:45 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-03-29 21:48:45 -0400 (Thu, 29 Mar 2007)
New Revision: 61876
Modified:
branches/Branch_4_0/testsuite/src/main/org/jboss/test/ha/singleton/test/HASingletonSupportUnitTestCase.java
Log:
[JBAS-4262] Port JBAS-4229 fix to Branch_4_0
Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/ha/singleton/test/HASingletonSupportUnitTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/ha/singleton/test/HASingletonSupportUnitTestCase.java 2007-03-30 01:45:00 UTC (rev 61875)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/ha/singleton/test/HASingletonSupportUnitTestCase.java 2007-03-30 01:48:45 UTC (rev 61876)
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
+import org.jboss.ha.framework.interfaces.ClusterMergeStatus;
import org.jboss.test.ha.singleton.HASingletonSupportTester;
/**
@@ -46,11 +47,17 @@
public void setUp()
{
singletonSupportTester = new HASingletonSupportTester();
+ // We want to port this test from 4.2 to CP releases where
+ // the default for restartOnMerge will be false; so set
+ // the property to the 4.2 default, allowing the remaining
+ // tests to go unchanged yet still run as they do in 4.2
+ singletonSupportTester.setRestartOnMerge(true);
}
public void tearDown()
{
singletonSupportTester = null;
+ ClusterMergeStatus.endMergeProcess();
}
public void testStartService() throws Exception
@@ -151,4 +158,154 @@
}
+ public void testStartServiceWithRestartOff() throws Exception
+ {
+ singletonSupportTester.setRestartOnMerge(false);
+ testStartService();
+ }
+
+ public void testStopServiceWithRestartOff() throws Exception
+ {
+ singletonSupportTester.setRestartOnMerge(false);
+ testStopService();
+ }
+
+ public void testBecomeMasterNodeWithRestartOff() throws Exception
+ {
+ singletonSupportTester.setRestartOnMerge(false);
+ testBecomeMasterNode();
+ }
+
+ public void testBecomeSlaveNodeWithAnotherMasterWithRestartOff() throws Exception
+ {
+ singletonSupportTester.setRestartOnMerge(false);
+ testBecomeSlaveNodeWithAnotherMaster();
+ }
+
+ public void testStartServiceWithBogusRestart() throws Exception
+ {
+ try
+ {
+ ClusterMergeStatus.startMergeProcess();
+ testStartService();
+ }
+ finally
+ {
+ ClusterMergeStatus.endMergeProcess();
+ }
+ }
+
+ public void testStopServiceWithBogusRestart() throws Exception
+ {
+ try
+ {
+ ClusterMergeStatus.startMergeProcess();
+ testStopService();
+ }
+ finally
+ {
+ ClusterMergeStatus.endMergeProcess();
+ }
+ }
+
+ public void testBecomeMasterNodeDuringMerge() throws Exception
+ {
+ try
+ {
+ ClusterMergeStatus.startMergeProcess();
+ testBecomeMasterNode();
+ }
+ finally
+ {
+ ClusterMergeStatus.endMergeProcess();
+ }
+ }
+
+ public void testMasterRestartDuringMerge() throws Exception
+ {
+ // Just run the BecomeMaster test to get ourself set up as master
+ testBecomeMasterNode();
+
+ // Drain off any un-popped events
+ singletonSupportTester.__invokationStack__.clear();
+
+ try
+ {
+ ClusterMergeStatus.startMergeProcess();
+ singletonSupportTester.partitionTopologyChanged( new ArrayList(3), 2);
+ }
+ finally
+ {
+ ClusterMergeStatus.endMergeProcess();
+ }
+
+ // test whether it's still master
+ assertTrue("expected to remain master", singletonSupportTester.isMasterNode());
+
+ // test whether the election sequence was followed correctly
+ assertEquals("method not invoked as expected",
+ "startSingleton", singletonSupportTester.__invokationStack__.pop());
+ assertEquals("method not invoked as expected",
+ "stopSingleton", singletonSupportTester.__invokationStack__.pop());
+ assertEquals("method not invoked as expected",
+ "restartMaster", singletonSupportTester.__invokationStack__.pop());
+ }
+
+ public void testBecomeSlaveNodeWithAnotherMasterDuringMerge() throws Exception
+ {
+ // Just run the BecomeMaster test to get ourself set up as master
+ testBecomeMasterNode();
+
+ // Drain off any un-popped events
+ singletonSupportTester.__invokationStack__.clear();
+
+ singletonSupportTester.__isDRMMasterReplica__ = false;
+ try
+ {
+ ClusterMergeStatus.startMergeProcess();
+ singletonSupportTester.partitionTopologyChanged( new ArrayList(3), 2);
+ }
+ finally
+ {
+ ClusterMergeStatus.endMergeProcess();
+ }
+
+ // now it should be slave
+ assertFalse("expected to be slave", singletonSupportTester.isMasterNode());
+
+ assertEquals("this node was the old master, but method not invoked as expected",
+ singletonSupportTester.__invokationStack__.pop(), "stopSingleton");
+ }
+
+
+ public void testMasterRestartDuringMergeWithRestartOff() throws Exception
+ {
+ singletonSupportTester.setRestartOnMerge(false);
+
+ // Just run the BecomeMaster test to get ourself set up as master
+ testBecomeMasterNode();
+
+ // Drain off any un-popped events
+ singletonSupportTester.__invokationStack__.clear();
+
+ try
+ {
+ ClusterMergeStatus.startMergeProcess();
+ singletonSupportTester.partitionTopologyChanged( new ArrayList(3), 2);
+ }
+ finally
+ {
+ ClusterMergeStatus.endMergeProcess();
+ }
+
+ // test whether it's still master
+ assertTrue("expected to remain master", singletonSupportTester.isMasterNode());
+
+ // test whether the election sequence was followed correctly
+ assertEquals("method not invoked as expected",
+ "isDRMMasterReplica", singletonSupportTester.__invokationStack__.pop());
+ assertEquals("method not invoked as expected",
+ 0, singletonSupportTester.__invokationStack__.size());
+ }
+
}
More information about the jboss-cvs-commits
mailing list