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
af6b146c
Commit
af6b146c
authored
Dec 30, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3055a942
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
104 deletions
+66
-104
go/internal/xtracing/tracetest/tracetest.go
go/internal/xtracing/tracetest/tracetest.go
+33
-26
go/neo/neo_test.go
go/neo/neo_test.go
+32
-77
go/neo/t_cluster_test.go
go/neo/t_cluster_test.go
+1
-1
No files found.
go/internal/xtracing/tracetest/tracetest.go
View file @
af6b146c
...
@@ -808,11 +808,15 @@ func (t *T) closeStreamTab() (nnak int) {
...
@@ -808,11 +808,15 @@ func (t *T) closeStreamTab() (nnak int) {
// - main func to run the system
// - main func to run the system
// - testf (serial) func to verify events that comes from channels
// - testf (serial) func to verify events that comes from channels
// Verify verifies a test system.
// Run runs f under tracing.
// XXX
//
// XXX try back -> testing.TB? (but TB does not have .Run)
// It is similar to Verify but f is ran only once.
func
Verify
(
t
*
testing
.
T
,
f
func
(
t
*
T
))
{
func
Run
(
t
testing
.
TB
,
f
func
(
t
*
T
))
{
testf
:=
func
(
t
testing
.
TB
,
delayInjectTab
map
[
string
]
*
delayInjectState
)
*
T
{
run
(
t
,
f
,
nil
)
}
// run serves Run and Verify: it creates T that wraps t, and runs f under T.
func
run
(
t
testing
.
TB
,
f
func
(
t
*
T
),
delayInjectTab
map
[
string
]
*
delayInjectState
)
*
T
{
tT
:=
&
T
{
tT
:=
&
T
{
_testing_TB
:
t
,
_testing_TB
:
t
,
streamTab
:
make
(
map
[
string
]
_Chan
),
streamTab
:
make
(
map
[
string
]
_Chan
),
...
@@ -833,9 +837,12 @@ func Verify(t *testing.T, f func(t *T)) {
...
@@ -833,9 +837,12 @@ func Verify(t *testing.T, f func(t *T)) {
f
(
tT
)
f
(
tT
)
return
tT
return
tT
}
}
tT0
:=
testf
(
t
,
nil
)
// Verify verifies a test system.
// XXX
func
Verify
(
t
*
testing
.
T
,
f
func
(
t
*
T
))
{
tT0
:=
run
(
t
,
f
,
nil
)
// now, if f succeeds, verify f with injected delays.
// now, if f succeeds, verify f with injected delays.
// XXX explain with more text
// XXX explain with more text
...
@@ -882,7 +889,7 @@ func Verify(t *testing.T, f func(t *T)) {
...
@@ -882,7 +889,7 @@ func Verify(t *testing.T, f func(t *T)) {
}
}
t
.
Run
(
fmt
.
Sprintf
(
"delay@%d(=%s:%d)"
,
i
,
stream
,
istream
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"delay@%d(=%s:%d)"
,
i
,
stream
,
istream
),
func
(
t
*
testing
.
T
)
{
tT
:=
testf
(
t
,
map
[
string
]
*
delayInjectState
{
tT
:=
run
(
t
,
f
,
map
[
string
]
*
delayInjectState
{
stream
:
&
delayInjectState
{
stream
:
&
delayInjectState
{
delayAt
:
istream
,
delayAt
:
istream
,
delayT
:
delayT
,
delayT
:
delayT
,
...
...
go/neo/neo_test.go
View file @
af6b146c
...
@@ -366,59 +366,13 @@ func (d tdispatch1) Dispatch(event interface{}) {
...
@@ -366,59 +366,13 @@ func (d tdispatch1) Dispatch(event interface{}) {
func
benchmarkGetObject
(
b
*
testing
.
B
,
Mnet
,
Snet
,
Cnet
xnet
.
Networker
,
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
)
{
// create test cluster
// create test cluster
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
zback
:=
xfs1back
(
"../zodb/storage/fs1/testdata/1.fs"
)
var
t0
*
tracetest
.
T
// XXX stub
t
:=
tNewCluster_MS
(
t0
,
"abc1"
,
zback
)
t
:=
tNewCluster_MS
(
t0
,
"abc1"
,
zback
)
defer
t
.
Stop
()
defer
t
.
Stop
()
M
:=
t
.
Master
(
"m"
)
M
:=
t
.
Master
(
"m"
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
/*
wg := xsync.NewWorkGroup(ctx)
defer wg.Wait()
// spawn M
M := tNewMaster("abc1", "", Mnet)
// XXX to wait for "M listens at ..." & "ready to start" -> XXX add something to M api?
cG := tracetest.NewChan("main")
tG := tracetest.NewEventChecker(b, nil , cG)
tracer := NewTraceCollector(tdispatch1{cG})
tracer.RegisterNode(M.node, "m")
tracing.Lock()
pnode := traceNodeChanged_Attach(nil, tracer.traceNode)
traceMasterStartReady_Attach(tracer.pg, tracer.traceMasterStartReady)
tracing.Unlock()
wg.Go(func(ctx context.Context) error {
return M.Run(ctx)
})
// determining M serving address XXX better with M api
ev := cG.Recv()
mnode, ok := ev.Event.(*eventNodeTab)
if !ok {
b.Fatalf("after M start: got %T ; want eventNodeTab", ev.Event)
}
Maddr := mnode.NodeInfo.Addr.String()
tracing.Lock()
pnode.Detach()
tracing.Unlock()
ev.Ack()
// now after we know Maddr create S & C and start S serving
S := tNewStorage("abc1", Maddr, "", Snet, zback)
wg.Go(func(ctx context.Context) error {
return S.Run(ctx)
})
*/
t
.
TraceOff
()
t
.
TraceOff
()
err
:=
M
.
Start
();
X
(
err
)
err
:=
M
.
Start
();
X
(
err
)
...
@@ -426,7 +380,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
...
@@ -426,7 +380,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
xid1
:=
zodb
.
Xid
{
Oid
:
1
,
At
:
zodb
.
TidMax
}
xid1
:=
zodb
.
Xid
{
Oid
:
1
,
At
:
zodb
.
TidMax
}
obj1
,
err
:=
zback
.
Load
(
ctx
,
xid1
)
obj1
,
err
:=
zback
.
Load
(
t
.
runCtx
,
xid1
)
// XXX -> t.Ctx ?
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -434,7 +388,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
...
@@ -434,7 +388,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
// C.Load(xid1)
// C.Load(xid1)
xcload1
:=
func
()
{
xcload1
:=
func
()
{
cbuf1
,
cserial1
,
err
:=
C
.
Load
(
ctx
,
xid1
)
cbuf1
,
cserial1
,
err
:=
C
.
Load
(
t
.
runCtx
,
xid1
)
// XXX -> t.Ctx ?
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -454,6 +408,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
...
@@ -454,6 +408,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
b
.
ResetTimer
()
b
.
ResetTimer
()
benchit
(
xcload1
)
benchit
(
xcload1
)
})
}
}
func
benchmarkGetObjectSerial
(
b
*
testing
.
B
,
Mnet
,
Snet
,
Cnet
xnet
.
Networker
)
{
func
benchmarkGetObjectSerial
(
b
*
testing
.
B
,
Mnet
,
Snet
,
Cnet
xnet
.
Networker
)
{
...
...
go/neo/t_cluster_test.go
View file @
af6b146c
...
@@ -61,7 +61,7 @@ type tCluster struct {
...
@@ -61,7 +61,7 @@ type tCluster struct {
nodeTab
map
[
string
/*node*/
]
*
tNode
nodeTab
map
[
string
/*node*/
]
*
tNode
runCtx
context
.
Context
// runCtx is canceled on .Stop()
runCtx
context
.
Context
// runCtx is canceled on .Stop()
TODO or test failure XXX -> .ctx?
runWG
*
xsync
.
WorkGroup
// started nodes are .Run() under runWG
runWG
*
xsync
.
WorkGroup
// started nodes are .Run() under runWG
runCancel
func
()
runCancel
func
()
}
}
...
...
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