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

.

parent 3bf9cf0d
...@@ -45,6 +45,9 @@ class WCFS(object): ...@@ -45,6 +45,9 @@ class WCFS(object):
self.mountpoint = mountpoint self.mountpoint = mountpoint
self._fwcfs = fwcfs self._fwcfs = fwcfs
def close(self):
self._fwcfs.close()
# serve starts and runs wcfs server for ZODB @ zurl. # serve starts and runs wcfs server for ZODB @ zurl.
# #
...@@ -106,7 +109,9 @@ def join(zurl, autostart=None): ...@@ -106,7 +109,9 @@ def join(zurl, autostart=None):
return _start(zurl) return _start(zurl)
# XXX doc -> WCFS # _start starts wcfs server for ZODB @ zurl.
#
# _start(zurl) -> WCFS
def _start(zurl): def _start(zurl):
mntpt = _mntpt_4zurl(zurl) mntpt = _mntpt_4zurl(zurl)
log.info("wcfs: starting for %s ...", zurl) log.info("wcfs: starting for %s ...", zurl)
......
...@@ -250,6 +250,7 @@ import ( ...@@ -250,6 +250,7 @@ import (
) )
// option to prevent starting if wcfs was already started ? // 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() { func main() {
log.SetPrefix("wcfs: ") log.SetPrefix("wcfs: ")
......
...@@ -21,17 +21,39 @@ ...@@ -21,17 +21,39 @@
from wendelin.lib.testing import getTestDB from wendelin.lib.testing import getTestDB
from wendelin import wcfs from wendelin import wcfs
from golang import go, chan from golang import go, chan
import os, os.path, subprocess
from pytest import raises from pytest import raises
testdb = None testdb = None
testzurl = None
def setup_module(): def setup_module():
global testdb global testdb, testzurl, testmntpt
testdb = getTestDB() testdb = getTestDB()
testdb.setup() testdb.setup()
zstor = testdb.getZODBStorage()
testzurl = wcfs._zstor_2zurl(zstor)
zstor.close()
testmntpt = wcfs._mntpt_4zurl(testzurl)
os.rmdir(testmntpt)
def teardown_module(): def teardown_module():
testdb.teardown() 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. # readfile reads file @ path.
def readfile(path): def readfile(path):
with open(path) as f: with open(path) as f:
...@@ -46,7 +68,13 @@ def test_join(): ...@@ -46,7 +68,13 @@ def test_join():
wc = wcfs._start(zurl) wc = wcfs._start(zurl)
assert readfile(wc.mountpoint + "/.wcfs") == 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(): 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