Commit 5d7f9718 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8689314b
......@@ -839,7 +839,7 @@ def _watch(twlink, zf, at, pinok, replyok):
wg.wait()
"""
def _(ctx):
def _(ctx, ev):
reply = twlink.sendReq(ctx, b"watch %s @%s" % (h(zf._p_oid), h(at)))
if replyok.endswith('…'):
rok = replyok[:-len('…')]
......@@ -854,13 +854,13 @@ def _watch(twlink, zf, at, pinok, replyok):
# doCheckingPin calls f and verifies that wcfs sends expected pins during the
# time f executes.
#
# f(ctx) # XXX + ev?
# f(ctx, eventv)
# pinokByWLink: {} tWatchLink -> (zf, {} blk -> at).
# pinfunc(wlink, foid, blk, at) | None. XXX foid -> ZBigFile?
#
# pinfunc is called after pin request is received from wcfs but before pin ack
# is replied back. pinfunc must not block.
def doCheckingPin(f, pinokByWLink, pinfunc=None):
def doCheckingPin(f, pinokByWLink, pinfunc=None): # -> []event(str)
# call f and check that we receive pins as specified.
# Use timeout to detect wcfs replying less pins than expected.
#
......@@ -869,14 +869,18 @@ def doCheckingPin(f, pinokByWLink, pinfunc=None):
# we did not received expeced pin when wcfs sends final ok?
ctx, cancel = with_timeout()
wg = sync.WorkGroup(ctx)
ev = []
for wlink, (zf, pinok) in pinokByWLink.items():
def _(ctx, wlink):
pinv = wlink._expectPin(ctx, zf, pinok)
ev.append('pin rx') # XXX + zf, pin details?
tdelay() # increase probability to receive erroneous extra pins
for p in pinv:
if pinfunc is not None:
if pinfunc is not None:
for p in pinv:
pinfunc(wlink, p.foid, p.blk, p.at)
ev.append('pin ack pre') # XXX +details?
for p in pinv:
p.reply(b"ack")
# check that we don't get extra pins before reply to "watch"
try:
......@@ -890,13 +894,15 @@ def doCheckingPin(f, pinokByWLink, pinfunc=None):
wg.go(_, wlink)
def _(ctx):
f(ctx)
f(ctx, ev)
# cancel _expectPin waiting upon completing f
# -> error that missed pins were not received.
cancel()
wg.go(_)
wg.wait()
return ev
# _expectPin asserts that wcfs sends expected pin messages.
#
......@@ -1067,8 +1073,7 @@ def test_wcfs():
blk_data = f.blk(blk)
assert f.cached()[blk] == 0
ev = []
def _(ctx):
def _(ctx, ev):
assert f.cached()[blk] == 0
ev.append('read pre')
......@@ -1090,7 +1095,7 @@ def test_wcfs():
b = _rx
ev.append('read ' + chr(b))
doCheckingPin(_, {wl: (zf, pinok)})
ev = doCheckingPin(_, {wl: (zf, pinok)})
"""
......
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