This content has been marked as final.
Show 1 reply
-
1. Re: Test framework for HA Shared Nodes
jmesnil Sep 1, 2010 10:52 AM (in response to jmesnil)I've reused the code in the JORAM tests to spawn VM and adapt it to make it easy to manage HornetQ server.
All you need is to extend RemoteServerConfiguration class:
static class SharedLiveServerConfiguration extends RemoteServerConfiguration { @Override public Configuration getConfiguration() { Configuration config = new ConfigurationImpl(); config.setSecurityEnabled(false); config.setJournalType(JournalType.NIO); config.setSharedStore(true); config.setClustered(true); config.getAcceptorConfigurations().add(createTransportConfiguration(true, true, generateParams(0, true))); config.getConnectorConfigurations().put("self", createTransportConfiguration(true, false, generateParams(0, true))); config.getClusterConfigurations().add(new ClusterConnectionConfiguration("cluster", "foo", "self", -1, false, false, 1, 1, new ArrayList<String>())); return config; } } static class SharedBackupServerConfiguration extends RemoteServerConfiguration { @Override public Configuration getConfiguration() { ... } }
and then in the tests, use RemoteHornetQServer static methods to start/stop/crash the server:
public void testCrashLiveServer() throws Exception { Process liveServer = null; Process backupServer = null; try { liveServer = RemoteHornetQServer.start(SharedLiveServerConfiguration.class.getName()); backupServer = RemoteHornetQServer.start(SharedBackupServerConfiguration.class.getName()); // write the tests from the client POV RemoteHornetQServer.crash(liveServer); assertTrue(liveServer.exitValue() == 1); liveServer = null; // check failover } finally { if (liveServer != null) { RemoteHornetQServer.stop(liveServer); } if (backupServer != null) { RemoteHornetQServer.stop(backupServer); } } }
With a bit more polish and magic, we could adapt it to reuse all the failover tests to test either:
* using invm servers + fake filelock
* using remote servers + real filelock
from the same base tests.
I've added a first test in FailoverWithSharedStoreTest using these methods.