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
f1f7eb02
Commit
f1f7eb02
authored
Feb 19, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
110de273
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
25 deletions
+22
-25
go/neo/t_cluster_test.go
go/neo/t_cluster_test.go
+7
-6
go/neo/t_tracego_test.go
go/neo/t_tracego_test.go
+15
-19
No files found.
go/neo/t_cluster_test.go
View file @
f1f7eb02
...
@@ -52,19 +52,20 @@ type tEnv struct {
...
@@ -52,19 +52,20 @@ type tEnv struct {
// Create it with tEnv.NewCluster.
// Create it with tEnv.NewCluster.
// Create nodes with .NewMaster, .NewStorage and .NewClient.
// Create nodes with .NewMaster, .NewStorage and .NewClient.
//
//
// NOTE network addresses are predictable due to using pipenet/lonet for inter-node networking.
// The cluster is tested based on synchronous event tracing -
// see package lab.nexedi.com/kirr/go123/tracing/tracetest for context.
//
//
//
XXX text about events tracing
//
NOTE network addresses are predictable due to using pipenet/lonet for inter-node networking.
type
tCluster
struct
{
type
tCluster
struct
{
*
tEnv
// original testing env this cluster was created at
*
tEnv
// original testing env this cluster was created at
name
string
// name of the cluster
name
string
// name of the cluster
network
*
virtnet
.
SubNetwork
// nodes interoperate via network
network
*
virtnet
.
SubNetwork
// nodes interoperate via network
traceOn
bool
// whether tracing is currently on or off
traceOn
bool
// whether tracing is currently on or off
gotracer
*
TraceCollector
// for tracing go nodes XXX -> GoTracer
gotracer
*
GoTracer
// for tracing go nodes
//tpy *PyTracer
// for tracing py nodes
//tpy *PyTracer
// for tracing py nodes TODO
erouter
*
EventRouter
// to which stream an event should go
erouter
*
EventRouter
// to which stream an event should go
tabMu
sync
.
Mutex
tabMu
sync
.
Mutex
nodeTab
map
[
string
/*node*/
]
*
tNode
nodeTab
map
[
string
/*node*/
]
*
tNode
...
...
go/neo/t_tracego_test.go
View file @
f1f7eb02
...
@@ -29,12 +29,8 @@ import (
...
@@ -29,12 +29,8 @@ import (
"lab.nexedi.com/kirr/neo/go/neo/xneo"
"lab.nexedi.com/kirr/neo/go/neo/xneo"
)
)
// GoTraceCollector collects events from NEO/go trace points and sends them to event dispatcher.
// GoTracer collects events from NEO/go trace points and sends them to event dispatcher.
//
type
GoTracer
struct
{
// 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
{
pg
*
tracing
.
ProbeGroup
pg
*
tracing
.
ProbeGroup
rx
interface
{
RxEvent
(
interface
{})
}
rx
interface
{
RxEvent
(
interface
{})
}
...
@@ -43,8 +39,8 @@ type TraceCollector struct {
...
@@ -43,8 +39,8 @@ type TraceCollector struct {
clusterState2Owner
map
[
*
proto
.
ClusterState
]
string
clusterState2Owner
map
[
*
proto
.
ClusterState
]
string
}
}
func
NewTraceCollector
(
rx
interface
{
RxEvent
(
interface
{})
})
*
TraceCollecto
r
{
func
NewTraceCollector
(
rx
interface
{
RxEvent
(
interface
{})
})
*
GoTrace
r
{
return
&
TraceCollecto
r
{
return
&
GoTrace
r
{
pg
:
&
tracing
.
ProbeGroup
{},
pg
:
&
tracing
.
ProbeGroup
{},
rx
:
rx
,
rx
:
rx
,
...
@@ -59,7 +55,7 @@ func NewTraceCollector(rx interface { RxEvent(interface{}) }) *TraceCollector {
...
@@ -59,7 +55,7 @@ func NewTraceCollector(rx interface { RxEvent(interface{}) }) *TraceCollector {
//trace:import "lab.nexedi.com/kirr/neo/go/neo/xneo"
//trace:import "lab.nexedi.com/kirr/neo/go/neo/xneo"
// Attach attaches the tracer to appropriate trace points.
// Attach attaches the tracer to appropriate trace points.
func
(
t
*
TraceCollecto
r
)
Attach
()
{
func
(
t
*
GoTrace
r
)
Attach
()
{
tracing
.
Lock
()
tracing
.
Lock
()
//neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv)
//neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv)
neonet_traceMsgSendPre_Attach
(
t
.
pg
,
t
.
traceNeoMsgSendPre
)
neonet_traceMsgSendPre_Attach
(
t
.
pg
,
t
.
traceNeoMsgSendPre
)
...
@@ -69,7 +65,7 @@ func (t *TraceCollector) Attach() {
...
@@ -69,7 +65,7 @@ func (t *TraceCollector) Attach() {
tracing
.
Unlock
()
tracing
.
Unlock
()
}
}
func
(
t
*
TraceCollecto
r
)
Detach
()
{
func
(
t
*
GoTrace
r
)
Detach
()
{
t
.
pg
.
Done
()
t
.
pg
.
Done
()
}
}
...
@@ -77,7 +73,7 @@ func (t *TraceCollector) Detach() {
...
@@ -77,7 +73,7 @@ func (t *TraceCollector) Detach() {
//
//
// This way it can translate e.g. *NodeTable -> owner node name when creating
// This way it can translate e.g. *NodeTable -> owner node name when creating
// corresponding event.
// corresponding event.
func
(
t
*
TraceCollecto
r
)
RegisterNode
(
node
*
xneo
.
Node
,
name
string
)
{
func
(
t
*
GoTrace
r
)
RegisterNode
(
node
*
xneo
.
Node
,
name
string
)
{
tracing
.
Lock
()
tracing
.
Lock
()
defer
tracing
.
Unlock
()
defer
tracing
.
Unlock
()
...
@@ -88,14 +84,14 @@ func (t *TraceCollector) RegisterNode(node *xneo.Node, name string) {
...
@@ -88,14 +84,14 @@ func (t *TraceCollector) RegisterNode(node *xneo.Node, name string) {
t
.
clusterState2Owner
[
&
node
.
State
.
Code
]
=
name
t
.
clusterState2Owner
[
&
node
.
State
.
Code
]
=
name
}
}
func
(
t
*
TraceCollecto
r
)
TraceNetDial
(
ev
*
xnet
.
TraceDial
)
{
func
(
t
*
GoTrace
r
)
TraceNetDial
(
ev
*
xnet
.
TraceDial
)
{
t
.
rx
.
RxEvent
(
&
eventNetDial
{
t
.
rx
.
RxEvent
(
&
eventNetDial
{
Dialer
:
ev
.
Dialer
,
Dialer
:
ev
.
Dialer
,
Addr
:
ev
.
Addr
,
Addr
:
ev
.
Addr
,
})
})
}
}
func
(
t
*
TraceCollector
)
TraceNetConnect
(
ev
*
xnet
.
TraceConnect
)
{
func
(
t
*
GoTracer
)
TraceNetConnect
(
ev
*
xnet
.
TraceConnect
)
{
t
.
rx
.
RxEvent
(
&
eventNetConnect
{
t
.
rx
.
RxEvent
(
&
eventNetConnect
{
Src
:
ev
.
Src
.
String
(),
Src
:
ev
.
Src
.
String
(),
Dst
:
ev
.
Dst
.
String
(),
Dst
:
ev
.
Dst
.
String
(),
...
@@ -103,27 +99,27 @@ func (t *TraceCollector) TraceNetConnect(ev *xnet.TraceConnect) {
...
@@ -103,27 +99,27 @@ func (t *TraceCollector) TraceNetConnect(ev *xnet.TraceConnect) {
})
})
}
}
func
(
t
*
TraceCollecto
r
)
TraceNetListen
(
ev
*
xnet
.
TraceListen
)
{
func
(
t
*
GoTrace
r
)
TraceNetListen
(
ev
*
xnet
.
TraceListen
)
{
t
.
rx
.
RxEvent
(
&
eventNetListen
{
Laddr
:
ev
.
Laddr
.
String
()})
t
.
rx
.
RxEvent
(
&
eventNetListen
{
Laddr
:
ev
.
Laddr
.
String
()})
}
}
func
(
t
*
TraceCollector
)
TraceNetTx
(
ev
*
xnet
.
TraceTx
)
{}
// we use traceNeoMsgSend instead
func
(
t
*
GoTracer
)
TraceNetTx
(
ev
*
xnet
.
TraceTx
)
{}
// we use traceNeoMsgSend instead
func
(
t
*
TraceCollecto
r
)
traceNeoMsgSendPre
(
l
*
neonet
.
NodeLink
,
connID
uint32
,
msg
proto
.
Msg
)
{
func
(
t
*
GoTrace
r
)
traceNeoMsgSendPre
(
l
*
neonet
.
NodeLink
,
connID
uint32
,
msg
proto
.
Msg
)
{
t
.
rx
.
RxEvent
(
&
eventNeoSend
{
l
.
LocalAddr
()
.
String
(),
l
.
RemoteAddr
()
.
String
(),
connID
,
msg
})
t
.
rx
.
RxEvent
(
&
eventNeoSend
{
l
.
LocalAddr
()
.
String
(),
l
.
RemoteAddr
()
.
String
(),
connID
,
msg
})
}
}
func
(
t
*
TraceCollecto
r
)
traceClusterState
(
cs
*
proto
.
ClusterState
)
{
func
(
t
*
GoTrace
r
)
traceClusterState
(
cs
*
proto
.
ClusterState
)
{
where
:=
t
.
clusterState2Owner
[
cs
]
where
:=
t
.
clusterState2Owner
[
cs
]
t
.
rx
.
RxEvent
(
&
eventClusterState
{
where
,
*
cs
})
t
.
rx
.
RxEvent
(
&
eventClusterState
{
where
,
*
cs
})
}
}
func
(
t
*
TraceCollecto
r
)
traceNode
(
nt
*
xneo
.
NodeTable
,
n
*
xneo
.
PeerNode
)
{
func
(
t
*
GoTrace
r
)
traceNode
(
nt
*
xneo
.
NodeTable
,
n
*
xneo
.
PeerNode
)
{
where
:=
t
.
nodeTab2Owner
[
nt
]
where
:=
t
.
nodeTab2Owner
[
nt
]
t
.
rx
.
RxEvent
(
&
eventNodeTab
{
where
,
n
.
NodeInfo
})
t
.
rx
.
RxEvent
(
&
eventNodeTab
{
where
,
n
.
NodeInfo
})
}
}
func
(
t
*
TraceCollecto
r
)
traceMasterStartReady
(
m
*
Master
,
ready
bool
)
{
func
(
t
*
GoTrace
r
)
traceMasterStartReady
(
m
*
Master
,
ready
bool
)
{
where
:=
t
.
node2Name
[
m
.
node
]
where
:=
t
.
node2Name
[
m
.
node
]
t
.
rx
.
RxEvent
(
&
eventMStartReady
{
where
,
ready
})
t
.
rx
.
RxEvent
(
&
eventMStartReady
{
where
,
ready
})
}
}
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