Commit 4a4c1998 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 5c299054
......@@ -55,8 +55,8 @@ testdb = None
testzurl = None # URL of testdb
testmntpt = None # wcfs is mounted here
def setup_module():
# if wcfs.py receives SIGBUS because wcfs.go panics, we want to see
# python-level traceback instead of being killed.
# if wcfs.py receives SIGBUS because wcfs.go panics while serving mmap'ed
# read, we want to see python-level traceback instead of being killed.
install_sigbus_trap()
global testdb, testzurl, testmntpt
......@@ -214,7 +214,7 @@ class tDB:
# check the thread is the same when .root is used )
t._maintid = gettid()
# prepare initail objects for test: zfile, nonzfile
# prepare initial objects for test: zfile, nonzfile
t.root['!file'] = t.nonzfile = Persistent()
t.root['zfile'] = t.zfile = ZBigFile(blksize)
t.at0 = t.commit()
......@@ -248,7 +248,7 @@ class tDB:
def openwatch(t): # -> tWatchLink
return tWatchLink(t)
# change schedules zf to be changed according changeDelta at commit.
# change schedules zf to be changed according to changeDelta at commit.
#
# changeDelta: {} blk -> data.
# data can be both bytes and unicode.
......@@ -267,17 +267,15 @@ class tDB:
#
# zf and changeDelta can be optionally provided, in which case .change(zf,
# changeDelta) call is made before actually committing.
def commit(t, zf=None, changeDelta=None):
def commit(t, zf=None, changeDelta=None): # -> tAt
if zf is not None:
assert changeDelta is not None
t.change(zf, changeDelta)
# we'll verify that all changed objects come from the same ZODB connection
zconns = set()
# perform modifications scheduled by change.
# use !wcfs mode so that we prepare data independently of wcfs code paths.
dF = DF()
zconns = set()
for zf, zfDelta in t._changed.items():
dfile = DFile()
zconns.add(zf._p_jar)
......@@ -289,6 +287,7 @@ class tDB:
memcpy(vma, data)
dF.byfile[zf] = dfile
# verify that all changed objects come from the same ZODB connection
assert len(zconns) in (0, 1) # either nothing to commit or all from the same zconn
if len(zconns) == 1:
zconn = zconns.pop()
......@@ -504,7 +503,6 @@ class tFile:
# provided pinokByWLink when it is present.
@func
def assertBlk(t, blk, dataok, pinokByWLink=None):
#print('assertBlk #%d' % blk)
# XXX -> assertCtx('blk #%d' % blk)
def _():
assertCtx = 'blk #%d' % blk
......@@ -555,7 +553,6 @@ class tFile:
assert cached == 0
# even if @head[blk] is uncached, the block could be
# already pinned by setup watch
# XXX assert blkaccessed.rev > w.at => w.pinned
if blk not in w.pinned:
pinok = {blk: t.tdb._blkRevAt(t.zf, blk, w.at)}
shouldPin = True
......@@ -569,7 +566,7 @@ class tFile:
for wlink, pinok in pinokByWLink.items():
pinokByWLink[wlink] = (t.zf, pinok)
# access 1 bye on the block and verify that wcfs sends us correct pins
# access 1 byte on the block and verify that wcfs sends us correct pins
blkview = t._blk(blk)
assert t.cached()[blk] == cached
......@@ -625,9 +622,9 @@ class tFile:
#
# Expected blocks may be given with size < zf.blksize. In such case they
# are implicitly appended with trailing zeros. If a block is specified as
# 'x' - this particular block is not checked.
# 'x' - this particular block is not accessed and is not checked.
#
# It also checks file size and optionally mtime.
# The file size and optionally mtime are also verified.
def assertData(t, dataokv, mtime=None):
st = os.fstat(t.f.fileno())
assert st.st_size == len(dataokv)*t.blksize
......@@ -823,7 +820,7 @@ class tWatchLink:
return _rx
def _sendReq(t, ctx, req): # -> rxq
stream = 1
stream = 1 # XXX -> dynamic
rxq = chan()
with t._rxmu:
......@@ -1032,7 +1029,7 @@ def _watch(twlink, zf, at, pinok, replyok):
#
# f(ctx, eventv)
# pinokByWLink: {} tWatchLink -> (zf, {} blk -> at).
# pinfunc(wlink, foid, blk, at) | None. XXX foid -> ZBigFile?
# pinfunc(wlink, foid, blk, at) | None.
#
# pinfunc is called after pin request is received from wcfs, but before pin ack
# is replied back. Pinfunc must not block.
......@@ -1135,8 +1132,6 @@ def _blkDataAt(t, zf, blk, at): # -> (data, rev)
if at is None:
at = t.head
# XXX dup wrt _pinnedAt
# all changes to zf
vdf = [_.byfile[zf] for _ in t.dFtail if zf in _.byfile]
......@@ -1150,8 +1145,8 @@ def _blkDataAt(t, zf, blk, at): # -> (data, rev)
_ = blkhistoryat[-1]
data = _.ddata[blk]
rev = _.rev
assert rev <= at
assert rev <= at
return data, rev
# _blkRevAt returns expected zf[blk] revision as of @at database state.
......@@ -1171,8 +1166,6 @@ def _blkRevAt(t, zf, blk, at): # -> rev
# ; (and so is tracked by wcfs)
@func(tDB)
def _pinnedAt(t, zf, at): # -> pin = {} blk -> rev
# XXX dup in _blkDataAt
# all changes to zf
vdf = [_.byfile[zf] for _ in t.dFtail if zf in _.byfile]
......@@ -1182,15 +1175,8 @@ def _pinnedAt(t, zf, at): # -> pin = {} blk -> rev
for blk in df.ddata:
if blk in pin:
continue
# history of blk changes <= at
blkhistoryat = [_.rev for _ in vdf if blk in _.ddata and _.rev <= at]
if len(blkhistoryat) == 0:
pinrev = t.dFtail[0].rev # was hole - at0 XXX -> pin to z64?
else:
pinrev = blkhistoryat[-1]
assert pinrev <= at
if blk in t._blkaccessed(zf):
pin[blk] = pinrev
pin[blk] = t._blkRevAt(zf, blk, at)
return pin
......@@ -1817,7 +1803,7 @@ def tidtime(tid):
# NOTE pytest.approx supports only ==, not e.g. <, so we use plain round.
return round(t, 6)
# tidfromtime converts time into corresponding transacton ID.
# tidfromtime converts time into corresponding transaction ID.
def tidfromtime(t):
f = t - int(t) # fraction of seconds
t = int(t)
......@@ -1955,7 +1941,7 @@ defer = xdefer
del xdefer
# ready reports whether chan ch is ready
# ready reports whether chan ch is ready.
def ready(ch):
_, _rx = select(
default, # 0
......
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