[jboss-cvs] JBossAS SVN: r62918 - in branches/Branch_4_2/testsuite: src/main/org/jboss/test/cluster/partition/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 8 19:24:45 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-05-08 19:24:45 -0400 (Tue, 08 May 2007)
New Revision: 62918
Added:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/JBAS4406UnitTestCase.java
branches/Branch_4_2/testsuite/src/resources/cluster/partition/jbas4406-service.xml
Modified:
branches/Branch_4_2/testsuite/imports/sections/cluster.xml
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/PartitionRestartUnitTestCase.java
Log:
[JBAS-4406] Register Channel in JMX if not from ChannelFactory
Modified: branches/Branch_4_2/testsuite/imports/sections/cluster.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/cluster.xml 2007-05-08 23:20:09 UTC (rev 62917)
+++ branches/Branch_4_2/testsuite/imports/sections/cluster.xml 2007-05-08 23:24:45 UTC (rev 62918)
@@ -358,5 +358,11 @@
<include name="org/jboss/test/cluster/ejb/*"/>
</fileset>
</zip>
+
+ <!-- JBAS-4406 -->
+ <copy todir="${build.lib}"
+ file="${build.resources}/cluster/partition/jbas4406-service.xml"
+ overwrite="true"/>
+
</target>
</project>
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/JBAS4406UnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/JBAS4406UnitTestCase.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/JBAS4406UnitTestCase.java 2007-05-08 23:24:45 UTC (rev 62918)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.partition.test;
+
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * A PartitionRestartUnitTestCase.
+ *
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class JBAS4406UnitTestCase extends JBossClusteredTestCase
+{
+ public static final String DEPLOYMENT = "jbas4406-service.xml";
+ /**
+ * Create a new PartitionRestartUnitTestCase.
+ *
+ * @param name
+ */
+ public JBAS4406UnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(JBAS4406UnitTestCase.class, DEPLOYMENT);
+ }
+
+ public void testMBeanRegistration()
+ throws Exception
+ {
+ getLog().debug("testMBeanRegistration");
+
+ RMIAdaptor[] adaptors = this.getAdaptors();
+
+ Set channelMBean = getChannelMBeans(adaptors[0]);
+ assertNotNull("Channel mbean registered", channelMBean);
+ assertEquals("Only one channel mbean", 1, channelMBean.size());
+
+ Set protocolMBeans = getProtocolMBeans(adaptors[0]);
+ assertNotNull("Protocol mbeans registered", channelMBean);
+ assertEquals("Multiple protocol mbeans", 10, protocolMBeans.size());
+
+ // Stop and confirm the mbeans are still registered
+ stopPartition(adaptors[0]);
+
+ // Let the cluster stabilize
+ sleep(2000);
+
+ Set channelMBean2 = getChannelMBeans(adaptors[0]);
+ assertTrue("Channel mbean unchanged", channelMBean.equals(channelMBean2));
+
+ Set protocolMBeans2 = getProtocolMBeans(adaptors[0]);
+ assertTrue("Protocol mbeans unchanged", protocolMBeans.equals(protocolMBeans2));
+
+ // Undeploy and confirm that mbeans are gone
+ undeploy(adaptors[0], DEPLOYMENT);
+
+ Set channelMBean3 = getChannelMBeans(adaptors[0]);
+ if (channelMBean3 != null)
+ assertTrue("Channel mbean undeployed", channelMBean3.size() == 0);
+
+ Set protocolMBeans3 = getProtocolMBeans(adaptors[0]);
+ if (protocolMBeans3 != null)
+ assertTrue("Protocol mbeans undeployed", protocolMBeans3.size() == 0);
+
+ getLog().debug("ok");
+ }
+
+ protected void stopPartition(RMIAdaptor adaptor) throws Exception
+ {
+ ObjectName partition = new ObjectName("jboss:service=JBAS4406Partition");
+
+ Object[] params = new Object[0];
+ String[] types = new String[0];
+ adaptor.invoke(partition, "stop", params, types);
+
+ sleep(2000);
+ }
+
+ protected Set getChannelMBeans(RMIAdaptor adaptor) throws Exception
+ {
+ ObjectName on = new ObjectName("jgroups.mux:type=channel,cluster=JBAS4406Partition");
+ return adaptor.queryNames(on, null);
+ }
+
+ protected Set getProtocolMBeans(RMIAdaptor adaptor) throws Exception
+ {
+ ObjectName on = new ObjectName("jgroups.mux:*,type=protocol,cluster=JBAS4406Partition");
+ return adaptor.queryNames(on, null);
+ }
+}
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/PartitionRestartUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/PartitionRestartUnitTestCase.java 2007-05-08 23:20:09 UTC (rev 62917)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/partition/test/PartitionRestartUnitTestCase.java 2007-05-08 23:24:45 UTC (rev 62918)
@@ -22,6 +22,7 @@
package org.jboss.test.cluster.partition.test;
import java.util.Properties;
+import java.util.Set;
import javax.management.ObjectName;
import javax.naming.Context;
@@ -59,13 +60,21 @@
return t1;
}
- public void testStatefulBeanFailover()
+ public void testPartitionRestart()
throws Exception
{
getLog().debug("testStatefulBeanFailover");
RMIAdaptor[] adaptors = this.getAdaptors();
+ Set channelMBean = getChannelMBeans(adaptors[0]);
+ assertNotNull("Channel mbean registered", channelMBean);
+ assertEquals("Only one channel mbean", 1, channelMBean.size());
+
+ Set protocolMBeans = getProtocolMBeans(adaptors[0]);
+ assertNotNull("Protocol mbeans registered", channelMBean);
+ assertTrue("Multiple protocol mbeans", protocolMBeans.size() > 1);
+
String[] urls = getNamingURLs();
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
@@ -120,6 +129,14 @@
assertTrue ("Value is identical on replicated node", "Changed".equals (node1.answer) );
statefulSession.remove();
+
+
+ Set channelMBean2 = getChannelMBeans(adaptors[0]);
+ assertTrue("Channel mbean unchanged", channelMBean.equals(channelMBean2));
+
+ Set protocolMBeans2 = getProtocolMBeans(adaptors[0]);
+ assertTrue("Protocol mbeans unchanged", protocolMBeans.equals(protocolMBeans2));
+
getLog().debug("ok");
}
@@ -138,5 +155,17 @@
sleep(2000);
}
+
+ protected Set getChannelMBeans(RMIAdaptor adaptor) throws Exception
+ {
+ ObjectName on = new ObjectName("jgroups.mux:type=channel,cluster=DefaultPartition");
+ return adaptor.queryNames(on, null);
+ }
+
+ protected Set getProtocolMBeans(RMIAdaptor adaptor) throws Exception
+ {
+ ObjectName on = new ObjectName("jgroups.mux:*,type=protocol,cluster=DefaultPartition");
+ return adaptor.queryNames(on, null);
+ }
}
Added: branches/Branch_4_2/testsuite/src/resources/cluster/partition/jbas4406-service.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cluster/partition/jbas4406-service.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cluster/partition/jbas4406-service.xml 2007-05-08 23:24:45 UTC (rev 62918)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+ <!-- ==================================================================== -->
+ <!-- Partition used for testing channel and protocl JMX registrations -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.ha.framework.server.ClusterPartition"
+ name="jboss:service=JBAS4406Partition">
+
+ <!-- Name of the partition being built -->
+ <attribute name="PartitionName">JBAS4406Partition</attribute>
+
+ <!-- The address used to determine the node name -->
+ <attribute name="NodeAddress">${jboss.bind.address}</attribute>
+
+ <!-- Determine if deadlock detection is enabled -->
+ <attribute name="DeadlockDetection">False</attribute>
+
+ <!-- Keep this timeout short -->
+ <attribute name="StateTransferTimeout">2000</attribute>
+
+ <!-- The JGroups protocol configuration -->
+ <attribute name="PartitionConfig">
+ <!--
+ IMPORTANT: These are bogus stacks, not intended for real use.
+ Key thing is that the UDP and TCP stacks both have 10 protocols,
+ as the unit test checks for 10 protocol mbean registrations!!!
+ -->
+ <Config>
+ <UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}" mcast_port="23456"
+ ip_ttl="8" ip_mcast="true"
+ mcast_send_buf_size="800000" mcast_recv_buf_size="150000"
+ ucast_send_buf_size="800000" ucast_recv_buf_size="150000"
+ loopback="false"/>
+ <PING timeout="2000" num_initial_members="3"
+ up_thread="true" down_thread="true"/>
+ <MERGE2 min_interval="10000" max_interval="20000"/>
+ <FD_SOCK down_thread="false" up_thread="false"/>
+ <VERIFY_SUSPECT timeout="3000" num_msgs="3"
+ up_thread="true" down_thread="true"/>
+ <pbcast.NAKACK gc_lag="50" retransmit_timeout="300,600,1200,2400,4800"
+ max_xmit_size="8192"
+ up_thread="true" down_thread="true"/>
+ <UNICAST timeout="300,600,1200,2400,4800" window_size="100" min_threshold="10"
+ down_thread="true"/>
+ <pbcast.STABLE desired_avg_gossip="20000"
+ up_thread="true" down_thread="true"/>
+ <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
+ shun="true" print_local_addr="true"/>
+ <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
+ </Config>
+
+ <!-- Alternate TCP stack: customize it for your environment, change bind_addr and initial_hosts -->
+ <!--
+ <Config>
+ <TCP bind_addr="thishost" start_port="7800" loopback="true"/>
+ <TCPPING initial_hosts="thishost[7800],otherhost[7800]" port_range="3" timeout="3500"
+ num_initial_members="3" up_thread="true" down_thread="true"/>
+ <MERGE2 min_interval="5000" max_interval="10000"/>
+ <FD_SOCK down_thread="false" up_thread="false"/>
+ <FD shun="true" up_thread="true" down_thread="true"
+ timeout="20000" max_tries="5"/>
+ <VERIFY_SUSPECT timeout="1500" down_thread="false" up_thread="false" />
+ <pbcast.NAKACK down_thread="true" up_thread="true" gc_lag="100"
+ retransmit_timeout="3000"/>
+ <pbcast.STABLE desired_avg_gossip="20000" down_thread="false" up_thread="false" />
+ <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="false"
+ print_local_addr="true" down_thread="true" up_thread="true"/>
+ <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
+ </Config>
+ -->
+ </attribute>
+
+ </mbean>
+
+</server>
More information about the jboss-cvs-commits
mailing list