Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-swarm
Commits
fbd1280e
Unverified
Commit
fbd1280e
authored
May 19, 2021
by
Marten Seemann
Committed by
GitHub
May 19, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #262 from libp2p/speed-up-fd-limit-underflow-test
speed up the TestFDLimitUnderflow test
parents
eef02f81
4728fd6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
24 deletions
+9
-24
limiter_test.go
limiter_test.go
+9
-24
No files found.
limiter_test.go
View file @
fbd1280e
...
...
@@ -358,22 +358,16 @@ func TestStressLimiter(t *testing.T) {
}
func
TestFDLimitUnderflow
(
t
*
testing
.
T
)
{
df
:=
func
(
ctx
context
.
Context
,
p
peer
.
ID
,
a
ma
.
Multiaddr
)
(
transport
.
CapableConn
,
error
)
{
timeout
:=
make
(
chan
bool
,
1
)
go
func
()
{
time
.
Sleep
(
time
.
Second
*
5
)
timeout
<-
true
}()
df
:=
func
(
ctx
context
.
Context
,
p
peer
.
ID
,
addr
ma
.
Multiaddr
)
(
transport
.
CapableConn
,
error
)
{
select
{
case
<-
ctx
.
Done
()
:
case
<-
time
out
:
case
<-
time
.
After
(
5
*
time
.
Second
)
:
}
return
nil
,
fmt
.
Errorf
(
"df timed out"
)
}
l
:=
newDialLimiterWithParams
(
isFdConsuming
,
df
,
20
,
3
)
const
fdLimit
=
20
l
:=
newDialLimiterWithParams
(
isFdConsuming
,
df
,
fdLimit
,
3
)
var
addrs
[]
ma
.
Multiaddr
for
i
:=
0
;
i
<=
1000
;
i
++
{
...
...
@@ -381,12 +375,14 @@ func TestFDLimitUnderflow(t *testing.T) {
}
wg
:=
sync
.
WaitGroup
{}
wg
.
Add
(
1000
)
errs
:=
make
(
chan
error
,
1000
)
for
i
:=
0
;
i
<
1000
;
i
++
{
const
num
=
3
*
fdLimit
wg
.
Add
(
num
)
errs
:=
make
(
chan
error
,
num
)
for
i
:=
0
;
i
<
num
;
i
++
{
go
func
(
id
peer
.
ID
,
i
int
)
{
defer
wg
.
Done
()
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
resp
:=
make
(
chan
dialResult
)
l
.
AddDialJob
(
&
dialJob
{
...
...
@@ -396,17 +392,6 @@ func TestFDLimitUnderflow(t *testing.T) {
resp
:
resp
,
})
//cancel first 60 after 1s, next 60 after 2s
if
i
>
60
{
time
.
Sleep
(
time
.
Second
*
1
)
}
if
i
<
120
{
time
.
Sleep
(
time
.
Second
*
1
)
cancel
()
return
}
defer
cancel
()
for
res
:=
range
resp
{
if
res
.
Err
!=
nil
{
return
...
...
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