Commit 56b8309c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ec103e5c
......@@ -118,6 +118,24 @@ def test_join_autostart():
# --- test access to data ----
# DF corresponds to ΔF in wcfs.
# it represents a change in files space.
class DF:
# .rev tid
# .byfile {} ZBigFile -> DFile
def __init__(dF):
# rev set from outside
dF.byfile = {}
# DFile is similar to ΔFile in wcfs.
# represents a change to one file.
class DFile:
# .rev tid
# .ddata {} blk -> data XXX name
def __init__(dfile):
# rev set from outside
dfile.ddata = {}
# tDB provides database/wcfs testing environment.
#
# BigFiles opened under tDB are represented as tFile - see .open for details.
......@@ -135,10 +153,10 @@ class tDB:
# ZBigFile(s) scheduled for commit
t._changed = {} # ZBigFile -> {} blk -> data
# committed: head + head history
# XXX -> vδF (committed changes to files)
# committed: head + δF history
t.head = None
t._headv = []
t._headv = [] # XXX -> just use dFtail[·].rev ?
t.dFtail = [] # of DF
# number of commits made so far
t.ncommit = 0
......@@ -185,13 +203,17 @@ class tDB:
def commit(t):
# perform modifications scheduled by change.
# use !wcfs mode so that we prepare data independently of wcfs code paths.
dF = DF()
for zf, zfDelta in t._changed.iteritems():
dfile = DFile()
zfh = zf.fileh_open(_use_wcfs=False)
for blk, data in zfDelta.iteritems():
dfile.ddata[blk] = data
data += b'\0'*(zf.blksize - len(data)) # trailing \0
vma = zfh.mmap(blk, 1)
memcpy(vma, data)
print(' δ f<%s>\t%s' % (h(zf._p_oid), sorted(zfDelta.keys())))
dF.byfile[zf] = dfile
t._changed = {}
# NOTE there is no clean way to retrieve tid of just committed transaction
......@@ -206,6 +228,11 @@ class tDB:
t.head = head
t._headv.append(head)
dF.rev = head
for dfile in dF.byfile.values():
dfile.rev = head
t.dFtail.append(dF)
# synchronize wcfs to db
t._wcsync()
......@@ -260,7 +287,7 @@ class tDB:
# tFile provides testing environment for one bigfile on wcfs.
#
# .blk() provides access to data of a block. .cached() gives state of which
# blocks are in OS pagecache. .assertCache and .assertBlk/.assertData assert
# blocks are in OS pagecache. .assertCache and .assertBlk/.assertData assert
# on state of cache and data.
class tFile:
# maximum number of pages we mmap for 1 file.
......@@ -366,8 +393,8 @@ class tWatch:
# open new head/watch handle.
#
# python/stdio lock file object on read/write
# however we need both read and write to be working simultaneously.
# python/stdio lock file object on read/write, however we need both
# read and write to be working simultaneously.
# -> we use 2 separate file objects for rx and tx.
#
# fdopen takes ownership of file descriptor and closes it when file
......@@ -623,7 +650,7 @@ def test_wcfs():
# XXX test watch with all at variants
# XXX both from scratch and going e.g. at1 -> at2 -> at3
# XXX going not only up, but also down at1 <- at2 <- at3
# XXX going not only up, but also down at1 <- at2 <- at3 ?
w = t.watch(zf, at1) # XXX <- pin @at2 @at3
#t.watch(zf, at1, {2: at1, 3: at1}) # XXX <- pin @at2 @at3
......@@ -655,14 +682,14 @@ def test_wcfs():
# XXX pin message when blk data only first appeared after > w.at - pin
# needs to pin to zero.
# XXX watch @at when file did not existed -> error
# XXX ZBlk copied from blk1 -> blk2 ; for the same file and for file1 -> file2
# XXX ZBlk moved from blk1 -> blk2 ; for the same file and for file1 -> file2
# XXX read file[blk]=hole; then file[blk]=zblk - must be invalidated and
# setupWatch must send pins.
# XXX watch @at when file did not existed
def test_wcfs_invproto():
# XXX
......
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