Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
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
Joshua
wendelin.core
Commits
8d046f41
Commit
8d046f41
authored
Mar 17, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f818193e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+31
-26
No files found.
wcfs/wcfs_test.py
View file @
8d046f41
...
...
@@ -134,8 +134,9 @@ class tDB:
t
.
tracked
=
set
()
def
close
(
t
):
for
tf
in
t
.
tracked
:
for
tf
in
t
.
tracked
.
copy
()
:
tf
.
close
()
assert
len
(
t
.
tracked
)
==
0
t
.
_wc_zheadfh
.
close
()
t
.
wc
.
close
()
dbclose
(
t
.
root
)
...
...
@@ -194,19 +195,15 @@ class tDB:
path
=
t
.
path
(
obj
,
at
=
at
)
return
os
.
stat
(
path
)
# open opens file corresponding to obj on wcfs.
def
open
(
t
,
obj
,
at
=
None
):
#
_
open opens file corresponding to obj on wcfs.
def
_
open
(
t
,
obj
,
at
=
None
):
path
=
t
.
path
(
obj
,
at
=
at
)
return
open
(
path
,
'rb'
,
0
)
# unbuffered
#
track starts to track wcfs file corresponding to zf@a
t.
#
open opens wcfs file corresponding to zf@at and starts to track i
t.
# see returned tFile for details.
#
# XXX -> openfile? testopen?
def
track
(
t
,
zf
,
at
=
None
):
tf
=
tFile
(
t
,
zf
,
at
=
at
)
t
.
tracked
.
add
(
tf
)
return
tf
def
open
(
t
,
zf
,
at
=
None
):
return
tFile
(
t
,
zf
,
at
=
at
)
# tFile is testing environment for one bigfile on wcfs.
class
tFile
:
...
...
@@ -217,7 +214,7 @@ class tFile:
def
__init__
(
t
,
tdb
,
zf
,
at
=
None
):
assert
isinstance
(
zf
,
ZBigFile
)
t
.
tdb
=
tdb
t
.
f
=
tdb
.
open
(
zf
,
at
=
at
)
t
.
f
=
tdb
.
_
open
(
zf
,
at
=
at
)
t
.
blksize
=
zf
.
blksize
# mmap the file past the end up to XXX pages and lock the pages with
...
...
@@ -228,8 +225,10 @@ class tFile:
t
.
fmmap
=
mm
.
map_ro
(
t
.
f
.
fileno
(),
0
,
t
.
_max_tracked
*
t
.
blksize
)
mm
.
lock
(
t
.
fmmap
,
mm
.
MLOCK_ONFAULT
)
tdb
.
tracked
.
add
(
t
)
def
close
(
t
):
# XXX remove from t.tdb.tracked
t
.
tdb
.
tracked
.
remove
(
t
)
mm
.
unmap
(
t
.
fmmap
)
t
.
f
.
close
()
...
...
@@ -247,7 +246,7 @@ class tFile:
@func
def readblk(t, zf, blk, at=None):
assert isinstance(zf, ZBigFile)
f = t.open(zf, at=at) # XXX binary, !buffered
f = t.
_
open(zf, at=at) # XXX binary, !buffered
defer(f.close)
blksize = zf.blksize
...
...
@@ -351,29 +350,27 @@ def test_wcfs():
t
.
stat
(
nonfile
)
assert
exc
.
value
.
errno
==
EINVAL
f
=
t
.
track
(
zf
)
# XXX -> testopen, fileopen?
f
=
t
.
open
(
zf
)
# file initially empty
f
.
assertCache
([])
f
.
assertData
([],
mtime
=
tid1
)
# commit data to zf
and make sure
we can see it on wcfs
#
use !wcfs mode so that we prepare data independently of wcfs code paths.
# commit data to zf
-> verify
we can see it on wcfs
#
(use !wcfs mode so that we prepare data independently of wcfs code paths)
zfh
=
zf
.
fileh_open
(
_use_wcfs
=
False
)
vma
=
zfh
.
mmap
(
2
,
1
)
# 1 page at offset=2
s
=
b"hello world"
memcpy
(
vma
,
s
)
t
.
commit
()
t
.
wcsync
()
# sync wcfs to ZODB
t
.
wcsync
()
f
.
assertCache
([
0
,
0
,
0
])
# initially not cached
f
.
assertData
([
b''
,
b''
,
s
],
mtime
=
t
.
head
)
# XXX assertCache all present?
# commit data again
and make sure
we can see both latest and snapshotted states.
tcommi
t1
=
t
.
head
# commit data again
-> verify
we can see both latest and snapshotted states.
a
t1
=
t
.
head
zfh
=
zf
.
fileh_open
(
_use_wcfs
=
False
)
vma1
=
zfh
.
mmap
(
2
,
1
)
...
...
@@ -382,18 +379,26 @@ def test_wcfs():
s2
=
b"alpha"
memcpy
(
vma1
,
s1
)
memcpy
(
vma2
,
s2
)
t
.
commit
()
t
.
wcsync
()
# f @head
f
.
assertCache
([
1
,
1
,
0
,
0
])
# XXX fails here (.size changed)
f
.
assertCache
([
1
,
1
,
0
,
0
])
f
.
assertData
([
b''
,
b''
,
s1
+
b'ld'
,
s2
],
mtime
=
t
.
head
)
# f @
tcommi
t1
f1
=
t
.
track
(
zf
,
at
=
tcommi
t1
)
# f @
a
t1
f1
=
t
.
open
(
zf
,
at
=
a
t1
)
f1
.
assertCache
([
0
,
0
,
1
])
f1
.
assertData
([
b''
,
b''
,
s
])
# XXX + mtime=tcommit1?
f1
.
assertData
([
b''
,
b''
,
s
])
# XXX + mtime=at1?
# f @head is opened again -> cache must not be lost
f
.
assertCache
([
1
,
1
,
1
,
1
])
f_
=
t
.
open
(
zf
)
f_
.
assertCache
([
1
,
1
,
1
,
1
])
f_
.
close
()
f
.
assertCache
([
1
,
1
,
1
,
1
])
def
test_wcfs_invproto
():
...
...
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