Commit c5a66254 authored by Levin Zimmermann's avatar Levin Zimmermann

wcfs/pintimeout_kill: Fix killed testing if successful

In case 'test_wcfs_pintimeout_kill' is successful, WCFS kills the
client process. In order to prevent WCFS from killing the full
testing process, we therefore need to encapsulate the test code into
a subprocess, so that only this subprocess is killed in case of a
success.
parent ba39a3ec
...@@ -44,6 +44,7 @@ import sys, os, os.path, subprocess ...@@ -44,6 +44,7 @@ import sys, os, os.path, subprocess
from thread import get_ident as gettid from thread import get_ident as gettid
from time import gmtime from time import gmtime
from errno import EINVAL, ENOTCONN from errno import EINVAL, ENOTCONN
from multiprocessing import Process, Value
from resource import setrlimit, getrlimit, RLIMIT_MEMLOCK from resource import setrlimit, getrlimit, RLIMIT_MEMLOCK
from golang import go, chan, select, func, defer, error, b from golang import go, chan, select, func, defer, error, b
from golang import context, errors, sync, time from golang import context, errors, sync, time
...@@ -1463,31 +1464,44 @@ def test_wcfs_pintimeout_kill(): ...@@ -1463,31 +1464,44 @@ def test_wcfs_pintimeout_kill():
f = t.open(zf) f = t.open(zf)
f.assertData(['','','c2']) f.assertData(['','','c2'])
# XXX move into subprocess not to kill whole testing # move into subprocess to avoid killing testing process, in
ctx, _ = context.with_timeout(context.background(), 2*tkill) # case test is successful
def test(state):
ctx, _ = context.with_timeout(context.background(), 2*tkill)
wl = t.openwatch() wl = t.openwatch()
wg = sync.WorkGroup(ctx) wg = sync.WorkGroup(ctx)
def _(ctx): def _(ctx):
# send watch. The pin handler won't be replying -> we should never get reply here. # send watch. The pin handler won't be replying -> we should never get reply here.
wl.sendReq(ctx, b"watch %s @%s" % (h(zf._p_oid), h(at1))) wl.sendReq(ctx, b"watch %s @%s" % (h(zf._p_oid), h(at1)))
fail("watch request completed (should not as pin handler is stuck)") state.value = 1
wg.go(_) wg.go(_)
def _(ctx): def _(ctx):
req = wl.recvReq(ctx) req = wl.recvReq(ctx)
assert req is not None assert req is not None
assert req.msg == b"pin %s #%d @%s" % (h(zf._p_oid), 2, h(at1)) assert req.msg == b"pin %s #%d @%s" % (h(zf._p_oid), 2, h(at1))
# sleep > wcfs pin timeout - wcfs must kill us # sleep > wcfs pin timeout - wcfs must kill us
_, _rx = select( _, _rx = select(
ctx.done().recv, # 0 ctx.done().recv, # 0
time.after(tkill).recv, # 1 time.after(tkill).recv, # 1
) )
if _ == 0: if _ == 0:
raise ctx.err() raise ctx.err()
fail("wcfs did not killed stuck client") state.value = 2
wg.go(_) wg.go(_)
wg.wait() wg.wait()
state = Value("b", 0)
p = Process(target=test, args=(state,))
p.start()
p.join()
if state.value != 0:
state = (
"watch request completed (should not as pin handler is stuck)",
"wcfs did not killed stuck client"
)[state.value - 1]
fail(state)
# watch with @at > head - must wait for head to become >= at. # watch with @at > head - must wait for head to become >= at.
......
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