Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
2510d03b
Commit
2510d03b
authored
Jun 14, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2bfd266f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+29
-18
go/xcommon/xnet/trace.go
go/xcommon/xnet/trace.go
+1
-0
No files found.
go/neo/server/cluster_test.go
View file @
2510d03b
...
@@ -39,6 +39,8 @@ import (
...
@@ -39,6 +39,8 @@ import (
"fmt"
"fmt"
)
)
var
_
=
fmt
.
Print
// XXX dup from connection_test
// XXX dup from connection_test
func
xwait
(
w
interface
{
Wait
()
error
})
{
func
xwait
(
w
interface
{
Wait
()
error
})
{
err
:=
w
.
Wait
()
err
:=
w
.
Wait
()
...
@@ -62,10 +64,9 @@ type traceMsg struct {
...
@@ -62,10 +64,9 @@ type traceMsg struct {
// TraceChecker synchronously collects and checks tracing events
// TraceChecker synchronously collects and checks tracing events
// it collects events from several sources and sends them all into one channel
// it collects events from several sources and sends them all into one channel
// for each event the goroutine which produced it will wait for ack before continue
// for each event the goroutine which produced it will wait for ack before continue
// XXX more text XXX naming -> verifier?
type
TraceChecker
struct
{
type
TraceChecker
struct
{
t
*
testing
.
T
t
*
testing
.
T
msgch
chan
*
traceMsg
// XXX
or chan traceMsg (no ptr)
?
msgch
chan
*
traceMsg
// XXX
naming -> tracech
?
}
}
func
NewTraceChecker
(
t
*
testing
.
T
)
*
TraceChecker
{
func
NewTraceChecker
(
t
*
testing
.
T
)
*
TraceChecker
{
...
@@ -74,26 +75,29 @@ func NewTraceChecker(t *testing.T) *TraceChecker {
...
@@ -74,26 +75,29 @@ func NewTraceChecker(t *testing.T) *TraceChecker {
// get1 gets 1 event in place and checks it has expected type
// get1 gets 1 event in place and checks it has expected type
func
(
tc
*
TraceChecker
)
xget1
(
eventp
interface
{})
*
traceMsg
{
func
(
tc
*
TraceChecker
)
xget1
(
eventp
interface
{})
*
traceMsg
{
println
(
"xget1: entry"
)
tc
.
t
.
Helper
()
//println("xget1: entry")
msg
:=
<-
tc
.
msgch
msg
:=
<-
tc
.
msgch
println
(
"xget1: msg"
,
msg
)
//
println("xget1: msg", msg)
revp
:=
reflect
.
ValueOf
(
eventp
)
rev
ent
p
:=
reflect
.
ValueOf
(
eventp
)
if
revp
.
Type
()
.
Elem
()
!=
reflect
.
TypeOf
(
msg
.
event
)
{
if
rev
ent
p
.
Type
()
.
Elem
()
!=
reflect
.
TypeOf
(
msg
.
event
)
{
tc
.
t
.
Fatalf
(
"expected %s; got %#v"
,
revp
.
Elem
()
.
Type
(),
msg
.
event
)
tc
.
t
.
Fatalf
(
"expected %s; got %#v"
,
rev
ent
p
.
Elem
()
.
Type
(),
msg
.
event
)
}
}
// TODO *event = msg.event
// *eventp = msg.event
reventp
.
Elem
()
.
Set
(
reflect
.
ValueOf
(
msg
.
event
))
return
msg
return
msg
}
}
// trace1 sends message with one tracing event to consumer
// trace1 sends message with one tracing event to consumer
func
(
tc
*
TraceChecker
)
trace1
(
event
interface
{})
{
func
(
tc
*
TraceChecker
)
trace1
(
event
interface
{})
{
ack
:=
make
(
chan
struct
{})
ack
:=
make
(
chan
struct
{})
fmt
.
Printf
(
"I: %v ..."
,
event
)
//fmt.Printf("I: %#v ...", event)
println
(
"zzz"
)
//panic(0)
tc
.
msgch
<-
&
traceMsg
{
event
,
ack
}
tc
.
msgch
<-
&
traceMsg
{
event
,
ack
}
<-
ack
<-
ack
fmt
.
Printf
(
" ok
\n
"
)
//
fmt.Printf(" ok\n")
}
}
func
(
tc
*
TraceChecker
)
TraceNetDial
(
ev
*
xnet
.
TraceDial
)
{
tc
.
trace1
(
ev
)
}
func
(
tc
*
TraceChecker
)
TraceNetDial
(
ev
*
xnet
.
TraceDial
)
{
tc
.
trace1
(
ev
)
}
...
@@ -104,6 +108,8 @@ func (tc *TraceChecker) TraceNetTx(ev *xnet.TraceTx) { tc.trace1(ev) }
...
@@ -104,6 +108,8 @@ func (tc *TraceChecker) TraceNetTx(ev *xnet.TraceTx) { tc.trace1(ev) }
// Expect instruct checker to expect next event to be ...
// Expect instruct checker to expect next event to be ...
// XXX
// XXX
func
(
tc
*
TraceChecker
)
ExpectNetDial
(
dst
string
)
{
func
(
tc
*
TraceChecker
)
ExpectNetDial
(
dst
string
)
{
tc
.
t
.
Helper
()
var
ev
*
xnet
.
TraceDial
var
ev
*
xnet
.
TraceDial
msg
:=
tc
.
xget1
(
&
ev
)
msg
:=
tc
.
xget1
(
&
ev
)
...
@@ -115,6 +121,8 @@ func (tc *TraceChecker) ExpectNetDial(dst string) {
...
@@ -115,6 +121,8 @@ func (tc *TraceChecker) ExpectNetDial(dst string) {
}
}
func
(
tc
*
TraceChecker
)
ExpectNetListen
(
laddr
string
)
{
func
(
tc
*
TraceChecker
)
ExpectNetListen
(
laddr
string
)
{
tc
.
t
.
Helper
()
var
ev
*
xnet
.
TraceListen
var
ev
*
xnet
.
TraceListen
msg
:=
tc
.
xget1
(
&
ev
)
msg
:=
tc
.
xget1
(
&
ev
)
...
@@ -122,11 +130,12 @@ func (tc *TraceChecker) ExpectNetListen(laddr string) {
...
@@ -122,11 +130,12 @@ func (tc *TraceChecker) ExpectNetListen(laddr string) {
tc
.
t
.
Fatalf
(
"net listen: have %v; want %v"
,
ev
.
Laddr
,
laddr
)
tc
.
t
.
Fatalf
(
"net listen: have %v; want %v"
,
ev
.
Laddr
,
laddr
)
}
}
println
(
"listen: ok"
)
close
(
msg
.
ack
)
close
(
msg
.
ack
)
}
}
func
(
tc
*
TraceChecker
)
ExpectNetTx
(
src
,
dst
string
,
pkt
string
)
{
func
(
tc
*
TraceChecker
)
ExpectNetTx
(
src
,
dst
string
,
pkt
string
)
{
tc
.
t
.
Helper
()
var
ev
*
xnet
.
TraceTx
var
ev
*
xnet
.
TraceTx
msg
:=
tc
.
xget1
(
&
ev
)
msg
:=
tc
.
xget1
(
&
ev
)
...
@@ -161,11 +170,8 @@ func TestMasterStorage(t *testing.T) {
...
@@ -161,11 +170,8 @@ func TestMasterStorage(t *testing.T) {
_
=
err
// XXX
_
=
err
// XXX
})
})
println
(
"222"
)
// expect:
// expect:
//tc.ExpectNetListen("0")
tc
.
ExpectNetListen
(
"0"
)
tc
.
ExpectNetDial
(
"0"
)
println
(
"333"
)
// M.clusterState <- RECOVERY
// M.clusterState <- RECOVERY
// M.nodeTab <- Node(M)
// M.nodeTab <- Node(M)
...
@@ -179,10 +185,15 @@ func TestMasterStorage(t *testing.T) {
...
@@ -179,10 +185,15 @@ func TestMasterStorage(t *testing.T) {
})
})
// expect:
// expect:
// M <- S .? RequestIdentification{...} + TODO test ID rejects
tc
.
ExpectNetListen
(
"1"
)
tc
.
ExpectNetDial
(
"0"
)
tc
.
ExpectNetTx
(
"2c"
,
"2s"
,
"
\x00\x00\x00\x01
"
)
// handshake
tc
.
ExpectNetTx
(
"2c"
,
"2s"
,
"
\x00\x00\x00\x01
"
)
// handshake
tc
.
ExpectNetTx
(
"2s"
,
"2c"
,
"
\x00\x00\x00\x01
"
)
tc
.
ExpectNetTx
(
"2s"
,
"2c"
,
"
\x00\x00\x00\x01
"
)
// XXX temp
return
// M <- S .? RequestIdentification{...} + TODO test ID rejects
// M -> S .? AcceptIdentification{...}
// M -> S .? AcceptIdentification{...}
// M.nodeTab <- Node(S) XXX order can be racy?
// M.nodeTab <- Node(S) XXX order can be racy?
// S.nodeTab <- Node(M) XXX order can be racy?
// S.nodeTab <- Node(M) XXX order can be racy?
...
...
go/xcommon/xnet/trace.go
View file @
2510d03b
...
@@ -47,6 +47,7 @@ type Tracer interface {
...
@@ -47,6 +47,7 @@ type Tracer interface {
// TraceDial is event corresponding to network dialing
// TraceDial is event corresponding to network dialing
type
TraceDial
struct
{
type
TraceDial
struct
{
// XXX also put Src here somehow ?
Dst
string
Dst
string
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment