Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
47052b24
Unverified
Commit
47052b24
authored
Oct 02, 2020
by
acud
Committed by
GitHub
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix test flake (#788)
parent
fb7dcddc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
puller_test.go
pkg/puller/puller_test.go
+29
-29
No files found.
pkg/puller/puller_test.go
View file @
47052b24
...
...
@@ -8,7 +8,6 @@ import (
"errors"
"io/ioutil"
"math"
"runtime"
"testing"
"time"
...
...
@@ -58,8 +57,7 @@ func TestOneSync(t *testing.T) {
})
defer
puller
.
Close
()
defer
pullsync
.
Close
()
runtime
.
Gosched
()
time
.
Sleep
(
10
*
time
.
Millisecond
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
kad
.
Trigger
()
...
...
@@ -108,15 +106,14 @@ func TestSyncFlow_PeerOutsideDepth_Live(t *testing.T) {
pullsync
.
Close
()
puller
.
Close
()
})
runtime
.
Gosched
()
time
.
Sleep
(
10
*
time
.
Millisecond
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
kad
.
Trigger
()
waitCursorsCalled
(
t
,
pullsync
,
addr
,
false
)
waitLiveSyncCalled
(
t
,
pullsync
,
addr
,
false
)
checkCalls
(
t
,
tc
.
expCalls
,
pullsync
.
SyncCalls
(
addr
)
)
// hist always empty
checkCalls
(
t
,
tc
.
expLiveCalls
,
pullsync
.
LiveSyncCalls
(
addr
)
)
waitCheckCalls
(
t
,
tc
.
expCalls
,
pullsync
.
SyncCalls
,
addr
)
// hist always empty
waitCheckCalls
(
t
,
tc
.
expLiveCalls
,
pullsync
.
LiveSyncCalls
,
addr
)
// check the intervals
checkIntervals
(
t
,
st
,
addr
,
tc
.
intervals
,
1
)
...
...
@@ -183,8 +180,7 @@ func TestSyncFlow_PeerOutsideDepth_Historical(t *testing.T) {
})
defer
puller
.
Close
()
defer
pullsync
.
Close
()
runtime
.
Gosched
()
time
.
Sleep
(
10
*
time
.
Millisecond
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
kad
.
Trigger
()
...
...
@@ -192,8 +188,8 @@ func TestSyncFlow_PeerOutsideDepth_Historical(t *testing.T) {
waitSyncCalledTimes
(
t
,
pullsync
,
addr
,
len
(
tc
.
expCalls
))
// check historical sync calls
checkCalls
(
t
,
tc
.
expCalls
,
pullsync
.
SyncCalls
(
addr
)
)
checkCalls
(
t
,
tc
.
expLiveCalls
,
pullsync
.
LiveSyncCalls
(
addr
)
)
waitCheckCalls
(
t
,
tc
.
expCalls
,
pullsync
.
SyncCalls
,
addr
)
waitCheckCalls
(
t
,
tc
.
expLiveCalls
,
pullsync
.
LiveSyncCalls
,
addr
)
// check the intervals
checkIntervals
(
t
,
st
,
addr
,
tc
.
intervals
,
1
)
...
...
@@ -231,7 +227,6 @@ func TestSyncFlow_PeerWithinDepth_Live(t *testing.T) {
})
defer
puller
.
Close
()
defer
pullsync
.
Close
()
runtime
.
Gosched
()
time
.
Sleep
(
100
*
time
.
Millisecond
)
kad
.
Trigger
()
...
...
@@ -240,7 +235,7 @@ func TestSyncFlow_PeerWithinDepth_Live(t *testing.T) {
waitLiveSyncCalledTimes
(
t
,
pullsync
,
addr
,
len
(
tc
.
expLiveCalls
))
time
.
Sleep
(
100
*
time
.
Millisecond
)
checkCalls
(
t
,
tc
.
expCalls
,
pullsync
.
SyncCalls
(
addr
)
)
// hist always empty
waitCheckCalls
(
t
,
tc
.
expCalls
,
pullsync
.
SyncCalls
,
addr
)
// hist always empty
checkCallsUnordered
(
t
,
tc
.
expLiveCalls
,
pullsync
.
LiveSyncCalls
(
addr
))
// check the intervals
...
...
@@ -267,7 +262,6 @@ func TestPeerDisconnected(t *testing.T) {
p
.
Close
()
})
runtime
.
Gosched
()
time
.
Sleep
(
50
*
time
.
Millisecond
)
kad
.
Trigger
()
...
...
@@ -359,7 +353,6 @@ func TestDepthChange(t *testing.T) {
defer
puller
.
Close
()
defer
pullsync
.
Close
()
runtime
.
Gosched
()
time
.
Sleep
(
100
*
time
.
Millisecond
)
for
i
:=
0
;
i
<
len
(
tc
.
depths
)
-
1
;
i
++
{
...
...
@@ -411,24 +404,31 @@ func checkNotFound(t *testing.T, s storage.StateStorer, addr swarm.Address, bin
t
.
Fatalf
(
"wanted error but got none. bin %d"
,
bin
)
}
func
checkCalls
(
t
*
testing
.
T
,
expCalls
[]
c
,
calls
[]
mockps
.
SyncCall
)
{
func
waitCheckCalls
(
t
*
testing
.
T
,
expCalls
[]
c
,
callsFn
func
(
swarm
.
Address
)
[]
mockps
.
SyncCall
,
addr
swarm
.
Address
)
{
t
.
Helper
()
exp
:=
len
(
expCalls
)
if
l
:=
len
(
calls
);
l
!=
exp
{
t
.
Fatalf
(
"expected %d calls but got %d. calls: %v"
,
exp
,
l
,
calls
)
}
// check the calls
for
i
,
v
:=
range
expCalls
{
if
b
:=
calls
[
i
]
.
Bin
;
b
!=
v
.
b
{
t
.
Errorf
(
"bin mismatch. got %d want %d index %d"
,
b
,
v
.
b
,
i
)
}
if
f
:=
calls
[
i
]
.
From
;
f
!=
v
.
f
{
t
.
Errorf
(
"from mismatch. got %d want %d index %d"
,
f
,
v
.
f
,
i
)
for
i
:=
0
;
i
<
10
;
i
++
{
time
.
Sleep
(
50
*
time
.
Millisecond
)
calls
:=
callsFn
(
addr
)
if
l
:=
len
(
calls
);
l
!=
len
(
expCalls
)
{
t
.
Log
(
l
,
len
(
expCalls
),
"continue"
)
continue
}
if
tt
:=
calls
[
i
]
.
To
;
tt
!=
v
.
t
{
t
.
Errorf
(
"to mismatch. got %d want %d index %d"
,
tt
,
v
.
t
,
i
)
// check the calls
for
i
,
v
:=
range
expCalls
{
if
b
:=
calls
[
i
]
.
Bin
;
b
!=
v
.
b
{
t
.
Errorf
(
"bin mismatch. got %d want %d index %d"
,
b
,
v
.
b
,
i
)
}
if
f
:=
calls
[
i
]
.
From
;
f
!=
v
.
f
{
t
.
Errorf
(
"from mismatch. got %d want %d index %d"
,
f
,
v
.
f
,
i
)
}
if
tt
:=
calls
[
i
]
.
To
;
tt
!=
v
.
t
{
t
.
Errorf
(
"to mismatch. got %d want %d index %d"
,
tt
,
v
.
t
,
i
)
}
}
return
}
calls
:=
callsFn
(
addr
)
t
.
Fatalf
(
"expected %d calls but got %d. calls: %v"
,
len
(
expCalls
),
len
(
calls
),
calls
)
}
// this is needed since there are several goroutines checking the calls,
...
...
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