Commit f5b60fb0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6e414cfd
...@@ -88,6 +88,55 @@ func masterStartReady(where string, ready bool) *eventMStartReady { ...@@ -88,6 +88,55 @@ func masterStartReady(where string, ready bool) *eventMStartReady {
// TODO eventPartTab // TODO eventPartTab
// ---- shortcuts ----
// shortcut for net connect event
func netconnect(src, dst, dialed string) *eventNetConnect {
return &eventNetConnect{Src: src, Dst: dst, Dialed: dialed}
}
func netlisten(laddr string) *eventNetListen {
return &eventNetListen{Laddr: laddr}
}
// shortcut for net tx event over nodelink connection
func conntx(src, dst string, connid uint32, msg proto.Msg) *eventNeoSend {
return &eventNeoSend{Src: src, Dst: dst, ConnID: connid, Msg: msg}
}
// shortcut for address
func xnaddr(addr string) proto.Address {
if addr == "" {
return proto.Address{}
}
// during testing we pretend addr is always of host:port form
a, err := proto.AddrString("tcp", addr)
if err != nil {
panic(err)
}
return a
}
// shortcut for NodeInfo
func nodei(laddr string, typ proto.NodeType, num int32, state proto.NodeState, idtime proto.IdTime) proto.NodeInfo {
return proto.NodeInfo{
Type: typ,
Addr: xnaddr(laddr),
UUID: proto.UUID(typ, num),
State: state,
IdTime: idtime,
}
}
// shortcut for nodetab change
func δnode(where string, laddr string, typ proto.NodeType, num int32, state proto.NodeState, idtime proto.IdTime) *eventNodeTab {
return &eventNodeTab{
Where: where,
NodeInfo: nodei(laddr, typ, num, state, idtime),
}
}
// ---- events routing ---- // ---- events routing ----
// EventRouter implements NEO-specific routing of events to trace test channels. // EventRouter implements NEO-specific routing of events to trace test channels.
......
...@@ -108,54 +108,6 @@ func TestMasterStorage(t *testing.T) { ...@@ -108,54 +108,6 @@ func TestMasterStorage(t *testing.T) {
tracer.Attach() tracer.Attach()
defer tracer.Detach() defer tracer.Detach()
// shortcut for addresses
xaddr := func(addr string) *pipenet.Addr {
a, err := net.ParseAddr(addr)
exc.Raiseif(err)
return a
}
xnaddr := func(addr string) proto.Address {
if addr == "" {
return proto.Address{}
}
a, err := proto.Addr(xaddr(addr))
exc.Raiseif(err)
return a
}
// shortcut for net connect event
netconnect := func(src, dst, dialed string) *eventNetConnect {
return &eventNetConnect{Src: src, Dst: dst, Dialed: dialed}
}
netlisten := func(laddr string) *eventNetListen {
return &eventNetListen{Laddr: laddr}
}
// shortcut for net tx event over nodelink connection
conntx := func(src, dst string, connid uint32, msg proto.Msg) *eventNeoSend {
return &eventNeoSend{Src: src, Dst: dst, ConnID: connid, Msg: msg}
}
// shortcut for NodeInfo
nodei := func(laddr string, typ proto.NodeType, num int32, state proto.NodeState, idtime proto.IdTime) proto.NodeInfo {
return proto.NodeInfo{
Type: typ,
Addr: xnaddr(laddr),
UUID: proto.UUID(typ, num),
State: state,
IdTime: idtime,
}
}
// shortcut for nodetab change
node := func(where string, laddr string, typ proto.NodeType, num int32, state proto.NodeState, idtime proto.IdTime) *eventNodeTab {
return &eventNodeTab{
Where: where,
NodeInfo: nodei(laddr, typ, num, state, idtime),
}
}
// XXX -> M = testenv.NewMaster("m") (mkhost, chan, register to tracer ...) // XXX -> M = testenv.NewMaster("m") (mkhost, chan, register to tracer ...)
// XXX ----//---- S, C // XXX ----//---- S, C
...@@ -230,7 +182,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -230,7 +182,7 @@ func TestMasterStorage(t *testing.T) {
// M starts listening // M starts listening
tM.Expect(netlisten("m:1")) tM.Expect(netlisten("m:1"))
tM.Expect(node("m", "m:1", proto.MASTER, 1, proto.RUNNING, proto.IdTimeNone)) tM.Expect(δnode("m", "m:1", proto.MASTER, 1, proto.RUNNING, proto.IdTimeNone))
tM.Expect(clusterState("m", proto.ClusterRecovering)) tM.Expect(clusterState("m", proto.ClusterRecovering))
// TODO create C; C tries connect to master - rejected ("not yet operational") // TODO create C; C tries connect to master - rejected ("not yet operational")
...@@ -248,7 +200,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -248,7 +200,7 @@ func TestMasterStorage(t *testing.T) {
IdTime: proto.IdTimeNone, IdTime: proto.IdTimeNone,
})) }))
tM.Expect(node("m", "s:1", proto.STORAGE, 1, proto.PENDING, 0.01)) tM.Expect(δnode("m", "s:1", proto.STORAGE, 1, proto.PENDING, 0.01))
tSM.Expect(conntx("m:2", "s:2", 1, &proto.AcceptIdentification{ tSM.Expect(conntx("m:2", "s:2", 1, &proto.AcceptIdentification{
NodeType: proto.MASTER, NodeType: proto.MASTER,
...@@ -290,7 +242,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -290,7 +242,7 @@ func TestMasterStorage(t *testing.T) {
// trace // trace
tM.Expect(node("m", "s:1", proto.STORAGE, 1, proto.RUNNING, 0.01)) tM.Expect(δnode("m", "s:1", proto.STORAGE, 1, proto.RUNNING, 0.01))
xwait(wg) xwait(wg)
// XXX M.partTab <- S1 // XXX M.partTab <- S1
...@@ -362,7 +314,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -362,7 +314,7 @@ func TestMasterStorage(t *testing.T) {
IdTime: proto.IdTimeNone, IdTime: proto.IdTimeNone,
})) }))
tM.Expect(node("m", "", proto.CLIENT, 1, proto.RUNNING, 0.02)) tM.Expect(δnode("m", "", proto.CLIENT, 1, proto.RUNNING, 0.02))
tCM.Expect(conntx("m:3", "c:1", 1, &proto.AcceptIdentification{ tCM.Expect(conntx("m:3", "c:1", 1, &proto.AcceptIdentification{
NodeType: proto.MASTER, NodeType: proto.MASTER,
...@@ -393,9 +345,9 @@ func TestMasterStorage(t *testing.T) { ...@@ -393,9 +345,9 @@ func TestMasterStorage(t *testing.T) {
}, },
})) }))
tMC.Expect(node("c", "m:1", proto.MASTER, 1, proto.RUNNING, proto.IdTimeNone)) tMC.Expect(δnode("c", "m:1", proto.MASTER, 1, proto.RUNNING, proto.IdTimeNone))
tMC.Expect(node("c", "s:1", proto.STORAGE, 1, proto.RUNNING, 0.01)) tMC.Expect(δnode("c", "s:1", proto.STORAGE, 1, proto.RUNNING, 0.01))
tMC.Expect(node("c", "", proto.CLIENT, 1, proto.RUNNING, 0.02)) tMC.Expect(δnode("c", "", proto.CLIENT, 1, proto.RUNNING, 0.02))
// ---------------------------------------- // ----------------------------------------
......
...@@ -31,6 +31,8 @@ import ( ...@@ -31,6 +31,8 @@ import (
) )
// TraceCollector connects to NEO-specific trace points via probes and sends events to dispatcher. // TraceCollector connects to NEO-specific trace points via probes and sends events to dispatcher.
//
// XXX naming -> GoTracer (and PyTracer for NEO/py)
type TraceCollector struct { type TraceCollector struct {
pg *tracing.ProbeGroup pg *tracing.ProbeGroup
d interface { Dispatch(interface{}) } d interface { Dispatch(interface{}) }
......
...@@ -148,6 +148,7 @@ func (t IdTime) String() string { ...@@ -148,6 +148,7 @@ func (t IdTime) String() string {
// ---------------------------------------- // ----------------------------------------
// Addr converts network address string into NEO Address // Addr converts network address string into NEO Address
//
// TODO make neo.Address just string without host:port split // TODO make neo.Address just string without host:port split
func AddrString(network, addr string) (Address, error) { func AddrString(network, addr string) (Address, error) {
// empty is always empty // empty is always empty
......
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