Author: borges
Date: 2011-11-08 11:33:21 -0500 (Tue, 08 Nov 2011)
New Revision: 11673
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/replication/ReplicationTest.java
Log:
Fix ReplicationTest.testNoActions()
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java 2011-11-08
16:33:01 UTC (rev 11672)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/BackupSyncJournalTest.java 2011-11-08
16:33:21 UTC (rev 11673)
@@ -65,12 +65,12 @@
backupServer.start();
// Deliver messages with Backup in-sync
- waitForBackup(sessionFactory, BACKUP_WAIT_TIME, false);
+ waitForBackup(sessionFactory, BACKUP_WAIT_TIME, false, backupServer.getServer());
sendMessages(session, producer, n_msgs);
// Deliver messages with Backup up-to-date
syncDelay.deliverUpToDateMsg();
- waitForBackup(sessionFactory, BACKUP_WAIT_TIME, true);
+ waitForBackup(sessionFactory, BACKUP_WAIT_TIME, true, backupServer.getServer());
// SEND more messages, now with the backup replicating
sendMessages(session, producer, n_msgs);
@@ -114,14 +114,14 @@
{
syncDelay.deliverUpToDateMsg();
backupServer.start();
- waitForBackup(sessionFactory, BACKUP_WAIT_TIME, true);
+ waitForBackup(sessionFactory, BACKUP_WAIT_TIME, true, backupServer.getServer());
}
public void testReplicationDuringSync() throws Exception
{
createProducerSendSomeMessages();
backupServer.start();
- waitForBackup(sessionFactory, BACKUP_WAIT_TIME, false);
+ waitForBackup(sessionFactory, BACKUP_WAIT_TIME, false, backupServer.getServer());
sendMessages(session, producer, n_msgs);
session.commit();
@@ -136,7 +136,7 @@
private void finishSyncAndFailover() throws Exception
{
syncDelay.deliverUpToDateMsg();
- waitForBackup(sessionFactory, BACKUP_WAIT_TIME, true);
+ waitForBackup(sessionFactory, BACKUP_WAIT_TIME, true, backupServer.getServer());
assertFalse("should not be initialized",
backupServer.getServer().isInitialised());
crash(session);
waitForServerInitialization(backupServer, 5);
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-11-08
16:33:01 UTC (rev 11672)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/cluster/failover/FailoverTestBase.java 2011-11-08
16:33:21 UTC (rev 11673)
@@ -38,6 +38,7 @@
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;
@@ -287,30 +288,36 @@
* @param seconds
* @throws Exception
*/
- protected void waitForBackup(ClientSessionFactoryInternal sessionFactory, long
seconds) throws Exception
+ protected void waitForBackup(ClientSessionFactoryInternal sessionFactory, int seconds)
throws Exception
{
- waitForBackup(sessionFactory, seconds, true);
- }
+ final HornetQServerImpl actualServer =
(HornetQServerImpl)backupServer.getServer();
+ waitForBackup(sessionFactory, seconds, true, actualServer);
+ }
/**
* @param sessionFactory
* @param seconds
- * @param waitForSync whether to wait for sync'ing data with the live to finish or
not
+ * @param waitForSync
+ * @param actualServer
*/
- protected void waitForBackup(ClientSessionFactoryInternal sessionFactory, long
seconds, boolean waitForSync)
+ public static void waitForBackup(ClientSessionFactoryInternal sessionFactory,
+ int seconds,
+ boolean waitForSync,
+ final HornetQServer backup)
{
+ final HornetQServerImpl actualServer = (HornetQServerImpl)backup;
final long toWait = seconds * 1000;
final long time = System.currentTimeMillis();
- final HornetQServerImpl actualServer =
(HornetQServerImpl)backupServer.getServer();
while (true)
{
- if (sessionFactory.getBackupConnector() != null &&
(actualServer.isRemoteBackupUpToDate() || !waitForSync))
+ if ((sessionFactory == null || sessionFactory.getBackupConnector() != null)
&&
+ (actualServer.isRemoteBackupUpToDate() || !waitForSync))
{
break;
}
if (System.currentTimeMillis() > (time + toWait))
{
- fail("backup server never started (" + backupServer.isStarted() +
"), or never finished synchronizing (" +
+ fail("backup server never started (" + actualServer.isStarted() +
"), or never finished synchronizing (" +
actualServer.isRemoteBackupUpToDate() + ")");
}
try
Modified:
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/replication/ReplicationTest.java
===================================================================
---
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/replication/ReplicationTest.java 2011-11-08
16:33:01 UTC (rev 11672)
+++
trunk/tests/integration-tests/src/test/java/org/hornetq/tests/integration/replication/ReplicationTest.java 2011-11-08
16:33:21 UTC (rev 11673)
@@ -75,6 +75,7 @@
import org.hornetq.core.settings.HierarchicalRepository;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.spi.core.protocol.RemotingConnection;
+import org.hornetq.tests.integration.cluster.failover.FailoverTestBase;
import org.hornetq.tests.util.ReplicatedBackupUtils;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.TransportConfigurationUtils;
@@ -114,6 +115,7 @@
Configuration backupConfig = createDefaultConfig(netty);
Configuration liveConfig = createDefaultConfig(netty);
+
backupConfig.setBackup(backup);
if (interceptors.length > 0)
{
@@ -431,6 +433,7 @@
StorageManager storage = getStorage();
manager = liveServer.getReplicationManager();
waitForComponent(manager);
+ FailoverTestBase.waitForBackup(null, 5, true, backupServer);
Journal replicatedJournal = new ReplicatedJournal((byte)1, new FakeJournal(),
manager);
@@ -452,7 +455,7 @@
Assert.assertTrue(latch.await(1, TimeUnit.SECONDS));
- Assert.assertEquals(0, manager.getActiveTokens().size());
+ Assert.assertEquals("should be empty " + manager.getActiveTokens(), 0,
manager.getActiveTokens().size());
}
public void testOrderOnNonPersistency() throws Exception