Commit 9a3b7413 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 12a3a4d7
...@@ -582,7 +582,8 @@ class tFile: ...@@ -582,7 +582,8 @@ class tFile:
# assertData asserts that file has data blocks as specified. # assertData asserts that file has data blocks as specified.
# #
# Expected blocks may be given with size < zf.blksize. In such case they # Expected blocks may be given with size < zf.blksize. In such case they
# are implicitly appended with trailing zeros. # are implicitly appended with trailing zeros. If a block is specified as
# 'x' - this particular block is not checked.
# #
# It also checks file size and optionally mtime. # It also checks file size and optionally mtime.
def assertData(t, dataokv, mtime=None): def assertData(t, dataokv, mtime=None):
...@@ -591,11 +592,15 @@ class tFile: ...@@ -591,11 +592,15 @@ class tFile:
if mtime is not None: if mtime is not None:
assert st.st_mtime == tidtime(mtime) assert st.st_mtime == tidtime(mtime)
cachev = t.cached()
for blk, dataok in enumerate(dataokv): for blk, dataok in enumerate(dataokv):
if dataok == 'x':
continue
t.assertBlk(blk, dataok) t.assertBlk(blk, dataok)
cachev[blk] = 1
# all blocks must be in cache after we touched them all # all accessed blocks must be in cache after we touched them all
t.assertCache([1]*len(dataokv)) t.assertCache(cachev)
# tWatch represents watch for one file setup on a tWatchLink. # tWatch represents watch for one file setup on a tWatchLink.
...@@ -1201,12 +1206,14 @@ def test_wcfs(): ...@@ -1201,12 +1206,14 @@ def test_wcfs():
f.assertData (['','','c1'], mtime=t.head) f.assertData (['','','c1'], mtime=t.head)
# >>> (@at2) commit again -> we can see both latest and snapshotted states # >>> (@at2) commit again -> we can see both latest and snapshotted states
t.change(zf, {2: 'c2', 3: 'd2'}) # NOTE blocks d(4) and f(5) will be not yet accessed till "watch+commit" test phase
t.change(zf, {2: 'c2', 3: 'd2', 5: 'f2'})
at2 = t.commit() at2 = t.commit()
# f @head # f @head
f.assertCache([1,1,0,0]) f.assertCache([1,1,0,0,0,0])
f.assertData (['','', 'c2', 'd2'], mtime=t.head) f.assertData (['','', 'c2', 'd2', 'x','x'], mtime=t.head)
f.assertCache([1,1,1,1,0,0])
# f @at1 # f @at1
f1 = t.open(zf, at=at1) f1 = t.open(zf, at=at1)
...@@ -1219,21 +1226,22 @@ def test_wcfs(): ...@@ -1219,21 +1226,22 @@ def test_wcfs():
t.change(zf, {2: 'c3'}) # FIXME + a3 after δbtree works (hole -> zblk) t.change(zf, {2: 'c3'}) # FIXME + a3 after δbtree works (hole -> zblk)
at3 = t.commit() at3 = t.commit()
f.assertCache([1,1,0,1]) f.assertCache([1,1,0,1,0,0])
# f @head is opened again -> cache must not be lost # f @head is opened again -> cache must not be lost
f_ = t.open(zf) f_ = t.open(zf)
f_.assertCache([1,1,0,1]) f_.assertCache([1,1,0,1,0,0])
f_.close() f_.close()
f.assertCache([1,1,0,1]) f.assertCache([1,1,0,1,0,0])
# f @head # f @head
f.assertCache([1,1,0,1]) f.assertCache([1,1,0,1,0,0])
f.assertData (['','','c3','d2'], mtime=t.head) f.assertData (['','','c3','d2','x','x'], mtime=t.head)
# f @at2 # f @at2
f2.assertCache([0,0,1,0]) # NOTE f2 is accessed but via @at/ not head/
f2.assertData (['','','c2','d2']) # XXX mtime=at2? f2.assertCache([0,0,1,0,0,0])
f2.assertData (['','','c2','d2','','f2']) # XXX mtime=at2?
# f @at1 # f @at1
f1.assertCache([1,1,1]) f1.assertCache([1,1,1])
...@@ -1242,10 +1250,10 @@ def test_wcfs(): ...@@ -1242,10 +1250,10 @@ def test_wcfs():
# >>> f close / open again -> cache must not be lost # >>> f close / open again -> cache must not be lost
# XXX a bit flaky since OS can evict whole f cache under pressure # XXX a bit flaky since OS can evict whole f cache under pressure
f.assertCache([1,1,1,1]) f.assertCache([1,1,1,1,0,0])
f.close() f.close()
f = t.open(zf) f = t.open(zf)
if f.cached() != [1,1,1,1]: if f.cached() != [1,1,1,1,0,0]:
assert sum(f.cached()) > 4*1/2 # > 50% assert sum(f.cached()) > 4*1/2 # > 50%
# >>> XXX commit data to not yet accessed f part - nothing happens # >>> XXX commit data to not yet accessed f part - nothing happens
...@@ -1349,7 +1357,7 @@ def test_wcfs(): ...@@ -1349,7 +1357,7 @@ def test_wcfs():
assert w3_.pinned == pinw3_ assert w3_.pinned == pinw3_
assert w2.pinned == pinw2 assert w2.pinned == pinw2
f.assertCache([1,1,1,1]) f.assertCache([1,1,1,1,0,0])
# XXX move f4 commit ^^^ (where watch with explicit pinok is tested) # XXX move f4 commit ^^^ (where watch with explicit pinok is tested)
t.change(zf, { 2: 'c4', 5: 'f4', 6: 'g4'}) # FIXME + b4 after δbtree works + update vvv t.change(zf, { 2: 'c4', 5: 'f4', 6: 'g4'}) # FIXME + b4 after δbtree works + update vvv
at4 = t.commit() at4 = t.commit()
...@@ -1459,7 +1467,7 @@ def test_wcfs(): ...@@ -1459,7 +1467,7 @@ def test_wcfs():
# XXX ZBlk moved from blk1 -> blk2 ; for the same file and for file1 -> file2 (δbtree) # XXX ZBlk moved from blk1 -> blk2 ; for the same file and for file1 -> file2 (δbtree)
# XXX read file[blk]=hole; then file[blk]=zblk - must be invalidated and # XXX read file[blk]=hole; then file[blk]=zblk - must be invalidated and
# setupWatch must send pins. (δbtree - see e.g. commit with b4 ^^^) # setupWatch must send pins. (δbtree - see e.g. commits with a3, b4 ^^^)
# ---- misc --- # ---- misc ---
......
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