Commit 155835df authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a436e928
......@@ -19,6 +19,8 @@
# See https://www.nexedi.com/licensing for rationale and options.
"""test wcfs filesystem from outside as python client process"""
from __future__ import print_function
from wendelin.lib.testing import getTestDB
from wendelin.lib.zodb import dbclose
from wendelin.lib.mem import memcpy
......@@ -132,11 +134,7 @@ class tDB:
t.wc.close()
dbclose(t.root)
# commit commits transaction and remembers/returns committed tid.
#
# it also stores:
#
# .head - last committed transaction ID
# commit commits transaction and remembers/returns committed transaction ID.
def commit(t):
# NOTE there is no clean way to retrieve tid of just committed transaction
# we are using last._p_serial as workaround.
......@@ -144,7 +142,7 @@ class tDB:
last._p_changed = 1
transaction.commit()
head = last._p_serial
print 'commit -> %s' % h(head)
#print('commit -> %s' % h(head))
t.head = head
t._headv.append(head)
return head
......@@ -161,7 +159,8 @@ class tDB:
raise RuntimeError("wcsync #%d: wczhead (%s) != zhead (%s)" % (i, wchead, t._headv[i]))
t._wc_zheadv.append(wchead)
# XXX test
# XXX text ...
# XXX parametrize zblk0, zblk1 XXX or just rely on tox?
@func
def test_wcfs():
......@@ -171,51 +170,6 @@ def test_wcfs():
t.root['obj'] = nonfile = Persistent()
t.root['zfile'] = f = ZBigFile(blksize)
"""
root = testdb.dbopen()
defer(lambda: dbclose(root))
wc = wcfs.join(testzurl, autostart=True)
defer(wc.close)
# commit commits transaction and remembers/returns committed tid.
#
# NOTE there is no clean way to retrieve tid of just committed transaction
# we'll be using last._p_serial as workaround.
#
# we also store:
#
# Z.head - last committed transaction ID
# Z.tidv - [] of all committed tid↑
root['last'] = last = Persistent()
class _: pass
Z = _()
Z.tidv = []
def commit():
last._p_changed = 1
transaction.commit()
tid = last._p_serial
print 'commit -> %s' % h(tid)
Z.head = tid
Z.tidv.append(tid)
return tid
# wcsync makes sure wc synchronized to latest committed transaction
Z.wctidv = []
wc_zhead = open(wc.mountpoint + "/.wcfs/zhead")
defer(wc_zhead.close)
def wcsync():
while len(Z.wctidv) < len(Z.tidv):
l = wc_zhead.readline()
#print '> zhead read: %r' % l
l = l.rstrip('\n')
wctid = fromhex(l)
i = len(Z.wctidv)
if wctid != Z.tidv[i]:
raise RuntimeError("wcsync #%d: Z.wctid (%s) != Z.tid (%s)" % (i, wctid, Z.tidv[i]))
Z.wctidv.append(wctid)
"""
tid1 = t.commit()
tid2 = t.commit()
assert tidtime(tid2) > tidtime(tid1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment