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
bfd30ffa
Commit
bfd30ffa
authored
Feb 09, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
347c32d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+16
-6
go/xcommon/xtracing/tsync/tsync.go
go/xcommon/xtracing/tsync/tsync.go
+4
-3
No files found.
go/neo/server/cluster_test.go
View file @
bfd30ffa
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
//"reflect"
//"reflect"
"sync"
"sync"
"testing"
"testing"
"unsafe"
//
"unsafe"
"golang.org/x/sync/errgroup"
"golang.org/x/sync/errgroup"
...
@@ -100,12 +100,14 @@ type eventNodeTab struct {
...
@@ -100,12 +100,14 @@ type eventNodeTab struct {
// event: master ready to start changed
// event: master ready to start changed
type
eventMStartReady
struct
{
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
Ready
bool
}
}
func
masterStartReady
(
m
*
Master
,
ready
bool
)
*
eventMStartReady
{
func
masterStartReady
(
where
string
,
ready
bool
)
*
eventMStartReady
{
return
&
eventMStartReady
{
unsafe
.
Pointer
(
m
),
ready
}
//return &eventMStartReady{unsafe.Pointer(m), ready}
return
&
eventMStartReady
{
where
,
ready
}
}
}
// ---- events routing ----
// ---- events routing ----
...
@@ -232,6 +234,9 @@ func (r *EventRouter) Route(event interface{}) (dst *tsync.SyncChan) {
...
@@ -232,6 +234,9 @@ func (r *EventRouter) Route(event interface{}) (dst *tsync.SyncChan) {
case
*
eventClusterState
:
case
*
eventClusterState
:
dst
=
r
.
byNode
[
ev
.
Where
]
dst
=
r
.
byNode
[
ev
.
Where
]
case
*
eventMStartReady
:
dst
=
r
.
byNode
[
ev
.
Where
]
}
}
if
dst
==
nil
{
if
dst
==
nil
{
...
@@ -283,6 +288,7 @@ type TraceCollector struct {
...
@@ -283,6 +288,7 @@ type TraceCollector struct {
pg
*
tracing
.
ProbeGroup
pg
*
tracing
.
ProbeGroup
d
*
tsync
.
EventDispatcher
d
*
tsync
.
EventDispatcher
node2Name
map
[
*
neo
.
NodeApp
]
string
nodeTab2Owner
map
[
*
neo
.
NodeTable
]
string
nodeTab2Owner
map
[
*
neo
.
NodeTable
]
string
clusterState2Owner
map
[
*
neo
.
ClusterState
]
string
clusterState2Owner
map
[
*
neo
.
ClusterState
]
string
}
}
...
@@ -292,6 +298,7 @@ func NewTraceCollector(dispatch *tsync.EventDispatcher) *TraceCollector {
...
@@ -292,6 +298,7 @@ func NewTraceCollector(dispatch *tsync.EventDispatcher) *TraceCollector {
pg
:
&
tracing
.
ProbeGroup
{},
pg
:
&
tracing
.
ProbeGroup
{},
d
:
dispatch
,
d
:
dispatch
,
node2Name
:
make
(
map
[
*
neo
.
NodeApp
]
string
),
nodeTab2Owner
:
make
(
map
[
*
neo
.
NodeTable
]
string
),
nodeTab2Owner
:
make
(
map
[
*
neo
.
NodeTable
]
string
),
clusterState2Owner
:
make
(
map
[
*
neo
.
ClusterState
]
string
),
clusterState2Owner
:
make
(
map
[
*
neo
.
ClusterState
]
string
),
}
}
...
@@ -324,6 +331,7 @@ func (t *TraceCollector) RegisterNode(node *neo.NodeApp, name string) {
...
@@ -324,6 +331,7 @@ func (t *TraceCollector) RegisterNode(node *neo.NodeApp, name string) {
// XXX verify there is no duplicate names
// XXX verify there is no duplicate names
// XXX verify the same pointer is not registerd twice
// XXX verify the same pointer is not registerd twice
t
.
node2Name
[
node
]
=
name
t
.
nodeTab2Owner
[
node
.
NodeTab
]
=
name
t
.
nodeTab2Owner
[
node
.
NodeTab
]
=
name
t
.
clusterState2Owner
[
&
node
.
ClusterState
]
=
name
t
.
clusterState2Owner
[
&
node
.
ClusterState
]
=
name
}
}
...
@@ -360,7 +368,9 @@ func (t *TraceCollector) traceNode(nt *neo.NodeTable, n *neo.Node) {
...
@@ -360,7 +368,9 @@ func (t *TraceCollector) traceNode(nt *neo.NodeTable, n *neo.Node) {
}
}
func
(
t
*
TraceCollector
)
traceMasterStartReady
(
m
*
Master
,
ready
bool
)
{
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) {
...
@@ -556,7 +566,7 @@ func TestMasterStorage(t *testing.T) {
}))
}))
// M ready to start: new cluster, no in-progress S recovery
// M ready to start: new cluster, no in-progress S recovery
tM
.
Expect
(
masterStartReady
(
M
,
true
))
tM
.
Expect
(
masterStartReady
(
"m"
,
true
))
// <<< trace <<<
// <<< trace <<<
...
...
go/xcommon/xtracing/tsync/tsync.go
View file @
bfd30ffa
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
// Package tsync provides infrastructure for synchronous testing based on program tracing.
// 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
// A serial system can be verified by checking that its execution produces
// expected serial stream of events. But concurrent systems cannot be verified
// expected serial stream of events. But concurrent systems cannot be verified
...
@@ -152,7 +152,7 @@ func (evc *EventChecker) xget1(eventp interface{}) *SyncMsg {
...
@@ -152,7 +152,7 @@ func (evc *EventChecker) xget1(eventp interface{}) *SyncMsg {
reventp
:=
reflect
.
ValueOf
(
eventp
)
reventp
:=
reflect
.
ValueOf
(
eventp
)
if
reventp
.
Type
()
.
Elem
()
!=
reflect
.
TypeOf
(
msg
.
Event
)
{
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
// *eventp = msg.Event
...
@@ -174,7 +174,8 @@ func (evc *EventChecker) expect1(eventExpect interface{}) *SyncMsg {
...
@@ -174,7 +174,8 @@ func (evc *EventChecker) expect1(eventExpect interface{}) *SyncMsg {
revent
:=
reventp
.
Elem
()
revent
:=
reventp
.
Elem
()
if
!
reflect
.
DeepEqual
(
revent
.
Interface
(),
reventExpect
.
Interface
())
{
if
!
reflect
.
DeepEqual
(
revent
.
Interface
(),
reventExpect
.
Interface
())
{
evc
.
t
.
Fatalf
(
"expect: %s:
\n
want: %v
\n
have: %v
\n
diff: %s"
,
evc
.
t
.
Fatalf
(
"%s: expect: %s:
\n
want: %v
\n
have: %v
\n
diff: %s"
,
evc
.
in
.
name
,
reventExpect
.
Type
(),
reventExpect
,
revent
,
reventExpect
.
Type
(),
reventExpect
,
revent
,
pretty
.
Compare
(
reventExpect
.
Interface
(),
revent
.
Interface
()))
pretty
.
Compare
(
reventExpect
.
Interface
(),
revent
.
Interface
()))
}
}
...
...
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