Commit 04e8a863 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3bf9cf0d
......@@ -45,6 +45,9 @@ class WCFS(object):
self.mountpoint = mountpoint
self._fwcfs = fwcfs
def close(self):
self._fwcfs.close()
# serve starts and runs wcfs server for ZODB @ zurl.
#
......@@ -106,7 +109,9 @@ def join(zurl, autostart=None):
return _start(zurl)
# XXX doc -> WCFS
# _start starts wcfs server for ZODB @ zurl.
#
# _start(zurl) -> WCFS
def _start(zurl):
mntpt = _mntpt_4zurl(zurl)
log.info("wcfs: starting for %s ...", zurl)
......
......@@ -250,6 +250,7 @@ import (
)
// option to prevent starting if wcfs was already started ?
// option to automatically exit/unmount if there are no requests for some t (UC: autospawned from join)
func main() {
log.SetPrefix("wcfs: ")
......
......@@ -21,17 +21,39 @@
from wendelin.lib.testing import getTestDB
from wendelin import wcfs
from golang import go, chan
import os, os.path, subprocess
from pytest import raises
testdb = None
testzurl = None
def setup_module():
global testdb
global testdb, testzurl, testmntpt
testdb = getTestDB()
testdb.setup()
zstor = testdb.getZODBStorage()
testzurl = wcfs._zstor_2zurl(zstor)
zstor.close()
testmntpt = wcfs._mntpt_4zurl(testzurl)
os.rmdir(testmntpt)
def teardown_module():
testdb.teardown()
# make sure we start every test without wcfs server running
def setup_function(f):
assert not os.path.exists(testmntpt)
# make sure we unmount wcfs after every function
def teardown_function(f):
mounted = not subprocess.call(["mountpoint", "-q", testmntpt])
if mounted:
subprocess.check_call(["fusermount", "-u", testmntpt])
if os.path.exists(testmntpt):
os.rmdir(testmntpt)
# readfile reads file @ path.
def readfile(path):
with open(path) as f:
......@@ -46,7 +68,13 @@ def test_join():
wc = wcfs._start(zurl)
assert readfile(wc.mountpoint + "/.wcfs") == zurl
#wc = wcfs.join(zurl, autostart=False)
wc2 = wcfs.join(zurl, autostart=False)
assert wc2.mountpoint == wc.mountpoint
wc.close()
wc2.close()
zstor.close()
def test_join_autostart():
......
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