diff options
| author | Robert Gemmell <robbie@apache.org> | 2009-10-13 11:40:03 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2009-10-13 11:40:03 +0000 |
| commit | 37808d6377cb46cc33e44e864508474fd2246592 (patch) | |
| tree | b61485b700802b7fbc5411e71221bbed2ecd8639 | |
| parent | 63b98517c5385f7ecea018b896b7c3355a1463f1 (diff) | |
| download | qpid-python-37808d6377cb46cc33e44e864508474fd2246592.tar.gz | |
QPID-1204: add temporary workaround for connection close race condition at tearDown() noted in QPID-2081 to allow enabling SimpleACLTest for java brokers. Update exclude lists accordingly, also removing a single-method exclude from the 010Excludes file made redundant by the complete SimpleACLTest exclusion when using cpp brokers
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@824706 13f79535-47bb-0310-9956-ffa450edef68
4 files changed, 174 insertions, 7 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java index 940ccbd9f1..910682c2c1 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java @@ -34,6 +34,7 @@ import org.apache.qpid.url.URLSyntaxException; import javax.jms.Connection; import javax.jms.DeliveryMode; +import javax.jms.ExceptionListener; import javax.jms.IllegalStateException; import javax.jms.JMSException; import javax.jms.Message; @@ -45,6 +46,8 @@ import javax.jms.TextMessage; import javax.naming.NamingException; import java.io.File; import java.io.IOException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class SimpleACLTest extends QpidTestCase implements ConnectionListener { @@ -136,10 +139,23 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("guest", "guest"); + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + + Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); @@ -155,6 +171,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener assertNotNull("There was no liked exception", cause); assertEquals("Wrong linked exception type", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code received", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -184,6 +205,10 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("client", "guest"); @@ -191,6 +216,14 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener //Prevent Failover ((AMQConnection) conn).setConnectionListener(this); + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); @@ -206,6 +239,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener assertNotNull("There was no liked exception", cause); assertEquals("Wrong linked exception type", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code received", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -237,6 +275,10 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("client", "guest"); @@ -245,6 +287,14 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener conn.start(); + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + //Create a Named Queue ((AMQSession) sesh).createQueue(new AMQShortString("IllegalQueue"), false, false, false); @@ -255,6 +305,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { amqe.printStackTrace(); assertEquals("Incorrect error code thrown", 403, ((AMQAuthenticationException) amqe).getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -323,11 +378,23 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("client", "guest"); ((AMQConnection) conn).setConnectionListener(this); + + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -363,6 +430,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener } assertEquals("Incorrect exception", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code thrown", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -392,10 +464,22 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("client", "guest"); + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); @@ -412,6 +496,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener assertNotNull("There was no liked exception", cause); assertEquals("Wrong linked exception type", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code received", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -419,10 +508,22 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("server", "guest"); + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); @@ -438,6 +539,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener assertNotNull("There was no liked exception", cause); assertEquals("Wrong linked exception type", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code received", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -479,10 +585,22 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("server", "guest"); + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); @@ -496,6 +614,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener catch (AMQAuthenticationException amqe) { assertEquals("Incorrect error code thrown", 403, amqe.getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -503,10 +626,22 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("server", "guest"); + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); conn.start(); @@ -523,6 +658,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener assertNotNull("There was no liked exception", cause); assertEquals("Wrong linked exception type", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code received", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -530,11 +670,23 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + Connection connection = null; try { connection = getConnection("server", "guest"); + connection.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); @@ -548,6 +700,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener catch (AMQAuthenticationException amqe) { assertEquals("Incorrect error code thrown", 403, amqe.getErrorCode().getCode()); + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } @@ -645,9 +802,21 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener { setUpACLTest(); + //QPID-2081: use a latch to sync on exception causing connection close, to work + //around the connection close race during tearDown() causing sporadic failures + final CountDownLatch exceptionReceived = new CountDownLatch(1); + try { Connection conn = getConnection("server", "guest"); + + conn.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + exceptionReceived.countDown(); + } + }); ((AMQConnection) conn).setConnectionListener(this); @@ -691,6 +860,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener assertEquals("Incorrect exception", AMQAuthenticationException.class, cause.getClass()); assertEquals("Incorrect error code thrown", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode()); } + + //use the latch to ensure the control thread waits long enough for the exception thread + //to have done enough to mark the connection closed before teardown commences + assertTrue("Timed out waiting for conneciton to report close", + exceptionReceived.await(2, TimeUnit.SECONDS)); } } diff --git a/qpid/java/test-profiles/010Excludes b/qpid/java/test-profiles/010Excludes index 757a1e425c..454aede07e 100755 --- a/qpid/java/test-profiles/010Excludes +++ b/qpid/java/test-profiles/010Excludes @@ -75,9 +75,6 @@ org.apache.qpid.server.AlertingTest#* // The C++ server has a totally different persistence mechanism org.apache.qpid.server.store.PersistentStoreTest#* -// QPID-1225 : Temporary remove this test until the problem has been addressed -org.apache.qpid.server.security.acl.SimpleACLTest#testClientPublishInvalidQueueSuccess - // CPP Broker does not follow the same Logging convention as the Java broker org.apache.qpid.server.logging.* diff --git a/qpid/java/test-profiles/08StandaloneExcludes b/qpid/java/test-profiles/08StandaloneExcludes index ee781fb80f..ed12973498 100644 --- a/qpid/java/test-profiles/08StandaloneExcludes +++ b/qpid/java/test-profiles/08StandaloneExcludes @@ -23,7 +23,6 @@ org.apache.qpid.test.client.failover.FailoverTest#* // InVM Broker tests awaiting resolution of QPID-1103 org.apache.qpid.test.client.timeouts.SyncWaitDelayTest#* org.apache.qpid.test.client.timeouts.SyncWaitTimeoutDelayTest#* -org.apache.qpid.server.security.acl.SimpleACLTest#* // Those tests are written against the 0.10 path org.apache.qpid.test.unit.message.UTF8Test#* diff --git a/qpid/java/test-profiles/Excludes b/qpid/java/test-profiles/Excludes index aa60554c04..c9c9e91836 100644 --- a/qpid/java/test-profiles/Excludes +++ b/qpid/java/test-profiles/Excludes @@ -17,9 +17,6 @@ org.apache.qpid.server.logging.MemoryMessageStoreLoggingTest#testMessageStoreClo // QPID-XXX : Test fails to start external broker due to Derby Exception. org.apache.qpid.server.logging.DerbyMessageStoreLoggingTest#* -// QPID-2081 :The configuration changes are now highlighting the close race condition -org.apache.qpid.server.security.acl.SimpleACLTest#* - // QPID-1816 : Client Ack has not been addressed org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverOnMessageTest#testDirtyClientAck org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverOnMessageTest#testClientAck |
