Author: borges
Date: 2011-07-22 09:57:33 -0400 (Fri, 22 Jul 2011)
New Revision: 11023
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterWithBackupTest.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusteredRequestResponseTest.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java
Log:
Make sure resources are closed at tearDown
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-07-22
13:56:49 UTC (rev 11022)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2011-07-22
13:57:33 UTC (rev 11023)
@@ -25,6 +25,7 @@
import junit.framework.Assert;
import org.hornetq.api.core.DiscoveryGroupConfiguration;
+import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
@@ -83,6 +84,18 @@
private static final long WAIT_TIMEOUT = 5000;
+ private static final SimpleString COUNT_PROP = new
SimpleString("count_prop");
+
+ protected static final SimpleString FILTER_PROP = new
SimpleString("animal");
+
+ private static final int MAX_SERVERS = 10;
+
+ protected ConsumerHolder[] consumers;
+ protected HornetQServer[] servers;
+ protected NodeManager[] nodeManagers;
+ protected ServerLocator[] locators0;
+ protected ClientSessionFactory[] sfs;
+
@Override
protected void setUp() throws Exception
{
@@ -95,55 +108,47 @@
consumers = new ConsumerHolder[ClusterTestBase.MAX_CONSUMERS];
servers = new HornetQServer[ClusterTestBase.MAX_SERVERS];
-
sfs = new ClientSessionFactory[ClusterTestBase.MAX_SERVERS];
-
nodeManagers = new NodeManager[ClusterTestBase.MAX_SERVERS];
+ locators0 = new ServerLocator[ClusterTestBase.MAX_SERVERS];
for (int i = 0, nodeManagersLength = nodeManagers.length; i <
nodeManagersLength; i++)
{
nodeManagers[i] = new InVMNodeManager();
}
- locators = new ServerLocator[ClusterTestBase.MAX_SERVERS];
-
}
@Override
protected void tearDown() throws Exception
{
- for (ServerLocator locator : locators)
+ closeAllConsumers();
+ closeAllSessionFactories();
+ closeAllServerLocatorsFactories();
+ for (int i = 0; i < MAX_SERVERS; i++)
{
- try
+ if (servers[i] == null)
+ continue;
+
+ for (ClusterConnection cc :
servers[i].getClusterManager().getClusterConnections())
{
- locator.close();
+ cc.stop();
}
- catch (Exception e)
- {
- //
- }
+ stopComponent(servers[i]);
+
}
-
- locators = null;
-
- locators = new ServerLocator[ClusterTestBase.MAX_SERVERS];
+ for (int i = 0; i < MAX_SERVERS; i++)
+ {
+ stopComponent(nodeManagers[i]);
+ }
UnitTestCase.checkFreePort(ClusterTestBase.PORTS);
+ locators0 = null;
servers = null;
-
sfs = null;
-
- consumers = null;
-
- consumers = new ConsumerHolder[ClusterTestBase.MAX_CONSUMERS];
-
-
-
nodeManagers = null;
super.tearDown();
-
- // ServerLocatorImpl.shutdown();
}
// Private
-------------------------------------------------------------------------------------------------------
@@ -161,29 +166,37 @@
ConsumerHolder(final int id, final ClientConsumer consumer, final ClientSession
session)
{
this.id = id;
-
this.consumer = consumer;
-
this.session = session;
}
- }
- private static final SimpleString COUNT_PROP = new
SimpleString("count_prop");
+ void close()
+ {
+ if (consumer != null)
+ {
+ try
+ {
+ consumer.close();
+ }
+ catch (HornetQException e)
+ {
+ // ignore
+ }
+ }
+ if (session != null) {
+ try
+ {
+ session.close();
+ }
+ catch (HornetQException e)
+ {
+ // ignore
+ }
+ }
+ }
- protected static final SimpleString FILTER_PROP = new
SimpleString("animal");
+ }
- private static final int MAX_SERVERS = 10;
-
- protected ConsumerHolder[] consumers;
-
- protected HornetQServer[] servers;
-
- protected NodeManager[] nodeManagers;
-
- protected ServerLocator[] locators;
-
- protected ClientSessionFactory[] sfs;
-
protected ClientConsumer getConsumer(final int node)
{
return consumers[node].consumer;
@@ -415,7 +428,7 @@
}
catch (Exception e)
{
- // Proxy the faliure and print a dump into System.out, so it is captured by
Hudson reports
+ // Proxy the failure and print a dump into System.out, so it is captured by
Hudson reports
e.printStackTrace();
System.out.println(UnitTestCase.threadDump(" - fired by
ClusterTestBase::addConsumer"));
@@ -471,15 +484,15 @@
protected void closeAllServerLocatorsFactories() throws Exception
{
- for (int i = 0; i < locators.length; i++)
+ for (int i = 0; i < locators0.length; i++)
{
- ServerLocator sf = locators[i];
+ ServerLocator sf = locators0[i];
if (sf != null)
{
sf.close();
- locators[i] = null;
+ locators0[i] = null;
}
}
}
@@ -1212,16 +1225,16 @@
if (ha)
{
- locators[node] = HornetQClient.createServerLocatorWithHA(serverTotc);
+ locators0[node] = HornetQClient.createServerLocatorWithHA(serverTotc);
}
else
{
- locators[node] = HornetQClient.createServerLocatorWithoutHA(serverTotc);
+ locators0[node] = HornetQClient.createServerLocatorWithoutHA(serverTotc);
}
- locators[node].setBlockOnNonDurableSend(true);
- locators[node].setBlockOnDurableSend(true);
- ClientSessionFactory sf = locators[node].createSessionFactory();
+ locators0[node].setBlockOnNonDurableSend(true);
+ locators0[node].setBlockOnDurableSend(true);
+ ClientSessionFactory sf = locators0[node].createSessionFactory();
sfs[node] = sf;
}
@@ -1247,12 +1260,12 @@
serverTotc = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY,
params);
}
- locators[node] = HornetQClient.createServerLocatorWithoutHA(serverTotc);
+ locators0[node] = HornetQClient.createServerLocatorWithoutHA(serverTotc);
- locators[node].setBlockOnNonDurableSend(true);
- locators[node].setBlockOnDurableSend(true);
- locators[node].setReconnectAttempts(reconnectAttempts);
- ClientSessionFactory sf = locators[node].createSessionFactory();
+ locators0[node].setBlockOnNonDurableSend(true);
+ locators0[node].setBlockOnDurableSend(true);
+ locators0[node].setReconnectAttempts(reconnectAttempts);
+ ClientSessionFactory sf = locators0[node].createSessionFactory();
sfs[node] = sf;
}
@@ -1278,14 +1291,14 @@
}
- locators[node] = HornetQClient.createServerLocatorWithHA(serverTotc);
- locators[node].setRetryInterval(100);
- locators[node].setRetryIntervalMultiplier(1d);
- locators[node].setReconnectAttempts(-1);
- locators[node].setBlockOnNonDurableSend(blocking);
- locators[node].setBlockOnDurableSend(blocking);
+ locators0[node] = HornetQClient.createServerLocatorWithHA(serverTotc);
+ locators0[node].setRetryInterval(100);
+ locators0[node].setRetryIntervalMultiplier(1d);
+ locators0[node].setReconnectAttempts(-1);
+ locators0[node].setBlockOnNonDurableSend(blocking);
+ locators0[node].setBlockOnDurableSend(blocking);
- ClientSessionFactory sf = locators[node].createSessionFactory();
+ ClientSessionFactory sf = locators0[node].createSessionFactory();
sfs[node] = sf;
}
@@ -1733,14 +1746,6 @@
}
}
- protected void clearAllServers()
- {
- for (int i = 0; i < servers.length; i++)
- {
- servers[i] = null;
- }
- }
-
protected void setupClusterConnection(final String name,
final int nodeFrom,
final int nodeTo,
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterWithBackupTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterWithBackupTest.java 2011-07-22
13:56:49 UTC (rev 11022)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusterWithBackupTest.java 2011-07-22
13:57:33 UTC (rev 11023)
@@ -46,14 +46,6 @@
setupServers();
}
- @Override
- protected void tearDown() throws Exception
- {
- stopServers();
-
- super.tearDown();
- }
-
protected boolean isNetty()
{
return false;
@@ -125,16 +117,4 @@
setupLiveServer(5, isFileStorage(), true, isNetty());
}
-
- protected void stopServers() throws Exception
- {
- closeAllConsumers();
-
- closeAllSessionFactories();
-
- closeAllServerLocatorsFactories();
-
- stopServers(0, 1, 2, 3, 4, 5);
- }
-
}
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusteredRequestResponseTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusteredRequestResponseTest.java 2011-07-22
13:56:49 UTC (rev 11022)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/distribution/ClusteredRequestResponseTest.java 2011-07-22
13:57:33 UTC (rev 11023)
@@ -36,14 +36,6 @@
setupServers();
}
- @Override
- protected void tearDown() throws Exception
- {
- stopServers();
-
- super.tearDown();
- }
-
protected boolean isNetty()
{
return false;
@@ -152,16 +144,4 @@
setupServer(3, isFileStorage(), isNetty());
setupServer(4, isFileStorage(), isNetty());
}
-
- protected void stopServers() throws Exception
- {
- closeAllConsumers();
-
- closeAllSessionFactories();
-
- closeAllServerLocatorsFactories();
-
- stopServers(0, 1, 2, 3, 4);
- }
-
}
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java 2011-07-22
13:56:49 UTC (rev 11022)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ClusterWithBackupFailoverTestBase.java 2011-07-22
13:57:33 UTC (rev 11023)
@@ -64,16 +64,6 @@
setupServers();
}
- @Override
- protected void tearDown() throws Exception
- {
- stopServers();
-
- // FailoverManagerImpl.disableDebug();
-
- super.tearDown();
- }
-
protected boolean isNetty()
{
return false;
@@ -180,10 +170,6 @@
removeConsumer(0);
removeConsumer(1);
removeConsumer(2);
-
- stopServers();
-
- ClusterWithBackupFailoverTestBase.log.info("*** test done");
}
private void waitForBindings() throws Exception
@@ -270,10 +256,6 @@
removeConsumer(0);
removeConsumer(1);
removeConsumer(2);
-
- stopServers();
-
- ClusterWithBackupFailoverTestBase.log.info("*** test done");
}
protected void setupCluster() throws Exception
@@ -281,17 +263,6 @@
setupCluster(false);
}
- protected void stopServers() throws Exception
- {
-
- closeAllServerLocatorsFactories();
- closeAllConsumers();
-
- closeAllSessionFactories();
-
- stopServers(0, 1, 2, 3, 4, 5);
- }
-
protected void failNode(final int node) throws Exception
{
ClusterWithBackupFailoverTestBase.log.info("*** failing node " + node);
@@ -447,9 +418,5 @@
removeConsumer(2);
failNode(5);
-
- stopServers();
-
- ClusterWithBackupFailoverTestBase.log.info("*** test done");
}
}
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java 2011-07-22
13:56:49 UTC (rev 11022)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/GroupingFailoverTestBase.java 2011-07-22
13:57:33 UTC (rev 11023)
@@ -12,12 +12,6 @@
*/
package org.hornetq.tests.integration.cluster.failover;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.Assert;
-
-import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
import org.hornetq.core.client.impl.Topology;
@@ -25,7 +19,6 @@
import org.hornetq.core.server.NodeManager;
import org.hornetq.core.server.group.impl.GroupingHandlerConfiguration;
import org.hornetq.core.server.impl.InVMNodeManager;
-import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.tests.integration.cluster.distribution.ClusterTestBase;
/**
@@ -56,9 +49,6 @@
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 2);
-
- try
- {
startServers(0, 2, 1);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -102,18 +92,7 @@
System.out.println("*****************************************************************************");
}
- finally
- {
- closeAllConsumers();
- closeAllSessionFactories();
-
- closeAllServerLocatorsFactories();
-
- stopServers(0, 1, 2);
- }
- }
-
public void testGroupingLocalHandlerFailsMultipleGroups() throws Exception
{
NodeManager nodeManager = new InVMNodeManager();
@@ -138,8 +117,6 @@
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 2);
- try
- {
startServers(0, 2, 1);
setupSessionFactory(0, isNetty());
@@ -203,17 +180,6 @@
verifyReceiveAllWithGroupIDRoundRobin(2, 30, 1, 2);
System.out.println("*****************************************************************************");
- }
- finally
- {
- closeAllConsumers();
-
- closeAllSessionFactories();
-
- closeAllServerLocatorsFactories();
-
- stopServers(0, 1, 2);
- }
}
private void waitForServerTopology(HornetQServer server, int nodes, int seconds)
@@ -238,16 +204,4 @@
abstract boolean isSharedServer();
- private void fail(final RemotingConnection conn, final CountDownLatch latch) throws
InterruptedException
- {
- // Simulate failure on connection
- conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));
-
- // Wait to be informed of failure
-
- boolean ok = latch.await(1000, TimeUnit.MILLISECONDS);
-
- Assert.assertTrue(ok);
- }
-
}
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2011-07-22
13:56:49 UTC (rev 11022)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/LargeMessageFailoverTest.java 2011-07-22
13:57:33 UTC (rev 11023)
@@ -73,12 +73,14 @@
public void testLiveAndBackupLiveComesBackNewFactory() throws Exception
{
// skip test because it triggers OutOfMemoryError.
+ Thread.sleep(1000);
}
@Override
public void testLiveAndBackupBackupComesBackNewFactory() throws Exception
{
// skip test because it triggers OutOfMemoryError.
+ Thread.sleep(1000);
}
/**
Modified:
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java
===================================================================
---
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java 2011-07-22
13:56:49 UTC (rev 11022)
+++
branches/HORNETQ-720_Replication/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/ReplicatedDistributionTest.java 2011-07-22
13:57:33 UTC (rev 11023)
@@ -289,18 +289,4 @@
{
return false;
}
-
- @Override
- protected void tearDown() throws Exception
- {
- servers[2].stop();
- servers[1].stop();
- servers[3].stop();
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}