Commit f622e751 authored by Kirill Smelkov's avatar Kirill Smelkov

X tests: Stop wcfs spawned during tests

Tests inside wcfs/ care to do this, but e.g. test.py/fs-wcfs autospawns
wcfs servers during regular bigfile tests. If we don't stop spawned
wcfs, those processes will leak, and also they keep `nxdtest
test.py/*-wcfs` in "hung" state, because nxdtest is waiting for wcfs to
stop as wcfs stdout is connected to nxdtest input.

Currently kills wcfs in abrupt way, because graceful pinner shutdown is
not yet implemented there.
parent 6dec74e7
# Wendelin.core | pytest config
# Copyright (C) 2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
from __future__ import print_function, absolute_import
from golang import func, defer
# Before pytest exits, teardown WCFS(s) that we automatically spawned during
# test runs in bigfile/bigarray/...
#
# If we do not do this, spawned wcfs servers are left running _and_ connected
# by stdout to nxdtest input - which makes nxdtest to wait for them to exit.
@func
def pytest_unconfigure(config):
from wendelin import wcfs
from wendelin.wcfs.wcfs_test import tWCFS
print("\n\nspawned WCFS:")
print(wcfs._wcstarted)
print("closing...")
for wc in wcfs._wcstarted:
twc = tWCFS(wc=wc)
# FIXME currently has to kill wcfs.go, because swapned pinner threads are running
# -> stop pinner first
# NOTE: defer instead of direct call - to call all wc.close if there was multiple wc spawned
defer(twc.close)
......@@ -143,6 +143,7 @@ def _open(wc, obj, mode='rb', at=None):
_wcmu = sync.Mutex()
_wcregistry = {} # mntpt -> WCFS
_wcstarted = [] # of WCFS for wcfs we ever _start'ed (for tests)
@func(WCFS)
def __init__(wc, mountpoint, fwcfs, proc):
......@@ -222,6 +223,7 @@ def _start(zurl, *optv): # -> WCFS
# spawn wcfs and wait till filesystem-level access to it is ready
wc = WCFS(mntpt, None, None)
_wcstarted.append(wc)
wg = sync.WorkGroup(context.background())
fsready = chan(dtype='C.structZ')
def _(ctx):
......
......@@ -214,12 +214,15 @@ class DFile:
# XXX print -> t.trace/debug() + t.verbose depending on py.test -v -v ?
class tWCFS(_tWCFS):
@func
def __init__(t):
def __init__(t, wc=None):
# `wc != None` is used to create tWCFS on existing WCFS connection
if wc is None:
assert not os.path.exists(testmntpt)
t.wc = wcfs.join(testzurl, autostart=True)
assert t.wc.mountpoint == testmntpt
assert os.path.exists(t.wc.mountpoint)
assert is_mountpoint(t.wc.mountpoint)
wc = wcfs.join(testzurl, autostart=True)
assert wc.mountpoint == testmntpt
assert os.path.exists(wc.mountpoint)
assert is_mountpoint(wc.mountpoint)
t.wc = wc
# force-unmount wcfs on timeout to unstuck current test and let it fail.
# Force-unmount can be done reliably only by writing into
......
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