Commit 58786531 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f1f7eb02
......@@ -47,6 +47,39 @@ type tEnv struct {
opt tClusterOptions // by default NEO clusters are created with this options
}
// tClusterOptions represents options for a test NEO cluster.
type tClusterOptions struct {
// Network forces usage of this kind of network for node inter-networking (pipenet|lonet).
Network string
}
// Verify verifies f for all combinations of NEO environments.
func Verify(t *testing.T, f func(*tEnv)) {
// TODO verify M=(go|py) x S=(go|py) x ...
// for now we only verify for all combinations of network
// TODO verify enc=(M|N) ?
// for all networks
for _, network := range []string{"pipenet", "lonet"} {
opt := tClusterOptions{
Network: network,
}
t.Run("net="+network, func (t *testing.T) {
tracetest.Verify(t, func(t *tracetest.T) {
tenv := &tEnv{
T: t,
opt: opt,
}
f(tenv)
})
})
}
}
// ----------------------------------------
// tCluster is a test NEO cluster.
//
// Create it with tEnv.NewCluster.
......@@ -64,13 +97,13 @@ type tCluster struct {
traceOn bool // whether tracing is currently on or off
gotracer *GoTracer // for tracing go nodes
//tpy *PyTracer // for tracing py nodes TODO
//tpy *PyTracer // for tracing py nodes TODO
erouter *EventRouter // to which stream an event should go
tabMu sync.Mutex
nodeTab map[string/*node*/]*tNode
runCtx context.Context // runCtx is canceled on .Stop() TODO or test failure
runCtx context.Context // runCtx is canceled on .Stop() TODO or test failure
runWG *xsync.WorkGroup // started nodes are .Run() under runWG
runCancel func()
}
......@@ -96,12 +129,6 @@ type ITestClient interface {
}
// tClusterOptions represents options for a test NEO cluster.
type tClusterOptions struct {
// Network forces usage of this kind of network for node inter-networking (pipenet|lonet).
Network string
}
// NewCluster creates new NEO test cluster.
//
// At the end of the test the cluster has to be stopped via t.Stop().
......@@ -128,7 +155,7 @@ func (t0 *tEnv) NewCluster(name string) *tCluster {
case "pipenet":
net = pipenet.AsVirtNet(pipenet.New("testnet"))
case "lonet":
net, err = lonet.Join(context.Background(), "") // XXX ctx = ttest.Ctx ?
net, err = lonet.Join(context.Background(), "") // XXX ctx -> t.Ctx() ?
if err != nil {
t0.Fatal(err)
}
......@@ -175,7 +202,7 @@ func (t *tCluster) Stop() {
func (t *tCluster) TraceOff() {
t.traceOn = false
t.gotracer.Detach()
//XXX t.pytracer.Detach()
//t.pytracer.Detach()
t.tabMu.Lock()
defer t.tabMu.Unlock()
......@@ -187,9 +214,8 @@ func (t *tCluster) TraceOff() {
// registerNewNode registers new node with given name.
//
// the node is registered in .nodeTab and .checkTab is populated ... XXX
//
// the node must not be registered before.
// The node is registered in .nodeTab and .erouter is updated for on-node and node-* events.
// The node must not be registered before.
func (t *tCluster) registerNewNode(name string) *tNode {
t.tabMu.Lock()
defer t.tabMu.Unlock()
......@@ -362,36 +388,7 @@ func (m *tMaster) Run(ctx context.Context) error {
return m.Master.Run(ctx, l)
}
// -------------------
// Verify verifies f for all combinations of node kinds.
// XXX place
func Verify(t *testing.T, f func(*tEnv)) {
// TODO verify M=(go|py) x S=(go|py) x ...
// for now we only verify for all combinations of network
// TODO verify enc=(M|N) ?
// for all networks
for _, network := range []string{"pipenet", "lonet"} {
opt := tClusterOptions{
Network: network,
}
t.Run("net="+network, func (t *testing.T) {
tracetest.Verify(t, func(t *tracetest.T) {
tenv := &tEnv{
T: t,
opt: opt,
}
f(tenv)
})
})
}
}
// --------------------
// ----------------------------------------
// tNewCluster_MS starts simple NEO cluster with 1 master and 1 storage nodes.
// The cluster is returned in ready-to-start state.
......@@ -430,7 +427,7 @@ func (t0 *tEnv) NewCluster_MS(name string, Sback storage.Backend) *tCluster {
}))
// M sends nodeTab to S
// XXX notifications should go to "m-s/notify" ?
// XXX better notifications should go to "m-s/notify" instead ?
t.Expect("m-s", conntx("m:2", "s:2", 0, &proto.NotifyNodeInformation{
IdTime: proto.IdTimeNone, // XXX ?
NodeList: []proto.NodeInfo{
......
......@@ -77,8 +77,8 @@ type eventNodeTab struct {
// event: master ready to start changed
type eventMStartReady struct {
Where string // ~ name of the master node
Ready bool
Where string // ~ name of the master node
Ready bool
}
func masterStartReady(where string, ready bool) *eventMStartReady {
......
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