ldb: Ensure we do not run out of File descriptors in autobuild
authorAndrew Bartlett <abartlet@samba.org>
Thu, 21 Sep 2017 02:15:32 +0000 (14:15 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:25 +0000 (21:20 +0200)
The python TestCase API will keep a reference to the test object until the end
of the tests, long after we need the actual LDB or the fd.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/ldb/tests/python/api.py

index ba9476a0e68f06a1f18fee5c0b36bc50aebfeb7d..14bbdcb1718897925eaa3ba67bcbb14d2c1e9cac 100755 (executable)
@@ -55,6 +55,9 @@ class SimpleLdb(TestCase):
     def tearDown(self):
         shutil.rmtree(self.testdir)
         super(SimpleLdb, self).tearDown()
+        # Ensure the LDB is closed now, so we close the FD
+        del(self.ldb)
+
 
     def test_connect(self):
         ldb.Ldb(self.filename)
@@ -610,6 +613,10 @@ class SearchTests(TestCase):
         shutil.rmtree(self.testdir)
         super(SearchTests, self).tearDown()
 
+        # Ensure the LDB is closed now, so we close the FD
+        del(self.l)
+
+
     def setUp(self):
         super(SearchTests, self).setUp()
         self.testdir = tempdir()
@@ -992,6 +999,9 @@ class AddModifyTests(TestCase):
         shutil.rmtree(self.testdir)
         super(AddModifyTests, self).tearDown()
 
+        # Ensure the LDB is closed now, so we close the FD
+        del(self.l)
+
     def setUp(self):
         super(AddModifyTests, self).setUp()
         self.testdir = tempdir()
@@ -1243,6 +1253,10 @@ class DnTests(TestCase):
         super(DnTests, self).setUp()
         self.ldb = ldb.Ldb()
 
+    def tearDown(self):
+        super(DnTests, self).tearDown()
+        del(self.ldb)
+
     def test_set_dn_invalid(self):
         x = ldb.Message()
         def assign():
@@ -1863,6 +1877,8 @@ class LdbResultTests(TestCase):
     def tearDown(self):
         shutil.rmtree(self.testdir)
         super(LdbResultTests, self).tearDown()
+        # Ensure the LDB is closed now, so we close the FD
+        del(self.l)
 
     def test_return_type(self):
         res = self.l.search()