Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
9ca89ca2
Commit
9ca89ca2
authored
Mar 17, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added AttributeCachingTest.
parent
ac34f0f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
samples/cachingfs/caching_fs_test.go
samples/cachingfs/caching_fs_test.go
+86
-0
No files found.
samples/cachingfs/caching_fs_test.go
View file @
9ca89ca2
...
...
@@ -370,3 +370,89 @@ func (t *EntryCachingTest) StatRenumberMtimeStat() {
ExpectThat
(
dirAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
ExpectThat
(
barAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
}
////////////////////////////////////////////////////////////////////////
// Attribute caching
////////////////////////////////////////////////////////////////////////
type
AttributeCachingTest
struct
{
cachingFSTest
getattrTimeout
time
.
Duration
}
var
_
SetUpInterface
=
&
AttributeCachingTest
{}
func
init
()
{
RegisterTestSuite
(
&
AttributeCachingTest
{})
}
func
(
t
*
AttributeCachingTest
)
SetUp
(
ti
*
TestInfo
)
{
t
.
getattrTimeout
=
250
*
time
.
Millisecond
t
.
cachingFSTest
.
setUp
(
0
,
t
.
getattrTimeout
)
}
func
(
t
*
AttributeCachingTest
)
StatStat
()
{
fooBefore
,
dirBefore
,
barBefore
:=
t
.
statAll
()
fooAfter
,
dirAfter
,
barAfter
:=
t
.
statAll
()
// Make sure everything matches.
ExpectThat
(
fooAfter
.
ModTime
(),
timeutil
.
TimeEq
(
fooBefore
.
ModTime
()))
ExpectThat
(
dirAfter
.
ModTime
(),
timeutil
.
TimeEq
(
dirBefore
.
ModTime
()))
ExpectThat
(
barAfter
.
ModTime
(),
timeutil
.
TimeEq
(
barBefore
.
ModTime
()))
ExpectEq
(
getInodeID
(
fooBefore
),
getInodeID
(
fooAfter
))
ExpectEq
(
getInodeID
(
dirBefore
),
getInodeID
(
dirAfter
))
ExpectEq
(
getInodeID
(
barBefore
),
getInodeID
(
barAfter
))
}
func
(
t
*
AttributeCachingTest
)
StatRenumberStat
()
{
t
.
statAll
()
t
.
fs
.
RenumberInodes
()
fooAfter
,
dirAfter
,
barAfter
:=
t
.
statAll
()
// We should see the new inode IDs, because the entries should not have been
// cached.
ExpectEq
(
t
.
fs
.
FooID
(),
getInodeID
(
fooAfter
))
ExpectEq
(
t
.
fs
.
DirID
(),
getInodeID
(
dirAfter
))
ExpectEq
(
t
.
fs
.
BarID
(),
getInodeID
(
barAfter
))
}
func
(
t
*
AttributeCachingTest
)
StatMtimeStat
()
{
newMtime
:=
t
.
initialMtime
.
Add
(
time
.
Second
)
fooBefore
,
dirBefore
,
barBefore
:=
t
.
statAll
()
t
.
fs
.
SetMtime
(
newMtime
)
fooAfter
,
dirAfter
,
barAfter
:=
t
.
statAll
()
// We should still see the old attributes.
ExpectThat
(
fooAfter
.
ModTime
(),
timeutil
.
TimeEq
(
fooBefore
.
ModTime
()))
ExpectThat
(
dirAfter
.
ModTime
(),
timeutil
.
TimeEq
(
dirBefore
.
ModTime
()))
ExpectThat
(
barAfter
.
ModTime
(),
timeutil
.
TimeEq
(
barBefore
.
ModTime
()))
// But after waiting for the attribute cache to expire, we should see the new
// attributes.
time
.
Sleep
(
2
*
t
.
getattrTimeout
)
fooAfter
,
dirAfter
,
barAfter
=
t
.
statAll
()
ExpectThat
(
fooAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
ExpectThat
(
dirAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
ExpectThat
(
barAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
}
func
(
t
*
AttributeCachingTest
)
StatRenumberMtimeStat
()
{
newMtime
:=
t
.
initialMtime
.
Add
(
time
.
Second
)
t
.
statAll
()
t
.
fs
.
RenumberInodes
()
t
.
fs
.
SetMtime
(
newMtime
)
fooAfter
,
dirAfter
,
barAfter
:=
t
.
statAll
()
// We should see new everything, because this is the first time the new
// inodes have been encountered. Entries for the old ones should not have
// been cached.
ExpectEq
(
t
.
fs
.
FooID
(),
getInodeID
(
fooAfter
))
ExpectEq
(
t
.
fs
.
DirID
(),
getInodeID
(
dirAfter
))
ExpectEq
(
t
.
fs
.
BarID
(),
getInodeID
(
barAfter
))
ExpectThat
(
fooAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
ExpectThat
(
dirAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
ExpectThat
(
barAfter
.
ModTime
(),
timeutil
.
TimeEq
(
newMtime
))
}
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