summaryrefslogtreecommitdiff
path: root/lib/ldb/tests/python/api.py
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2017-06-16 15:49:16 +1200
committerStefan Metzmacher <metze@samba.org>2017-07-02 17:35:19 +0200
commitb8b8439f1a7213d03e251ddc0279ae8a2be414d3 (patch)
treeb89841288215da8589cc7fca076fa2a93a5f9249 /lib/ldb/tests/python/api.py
parent6d7208c36fcf104eb07405e1d02e3e167efd854d (diff)
downloadsamba-b8b8439f1a7213d03e251ddc0279ae8a2be414d3.tar.gz
samba-b8b8439f1a7213d03e251ddc0279ae8a2be414d3.tar.bz2
samba-b8b8439f1a7213d03e251ddc0279ae8a2be414d3.zip
ldb:tests: Extend api.py testsuite to show transaction_commit() blocks against the whole-db read lock
The new ldb whole-db lock behaviour now allows this test Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/ldb/tests/python/api.py')
-rwxr-xr-xlib/ldb/tests/python/api.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py
index f9999baeb9a..0c3b20e28ad 100755
--- a/lib/ldb/tests/python/api.py
+++ b/lib/ldb/tests/python/api.py
@@ -1393,16 +1393,13 @@ class LdbResultTests(TestCase):
(r2, w2) = os.pipe()
- l = next(res)
- if str(l.dn) == "OU=OU10,DC=SAMBA,DC=ORG":
- found = True
-
# For the first element, with the sequence open (which
# means with ldb locks held), fork a child that will
# write to the DB
pid = os.fork()
if pid == 0:
# In the child, re-open
+ del(res)
del(self.l)
gc.collect()
@@ -1439,25 +1436,26 @@ class LdbResultTests(TestCase):
os.write(w2, b"search")
- # Now wait for the transaction to be done. This should
- # deadlock, but the search doesn't hold a read lock for the
- # iterator lifetime currently.
- self.assertEqual(os.read(r1, 11), b"transaction")
+ # allow the transaction to start
+ time.sleep(1)
# This should not turn up until the search finishes and
# removed the read lock, but for ldb_tdb that happened as soon
# as we called the first res.next()
res11 = self.l.search(base="OU=OU11,DC=SAMBA,DC=ORG",
scope=ldb.SCOPE_BASE)
- self.assertEqual(len(res11), 1)
+ self.assertEqual(len(res11), 0)
- # These results were actually collected at the first next(res) call
+ # These results are all collected at the first next(res) call
for l in res:
if str(l.dn) == "OU=OU10,DC=SAMBA,DC=ORG":
found = True
if str(l.dn) == "OU=OU11,DC=SAMBA,DC=ORG":
found11 = True
+ # Now wait for the transaction to be done.
+ self.assertEqual(os.read(r1, 11), b"transaction")
+
# This should now turn up, as the transaction is over and all
# read locks are gone
res11 = self.l.search(base="OU=OU11,DC=SAMBA,DC=ORG",