From b70cd55cc5ed379017c7ec18dab1415e4004b51a Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 31 Jan 2012 12:52:16 -0500 Subject: [PATCH] Be more explicit about emptying connection pool. This patch makes some code in test_qpid be more explicit about emptying the connection pool. It now ensures that it removes exactly how many connections are in the pool. The previous code made a couple of assumptions. First, it assumed that only one connection was in the pool (which is true, but it's still nice not to make the assumption here in the cleanup code). Second, it assumed that free() returned the number of connections that have been placed in the pool. This is not correct. The result also includes the number of connections that could be created based on the max size of the pool. Use the free_items attribute instead, which gives the exact number of connections that have been put() in the pool. Change-Id: I97378919c2d3e68f224862f07a75529575647163 --- nova/tests/rpc/test_qpid.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/tests/rpc/test_qpid.py b/nova/tests/rpc/test_qpid.py index b08c7b96d..0417674b8 100644 --- a/nova/tests/rpc/test_qpid.py +++ b/nova/tests/rpc/test_qpid.py @@ -186,7 +186,7 @@ class RpcQpidTestCase(test.TestCase): self.mocker.VerifyAll() finally: - if rpc_amqp.ConnectionContext._connection_pool.free(): + while rpc_amqp.ConnectionContext._connection_pool.free_items: # Pull the mock connection object out of the connection pool so # that it doesn't mess up other test cases. rpc_amqp.ConnectionContext._connection_pool.get() @@ -261,7 +261,7 @@ class RpcQpidTestCase(test.TestCase): self.mocker.VerifyAll() finally: - if rpc_amqp.ConnectionContext._connection_pool.free(): + while rpc_amqp.ConnectionContext._connection_pool.free_items: # Pull the mock connection object out of the connection pool so # that it doesn't mess up other test cases. rpc_amqp.ConnectionContext._connection_pool.get()