Commit 5454a41c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c2e53f66
......@@ -242,15 +242,35 @@ package main
// tell the kernel it is fully responsible for invalidating pagecache.
import (
"context"
"flag"
"log"
"os"
"github.com/hanwen/go-fuse/fuse/nodefs"
"lab.nexedi.com/kirr/neo/go/zodb"
)
// 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)
// BigFileRoot represents "/bigfile"
type BigFileRoot struct {
nodefs.Node
zstor zodb.IStorage
}
func NewBigFileRoot(zstor zodb.IStorage) *BigFileRoot {
return &BigFileRoot{
Node: nodefs.NewDefaultNode(),
zstor: zstor,
}
}
// XXX option to prevent starting if wcfs was already started ?
// XXX option to automatically exit/unmount if there are no requests for some t
// (UC: autospawned from join)
func main() {
log.SetPrefix("wcfs: ")
......@@ -263,6 +283,16 @@ func main() {
zurl := flag.Args()[0]
mntpt := flag.Args()[1]
// open zodb storage
ctx := context.Background() // XXX + timeout?
zstor, err := zodb.OpenStorage(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
log.Fatal(err)
}
defer zstor.Close()
// mount root
opts := nodefs.NewOptions()
opts.Debug = *debug
......@@ -275,7 +305,8 @@ func main() {
// add entries to /
mkfile(root, ".wcfs", NewStaticFile([]byte(zurl)))
//mkdir(root, "bigfile", ...)
mkdir(root, "bigfile", NewBigFileRoot(zstor))
// serve client requests
server.Serve() // XXX Serve returns no eror
}
......@@ -19,8 +19,10 @@
# See https://www.nexedi.com/licensing for rationale and options.
from wendelin.lib.testing import getTestDB
from wendelin.bigfile.file_zodb import ZBigFile
from wendelin.bigfile.tests.test_filezodb import blksize
from wendelin import wcfs
from golang import go, chan
import transaction
import os, os.path, subprocess
from pytest import raises
......@@ -77,6 +79,7 @@ def test_join():
wc = wcfs._start(zurl)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl
assert os.path.isdir(wc.mountpoint + "/bigfile")
wc2 = wcfs.join(zurl, autostart=False)
assert wc2.mountpoint == wc.mountpoint
......@@ -93,5 +96,29 @@ def test_join_autostart():
wc = wcfs.join(zurl, autostart=True)
assert wc.mountpoint == testmntpt
assert readfile(wc.mountpoint + "/.wcfs") == zurl
assert os.path.isdir(wc.mountpoint + "/bigfile")
wc.close()
# XXX parametrize zblk0, zblk1
# XXX select !wcfs mode so that we prepare data through !wcfs path.
def _test_bigfile_empty():
root = testdb.dbopen()
root['zfile'] = f = ZBigFile(blksize)
transaction.commit()
root['aaa'] = 'bbb'
transaction.commit()
wc = wcfs.join(testzurl, autostart=True)
os.mkdir("%s/bigfile/%s" % (wc.mountpoint, f._p_oid.encode('hex')))
# XXX size(head/data) = 0
# XXX mtime(head/data) ~= last txn that changed bigdile
# XXX head/at = last txn of whole db
# XXX non-BigFile - rejected
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