Commit 0e4fc602 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 08a54443
...@@ -41,34 +41,36 @@ func xwait(w interface { Wait() error }) { ...@@ -41,34 +41,36 @@ func xwait(w interface { Wait() error }) {
exc.Raiseif(err) exc.Raiseif(err)
} }
// xfs1stor creates new NEO storage node backed by fs1 func xfs1stor(path string) *fs1.FileStorage {
// XXX is this wrapper a good idea?
func xfs1stor(net Network, path string) (*server.Storage, *fs1.FileStorage) {
// TODO +readonly ?
zstor, err := fs1.Open(context.Background(), path) zstor, err := fs1.Open(context.Background(), path)
exc.Raiseif(err) exc.Raiseif(err)
return zstor
return server.NewStorage("test cluster", "TODO master", "", net, zstor), zstor
} }
// M drives cluster with 1 S through recovery -> verification -> service -> shutdown // M drives cluster with 1 S through recovery -> verification -> service -> shutdown
func TestMasterStorage(t *testing.T) { func TestMasterStorage(t *testing.T) {
// XXX temp disabled net := NetPipe("") // test network
return Maddr := "0"
Saddr := "1"
net := NetPipe("") // test network FIXME New registers to global table M := server.NewMaster("abc1", Maddr, net)
M := server.NewMaster("abc1")
S, _ := xfs1stor(net, "../zodb/storage/fs1/testdata/1.fs") // XXX +readonly zstor := xfs1stor("../zodb/storage/fs1/testdata/1.fs")
S := server.NewStorage("abc1", Maddr, Saddr, net, zstor)
Mctx, Mcancel := context.WithCancel(context.Background()) Mctx, Mcancel := context.WithCancel(context.Background())
Sctx, Scancel := context.WithCancel(context.Background()) Sctx, Scancel := context.WithCancel(context.Background())
// XXX temp _ = Scancel; _ = Mcancel;
Sbind := ""; Mbind := ""; var err error
_ = Scancel; _ = Mcancel; _ = err
err = server.ListenAndServe(Mctx, net, Mbind, M) // XXX go err := M.Run(Mctx) // XXX go
err = server.ListenAndServe(Sctx, net, Sbind, S) // XXX go err = S.Run(Sctx) // XXX go
// XXX temp
if err != nil {
panic(err)
}
} }
// basic interaction between Client -- Storage // basic interaction between Client -- Storage
...@@ -82,7 +84,8 @@ func TestClientStorage(t *testing.T) { ...@@ -82,7 +84,8 @@ func TestClientStorage(t *testing.T) {
Sctx, Scancel := context.WithCancel(context.Background()) Sctx, Scancel := context.WithCancel(context.Background())
net := NetPipe("") // XXX here? (or a bit above?) net := NetPipe("") // XXX here? (or a bit above?)
S, zstor := xfs1stor(net, "../zodb/storage/fs1/testdata/1.fs") // XXX +readonly zstor := xfs1stor("../zodb/storage/fs1/testdata/1.fs") // XXX +readonly
S := server.NewStorage("cluster", "Maddr", "Saddr", net, zstor)
wg.Gox(func() { wg.Gox(func() {
S.ServeLink(Sctx, Snl) S.ServeLink(Sctx, Snl)
// XXX + test error return // XXX + test error return
......
...@@ -46,7 +46,7 @@ type Storage struct { ...@@ -46,7 +46,7 @@ type Storage struct {
// NewStorage creates new storage node that will listen on serveAddr and talk to master on masterAddr // NewStorage creates new storage node that will listen on serveAddr and talk to master on masterAddr
// The storage uses zstor as underlying backend for storing data. // The storage uses zstor as underlying backend for storing data.
// To actually start running the node - call Run. XXX text // To actually start running the node - call Run. XXX text
func NewStorage(cluster string, masterAddr string, serveAddr string, net neo.Network, zstor zodb.IStorage) *Storage { func NewStorage(cluster, masterAddr, serveAddr string, net neo.Network, zstor zodb.IStorage) *Storage {
// convert serveAddr into neo format // convert serveAddr into neo format
addr, err := neo.AddrString(net.Network(), serveAddr) addr, err := neo.AddrString(net.Network(), serveAddr)
if err != nil { if err != nil {
......
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