Commit bfd30ffa authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 347c32d8
......@@ -31,7 +31,7 @@ import (
//"reflect"
"sync"
"testing"
"unsafe"
// "unsafe"
"golang.org/x/sync/errgroup"
......@@ -100,12 +100,14 @@ type eventNodeTab struct {
// event: master ready to start changed
type eventMStartReady struct {
Master unsafe.Pointer // *Master XXX not to noise test diff
//Master unsafe.Pointer // *Master XXX not to noise test diff
Where string // host (XXX name) of running node
Ready bool
}
func masterStartReady(m *Master, ready bool) *eventMStartReady {
return &eventMStartReady{unsafe.Pointer(m), ready}
func masterStartReady(where string, ready bool) *eventMStartReady {
//return &eventMStartReady{unsafe.Pointer(m), ready}
return &eventMStartReady{where, ready}
}
// ---- events routing ----
......@@ -232,6 +234,9 @@ func (r *EventRouter) Route(event interface{}) (dst *tsync.SyncChan) {
case *eventClusterState:
dst = r.byNode[ev.Where]
case *eventMStartReady:
dst = r.byNode[ev.Where]
}
if dst == nil {
......@@ -283,6 +288,7 @@ type TraceCollector struct {
pg *tracing.ProbeGroup
d *tsync.EventDispatcher
node2Name map[*neo.NodeApp]string
nodeTab2Owner map[*neo.NodeTable]string
clusterState2Owner map[*neo.ClusterState]string
}
......@@ -292,6 +298,7 @@ func NewTraceCollector(dispatch *tsync.EventDispatcher) *TraceCollector {
pg: &tracing.ProbeGroup{},
d: dispatch,
node2Name: make(map[*neo.NodeApp]string),
nodeTab2Owner: make(map[*neo.NodeTable]string),
clusterState2Owner: make(map[*neo.ClusterState]string),
}
......@@ -324,6 +331,7 @@ func (t *TraceCollector) RegisterNode(node *neo.NodeApp, name string) {
// XXX verify there is no duplicate names
// XXX verify the same pointer is not registerd twice
t.node2Name[node] = name
t.nodeTab2Owner[node.NodeTab] = name
t.clusterState2Owner[&node.ClusterState] = name
}
......@@ -360,7 +368,9 @@ func (t *TraceCollector) traceNode(nt *neo.NodeTable, n *neo.Node) {
}
func (t *TraceCollector) traceMasterStartReady(m *Master, ready bool) {
t.d.Dispatch(masterStartReady(m, ready))
//t.d.Dispatch(masterStartReady(m, ready))
where := t.node2Name[m.node]
t.d.Dispatch(&eventMStartReady{where, ready})
}
// ----------------------------------------
......@@ -556,7 +566,7 @@ func TestMasterStorage(t *testing.T) {
}))
// M ready to start: new cluster, no in-progress S recovery
tM.Expect(masterStartReady(M, true))
tM.Expect(masterStartReady("m", true))
// <<< trace <<<
......
......@@ -18,7 +18,7 @@
// See https://www.nexedi.com/licensing for rationale and options.
// Package tsync provides infrastructure for synchronous testing based on program tracing.
// XXX naming -> ttest? tracetest?
// XXX naming -> ttest? tracetest? synctest?
//
// A serial system can be verified by checking that its execution produces
// expected serial stream of events. But concurrent systems cannot be verified
......@@ -152,7 +152,7 @@ func (evc *EventChecker) xget1(eventp interface{}) *SyncMsg {
reventp := reflect.ValueOf(eventp)
if reventp.Type().Elem() != reflect.TypeOf(msg.Event) {
evc.t.Fatalf("expect: %s: got %#v", reventp.Elem().Type(), msg.Event)
evc.t.Fatalf("%s: expect: %s: got %#v", evc.in.name, reventp.Elem().Type(), msg.Event)
}
// *eventp = msg.Event
......@@ -174,7 +174,8 @@ func (evc *EventChecker) expect1(eventExpect interface{}) *SyncMsg {
revent := reventp.Elem()
if !reflect.DeepEqual(revent.Interface(), reventExpect.Interface()) {
evc.t.Fatalf("expect: %s:\nwant: %v\nhave: %v\ndiff: %s",
evc.t.Fatalf("%s: expect: %s:\nwant: %v\nhave: %v\ndiff: %s",
evc.in.name,
reventExpect.Type(), reventExpect, revent,
pretty.Compare(reventExpect.Interface(), revent.Interface()))
}
......
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