Commit 6dba6409 authored by Levin Zimmermann's avatar Levin Zimmermann

client_test: Support test cluster /w >1 master

Now it's possible to run client tests against a NEO cluster which
has more than one master nodes. We need this adjustement in order
to test NEO/go client modification in order to support more than
one master node.
parent 5d93e434
......@@ -63,7 +63,7 @@ type NEOSrv interface {
type NEOSrvOptions struct {
workdir string // location for database and log files
name string // name of the cluster
// nmaster
nmaster int // how many masters our cluster has
// npartition
// nreplica
......@@ -82,7 +82,7 @@ type NEOPySrv struct {
done chan struct{} // ready after Wait completes
errExit error // error from Wait
masterAddr string // address of master in spawned cluster
masterAddrSlice []string // addresses of master in spawned cluster
}
func (_ *NEOPySrv) Bugs() []string {
......@@ -114,6 +114,7 @@ func StartNEOPySrv(opt NEOSrvOptions) (_ *NEOPySrv, err error) {
// TODO set $PYTHONPATH to top, so that `import neo` works without `pip install -e .`
n.pysrv = xexec.Command("./py/runneo.py", workdir, opt.name)
n.pysrv.Args = append(n.pysrv.Args, "master_count="+fmt.Sprintf("%v", opt.nmaster))
if opt.SSL {
n.pysrv.Args = append(n.pysrv.Args, "ca=" +opt.CA())
n.pysrv.Args = append(n.pysrv.Args, "cert="+opt.Cert())
......@@ -165,7 +166,7 @@ func StartNEOPySrv(opt NEOSrvOptions) (_ *NEOPySrv, err error) {
if err != nil {
return nil, err
}
n.masterAddr = string(masterAddr)
n.masterAddrSlice = strings.Split(string(masterAddr), " ")
return n, nil
}
......@@ -175,7 +176,7 @@ func (n *NEOPySrv) clusterName() string {
}
func (n *NEOPySrv) URL() string {
return fmt.Sprintf("%s%s/%s", n.opt.URLPrefix(), n.masterAddr, n.clusterName())
return fmt.Sprintf("%s%s/%s", n.opt.URLPrefix(), strings.Join(n.masterAddrSlice, ","), n.clusterName())
}
func (n *NEOPySrv) LogTail() (string, error) {
......@@ -290,7 +291,7 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
if err != nil {
return nil, err
}
n.S = NewStorage(opt.name, []string{n.masterAddr()}, net, n.Sback)
n.S = NewStorage(opt.name, n.masterAddrSlice(), net, n.Sback)
serveWG.Go(func(ctx context.Context) error {
return n.S.Run(ctx, n.Sl)
})
......@@ -353,12 +354,12 @@ func (n *NEOGoSrv) Close() (err error) {
return err
}
func (n *NEOGoSrv) masterAddr() string {
return n.Ml.Addr().String()
func (n *NEOGoSrv) masterAddrSlice() []string {
return []string {n.Ml.Addr().String()}
}
func (n *NEOGoSrv) URL() string {
return fmt.Sprintf("%s%s/%s", n.opt.URLPrefix(), n.masterAddr(), n.opt.name)
return fmt.Sprintf("%s%s/%s", n.opt.URLPrefix(), strings.Join(n.masterAddrSlice(), ","), n.opt.name)
}
......@@ -437,6 +438,7 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv), optv ...tOption
// TODO + all variants with nreplica=X, npartition=Y, nmaster=Z, ... ?
for _, ssl := range []bool{false, true} {
kind := ""
if ssl { kind = "ssl" } else { kind = "!ssl" }
......@@ -444,6 +446,7 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv), optv ...tOption
neoOpt := NEOSrvOptions{
name: "1",
SSL: ssl,
nmaster: 1,
}
// startNEOpy starts NEO/py server with database in workdir/
......@@ -468,7 +471,9 @@ func withNEOSrv(t *testing.T, f func(t *testing.T, nsrv NEOSrv), optv ...tOption
}
cmd.Args = append(cmd.Args,
opt.Preload,
npy.masterAddr,
// py internal representation of master_nodes is a
// string where each addr is separated by 1 space
strings.Join(npy.masterAddrSlice, " "),
)
cmd.Stdin = nil
cmd.Stdout = os.Stdout
......
......@@ -45,6 +45,9 @@ def main():
kw = {'clear_databases': False} # switch default not to clear data on startup
for arg in sys.argv[3:]:
k, v = arg.split('=')
# We need to cast specific argument to specific types
if k in ("master_count",):
v = int(v)
kw[k] = v
......
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