Commit c07d771b authored by Kirill Smelkov's avatar Kirill Smelkov

wcfs: tests: Simplify syncing WCFS to database in tDB.commit

tDB.commit always creates only one transaction and so wcfs should be
expected to catch up with only that single one -> no need to loop.

No need to keep tDB._wc_zheadv as we have information about all
committed transactions in t.dFtail.
parent 1de68556
...@@ -416,7 +416,6 @@ class tDB(tWCFS): ...@@ -416,7 +416,6 @@ class tDB(tWCFS):
# fh(.wcfs/zhead) + history of zhead read from there # fh(.wcfs/zhead) + history of zhead read from there
t._wc_zheadfh = open(t.wc.mountpoint + "/.wcfs/zhead") t._wc_zheadfh = open(t.wc.mountpoint + "/.wcfs/zhead")
t._wc_zheadv = []
# whether head/ ZBigFile(s) blocks were ever accessed via wcfs. # whether head/ ZBigFile(s) blocks were ever accessed via wcfs.
# this is updated only explicitly via ._blkheadaccess() . # this is updated only explicitly via ._blkheadaccess() .
...@@ -494,16 +493,14 @@ class tDB(tWCFS): ...@@ -494,16 +493,14 @@ class tDB(tWCFS):
head = t._commit(zf, changeDelta) head = t._commit(zf, changeDelta)
# make sure wcfs is synchronized to committed transaction # make sure wcfs is synchronized to committed transaction
while len(t._wc_zheadv) < len(t.dFtail): l = t._wc_zheadfh.readline()
l = t._wc_zheadfh.readline() #print('> zhead read: %r' % l)
#print('> zhead read: %r' % l) l = l.rstrip('\n')
l = l.rstrip('\n') wchead = tAt(t, fromhex(l))
wchead = tAt(t, fromhex(l)) if wchead != t.dFtail[-1].rev:
i = len(t._wc_zheadv) raise RuntimeError("commit #%d: wcsync: wczhead (%s) != zhead (%s)" %
if wchead != t.dFtail[i].rev: (len(t.dFtail), wchead, t.dFtail[-1].rev))
raise RuntimeError("wcsync #%d: wczhead (%s) != zhead (%s)" % (i, wchead, t.dFtail[i].rev)) assert t.wc._read("head/at") == h(head)
t._wc_zheadv.append(wchead)
assert t.wc._read("head/at") == h(t.head)
return head return head
......
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