Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go-fuse
Commits
eedf4e5e
Commit
eedf4e5e
authored
Jun 04, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make memory pressure test resilient to random processes statting files
in the mount.
parent
f2a679a9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
fuse/pressure_test.go
fuse/pressure_test.go
+19
-7
No files found.
fuse/pressure_test.go
View file @
eedf4e5e
...
...
@@ -3,31 +3,43 @@ package fuse
import
(
"fmt"
"io/ioutil"
"log"
"os"
"
strings
"
"
regexp
"
"sync"
"testing"
"time"
)
var
_
=
log
.
Println
// This test checks that highly concurrent loads don't use a lot of
// memory if it is not needed: The input buffer needs to accomodata
// the max write size, but it is only really needed when we are
// processing writes.
type
DelayFs
struct
{
DefaultFileSystem
fileRegex
*
regexp
.
Regexp
dirRegex
*
regexp
.
Regexp
}
func
(
d
*
DelayFs
)
GetAttr
(
name
string
,
c
*
Context
)
(
*
Attr
,
Status
)
{
if
name
==
""
||
strings
.
HasSuffix
(
name
,
"dir"
)
{
if
name
==
""
||
d
.
dirRegex
.
MatchString
(
name
)
{
return
&
Attr
{
Mode
:
S_IFDIR
|
0755
},
OK
}
if
d
.
fileRegex
.
MatchString
(
name
)
{
time
.
Sleep
(
time
.
Second
)
return
&
Attr
{
Mode
:
S_IFREG
|
0644
},
OK
}
return
nil
,
ENOENT
}
func
TestMemoryPressure
(
t
*
testing
.
T
)
{
fs
:=
&
DelayFs
{}
fs
:=
&
DelayFs
{
fileRegex
:
regexp
.
MustCompile
(
"^dir[0-9]*/file[0-9]*$"
),
dirRegex
:
regexp
.
MustCompile
(
"^dir[0-9]*$"
),
}
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
CheckSuccess
(
err
)
...
...
@@ -54,7 +66,7 @@ func TestMemoryPressure(t *testing.T) {
for
i
:=
0
;
i
<
10
*
_MAX_READERS
;
i
++
{
wg
.
Add
(
1
)
go
func
(
x
int
)
{
fn
:=
fmt
.
Sprintf
(
"%s/
%ddir
/file%d"
,
dir
,
x
,
x
)
fn
:=
fmt
.
Sprintf
(
"%s/
dir%d
/file%d"
,
dir
,
x
,
x
)
_
,
err
:=
os
.
Lstat
(
fn
)
if
err
!=
nil
{
t
.
Errorf
(
"parallel stat %q: %v"
,
fn
,
err
)
...
...
@@ -66,7 +78,7 @@ func TestMemoryPressure(t *testing.T) {
created
:=
bufs
.
createdBuffers
+
state
.
outstandingReadBufs
t
.
Logf
(
"Have %d read bufs"
,
state
.
outstandingReadBufs
)
if
created
>
2
*
_MAX_READERS
{
if
created
>
_MAX_READERS
{
t
.
Errorf
(
"created %d buffers, max reader %d"
,
created
,
_MAX_READERS
)
}
...
...
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