Commit 6b9c53a4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dcdb9592
...@@ -60,7 +60,9 @@ type tCluster struct { ...@@ -60,7 +60,9 @@ type tCluster struct {
tabMu sync.Mutex tabMu sync.Mutex
nodeTab map[string/*node*/]*tNode nodeTab map[string/*node*/]*tNode
runWG *xsync.WorkGroup // started nodes are .Run under runWG
runCtx context.Context // runCtx is canceled on .Stop()
runWG *xsync.WorkGroup // started nodes are .Run() under runWG
runCancel func() runCancel func()
} }
...@@ -109,9 +111,8 @@ func tNewCluster(ttest *tracetest.T, name string) *tCluster { ...@@ -109,9 +111,8 @@ func tNewCluster(ttest *tracetest.T, name string) *tCluster {
t.gotracer.Attach() t.gotracer.Attach()
runCtx, runCancel := context.WithCancel(context.Background()) t.runCtx, t.runCancel = context.WithCancel(context.Background())
t.runWG = xsync.NewWorkGroup(runCtx) t.runWG = xsync.NewWorkGroup(t.runCtx)
t.runCancel = runCancel
return t return t
} }
...@@ -128,7 +129,10 @@ func (t *tCluster) Stop() { ...@@ -128,7 +129,10 @@ func (t *tCluster) Stop() {
if xcontext.Canceled(err) { // cancel is expected if xcontext.Canceled(err) { // cancel is expected
err = nil err = nil
} }
// XXX t.network.Close() err2 := t.network.Close()
if err == nil {
err = err2
}
if err != nil { if err != nil {
t.Fatalf("run shutdown: %s", err) t.Fatalf("run shutdown: %s", err)
} }
...@@ -187,6 +191,11 @@ func (t *tCluster) registerNewNode(name string) *tNode { ...@@ -187,6 +191,11 @@ func (t *tCluster) registerNewNode(name string) *tNode {
panic(fmt.Sprintf("test cluster: node %q registered twice", name)) panic(fmt.Sprintf("test cluster: node %q registered twice", name))
} }
host, err := t.network.NewHost(t.runCtx, name)
if err != nil {
t.Fatalf("register new node %q: %s", name, err)
}
// trace of events local to node // trace of events local to node
t.erouter.BranchNode(name, name) t.erouter.BranchNode(name, name)
...@@ -199,7 +208,7 @@ func (t *tCluster) registerNewNode(name string) *tNode { ...@@ -199,7 +208,7 @@ func (t *tCluster) registerNewNode(name string) *tNode {
} }
node := &tNode{} node := &tNode{}
node.net = xnet.NetTrace(t.network.Host(name), t.gotracer) node.net = xnet.NetTrace(host, t.gotracer)
t.nodeTab[name] = node t.nodeTab[name] = node
return node return node
......
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