From 248b21aed2d7aa3181802f73033aa8206d0ed828 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Thu, 27 Jan 2011 12:37:51 +0000 Subject: QPID-3013: use an equation based delta threshold that takes processor count into consideration git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1064108 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/unit/client/connection/ConnectionCloseTest.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'java') diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java index 8f9eaf5815..6d1b6de238 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java @@ -45,10 +45,6 @@ public class ConnectionCloseTest extends QpidBrokerTestCase public void testSendReceiveClose() throws Exception { - //Create an initial connection to ensure any necessary thread pools - //are initialised before the test really begins. - Connection intialConnection = getConnection(); - Map before = Thread.getAllStackTraces(); for (int i = 0; i < 50; i++) @@ -76,8 +72,6 @@ public class ConnectionCloseTest extends QpidBrokerTestCase assertEquals(m.getText(), "test"); receiver.close(); } - - intialConnection.close(); // The finalizer is notifying connector thread waiting on a selector key. // This should leave the finalizer enough time to notify those threads @@ -87,7 +81,7 @@ public class ConnectionCloseTest extends QpidBrokerTestCase } Map after = Thread.getAllStackTraces(); - + Map delta = new HashMap(after); for (Thread t : before.keySet()) { @@ -96,9 +90,12 @@ public class ConnectionCloseTest extends QpidBrokerTestCase dumpStacks(delta); + int deltaThreshold = (isExternalBroker()? 1 : 2) //InVM creates more thread pools in the same VM + * (Runtime.getRuntime().availableProcessors() + 1) + 5; + assertTrue("Spurious thread creation exceeded threshold, " + delta.size() + " threads created.", - delta.size() < 10); + delta.size() < deltaThreshold); } private void dumpStacks(Map map) -- cgit v1.2.1