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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
805c4b8f
Commit
805c4b8f
authored
Jun 20, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
65803eb1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
33 deletions
+29
-33
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+29
-33
No files found.
wcfs/wcfs_test.py
View file @
805c4b8f
...
@@ -166,7 +166,7 @@ class DFile:
...
@@ -166,7 +166,7 @@ class DFile:
#
#
# The primary way to access wcfs is by opening BigFiles and Watches.
# The primary way to access wcfs is by opening BigFiles and Watches.
# A BigFile opened under tDB is represented as tFile - see .open for details.
# A BigFile opened under tDB is represented as tFile - see .open for details.
# A Watch
e
opened under tDB is represented as tWatchLink - see .openwatch for details.
# A Watch
opened under tDB is represented as tWatchLink - see .openwatch for details.
#
#
# The database can be mutated (via !wcfs path) with .change + .commit .
# The database can be mutated (via !wcfs path) with .change + .commit .
# Current database head is represented by .head .
# Current database head is represented by .head .
...
@@ -175,7 +175,7 @@ class DFile:
...
@@ -175,7 +175,7 @@ class DFile:
#
#
# tDB must be explicitly closed once no longer used.
# tDB must be explicitly closed once no longer used.
#
#
#
XXX .path/.read/.
stat/._open
#
Raw files on wcfs can be accessed with ._path/._read/._
stat/._open
#
#
# XXX print -> t.trace/debug() + t.verbose depending on py.test -v -v ?
# XXX print -> t.trace/debug() + t.verbose depending on py.test -v -v ?
class
tDB
:
class
tDB
:
...
@@ -293,62 +293,58 @@ class tDB:
...
@@ -293,62 +293,58 @@ class tDB:
t
.
_wc_zheadv
.
append
(
wchead
)
t
.
_wc_zheadv
.
append
(
wchead
)
# head/at = last txn of whole db
# head/at = last txn of whole db
assert
t
.
read
(
"head/at"
)
==
h
(
t
.
head
)
assert
t
.
_
read
(
"head/at"
)
==
h
(
t
.
head
)
# _blkaccess marks head/zf[blk] accessed.
# _blkaccess marks head/zf[blk] accessed.
# XXX place=?
# XXX place=?
-> history query
def
_blkaccess
(
t
,
zf
,
blk
):
def
_blkaccess
(
t
,
zf
,
blk
):
# XXX locking?
# XXX locking?
zfAccessed
=
t
.
_accessed
.
setdefault
(
zf
,
{})
zfAccessed
=
t
.
_accessed
.
setdefault
(
zf
,
{})
zfAccessed
[
blk
]
=
t
.
head
zfAccessed
[
blk
]
=
t
.
head
# XXX vvv -> not what we need, think again
# _blkHeadAccessed returns whether block state corresponding to zf[blk] at
# current head was accessed.
#
# for example - if head/<zf>[blk] was accessed and later changed, the answer is "no".
# buf if head/<zf>[blk] was accessed again after change, and was no longer
# changed, the answer is "yes"
# XXX text
# XXX -> _blkLastRevAccessed ? _blkRevLastAccessed ? _blkHeadRevAccessed ?
"""
def _blkHeadAccessed(t, zf, blk):
zfAccessed = t._accessed.get(zf, {})
zfAccessed.get(blk) vs t._blkRev(zf, blk, t.head)
"""
# path returns path for object on wcfs.
#
_
path returns path for object on wcfs.
# - str: wcfs root + obj;
# - str: wcfs root + obj;
# - Persistent: wcfs root + (head|@<at>)/bigfile/obj
# - Persistent: wcfs root + (head|@<at>)/bigfile/obj
def
path
(
t
,
obj
,
at
=
None
):
def
_
path
(
t
,
obj
,
at
=
None
):
if
isinstance
(
obj
,
Persistent
):
if
isinstance
(
obj
,
Persistent
):
head
=
"head/"
if
at
is
None
else
(
"@%s/"
%
h
(
at
))
head
=
"head/"
if
at
is
None
else
(
"@%s/"
%
h
(
at
))
obj
=
"%s/bigfile/%s"
%
(
head
,
h
(
obj
.
_p_oid
))
obj
=
"%s/bigfile/%s"
%
(
head
,
h
(
obj
.
_p_oid
))
at
=
None
at
=
None
assert
isinstance
(
obj
,
str
)
assert
isinstance
(
obj
,
str
)
assert
at
is
None
# must not be used with str
assert
at
is
None
# must not be used with str
return
os
.
path
.
join
(
t
.
wc
.
mountpoint
,
obj
)
return
os
.
path
.
join
(
t
.
wc
.
mountpoint
,
obj
)
# read reads file corresponding to obj on wcfs.
#
_
read reads file corresponding to obj on wcfs.
def
read
(
t
,
obj
,
at
=
None
):
def
_
read
(
t
,
obj
,
at
=
None
):
path
=
t
.
path
(
obj
,
at
=
at
)
path
=
t
.
_
path
(
obj
,
at
=
at
)
return
readfile
(
path
)
return
readfile
(
path
)
# stat stats file corresponding to obj on wcfs.
#
_
stat stats file corresponding to obj on wcfs.
def
stat
(
t
,
obj
,
at
=
None
):
def
_
stat
(
t
,
obj
,
at
=
None
):
path
=
t
.
path
(
obj
,
at
=
at
)
path
=
t
.
_
path
(
obj
,
at
=
at
)
return
os
.
stat
(
path
)
return
os
.
stat
(
path
)
# _open opens file corresponding to obj on wcfs.
# _open opens file corresponding to obj on wcfs.
def
_open
(
t
,
obj
,
mode
=
'rb'
,
at
=
None
):
def
_open
(
t
,
obj
,
mode
=
'rb'
,
at
=
None
):
path
=
t
.
path
(
obj
,
at
=
at
)
path
=
t
.
_
path
(
obj
,
at
=
at
)
return
open
(
path
,
mode
,
0
)
# unbuffered
return
open
(
path
,
mode
,
0
)
# unbuffered
# XXX vvv -> not what we need, think again
# _blkHeadAccessed returns whether block state corresponding to zf[blk] at
# current head was accessed.
#
# for example - if head/<zf>[blk] was accessed and later changed, the answer is "no".
# buf if head/<zf>[blk] was accessed again after change, and was no longer
# changed, the answer is "yes"
# XXX text
# XXX -> _blkLastRevAccessed ? _blkRevLastAccessed ? _blkHeadRevAccessed ?
"""
def _blkHeadAccessed(t, zf, blk):
zfAccessed = t._accessed.get(zf, {})
zfAccessed.get(blk) vs t._blkRev(zf, blk, t.head)
"""
# tFile provides testing environment for one bigfile on wcfs.
# tFile provides testing environment for one bigfile on wcfs.
#
#
# ._blk() provides access to data of a block. .cached() gives state of which
# ._blk() provides access to data of a block. .cached() gives state of which
...
@@ -627,7 +623,7 @@ class tWatchLink:
...
@@ -627,7 +623,7 @@ class tWatchLink:
#
#
# fdopen takes ownership of file descriptor and closes it when file
# fdopen takes ownership of file descriptor and closes it when file
# object is closed -> dup fd so that each file object has its own fd.
# object is closed -> dup fd so that each file object has its own fd.
wh
=
os
.
open
(
tdb
.
path
(
"head/watch"
),
os
.
O_RDWR
)
wh
=
os
.
open
(
tdb
.
_
path
(
"head/watch"
),
os
.
O_RDWR
)
wh2
=
os
.
dup
(
wh
)
wh2
=
os
.
dup
(
wh
)
t
.
_wrx
=
os
.
fdopen
(
wh
,
'rb'
)
t
.
_wrx
=
os
.
fdopen
(
wh
,
'rb'
)
t
.
_wtx
=
os
.
fdopen
(
wh2
,
'wb'
)
t
.
_wtx
=
os
.
fdopen
(
wh2
,
'wb'
)
...
@@ -1163,7 +1159,7 @@ def test_wcfs():
...
@@ -1163,7 +1159,7 @@ def test_wcfs():
# >>> lookup non-BigFile -> must be rejected
# >>> lookup non-BigFile -> must be rejected
with
raises
(
OSError
)
as
exc
:
with
raises
(
OSError
)
as
exc
:
t
.
stat
(
nonfile
)
t
.
_
stat
(
nonfile
)
assert
exc
.
value
.
errno
==
EINVAL
assert
exc
.
value
.
errno
==
EINVAL
# >>> file initially empty
# >>> file initially empty
...
...
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