From f6c381009bf361da1aac318981e24293c8ea688c Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Fri, 15 Jul 2011 10:26:24 +0000 Subject: QPID-3359: revert testNoFailover to run in same-vm profiles only Applied patch by Keith Wall git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1147076 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/failover/FailoverMethodTest.java | 36 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'java') diff --git a/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java b/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java index 35650e314a..11db513e00 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java @@ -159,19 +159,34 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL */ public void testNoFailover() throws Exception { + if (!isInternalBroker()) + { + // QPID-3359 + // These tests always used to be inVM tests, then QPID-2815, with removal of ivVM, + // converted the test to use QpidBrokerTestCase. However, since then we notice this + // test fails on slower CI boxes. It turns out the test design is *extremely* + // sensitive the length of time the broker takes to start up. + // + // Making the test a same-VM test to temporarily avoid the issue. In long term, test + // needs redesigned to avoid the issue. + return; + } + int CONNECT_DELAY = 2000; String connectionString = "amqp://guest:guest@/test?brokerlist='tcp://localhost:" + getPort() + "?connectdelay='" + CONNECT_DELAY + "'," + "retries='3'',failover='nofailover'"; + AMQConnectionURL url = new AMQConnectionURL(connectionString); + Thread brokerStart = null; try { //Kill initial broker stopBroker(); //Create a thread to start the broker asynchronously - Thread brokerStart = new Thread(new Runnable() + brokerStart = new Thread(new Runnable() { public void run() { @@ -194,7 +209,6 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL brokerStart.start(); long start = System.currentTimeMillis(); - //Start the connection so it will use the retries AMQConnection connection = new AMQConnection(url, null); @@ -210,6 +224,7 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL //Ensure we collect the brokerStart thread brokerStart.join(); + brokerStart = null; start = System.currentTimeMillis(); @@ -233,6 +248,23 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL { fail(e.getMessage()); } + finally + { + // Guard against the case where the broker took too long to start + // and the initial connection failed to be formed. + if (brokerStart != null) + { + brokerStart.join(); + } + } + } + + public void stopBroker(int port) throws Exception + { + if (isBrokerPresent(port)) + { + super.stopBroker(port); + } } } -- cgit v1.2.1