Skip to content
Browse files

test must wait for backup's to be in-sync (problem cause found by Cle…

…bert)

Otherwise it might hang given our default test configs.
  • Loading branch information...
1 parent 5eab218 commit c0e1c83cd7e11036f549c1a7eb6bf2d73b28fb58 Francisco Borges committed Nov 14, 2012
View
44 hornetq-server/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
@@ -355,6 +355,50 @@ protected void waitForServer(HornetQServer server) throws InterruptedException
}
}
+ /**
+ * @param backup
+ */
+ public static final void waitForRemoteBackupSynchronization(final HornetQServer backup)
+ {
+ waitForRemoteBackup(null, 10, true, backup);
+ }
+
+ /**
+ * @param sessionFactory
+ * @param seconds
+ * @param waitForSync
+ * @param backup
+ */
+ public static final void waitForRemoteBackup(ClientSessionFactoryInternal sessionFactory, int seconds,
+ boolean waitForSync, final HornetQServer backup)
+ {
+ final HornetQServerImpl actualServer = (HornetQServerImpl)backup;
+ final long toWait = seconds * 1000;
+ final long time = System.currentTimeMillis();
+ while (true)
+ {
+ if ((sessionFactory == null || sessionFactory.getBackupConnector() != null) &&
+ (actualServer.isRemoteBackupUpToDate() || !waitForSync))
+ {
+ break;
+ }
+ if (System.currentTimeMillis() > (time + toWait))
+ {
+ fail("backup started? (" + actualServer.isStarted() + "). Finished synchronizing (" +
+ actualServer.isRemoteBackupUpToDate() + "). SessionFactory!=null ? " + (sessionFactory != null) +
+ " || sessionFactory.getBackupConnector()==" +
+ (sessionFactory != null ? sessionFactory.getBackupConnector() : "not-applicable"));
+ }
+ try
+ {
+ Thread.sleep(100);
+ }
+ catch (InterruptedException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+ }
protected final HornetQServer
createServer(final boolean realFiles,
View
40 ...-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
@@ -37,7 +37,6 @@
import org.hornetq.core.config.Configuration;
import org.hornetq.core.remoting.impl.invm.InVMConnector;
import org.hornetq.core.remoting.impl.invm.InVMRegistry;
-import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.NodeManager;
import org.hornetq.core.server.impl.HornetQServerImpl;
import org.hornetq.core.server.impl.InVMNodeManager;
@@ -298,46 +297,9 @@ protected void waitForBackup(ClientSessionFactoryInternal sessionFactory, int se
}
}
- /**
- * @param sessionFactory
- * @param seconds
- * @param waitForSync
- * @param backup
- */
- public static void waitForRemoteBackup(ClientSessionFactoryInternal sessionFactory, int seconds,
- boolean waitForSync, final HornetQServer backup)
- {
- final HornetQServerImpl actualServer = (HornetQServerImpl)backup;
- final long toWait = seconds * 1000;
- final long time = System.currentTimeMillis();
- while (true)
- {
- if ((sessionFactory == null || sessionFactory.getBackupConnector() != null) &&
- (actualServer.isRemoteBackupUpToDate() || !waitForSync))
- {
- break;
- }
- if (System.currentTimeMillis() > (time + toWait))
- {
- fail("backup started? (" + actualServer.isStarted() + "). Finished synchronizing (" +
- actualServer.isRemoteBackupUpToDate() + "). SessionFactory!=null ? " +
- (sessionFactory != null) + " || sessionFactory.getBackupConnector()==" +
- (sessionFactory != null ? sessionFactory.getBackupConnector() : "not-applicable"));
- }
- try
- {
- Thread.sleep(100);
- }
- catch (InterruptedException e)
- {
- fail(e.getMessage());
- }
- }
- }
-
protected abstract TransportConfiguration getAcceptorTransportConfiguration(boolean live);
- protected abstract TransportConfiguration getConnectorTransportConfiguration(final boolean live);
+ protected abstract TransportConfiguration getConnectorTransportConfiguration(final boolean live);
protected ServerLocatorInternal getServerLocator() throws Exception
{
View
18 .../tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java
@@ -21,7 +21,11 @@
*/
package org.hornetq.tests.integration.cluster.failover;
+import java.util.ArrayList;
+import java.util.List;
+
import junit.framework.Assert;
+
import org.hornetq.api.core.client.ClientConsumer;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ClientProducer;
@@ -30,15 +34,12 @@
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.tests.integration.cluster.util.TestableServer;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
- * 8/6/12
*/
public class ReplicatedMultipleServerFailoverExtraBackupsTest extends ReplicatedMultipleServerFailoverTest
{
+ @Override
public void testStartLiveFirst() throws Exception
{
backupServers.get(2).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-0");
@@ -50,12 +51,15 @@ public void testStartLiveFirst() throws Exception
for (TestableServer backupServer : backupServers)
{
backupServer.start();
+ waitForRemoteBackupSynchronization(backupServer.getServer());
}
+
sendCrashReceive();
waitForTopology(backupServers.get(0).getServer(), liveServers.size(), 2);
sendCrashBackupReceive();
}
+ @Override
public void testStartBackupFirst() throws Exception
{
backupServers.get(2).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-0");
@@ -69,6 +73,12 @@ public void testStartBackupFirst() throws Exception
{
liveServer.start();
}
+
+ for (TestableServer backupServer : backupServers)
+ {
+ waitForRemoteBackupSynchronization(backupServer.getServer());
+ }
+
waitForTopology(liveServers.get(0).getServer(), liveServers.size(), 2);
sendCrashReceive();
}

0 comments on commit c0e1c83

Please sign in to comment.
Something went wrong with that request. Please try again.