[jboss-cvs] JBossAS SVN: r69437 - in trunk/testsuite/src/main/org/jboss/test/cluster: hasingleton and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 29 00:16:28 EST 2008
Author: bstansberry at jboss.com
Date: 2008-01-29 00:16:27 -0500 (Tue, 29 Jan 2008)
New Revision: 69437
Modified:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonSupportUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/hasingleton/HASingletonSupportTester.java
Log:
[JBAS-4261] Port HASingleton "restart on merge" to trunk
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonSupportUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonSupportUnitTestCase.java 2008-01-29 05:14:46 UTC (rev 69436)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonSupportUnitTestCase.java 2008-01-29 05:16:27 UTC (rev 69437)
@@ -1,8 +1,8 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
@@ -27,7 +27,13 @@
import org.jboss.test.cluster.hasingleton.HASingletonSupportTester;
-
+/**
+ * Tests of the HASingletonSupport class.
+ *
+ * @author Ivelin Ivanov <ivelin at jboss.org>
+ * @author Brian Stansberry
+ *
+ */
public class HASingletonSupportUnitTestCase extends TestCase
{
@@ -42,6 +48,7 @@
public void setUp()
{
singletonSupportTester = new HASingletonSupportTester();
+ singletonSupportTester.setRestartOnMerge(true);
}
public void tearDown()
@@ -50,7 +57,7 @@
}
public void testStartService() throws Exception
- {
+ {
singletonSupportTester.start();
// test that the correct start sequence was followed correctly
@@ -59,8 +66,7 @@
assertEquals("method not invoked as expected",
singletonSupportTester.__invokationStack__.pop(), "registerRPCHandler");
assertEquals("method not invoked as expected",
- singletonSupportTester.__invokationStack__.pop(), "setupPartition");
-
+ singletonSupportTester.__invokationStack__.pop(), "setupPartition");
}
public void testStopService() throws Exception
@@ -71,17 +77,21 @@
assertEquals("method not invoked as expected",
singletonSupportTester.__invokationStack__.pop(), "unregisterRPCHandler");
assertEquals("method not invoked as expected",
- singletonSupportTester.__invokationStack__.pop(), "unregisterDRMListener");
-
+ singletonSupportTester.__invokationStack__.pop(), "unregisterDRMListener");
}
public void testBecomeMasterNode() throws Exception
{
+ becomeMasterNodeTest(false);
+ }
+
+ private void becomeMasterNodeTest(boolean merge) throws Exception
+ {
singletonSupportTester.start();
// register DRM Listener is expected to call back
singletonSupportTester.__isDRMMasterReplica__ = true;
- singletonSupportTester.partitionTopologyChanged( new ArrayList(2), 1, false);
+ singletonSupportTester.partitionTopologyChanged( new ArrayList(2), 1, merge);
// test whether it was elected
assertTrue("expected to become master", singletonSupportTester.isMasterNode());
@@ -97,13 +107,18 @@
public void testBecomeSlaveNodeWithAnotherMaster() throws Exception
{
+ becomeSlaveNodeWithAnotherMasterTest(false);
+ }
+
+ private void becomeSlaveNodeWithAnotherMasterTest(boolean merge) throws Exception
+ {
singletonSupportTester.start();
boolean savedIsMasterNode = singletonSupportTester.isMasterNode();
// register DRM Listener is expected to call back
singletonSupportTester.__isDRMMasterReplica__ = false;
- singletonSupportTester.partitionTopologyChanged(new ArrayList(2), 1, false);
+ singletonSupportTester.partitionTopologyChanged(new ArrayList(2), 1, merge);
// this call back should not change the master/slave status
assertEquals("expected to be still in old master/slave state", singletonSupportTester.isMasterNode(), savedIsMasterNode );
@@ -140,11 +155,104 @@
// since the only node (this one) in the partition is now removed, the replicants list should be empty
singletonSupportTester.partitionTopologyChanged(new ArrayList(0), 1, false);
- assertTrue("expected to have made a call to _stopOldMater(), thus become slave", !singletonSupportTester.isMasterNode() );
+ assertTrue("expected to have made a call to _stopOldMaster(), thus become slave", !singletonSupportTester.isMasterNode() );
assertEquals("method not invoked as expected",
singletonSupportTester.__invokationStack__.pop(), "stopSingleton");
}
+ 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);
+ becomeMasterNodeTest(false);
+ }
+
+ public void testBecomeSlaveNodeWithAnotherMasterWithRestartOff() throws Exception
+ {
+ singletonSupportTester.setRestartOnMerge(false);
+ becomeSlaveNodeWithAnotherMasterTest(false);
+ }
+
+ public void testBecomeMasterNodeDuringMerge() throws Exception
+ {
+ becomeMasterNodeTest(true);
+ }
+
+ public void testMasterRestartDuringMerge() throws Exception
+ {
+ // Just run the BecomeMaster test to get ourself set up as master
+ becomeMasterNodeTest(false);
+
+ // Drain off any un-popped events
+ singletonSupportTester.__invokationStack__.clear();
+
+ singletonSupportTester.partitionTopologyChanged( new ArrayList(3), 2, true);
+
+ // 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
+ becomeMasterNodeTest(false);
+
+ // Drain off any un-popped events
+ singletonSupportTester.__invokationStack__.clear();
+
+ singletonSupportTester.__isDRMMasterReplica__ = false;
+
+ singletonSupportTester.partitionTopologyChanged( new ArrayList(3), 2, true);
+
+ // 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();
+
+ singletonSupportTester.partitionTopologyChanged( new ArrayList(3), 2, true);
+
+ // 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());
+ }
+
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/hasingleton/HASingletonSupportTester.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/hasingleton/HASingletonSupportTester.java 2008-01-29 05:14:46 UTC (rev 69436)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/hasingleton/HASingletonSupportTester.java 2008-01-29 05:16:27 UTC (rev 69437)
@@ -1,8 +1,8 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
@@ -100,8 +100,14 @@
__invokationStack__.push("makeThisNodeMaster");
super.makeThisNodeMaster();
}
+
+ @Override
+ protected void restartMaster()
+ {
+ __invokationStack__.push("restartMaster");
+ super.restartMaster();
+ }
-
public void sendNotification(Notification notification)
{
return;
More information about the jboss-cvs-commits
mailing list