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
a22c8d74
Commit
a22c8d74
authored
Dec 30, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8d420d23
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
13 deletions
+39
-13
go/neo/t_cluster_test.go
go/neo/t_cluster_test.go
+39
-13
No files found.
go/neo/t_cluster_test.go
View file @
a22c8d74
...
@@ -213,6 +213,20 @@ func (t *tCluster) registerNewNode(name string) *tNode {
...
@@ -213,6 +213,20 @@ func (t *tCluster) registerNewNode(name string) *tNode {
return
node
return
node
}
}
// getNode returns node by name.
//
// The node must be registered before with registerNewNode.
func
(
t
*
tCluster
)
getNode
(
name
string
)
*
tNode
{
t
.
tabMu
.
Lock
()
defer
t
.
tabMu
.
Unlock
()
tnode
,
ok
:=
t
.
nodeTab
[
name
]
if
!
ok
{
t
.
Fatalf
(
"no node %q"
,
name
)
}
return
tnode
}
// NewMaster creates new master on node name.
// NewMaster creates new master on node name.
//
//
...
@@ -236,40 +250,52 @@ func (t *tCluster) NewMaster(name string) ITestMaster {
...
@@ -236,40 +250,52 @@ func (t *tCluster) NewMaster(name string) ITestMaster {
// Master returns master node that was previouslt created via NewMaster(name).
// Master returns master node that was previouslt created via NewMaster(name).
func
(
t
*
tCluster
)
Master
(
name
string
)
ITestMaster
{
func
(
t
*
tCluster
)
Master
(
name
string
)
ITestMaster
{
t
.
tabMu
.
Lock
()
tnode
:=
t
.
getNode
(
name
)
defer
t
.
tabMu
.
Unlock
()
tnode
,
ok
:=
t
.
nodeTab
[
name
]
if
!
ok
{
t
.
Fatalf
(
"no node %q"
,
name
)
}
m
,
ok
:=
tnode
.
itest
.
(
ITestMaster
)
m
,
ok
:=
tnode
.
itest
.
(
ITestMaster
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"node %q i
f
of type %T, not master"
,
name
,
tnode
.
itest
)
t
.
Fatalf
(
"node %q i
s
of type %T, not master"
,
name
,
tnode
.
itest
)
}
}
return
m
return
m
}
}
// {New,}Storage are similar to {New,}Master but for storage nodes.
func
(
t
*
tCluster
)
NewStorage
(
name
,
masterAddr
string
,
back
storage
.
Backend
)
ITestStorage
{
func
(
t
*
tCluster
)
NewStorage
(
name
,
masterAddr
string
,
back
storage
.
Backend
)
ITestStorage
{
node
:=
t
.
registerNewNode
(
name
)
t
node
:=
t
.
registerNewNode
(
name
)
s
:=
tNewStorage
(
t
.
name
,
masterAddr
,
":1"
,
node
.
net
,
back
)
s
:=
tNewStorage
(
t
.
name
,
masterAddr
,
":1"
,
t
node
.
net
,
back
)
t
.
gotracer
.
RegisterNode
(
s
.
node
,
name
)
t
.
gotracer
.
RegisterNode
(
s
.
node
,
name
)
t
.
runWG
.
Go
(
func
(
ctx
context
.
Context
)
error
{
t
.
runWG
.
Go
(
func
(
ctx
context
.
Context
)
error
{
return
s
.
Run
(
ctx
)
return
s
.
Run
(
ctx
)
})
})
return
s
return
s
}
}
func
(
t
*
tCluster
)
Storage
(
name
string
)
ITestStorage
{
tnode
:=
t
.
getNode
(
name
)
s
,
ok
:=
tnode
.
itest
.
(
ITestStorage
)
if
!
ok
{
t
.
Fatalf
(
"node %q is of type %T, not storage"
,
name
,
tnode
.
itest
)
}
return
s
}
// {New,}Client are similar to {New,}Master but for client nodes.
func
(
t
*
tCluster
)
NewClient
(
name
,
masterAddr
string
)
ITestClient
{
func
(
t
*
tCluster
)
NewClient
(
name
,
masterAddr
string
)
ITestClient
{
node
:=
t
.
registerNewNode
(
name
)
t
node
:=
t
.
registerNewNode
(
name
)
c
:=
NewClient
(
t
.
name
,
masterAddr
,
node
.
net
)
c
:=
NewClient
(
t
.
name
,
masterAddr
,
t
node
.
net
)
t
.
gotracer
.
RegisterNode
(
c
.
node
,
name
)
t
.
gotracer
.
RegisterNode
(
c
.
node
,
name
)
t
.
runWG
.
Go
(
func
(
ctx
context
.
Context
)
error
{
t
.
runWG
.
Go
(
func
(
ctx
context
.
Context
)
error
{
return
c
.
Run
(
ctx
)
return
c
.
Run
(
ctx
)
})
})
return
c
return
c
}
}
func
(
t
*
tCluster
)
Client
(
name
string
)
ITestClient
{
tnode
:=
t
.
getNode
(
name
)
c
,
ok
:=
tnode
.
itest
.
(
ITestClient
)
if
!
ok
{
t
.
Fatalf
(
"node %q is of type %T, not client"
,
name
,
tnode
.
itest
)
}
return
c
}
// tStorage is test-wrapper around Storage.
// tStorage is test-wrapper around Storage.
...
...
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