Commit 4c91dc61 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 57a86cd5
......@@ -203,7 +203,7 @@ func (nl *NodeLink) NewConn() (*Conn, error) {
return c, nil
}
// shutdown closes peerLink and marks NodeLink as no longer operational
// shutdown closes raw link to peer and marks NodeLink as no longer operational.
// it also shutdowns all opened connections over this node link.
func (nl *NodeLink) shutdown() {
nl.downOnce.Do(func() {
......@@ -699,9 +699,32 @@ func Dial(ctx context.Context, net xnet.Networker, addr string) (nl *NodeLink, e
// block further Accepts.
// ---- for convenience: Conn -> NodeLink & local/remote link addresses ----
// LocalAddr returns local address of the underlying link to peer.
func (nl *NodeLink) LocalAddr() net.Addr {
return nl.peerLink.LocalAddr()
}
// RemoteAddr returns remote address of the underlying link to peer.
func (nl *NodeLink) RemoteAddr() net.Addr {
return nl.peerLink.RemoteAddr()
}
// Link returns underlying NodeLink of this connection.
func (c *Conn) Link() *NodeLink {
return c.nodeLink
}
// ConnID returns connection identifier used for the connection.
func (c *Conn) ConnID() uint32 {
return c.connId
}
// ---- for convenience: String / Error ----
func (nl *NodeLink) String() string {
s := fmt.Sprintf("%s - %s", nl.peerLink.LocalAddr(), nl.peerLink.RemoteAddr())
s := fmt.Sprintf("%s - %s", nl.LocalAddr(), nl.RemoteAddr())
return s // XXX add "(closed)" if nl is closed ?
// XXX other flags e.g. (down) ?
}
......
......@@ -27,6 +27,7 @@ import (
//"bytes"
"context"
//"io"
"net"
//"reflect"
"testing"
......@@ -78,7 +79,9 @@ type traceNeoSend struct {
ConnID uint32
Msg neo.Msg
}
func (t *MyTracer) traceNeoConnSend(c *neo.Conn, msg neo.Msg) { t.Trace1(&traceNeoSend{c, msg}) }
func (t *MyTracer) traceNeoConnSendPre(c *neo.Conn, msg neo.Msg) {
t.Trace1(&traceNeoSend{c.Link().LocalAddr(), c.Link().RemoteAddr(), c.ConnID(), msg})
}
......@@ -169,6 +172,11 @@ func TestMasterStorage(t *testing.T) {
return &xnet.TraceListen{Laddr: xaddr(laddr)}
}
// XXX
conntx := func(src, dst string, connid uint32, msg neo.Msg) *traceNeoSend {
return &traceNeoSend{Src: xaddr(src), Dst: xaddr(dst), ConnID: connid, Msg: msg}
}
Mhost := xnet.NetTrace(net.Host("m"), tracer)
Shost := xnet.NetTrace(net.Host("s"), tracer)
......@@ -209,11 +217,9 @@ func TestMasterStorage(t *testing.T) {
//)
_ = nettx
tc.Expect(
conntx("s:1", "m:1", 1, RequestIdentification{...})
// ... M adjust nodetab...
conntx("m:1", "s:1", 1, AcceptIdentification{...})
)
tc.Expect(conntx("s:1", "m:1", 1, &neo.RequestIdentification{})) // XXX
// XXX ... M adjust nodetab...
tc.Expect(conntx("m:1", "s:1", 1, &neo.AcceptIdentification{})) // XXX
......
......@@ -13,7 +13,7 @@ import (
// traceimport: "lab.nexedi.com/kirr/neo/go/neo"
// rerun "gotrace gen" if you see link failure ↓↓↓
//go:linkname neo_trace_exporthash lab.nexedi.com/kirr/neo/go/neo._trace_exporthash_bc56cd7a9caf82c14d9586243f763e65afb91ea0
//go:linkname neo_trace_exporthash lab.nexedi.com/kirr/neo/go/neo._trace_exporthash_d2fa0ebb37c3e2bf54309859a1eeb0e831edd435
func neo_trace_exporthash()
func init() { neo_trace_exporthash() }
......@@ -21,5 +21,5 @@ func init() { neo_trace_exporthash() }
//go:linkname neo_traceConnRecv_Attach lab.nexedi.com/kirr/neo/go/neo.traceConnRecv_Attach
func neo_traceConnRecv_Attach(*tracing.ProbeGroup, func(c *neo.Conn, msg neo.Msg)) *tracing.Probe
//go:linkname neo_traceConnSend_Attach lab.nexedi.com/kirr/neo/go/neo.traceConnSend_Attach
func neo_traceConnSend_Attach(*tracing.ProbeGroup, func(c *neo.Conn, msg neo.Msg)) *tracing.Probe
//go:linkname neo_traceConnSendPre_Attach lab.nexedi.com/kirr/neo/go/neo.traceConnSendPre_Attach
func neo_traceConnSendPre_Attach(*tracing.ProbeGroup, func(c *neo.Conn, msg neo.Msg)) *tracing.Probe
......@@ -25,6 +25,8 @@ import (
"reflect"
"strings"
"testing"
"github.com/kylelemons/godebug/pretty"
)
// XXX move -> tracing
......@@ -114,7 +116,9 @@ func (tc *TraceChecker) expect1(eventExpect interface{}) {
revent := reventp.Elem()
if !reflect.DeepEqual(revent.Interface(), reventExpect.Interface()) {
tc.t.Fatalf("expect: %s:\nhave: %v\nwant: %v", reventExpect.Type(), revent, reventExpect)
tc.t.Fatalf("expect: %s:\nwant: %v\nhave: %v\ndiff: %s",
reventExpect.Type(), reventExpect, revent,
pretty.Compare(reventExpect.Interface(), revent.Interface()))
}
close(msg.Ack)
......
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