Commit c1f63a6b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c1a7c85a
...@@ -45,14 +45,15 @@ type NEOSrv interface { ...@@ -45,14 +45,15 @@ type NEOSrv interface {
// //
// Create it with StartNEOPySrv(XXX). // Create it with StartNEOPySrv(XXX).
type NEOPySrv struct { type NEOPySrv struct {
pysrv *exec.Cmd // spawned `XXX` pysrv *exec.Cmd // spawned `runneo.py`
workdir string // location for database and log files workdir string // location for database and log files
opt NEOPyOptions // options for spawned server clusterName string // name of the cluster
cancel func() // to stop pysrv opt NEOPyOptions // options for spawned server
done chan struct{} // ready after Wait completes cancel func() // to stop pysrv
errExit error // error from Wait done chan struct{} // ready after Wait completes
errExit error // error from Wait
masterAddr string // address of master in spawned cluster
masterAddr string // address of master in spawned cluster
} }
// NEOPySrv.Bugs // NEOPySrv.Bugs
...@@ -65,10 +66,10 @@ type NEOPyOptions struct { ...@@ -65,10 +66,10 @@ type NEOPyOptions struct {
// name // name
} }
// StartNEOPySrv starts NEO/py server for NEO database located in workdir/. // StartNEOPySrv starts NEO/py server for clusterName NEO database located in workdir/.
// XXX dup wrt zeo? // XXX dup wrt zeo?
func StartNEOPySrv(workdir string, opt NEOPyOptions) (_ *NEOPySrv, err error) { func StartNEOPySrv(workdir, clusterName string, opt NEOPyOptions) (_ *NEOPySrv, err error) {
defer xerr.Contextf(&err, "startneo %s", workdir) defer xerr.Contextf(&err, "startneo %s/%s", workdir, clusterName)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
...@@ -81,8 +82,8 @@ func StartNEOPySrv(workdir string, opt NEOPyOptions) (_ *NEOPySrv, err error) { ...@@ -81,8 +82,8 @@ func StartNEOPySrv(workdir string, opt NEOPyOptions) (_ *NEOPySrv, err error) {
return nil, err return nil, err
} }
n := &NEOPySrv{workdir: workdir, cancel: cancel, done: make(chan struct{})} n := &NEOPySrv{workdir: workdir, clusterName: clusterName, cancel: cancel, done: make(chan struct{})}
n.pysrv = exec.CommandContext(ctx, "python", "./py/runneo.py", workdir) // XXX +opt n.pysrv = exec.CommandContext(ctx, "python", "./py/runneo.py", workdir, clusterName) // XXX +opt
n.opt = opt n.opt = opt
// $TEMP -> workdir (else NEO/py creates another one for e.g. coverage) // $TEMP -> workdir (else NEO/py creates another one for e.g. coverage)
n.pysrv.Env = append(os.Environ(), "TEMP="+workdir) n.pysrv.Env = append(os.Environ(), "TEMP="+workdir)
...@@ -136,7 +137,7 @@ func StartNEOPySrv(workdir string, opt NEOPyOptions) (_ *NEOPySrv, err error) { ...@@ -136,7 +137,7 @@ func StartNEOPySrv(workdir string, opt NEOPyOptions) (_ *NEOPySrv, err error) {
} }
func (n *NEOPySrv) ClusterName() string { func (n *NEOPySrv) ClusterName() string {
return "xxx" // FIXME stub return n.clusterName
} }
func (n *NEOPySrv) MasterAddr() string { func (n *NEOPySrv) MasterAddr() string {
...@@ -198,7 +199,7 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv), optv ...tOption ...@@ -198,7 +199,7 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv), optv ...tOption
inWorkDir(t, func(workdir string) { inWorkDir(t, func(workdir string) {
X := xtesting.FatalIf(t) X := xtesting.FatalIf(t)
npy, err := StartNEOPySrv(workdir, NEOPyOptions{}); X(err) npy, err := StartNEOPySrv(workdir, "1", NEOPyOptions{}); X(err)
defer func() { defer func() {
err := npy.Close(); X(err) err := npy.Close(); X(err)
}() }()
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
# See https://www.nexedi.com/licensing for rationale and options. # See https://www.nexedi.com/licensing for rationale and options.
"""runneo.py runs NEO/py cluster for NEO/go testing. """runneo.py runs NEO/py cluster for NEO/go testing.
Usage: runneopy <workdir> <readyfile> XXX + (**kw for NEOCluster) Usage: runneo.py <workdir> <cluster-name> XXX + (**kw for NEOCluster)
XXX XXX
""" """
...@@ -32,10 +32,11 @@ from time import sleep ...@@ -32,10 +32,11 @@ from time import sleep
@func @func
def main(): def main():
workdir = sys.argv[1] workdir = sys.argv[1]
readyf = workdir + "/ready" clusterName = sys.argv[2]
readyf = workdir + "/ready"
cluster = NEOCluster(['1'], adapter='SQLite', temp_dir=workdir) # XXX +kw cluster = NEOCluster([clusterName], adapter='SQLite', temp_dir=workdir) # XXX +kw
cluster.start() cluster.start()
defer(cluster.stop) defer(cluster.stop)
......
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