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
4328ac71
Commit
4328ac71
authored
Dec 31, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fb095f94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
20 deletions
+31
-20
go/neo/neo_test.go
go/neo/neo_test.go
+6
-5
go/neo/t_cluster_test.go
go/neo/t_cluster_test.go
+25
-15
No files found.
go/neo/neo_test.go
View file @
4328ac71
...
@@ -41,9 +41,9 @@ import (
...
@@ -41,9 +41,9 @@ import (
// Verify basic M+S recovery.
// Verify basic M+S recovery.
func
TestClusterRecoveryBasic
(
t
*
testing
.
T
)
{
func
TestClusterRecoveryBasic
(
t
*
testing
.
T
)
{
Verify
(
t
,
func
(
t0
*
t
racetest
.
T
,
opt
tClusterOptions
)
{
Verify
(
t
,
func
(
t0
*
t
Env
)
{
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
t
:=
t
NewCluster_MS
(
t0
,
"abc1"
,
zback
,
opt
)
t
:=
t
0
.
NewCluster_MS
(
"abc1"
,
zback
)
defer
t
.
Stop
()
defer
t
.
Stop
()
})
})
}
}
...
@@ -52,7 +52,7 @@ func TestClusterRecoveryBasic(t *testing.T) {
...
@@ -52,7 +52,7 @@ func TestClusterRecoveryBasic(t *testing.T) {
func
TestMasterStorage
(
t
*
testing
.
T
)
{
func
TestMasterStorage
(
t
*
testing
.
T
)
{
Verify
(
t
,
tracetestMasterStorage
)
Verify
(
t
,
tracetestMasterStorage
)
}
}
func
tracetestMasterStorage
(
t0
*
t
racetest
.
T
,
opt
tClusterOptions
)
{
func
tracetestMasterStorage
(
t0
*
t
Env
)
{
X
:=
exc
.
Raiseif
X
:=
exc
.
Raiseif
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
...
@@ -60,7 +60,7 @@ func tracetestMasterStorage(t0 *tracetest.T, opt tClusterOptions) {
...
@@ -60,7 +60,7 @@ func tracetestMasterStorage(t0 *tracetest.T, opt tClusterOptions) {
lastTid
,
err
:=
zstor
.
Sync
(
bg
);
X
(
err
)
lastTid
,
err
:=
zstor
.
Sync
(
bg
);
X
(
err
)
// create the cluster
// create the cluster
t
:=
t
NewCluster_MS
(
t0
,
"abc1"
,
zback
,
opt
)
t
:=
t
0
.
NewCluster_MS
(
"abc1"
,
zback
)
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"
)
...
@@ -359,9 +359,10 @@ func benchmarkGetObject(b *testing.B, opt tClusterOptions, benchit func(xcload1
...
@@ -359,9 +359,10 @@ func benchmarkGetObject(b *testing.B, opt tClusterOptions, benchit func(xcload1
X
:=
exc
.
Raiseif
X
:=
exc
.
Raiseif
tracetest
.
Run
(
b
,
func
(
t0
*
tracetest
.
T
)
{
tracetest
.
Run
(
b
,
func
(
t0
*
tracetest
.
T
)
{
tenv
:=
&
tEnv
{
t0
,
opt
}
// create test cluster
// create test cluster
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
t
:=
t
NewCluster_MS
(
t0
,
"abc1"
,
zback
,
opt
)
t
:=
t
env
.
NewCluster_MS
(
"abc1"
,
zback
)
defer
t
.
Stop
()
defer
t
.
Stop
()
M
:=
t
.
Master
(
"m"
)
M
:=
t
.
Master
(
"m"
)
...
...
go/neo/t_cluster_test.go
View file @
4328ac71
...
@@ -40,17 +40,23 @@ import (
...
@@ -40,17 +40,23 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
)
)
// tEnv is environment for a NEO test.
type
tEnv
struct
{
*
tracetest
.
T
// tracetest environment behind tEnv
opt
tClusterOptions
// by default NEO clusters are created with this options
}
// tCluster is a test NEO cluster.
// tCluster is a test NEO cluster.
//
//
// Create it with tNewCluster.
// Create it with t
Env.
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-networking.
// NOTE network addresses are predictable due to using pipenet/lonet for inter-networking.
//
//
// XXX text about events tracing
// XXX text about events tracing
type
tCluster
struct
{
type
tCluster
struct
{
*
t
racetest
.
T
// original testing env this cluster was created at
*
t
Env
// 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
...
@@ -96,21 +102,21 @@ type tClusterOptions struct {
...
@@ -96,21 +102,21 @@ type tClusterOptions struct {
Network
string
Network
string
}
}
//
t
NewCluster creates new NEO test cluster.
// NewCluster 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
,
opt
tClusterOptions
)
*
tCluster
{
func
(
t0
*
tEnv
)
NewCluster
(
name
string
)
*
tCluster
{
t
:=
&
tCluster
{
t
:=
&
tCluster
{
T
:
ttest
,
tEnv
:
t0
,
name
:
name
,
name
:
name
,
nodeTab
:
make
(
map
[
string
]
*
tNode
),
nodeTab
:
make
(
map
[
string
]
*
tNode
),
}
}
// create test network
// create test network
network
:=
opt
.
Network
network
:=
t0
.
opt
.
Network
if
network
==
""
{
if
network
==
""
{
network
=
"pipenet"
// TODO default to lonet if Py nodes will be present
network
=
"pipenet"
// TODO default to lonet if Py nodes will be present
}
}
...
@@ -124,15 +130,15 @@ func tNewCluster(ttest *tracetest.T, name string, opt tClusterOptions) *tCluster
...
@@ -124,15 +130,15 @@ func tNewCluster(ttest *tracetest.T, name string, opt tClusterOptions) *tCluster
case
"lonet"
:
case
"lonet"
:
net
,
err
=
lonet
.
Join
(
context
.
Background
(),
""
)
// XXX ctx = ttest.Ctx ?
net
,
err
=
lonet
.
Join
(
context
.
Background
(),
""
)
// XXX ctx = ttest.Ctx ?
if
err
!=
nil
{
if
err
!=
nil
{
t
test
.
Fatal
(
err
)
t
0
.
Fatal
(
err
)
}
}
}
}
t
.
network
=
net
t
.
network
=
net
t
.
traceOn
=
true
t
.
traceOn
=
true
t
.
erouter
=
NewEventRouter
()
t
.
erouter
=
NewEventRouter
()
t
.
gotracer
=
NewTraceCollector
(
t
test
)
t
.
gotracer
=
NewTraceCollector
(
t
0
)
t
test
.
SetEventRouter
(
t
.
erouter
.
RouteEvent
)
t
0
.
SetEventRouter
(
t
.
erouter
.
RouteEvent
)
t
.
gotracer
.
Attach
()
t
.
gotracer
.
Attach
()
...
@@ -390,7 +396,7 @@ func (m *tMaster) Run(ctx context.Context) error {
...
@@ -390,7 +396,7 @@ func (m *tMaster) Run(ctx context.Context) error {
// Verify verifies f for all combinations of node kinds.
// Verify verifies f for all combinations of node kinds.
// XXX place
// XXX place
func
Verify
(
t
*
testing
.
T
,
f
func
(
*
t
racetest
.
T
,
tClusterOptions
))
{
func
Verify
(
t
*
testing
.
T
,
f
func
(
*
t
Env
))
{
// TODO verify M=(go|py) x S=(go|py) x ...
// TODO verify M=(go|py) x S=(go|py) x ...
// for now we only verify for all combinations of network
// for now we only verify for all combinations of network
...
@@ -400,10 +406,14 @@ func Verify(t *testing.T, f func(*tracetest.T, tClusterOptions)) {
...
@@ -400,10 +406,14 @@ func Verify(t *testing.T, f func(*tracetest.T, tClusterOptions)) {
Network
:
network
,
Network
:
network
,
}
}
// TODO don't pass in opt -> instead pass in
T
which will have .NewCluster() and use T.opt for it.
// TODO don't pass in opt -> instead pass in
tEnv
which will have .NewCluster() and use T.opt for it.
t
.
Run
(
"net="
+
network
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"net="
+
network
,
func
(
t
*
testing
.
T
)
{
tracetest
.
Verify
(
t
,
func
(
t
*
tracetest
.
T
)
{
tracetest
.
Run
(
t
,
func
(
t
*
tracetest
.
T
)
{
// XXX -> Verify
f
(
t
,
opt
)
tenv
:=
&
tEnv
{
T
:
t
,
opt
:
opt
,
}
f
(
tenv
)
})
})
})
})
}
}
...
@@ -414,8 +424,8 @@ func Verify(t *testing.T, f func(*tracetest.T, tClusterOptions)) {
...
@@ -414,8 +424,8 @@ func Verify(t *testing.T, f func(*tracetest.T, tClusterOptions)) {
// 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
,
opt
tClusterOptions
)
*
tCluster
{
func
(
t0
*
tEnv
)
NewCluster_MS
(
name
string
,
Sback
storage
.
Backend
)
*
tCluster
{
t
:=
t
NewCluster
(
t0
,
name
,
opt
)
t
:=
t
0
.
NewCluster
(
name
)
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