Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
58786531
Commit
58786531
authored
Feb 19, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f1f7eb02
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
46 deletions
+43
-46
go/neo/t_cluster_test.go
go/neo/t_cluster_test.go
+41
-44
go/neo/t_events_test.go
go/neo/t_events_test.go
+2
-2
No files found.
go/neo/t_cluster_test.go
View file @
58786531
...
...
@@ -47,6 +47,39 @@ type tEnv struct {
opt
tClusterOptions
// by default NEO clusters are created with this options
}
// tClusterOptions represents options for a test NEO cluster.
type
tClusterOptions
struct
{
// Network forces usage of this kind of network for node inter-networking (pipenet|lonet).
Network
string
}
// Verify verifies f for all combinations of NEO environments.
func
Verify
(
t
*
testing
.
T
,
f
func
(
*
tEnv
))
{
// TODO verify M=(go|py) x S=(go|py) x ...
// for now we only verify for all combinations of network
// TODO verify enc=(M|N) ?
// for all networks
for
_
,
network
:=
range
[]
string
{
"pipenet"
,
"lonet"
}
{
opt
:=
tClusterOptions
{
Network
:
network
,
}
t
.
Run
(
"net="
+
network
,
func
(
t
*
testing
.
T
)
{
tracetest
.
Verify
(
t
,
func
(
t
*
tracetest
.
T
)
{
tenv
:=
&
tEnv
{
T
:
t
,
opt
:
opt
,
}
f
(
tenv
)
})
})
}
}
// ----------------------------------------
// tCluster is a test NEO cluster.
//
// Create it with tEnv.NewCluster.
...
...
@@ -64,13 +97,13 @@ type tCluster struct {
traceOn
bool
// whether tracing is currently on or off
gotracer
*
GoTracer
// for tracing go nodes
//tpy *PyTracer // for tracing py nodes TODO
//tpy *PyTracer // for tracing py nodes
TODO
erouter
*
EventRouter
// to which stream an event should go
tabMu
sync
.
Mutex
nodeTab
map
[
string
/*node*/
]
*
tNode
runCtx
context
.
Context
// runCtx is canceled on .Stop() TODO or test failure
runCtx
context
.
Context
// runCtx is canceled on .Stop()
TODO or test failure
runWG
*
xsync
.
WorkGroup
// started nodes are .Run() under runWG
runCancel
func
()
}
...
...
@@ -96,12 +129,6 @@ type ITestClient interface {
}
// tClusterOptions represents options for a test NEO cluster.
type
tClusterOptions
struct
{
// Network forces usage of this kind of network for node inter-networking (pipenet|lonet).
Network
string
}
// NewCluster creates new NEO test cluster.
//
// At the end of the test the cluster has to be stopped via t.Stop().
...
...
@@ -128,7 +155,7 @@ func (t0 *tEnv) NewCluster(name string) *tCluster {
case
"pipenet"
:
net
=
pipenet
.
AsVirtNet
(
pipenet
.
New
(
"testnet"
))
case
"lonet"
:
net
,
err
=
lonet
.
Join
(
context
.
Background
(),
""
)
// XXX ctx
= ttest.Ctx
?
net
,
err
=
lonet
.
Join
(
context
.
Background
(),
""
)
// XXX ctx
-> t.Ctx()
?
if
err
!=
nil
{
t0
.
Fatal
(
err
)
}
...
...
@@ -175,7 +202,7 @@ func (t *tCluster) Stop() {
func
(
t
*
tCluster
)
TraceOff
()
{
t
.
traceOn
=
false
t
.
gotracer
.
Detach
()
//
XXX
t.pytracer.Detach()
//t.pytracer.Detach()
t
.
tabMu
.
Lock
()
defer
t
.
tabMu
.
Unlock
()
...
...
@@ -187,9 +214,8 @@ func (t *tCluster) TraceOff() {
// registerNewNode registers new node with given name.
//
// the node is registered in .nodeTab and .checkTab is populated ... XXX
//
// the node must not be registered before.
// The node is registered in .nodeTab and .erouter is updated for on-node and node-* events.
// The node must not be registered before.
func
(
t
*
tCluster
)
registerNewNode
(
name
string
)
*
tNode
{
t
.
tabMu
.
Lock
()
defer
t
.
tabMu
.
Unlock
()
...
...
@@ -362,36 +388,7 @@ func (m *tMaster) Run(ctx context.Context) error {
return
m
.
Master
.
Run
(
ctx
,
l
)
}
// -------------------
// Verify verifies f for all combinations of node kinds.
// XXX place
func
Verify
(
t
*
testing
.
T
,
f
func
(
*
tEnv
))
{
// TODO verify M=(go|py) x S=(go|py) x ...
// for now we only verify for all combinations of network
// TODO verify enc=(M|N) ?
// for all networks
for
_
,
network
:=
range
[]
string
{
"pipenet"
,
"lonet"
}
{
opt
:=
tClusterOptions
{
Network
:
network
,
}
t
.
Run
(
"net="
+
network
,
func
(
t
*
testing
.
T
)
{
tracetest
.
Verify
(
t
,
func
(
t
*
tracetest
.
T
)
{
tenv
:=
&
tEnv
{
T
:
t
,
opt
:
opt
,
}
f
(
tenv
)
})
})
}
}
// --------------------
// ----------------------------------------
// tNewCluster_MS starts simple NEO cluster with 1 master and 1 storage nodes.
// The cluster is returned in ready-to-start state.
...
...
@@ -430,7 +427,7 @@ func (t0 *tEnv) NewCluster_MS(name string, Sback storage.Backend) *tCluster {
}))
// M sends nodeTab to S
// XXX
notifications should go to "m-s/notify"
?
// XXX
better notifications should go to "m-s/notify" instead
?
t
.
Expect
(
"m-s"
,
conntx
(
"m:2"
,
"s:2"
,
0
,
&
proto
.
NotifyNodeInformation
{
IdTime
:
proto
.
IdTimeNone
,
// XXX ?
NodeList
:
[]
proto
.
NodeInfo
{
...
...
go/neo/t_events_test.go
View file @
58786531
...
...
@@ -77,8 +77,8 @@ type eventNodeTab struct {
// event: master ready to start changed
type
eventMStartReady
struct
{
Where
string
// ~ name of the master node
Ready
bool
Where
string
// ~ name of the master node
Ready
bool
}
func
masterStartReady
(
where
string
,
ready
bool
)
*
eventMStartReady
{
...
...
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