[Neo-report] r2830 jm - in /trunk/neo/tests: ./ storage/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Sep 7 16:33:38 CEST 2011


Author: jm
Date: Wed Sep  7 16:33:38 2011
New Revision: 2830

Log:
tests: fix resource leak in storage unit tests

MySQL connections remained open, which even led to deadlocks with MySQL 5.5

Modified:
    trunk/neo/tests/storage/testClientHandler.py
    trunk/neo/tests/storage/testIdentificationHandler.py
    trunk/neo/tests/storage/testInitializationHandler.py
    trunk/neo/tests/storage/testMasterHandler.py
    trunk/neo/tests/storage/testStorageApp.py
    trunk/neo/tests/storage/testStorageDBTests.py
    trunk/neo/tests/storage/testVerificationHandler.py
    trunk/neo/tests/testBootstrap.py

Modified: trunk/neo/tests/storage/testClientHandler.py
==============================================================================
--- trunk/neo/tests/storage/testClientHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testClientHandler.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -56,6 +56,11 @@ class StorageClientHandlerTests(NeoUnitT
         self.app.primary_master_node = pmn
         self.master_port = 10010
 
+    def tearDown(self):
+        self.app.close()
+        del self.app
+        super(StorageClientHandlerTests, self).tearDown()
+
     def _getConnection(self, uuid=None):
         return self.getFakeConnection(uuid=uuid, address=('127.0.0.1', 1000))
 

Modified: trunk/neo/tests/storage/testIdentificationHandler.py
==============================================================================
--- trunk/neo/tests/storage/testIdentificationHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testIdentificationHandler.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -35,6 +35,11 @@ class StorageIdentificationHandlerTests(
         self.app.pt = PartitionTable(4, 1)
         self.identification = IdentificationHandler(self.app)
 
+    def tearDown(self):
+        self.app.close()
+        del self.app
+        super(StorageIdentificationHandlerTests, self).tearDown()
+
     def test_requestIdentification1(self):
         """ nodes are rejected during election or if unknown storage """
         self.app.ready = False

Modified: trunk/neo/tests/storage/testInitializationHandler.py
==============================================================================
--- trunk/neo/tests/storage/testInitializationHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testInitializationHandler.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -43,6 +43,11 @@ class StorageInitializationHandlerTests(
         self.app.load_lock_dict = {}
         self.app.pt = PartitionTable(self.num_partitions, self.num_replicas)
 
+    def tearDown(self):
+        self.app.close()
+        del self.app
+        super(StorageInitializationHandlerTests, self).tearDown()
+
     # Common methods
     def getLastUUID(self):
         return self.uuid

Modified: trunk/neo/tests/storage/testMasterHandler.py
==============================================================================
--- trunk/neo/tests/storage/testMasterHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testMasterHandler.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -53,6 +53,11 @@ class StorageMasterHandlerTests(NeoUnitT
         self.app.primary_master_node = pmn
         self.master_port = 10010
 
+    def tearDown(self):
+        self.app.close()
+        del self.app
+        super(StorageMasterHandlerTests, self).tearDown()
+
     def getMasterConnection(self):
         address = ("127.0.0.1", self.master_port)
         return self.getFakeConnection(uuid=self.master_uuid, address=address)

Modified: trunk/neo/tests/storage/testStorageApp.py
==============================================================================
--- trunk/neo/tests/storage/testStorageApp.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testStorageApp.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -36,6 +36,11 @@ class StorageAppTests(NeoUnitTestBase):
         self.app.event_queue = deque()
         self.app.event_queue_dict = {}
 
+    def tearDown(self):
+        self.app.close()
+        del self.app
+        super(StorageAppTests, self).tearDown()
+
     def test_01_loadPartitionTable(self):
         self.app.dm = Mock({
             'getPartitionTable': [],

Modified: trunk/neo/tests/storage/testStorageDBTests.py
==============================================================================
--- trunk/neo/tests/storage/testStorageDBTests.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testStorageDBTests.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -40,7 +40,7 @@ class StorageDBTests(NeoUnitTestBase):
 
     def tearDown(self):
         try:
-            del self._db
+            self.__dict__.pop('_db', None).close()
         except AttributeError:
             pass
         NeoUnitTestBase.tearDown(self)

Modified: trunk/neo/tests/storage/testVerificationHandler.py
==============================================================================
--- trunk/neo/tests/storage/testVerificationHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testVerificationHandler.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -44,6 +44,11 @@ class StorageVerificationHandlerTests(Ne
         self.app.load_lock_dict = {}
         self.app.pt = PartitionTable(self.num_partitions, self.num_replicas)
 
+    def tearDown(self):
+        self.app.close()
+        del self.app
+        super(StorageVerificationHandlerTests, self).tearDown()
+
     # Common methods
     def getLastUUID(self):
         return self.uuid

Modified: trunk/neo/tests/testBootstrap.py
==============================================================================
--- trunk/neo/tests/testBootstrap.py [iso-8859-1] (original)
+++ trunk/neo/tests/testBootstrap.py [iso-8859-1] Wed Sep  7 16:33:38 2011
@@ -37,6 +37,11 @@ class BootstrapManagerTests(NeoUnitTestB
         self.num_partitions = 1009
         self.num_replicas = 2
 
+    def tearDown(self):
+        self.app.close()
+        del self.app
+        super(BootstrapManagerTests, self).tearDown()
+
     # Common methods
     def getLastUUID(self):
         return self.uuid




More information about the Neo-report mailing list