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
dms3
go-ds-flatfs
Commits
bba93ebd
Commit
bba93ebd
authored
Dec 17, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
query: test for goroutine leaks
parent
e994c05d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
flatfs_test.go
flatfs_test.go
+31
-0
No files found.
flatfs_test.go
View file @
bba93ebd
...
...
@@ -988,3 +988,34 @@ func BenchmarkBatchedPut(b *testing.B) {
}
b
.
StopTimer
()
// avoid counting cleanup
}
func
TestQueryLeak
(
t
*
testing
.
T
)
{
temp
,
cleanup
:=
tempdir
(
t
)
defer
cleanup
()
fs
,
err
:=
flatfs
.
CreateOrOpen
(
temp
,
flatfs
.
Prefix
(
2
),
false
)
if
err
!=
nil
{
t
.
Fatalf
(
"New fail: %v
\n
"
,
err
)
}
defer
fs
.
Close
()
for
i
:=
0
;
i
<
1000
;
i
++
{
err
=
fs
.
Put
(
datastore
.
NewKey
(
fmt
.
Sprint
(
i
)),
[]
byte
(
"foobar"
))
if
err
!=
nil
{
t
.
Fatalf
(
"Put fail: %v
\n
"
,
err
)
}
}
before
:=
runtime
.
NumGoroutine
()
for
i
:=
0
;
i
<
200
;
i
++
{
res
,
err
:=
fs
.
Query
(
query
.
Query
{
KeysOnly
:
true
})
if
err
!=
nil
{
t
.
Errorf
(
"Query fail: %v
\n
"
,
err
)
}
res
.
Close
()
}
after
:=
runtime
.
NumGoroutine
()
if
after
-
before
>
100
{
t
.
Errorf
(
"leaked %d goroutines"
,
after
-
before
)
}
}
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