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
bae69488
Commit
bae69488
authored
Dec 30, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b5bfc158
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
33 deletions
+41
-33
go/neo/neo_test.go
go/neo/neo_test.go
+11
-26
go/neo/t_cluster_test.go
go/neo/t_cluster_test.go
+30
-7
No files found.
go/neo/neo_test.go
View file @
bae69488
...
@@ -36,8 +36,6 @@ import (
...
@@ -36,8 +36,6 @@ import (
"lab.nexedi.com/kirr/neo/go/internal/xtracing/tracetest"
"lab.nexedi.com/kirr/neo/go/internal/xtracing/tracetest"
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xnet/pipenet"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/go123/xsync"
)
)
...
@@ -54,7 +52,7 @@ func tracetestMasterStorage(t0 *tracetest.T) {
...
@@ -54,7 +52,7 @@ func tracetestMasterStorage(t0 *tracetest.T) {
lastTid
,
err
:=
zstor
.
Sync
(
bg
);
X
(
err
)
lastTid
,
err
:=
zstor
.
Sync
(
bg
);
X
(
err
)
// create the cluster
// create the cluster
t
:=
tNewCluster_MS
(
t0
,
"abc1"
,
zback
)
t
:=
tNewCluster_MS
(
t0
,
"abc1"
,
zback
,
tClusterOptions
{}
)
defer
t
.
Stop
()
defer
t
.
Stop
()
M
:=
t
.
Master
(
"m"
)
M
:=
t
.
Master
(
"m"
)
C
:=
t
.
NewClient
(
"c"
,
"m:1"
)
C
:=
t
.
NewClient
(
"c"
,
"m:1"
)
...
@@ -349,14 +347,13 @@ func tracetestMasterStorage(t0 *tracetest.T) {
...
@@ -349,14 +347,13 @@ func tracetestMasterStorage(t0 *tracetest.T) {
}
}
// XXX kill Mnet/Snet/Cnet -> pass which network to use to tNewCluster
func
benchmarkGetObject
(
b
*
testing
.
B
,
opt
tClusterOptions
,
benchit
func
(
xcload1
func
()))
{
func
benchmarkGetObject
(
b
*
testing
.
B
,
Mnet
,
Snet
,
Cnet
xnet
.
Networker
,
benchit
func
(
xcload1
func
()))
{
X
:=
exc
.
Raiseif
X
:=
exc
.
Raiseif
tracetest
.
Run
(
b
,
func
(
t0
*
tracetest
.
T
)
{
tracetest
.
Run
(
b
,
func
(
t0
*
tracetest
.
T
)
{
// create test cluster
// create test cluster
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
t
:=
tNewCluster_MS
(
t0
,
"abc1"
,
zback
)
t
:=
tNewCluster_MS
(
t0
,
"abc1"
,
zback
,
opt
)
defer
t
.
Stop
()
defer
t
.
Stop
()
M
:=
t
.
Master
(
"m"
)
M
:=
t
.
Master
(
"m"
)
...
@@ -398,16 +395,16 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
...
@@ -398,16 +395,16 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
})
})
}
}
func
benchmarkGetObjectSerial
(
b
*
testing
.
B
,
Mnet
,
Snet
,
Cnet
xnet
.
Networker
)
{
func
benchmarkGetObjectSerial
(
b
*
testing
.
B
,
opt
tClusterOptions
)
{
benchmarkGetObject
(
b
,
Mnet
,
Snet
,
Cne
t
,
func
(
xcload1
func
())
{
benchmarkGetObject
(
b
,
op
t
,
func
(
xcload1
func
())
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
xcload1
()
xcload1
()
}
}
})
})
}
}
func
benchmarkGetObjectParallel
(
b
*
testing
.
B
,
Mnet
,
Snet
,
Cnet
xnet
.
Networker
)
{
func
benchmarkGetObjectParallel
(
b
*
testing
.
B
,
opt
tClusterOptions
)
{
benchmarkGetObject
(
b
,
Mnet
,
Snet
,
Cne
t
,
func
(
xcload1
func
())
{
benchmarkGetObject
(
b
,
op
t
,
func
(
xcload1
func
())
{
//println()
//println()
b
.
SetParallelism
(
32
)
// we are io-bound
b
.
SetParallelism
(
32
)
// we are io-bound
b
.
RunParallel
(
func
(
pb
*
testing
.
PB
)
{
b
.
RunParallel
(
func
(
pb
*
testing
.
PB
)
{
...
@@ -420,29 +417,17 @@ func benchmarkGetObjectParallel(b *testing.B, Mnet, Snet, Cnet xnet.Networker) {
...
@@ -420,29 +417,17 @@ func benchmarkGetObjectParallel(b *testing.B, Mnet, Snet, Cnet xnet.Networker) {
}
}
func
BenchmarkGetObjectNetPipe
(
b
*
testing
.
B
)
{
func
BenchmarkGetObjectNetPipe
(
b
*
testing
.
B
)
{
net
:=
pipenet
.
New
(
"testnet"
)
benchmarkGetObjectSerial
(
b
,
tClusterOptions
{
Network
:
"pipenet"
})
Mhost
:=
net
.
Host
(
"m"
)
Shost
:=
net
.
Host
(
"s"
)
Chost
:=
net
.
Host
(
"c"
)
benchmarkGetObjectSerial
(
b
,
Mhost
,
Shost
,
Chost
)
}
}
func
BenchmarkGetObjectNetPipeParallel
(
b
*
testing
.
B
)
{
func
BenchmarkGetObjectNetPipeParallel
(
b
*
testing
.
B
)
{
net
:=
pipenet
.
New
(
"testnet"
)
benchmarkGetObjectParallel
(
b
,
tClusterOptions
{
Network
:
"pipenet"
})
Mhost
:=
net
.
Host
(
"m"
)
Shost
:=
net
.
Host
(
"s"
)
Chost
:=
net
.
Host
(
"c"
)
benchmarkGetObjectParallel
(
b
,
Mhost
,
Shost
,
Chost
)
}
}
func
BenchmarkGetObjectTCPlo
(
b
*
testing
.
B
)
{
func
BenchmarkGetObjectTCPlo
(
b
*
testing
.
B
)
{
net
:=
xnet
.
NetPlain
(
"tcp"
)
benchmarkGetObjectSerial
(
b
,
tClusterOptions
{
Network
:
"lonet"
})
defer
net
.
Close
()
benchmarkGetObjectSerial
(
b
,
net
,
net
,
net
)
}
}
func
BenchmarkGetObjectTCPloParallel
(
b
*
testing
.
B
)
{
func
BenchmarkGetObjectTCPloParallel
(
b
*
testing
.
B
)
{
net
:=
xnet
.
NetPlain
(
"tcp"
)
benchmarkGetObjectParallel
(
b
,
tClusterOptions
{
Network
:
"lonet"
})
defer
net
.
Close
()
benchmarkGetObjectParallel
(
b
,
net
,
net
,
net
)
}
}
go/neo/t_cluster_test.go
View file @
bae69488
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"sync"
"sync"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xnet/lonet"
"lab.nexedi.com/kirr/go123/xnet/pipenet"
"lab.nexedi.com/kirr/go123/xnet/pipenet"
"lab.nexedi.com/kirr/go123/xnet/virtnet"
"lab.nexedi.com/kirr/go123/xnet/virtnet"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/go123/xsync"
...
@@ -87,12 +88,19 @@ type ITestClient interface {
...
@@ -87,12 +88,19 @@ type ITestClient interface {
zodb
.
IStorageDriver
zodb
.
IStorageDriver
}
}
// 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
}
// tNewCluster creates new NEO test cluster.
// tNewCluster creates new NEO test cluster.
//
//
// At the end of the test the cluster has to be stopped via t.Stop().
// At the end of the test the cluster has to be stopped via t.Stop().
//
//
// TODO add options describing whether node type X should be created via Go or via Py.
// TODO add options describing whether node type X should be created via Go or via Py.
func
tNewCluster
(
ttest
*
tracetest
.
T
,
name
string
)
*
tCluster
{
func
tNewCluster
(
ttest
*
tracetest
.
T
,
name
string
,
opt
tClusterOptions
)
*
tCluster
{
t
:=
&
tCluster
{
t
:=
&
tCluster
{
T
:
ttest
,
T
:
ttest
,
name
:
name
,
name
:
name
,
...
@@ -100,10 +108,25 @@ func tNewCluster(ttest *tracetest.T, name string) *tCluster {
...
@@ -100,10 +108,25 @@ func tNewCluster(ttest *tracetest.T, name string) *tCluster {
nodeTab
:
make
(
map
[
string
]
*
tNode
),
nodeTab
:
make
(
map
[
string
]
*
tNode
),
}
}
// test network
// create test network
// XXX allow to use lonet
network
:=
opt
.
Network
t
.
network
=
pipenet
.
AsVirtNet
(
pipenet
.
New
(
"testnet"
))
if
network
==
""
{
network
=
"pipenet"
// TODO default to lonet if Py nodes will be present
}
var
net
*
virtnet
.
SubNetwork
var
err
error
switch
network
{
default
:
panic
(
fmt
.
Sprintf
(
"unknown network %q"
,
network
))
case
"pipenet"
:
net
=
pipenet
.
AsVirtNet
(
pipenet
.
New
(
"testnet"
))
case
"lonet"
:
net
,
err
=
lonet
.
Join
(
context
.
Background
(),
""
)
// XXX ctx = ttest.Ctx ?
if
err
!=
nil
{
ttest
.
Fatal
(
err
)
}
}
t
.
network
=
net
t
.
traceOn
=
true
t
.
traceOn
=
true
t
.
erouter
=
NewEventRouter
()
t
.
erouter
=
NewEventRouter
()
...
@@ -367,8 +390,8 @@ func (m *tMaster) Run(ctx context.Context) error {
...
@@ -367,8 +390,8 @@ func (m *tMaster) Run(ctx context.Context) error {
// tNewCluster_MS starts simple NEO cluster with 1 master and 1 storage nodes.
// tNewCluster_MS starts simple NEO cluster with 1 master and 1 storage nodes.
// The cluster is returned in ready-to-start state.
// The cluster is returned in ready-to-start state.
func
tNewCluster_MS
(
t0
*
tracetest
.
T
,
name
string
,
Sback
storage
.
Backend
)
*
tCluster
{
func
tNewCluster_MS
(
t0
*
tracetest
.
T
,
name
string
,
Sback
storage
.
Backend
,
opt
tClusterOptions
)
*
tCluster
{
t
:=
tNewCluster
(
t0
,
name
)
t
:=
tNewCluster
(
t0
,
name
,
opt
)
t
.
NewMaster
(
"m"
)
t
.
NewMaster
(
"m"
)
t
.
NewStorage
(
"s"
,
"m:1"
,
Sback
)
t
.
NewStorage
(
"s"
,
"m:1"
,
Sback
)
...
...
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