Commit 25f5ea2f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 155835df
......@@ -159,6 +159,17 @@ class tDB:
raise RuntimeError("wcsync #%d: wczhead (%s) != zhead (%s)" % (i, wchead, t._headv[i]))
t._wc_zheadv.append(wchead)
# path returns path joined with wcfs root
def path(t, path):
return os.path.join(t.wc.mountpoint, path)
# fpath returns wcfs path for file corresponding to object ID.
# By default head/... is returned. If rev != None - @<rev>/... is returned.
# XXX -> filepath? fpath?
def filepath(t, obj, rev=None):
head = "head/" if rev is None else ("@%s/" % h(rev))
return t.path("%s/bigfile/%s" % (head, h(obj._p_oid)))
# XXX text ...
# XXX parametrize zblk0, zblk1 XXX or just rely on tox?
......@@ -173,27 +184,22 @@ def test_wcfs():
tid1 = t.commit()
tid2 = t.commit()
assert tidtime(tid2) > tidtime(tid1)
t.wcsync()
# path to head/ and head/bigfile/ under wcfs
head = t.wc.mountpoint + "/head"
bigpath = head + "/bigfile"
# lookup to non-BigFile - must be rejected
with raises(OSError) as exc:
os.stat("%s/%s" % (bigpath, h(nonfile._p_oid)))
os.stat(t.filepath(nonfile))
assert exc.value.errno == EINVAL
# path to f under wcfs
fpath = "%s/%s" % (bigpath, h(f._p_oid))
fpath = t.filepath(f)
st = os.stat(fpath)
assert st.st_size == 0
assert st.st_mtime == tidtime(tid1)
# head/at = last txn of whole db
assert readfile(head + "/at") == h(tid2)
assert readfile(t.path("head/at")) == h(tid2)
# commit data to f and make sure we can see it on wcfs
......@@ -214,7 +220,7 @@ def test_wcfs():
st = os.stat(fpath)
assert st.st_size == fsize
assert st.st_mtime == tidtime(t.head)
assert readfile(head + "/at") == h(t.head)
assert readfile(t.path("head/at")) == h(t.head)
data = readfile(fpath)
assert len(data) == fsize
......@@ -245,7 +251,7 @@ def test_wcfs():
st = os.stat(fpath)
assert st.st_size == fsize
assert st.st_mtime == tidtime(t.head)
assert readfile(head + "/at") == h(t.head)
assert readfile(t.path("head/at")) == h(t.head)
data = readfile(fpath)
assert len(data) == fsize
......
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