[Design of Messaging on JBoss (Messaging/JBoss)] - Re: Testing the wireformat
by timfox
Currently our "unit tests" in JBM are actually a mixture of pure unit tests and integration tests.
Pure unit tests should not have any dependencies on other components - so that means they shouldn't use MINA, database, JGroups etc.
For the JBM 2.0 timescale one of my goals is to clean up the separation between unit tests and integration tests.
This means each component should not deal directly with the third party component interface, but we should abstract out our own interface(s).
We then create a mock implementation of that interface(s) which is used for unit testing.
E.g. for our clustering tests, we currently use JGroups directly. Instead we should abstract out our own group management interface(s) which suits the need of JBM (actually we kind of have this already), then we create a mock implementation - which for unit tests trivially just forwards messages directly in vm. We would then have another implementation for the real world which actually uses JGroups.
Similarly for the wire format - instead of calling the MINA interfaces directly - we should abstract out that subset of functionality we need in a set of interface(s) and create a mock implemention that just forwards requests/responses directly invm. The unit tests should then use the mock implementation.
It's not going be overnight that we refactor all our tests to work this way, but for the new work we should certainly aim to do it in this way.
One benefit of doing this (certainly for clustering anyway) is our test suite will be lightning fast!
And, as Adrian has pointed out many times probably ;) , we can create interesting error conditions that would be hard to do with the real product.
Testing failover also becomes very fast and thorough with mocks, we can cause failover to occur at any point in message passing, without having to start lots of servers up (which can take ages) and it all can run in vm.
Once we get over the initial mindset of doing it this way, I think we'll really see the benefits :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105328#4105328
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105328
18 years, 4 months
[Design of Messaging on JBoss (Messaging/JBoss)] - Re: Testing the wireformat
by jmesnil
"timfox" wrote : Now that testing is on my mind, here's a suggestion for testing the new JBM remoting code:
|
| MINA is a third party component, so the unit tests shouldn't really test with the real MINA.
|
| Instead, abstract out a simple interface that represents the interface between our new remoting code and MINA.
|
| Our new remoting code then deals with that interface, not MINA directly.
|
| Create a simple mock implementation of the interface which just forwards requests responses directly from client->server or vice versa (no actual sockets required).
|
The unit tests I put in the BRANCH_JBMessaging-544 (refactored but not committed yet) no longer require sockets.
They use MINA's own ProtocolCodecSession which encode & decode the packets using the same codec than when they're sent on the wire but there is no network trip.
All the wireformat tests looks like that:
1/ create the packet
2/ encode & decode it using MINA protocolCodecSession
3/ retrieve the decoded packet
4/ check it is equivalent to the created packet
the code for (2) is straightforward:
| private AbstractPacket encodeAndDecode(AbstractPacket packet)
| throws Exception
| {
| IoBuffer buffer = encode(packet);
| return decode(buffer);
| }
|
| private IoBuffer encode(AbstractPacket packet) throws Exception
| {
| ProtocolCodecSession session = new ProtocolCodecSession();
| ProtocolEncoder encoder = new PacketCodecFactory().getEncoder();
| encoder.encode(session, packet, session
| .getEncoderOutput());
| IoBuffer buffer = session.getEncoderOutputQueue().poll();
| return buffer;
| }
|
| private AbstractPacket decode(IoBuffer buffer) throws Exception
| {
| ProtocolCodecSession session = new ProtocolCodecSession();
| ProtocolDecoder decoder = new PacketCodecFactory().getDecoder();
| decoder.decode(session, buffer, session.getDecoderOutput());
|
| Object o = session.getDecoderOutputQueue().poll();
|
| assertTrue(o instanceof AbstractPacket);
|
| return (AbstractPacket) o;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105322#4105322
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105322
18 years, 4 months
[Design of Management Features on JBoss] - Re: Using xinclude in config files
by snacker
However it fails when using in the deploy.last directory of jboss (JBoss_4_0_3_SP1 date=200510231054)
anonymous wrote :
| 15:49:08,784 INFO [ServiceConfigurator] Problem configuring service jboss.cache:service=CacheA
| org.jboss.deployment.DeploymentException: Exception setting attribute ClusterConfig = [xi:include: null] on mbean jboss.cache:service=CacheA; - nested throwable: (java.lang.StringIndexOutOfBoundsException: String index out of range: -1)
| at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:669)
| at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:314)
| at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:442)
| at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:153)
| at org.jboss.system.ServiceController.install(ServiceController.java:215)
| at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
| at $Proxy4.install(Unknown Source)
| at org.jboss.deployment.SARDeployer.create(SARDeployer.java:232)
| at org.jboss.deployment.MainDeployer.create(MainDeployer.java:935)
| at org.jboss.deployment.MainDeployer.create(MainDeployer.java:925)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:789)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
| at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
| at $Proxy9.deploy(Unknown Source)
| at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:319)
| at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:489)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:192)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:203)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:182)
| Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
| at java.lang.AbstractStringBuilder.setLength(AbstractStringBuilder.java:143)
| at java.lang.StringBuffer.setLength(StringBuffer.java:153)
| at org.jboss.cache.TreeCache.setClusterConfig(TreeCache.java:676)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.mx.interceptor.AttributeDispatcher.invoke(AttributeDispatcher.java:121)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
| at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.invoke(ModelMBeanAttributeInterceptor.java:88)
| at org.jboss.mx.interceptor.PersistenceInterceptor.invoke(PersistenceInterceptor.java:61)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
| at org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanInvoker.java:442)
| at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:593)
| at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:665)
| ... 37 more
|
I replaced the xerces*.jar, xml-api.jar and xalan.jar in jboss/lib/endorsed with the most recent version ()
http://www.apache.org/dist/xerces/j/Xerces-J-bin.2.9.1.zip
Still didn't work.
Perhaps I need to use a more recent version of JBOSS???
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105222#4105222
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105222
18 years, 4 months
[Design of Management Features on JBoss] - Re: Using xinclude in config files
by snacker
Compiling this:
| import java.io.File;
| import javax.xml.parsers.DocumentBuilder;
| import javax.xml.parsers.DocumentBuilderFactory;
| import javax.xml.transform.Result;
| import javax.xml.transform.Source;
| import javax.xml.transform.Transformer;
| import javax.xml.transform.TransformerFactory;
| import javax.xml.transform.dom.DOMSource;
| import javax.xml.transform.stream.StreamResult;
| import org.w3c.dom.Document;
|
| public class JunkXInclude{
| public static void main( String[] args )throws Exception{
| DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
| dbf.setNamespaceAware( true );
| dbf.setXIncludeAware( true );
| System.out.println( "dbf=" + dbf );
| DocumentBuilder db = dbf.newDocumentBuilder();
| System.out.println( "db=" + db );
| Document doc = db.parse( new File( null == args || 0 == args.length ? "/jboss/server/all/deploy/deploy.last/cachea-service.xml" : args[ 0 ] ) );
| System.out.println( "doc=" + doc );
| Source source = new DOMSource(doc);
| Result result = new StreamResult( System.out );
| Transformer xformer = TransformerFactory.newInstance().newTransformer();
| xformer.transform(source, result);
| }
| }
|
... and executing with this:
anonymous wrote :
| java -cp xml-apis.jar;xercesImpl.jar;serializer.jar;resolver.jar;. JunkXInclude
|
shows that it is properly included:
| <?xml version="1.0" encoding="UTF-8" standalone="no"?><server>
| <classpath archives="jboss-cache.jar, jgroups.jar" codebase="./lib"/>
| <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=CacheA">
| <depends>jboss:service=Naming</depends>
| <depends>jboss:service=TransactionManager</depends>
| <depends>jboss:service=FarmMember,partition=${jboss.partition.name:DefaultPartition}</depends>
|
| <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
| <attribute name="IsolationLevel">NONE</attribute>
| <attribute name="CacheMode">REPL_ASYNC</attribute>
| <attribute name="ClusterName">CacheA-Cluster</attribute>
| <attribute name="ClusterConfig">
| <!--xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="/jboss/server/all/deploy/deploy.last/config-setup.xml" xpointer="element(/1/1)"/>
| <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="/jboss/server/all/deploy/deploy.last/config-setup.xml" xpointer="element(/1/2)"/-->
| <TCP bind_addr="localhost" id="cache-config-a-tcp" loopback="true" start_port="7850" xml:base="/jboss/server/all/deploy/deploy.last/config-setup.xml"/>
| <TCPPING down_thread="true" id="cache-config-a-tcpping" initial_hosts="localhost[7850]" num_initial_members="1" port_range="1" timeout="3500" up_thread="true" xml:base="/jboss/server/all/deploy/deploy.last/config-setup.xml"/>
| <MERGE2 max_interval="10000" min_interval="5000"/>
| <FD_SOCK/>
| <FD down_thread="true" max_tries="5" shun="true" timeout="2500" up_thread="true"/>
| <VERIFY_SUSPECT down_thread="false" timeout="1500" up_thread="false"/>
| <pbcast.NAKACK down_thread="true" gc_lag="100" retransmit_timeout="300,600,1200,2400,4800" up_thread="true"/>
| <pbcast.STABLE desired_avg_gossip="50000" down_thread="false" max_bytes="2100000" stability_delay="1000" up_thread="false"/>
| <pbcast.GMS join_retry_timeout="2000" join_timeout="5000" print_local_addr="true" shun="false"/>
| <pbcast.STATE_TRANSFER down_thread="true" up_thread="true"/>
| </attribute>
|
| <attribute name="SyncReplTimeout">20000</attribute>
| <attribute name="InitialStateRetrievalTimeout">600000</attribute>
|
| <!-- Max number of milliseconds to wait for a lock acquisition -->
| <attribute name="LockAcquisitionTimeout">15000</attribute>
| <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
| <attribute name="EvictionPolicyConfig">
| <config>
| <attribute name="wakeUpIntervalSeconds">600</attribute>
| <region name="/_default_">
| <attribute name="maxNodes">10000</attribute>
| <attribute name="timeToIdleSeconds">14400</attribute>
| </region>
| </config>
| </attribute>
| </mbean>
| </server>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105220#4105220
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105220
18 years, 4 months
[Design of Management Features on JBoss] - Re: Using xinclude in config files
by snacker
So will xinclude work with the config files dropped in deploy.last?
We have multiple development environments and would like to do this:
cachea-service.xml
| <?xml version="1.0" encoding="UTF-8"?>
|
| <server>
| <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
| <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=CacheA">
| <depends>jboss:service=Naming</depends>
| <depends>jboss:service=TransactionManager</depends>
| <depends>jboss:service=FarmMember,partition=${jboss.partition.name:DefaultPartition}</depends>
|
| <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
| <attribute name="IsolationLevel">NONE</attribute>
| <attribute name="CacheMode">REPL_ASYNC</attribute>
| <attribute name="ClusterName">CacheA-Cluster</attribute>
| <attribute name="ClusterConfig">
| <!--xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="/jboss/server/all/deploy/deploy.last/cache-setup.xml" xpointer="element(/1/1)"/>
| <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="/jboss/server/all/deploy/deploy.last/cache-setup.xml" xpointer="element(/1/2)"/-->
| <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="/jboss/server/all/deploy/deploy.last/cache-setup.xml" xpointer="cache-config-a-tcp"/>
| <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="/jboss/server/all/deploy/deploy.last/cache-setup.xml" xpointer="cache-config-a-tcpping"/>
| <MERGE2 min_interval="5000" max_interval="10000"/>
| <FD_SOCK />
| <FD shun="true" timeout="2500" max_tries="5" up_thread="true" down_thread="true" />
| <VERIFY_SUSPECT timeout="1500" down_thread="false" up_thread="false" />
| <pbcast.NAKACK down_thread="true" up_thread="true" gc_lag="100" retransmit_timeout="300,600,1200,2400,4800" />
| <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000" down_thread="false" up_thread="false" max_bytes="2100000"/>
| <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="false" print_local_addr="true"/>
| <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
| </attribute>
|
| <attribute name="SyncReplTimeout">20000</attribute>
| <attribute name="InitialStateRetrievalTimeout">600000</attribute>
|
| <!-- Max number of milliseconds to wait for a lock acquisition -->
| <attribute name="LockAcquisitionTimeout">15000</attribute>
| <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
| <attribute name="EvictionPolicyConfig">
| <config>
| <attribute name="wakeUpIntervalSeconds">600</attribute>
| <region name="/_default_">
| <attribute name="maxNodes">10000</attribute>
| <attribute name="timeToIdleSeconds">14400</attribute>
| </region>
| </config>
| </attribute>
| </mbean>
| </server>
|
config-setup.xml
| <?xml version="1.0" encoding="UTF-8"?>
|
| <!DOCTYPE config-setup[
| <!ELEMENT config-setup (TCP|TCPPING)*>
| <!ELEMENT TCP EMPTY>
| <!ATTLIST TCP
| id ID #REQUIRED
| bind_addr CDATA #IMPLIED
| start_port CDATA #IMPLIED
| loopback CDATA #IMPLIED
| >
| <!ELEMENT TCPPING EMPTY>
| <!ATTLIST TCPPING
| id ID #REQUIRED
| initial_hosts CDATA #IMPLIED
| port_range CDATA #IMPLIED
| timeout CDATA #IMPLIED
| num_initial_members CDATA #IMPLIED
| up_thread CDATA #IMPLIED
| down_thread CDATA #IMPLIED
| >
| ]>
|
| <config-setup>
| <TCP id="cache-config-a-tcp" bind_addr="localhost" start_port="1111" loopback="true"/>
| <TCPPING id="cache-config-a-tcpping" initial_hosts="localhost[1111]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
|
| <TCP id="cache-config-b-tcp" bind_addr="localhost" start_port="1112" loopback="true"/>
| <TCPPING id="cache-config-b-tcpping" initial_hosts="localhost[1112]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
|
| <TCP id="cache-config-c-tcp" bind_addr="localhost" start_port="1113" loopback="true"/>
| <TCPPING id="cache-config-c-tcpping" initial_hosts="localhost[1113]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
|
| <TCP id="cache-config-e-tcp" bind_addr="localhost" start_port="1114" loopback="true"/>
| <TCPPING id="cache-config-e-tcpping" initial_hosts="localhost[1114]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
|
| <TCP id="cache-config-f-tcp" bind_addr="localhost" start_port="1115" loopback="true"/>
| <TCPPING id="cache-config-f-tcpping" initial_hosts="localhost[1115]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
|
| <TCP id="cache-config-g-tcp" bind_addr="localhost" start_port="1116" loopback="true"/>
| <TCPPING id="cache-config-g-tcpping" initial_hosts="localhost[1116]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
|
| <TCP id="cache-config-h-tcp" bind_addr="localhost" start_port="1117" loopback="true"/>
| <TCPPING id="cache-config-h-tcpping" initial_hosts="localhost[1118]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
|
| <TCP id="cache-config-tc5-cluster-tcp" bind_addr="localhost" start_port="1119" loopback="true"/>
| <TCPPING id="cache-config-tc5-cluster-tcpping" initial_hosts="localhost[1119]" port_range="1" timeout="3500" num_initial_members="1" up_thread="true" down_thread="true"/>
| </config-setup>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105215#4105215
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105215
18 years, 4 months