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
56b8309c
Commit
56b8309c
authored
Apr 30, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ec103e5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
+36
-9
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+36
-9
No files found.
wcfs/wcfs_test.py
View file @
56b8309c
...
@@ -118,6 +118,24 @@ def test_join_autostart():
...
@@ -118,6 +118,24 @@ def test_join_autostart():
# --- test access to data ----
# --- test access to data ----
# DF corresponds to ΔF in wcfs.
# it represents a change in files space.
class
DF
:
# .rev tid
# .byfile {} ZBigFile -> DFile
def
__init__
(
dF
):
# rev set from outside
dF
.
byfile
=
{}
# DFile is similar to ΔFile in wcfs.
# represents a change to one file.
class
DFile
:
# .rev tid
# .ddata {} blk -> data XXX name
def
__init__
(
dfile
):
# rev set from outside
dfile
.
ddata
=
{}
# tDB provides database/wcfs testing environment.
# tDB provides database/wcfs testing environment.
#
#
# BigFiles opened under tDB are represented as tFile - see .open for details.
# BigFiles opened under tDB are represented as tFile - see .open for details.
...
@@ -135,10 +153,10 @@ class tDB:
...
@@ -135,10 +153,10 @@ class tDB:
# ZBigFile(s) scheduled for commit
# ZBigFile(s) scheduled for commit
t
.
_changed
=
{}
# ZBigFile -> {} blk -> data
t
.
_changed
=
{}
# ZBigFile -> {} blk -> data
# committed: head + head history
# committed: head + δF history
# XXX -> vδF (committed changes to files)
t
.
head
=
None
t
.
head
=
None
t
.
_headv
=
[]
t
.
_headv
=
[]
# XXX -> just use dFtail[·].rev ?
t
.
dFtail
=
[]
# of DF
# number of commits made so far
# number of commits made so far
t
.
ncommit
=
0
t
.
ncommit
=
0
...
@@ -185,13 +203,17 @@ class tDB:
...
@@ -185,13 +203,17 @@ class tDB:
def
commit
(
t
):
def
commit
(
t
):
# perform modifications scheduled by change.
# perform modifications scheduled by change.
# use !wcfs mode so that we prepare data independently of wcfs code paths.
# use !wcfs mode so that we prepare data independently of wcfs code paths.
dF
=
DF
()
for
zf
,
zfDelta
in
t
.
_changed
.
iteritems
():
for
zf
,
zfDelta
in
t
.
_changed
.
iteritems
():
dfile
=
DFile
()
zfh
=
zf
.
fileh_open
(
_use_wcfs
=
False
)
zfh
=
zf
.
fileh_open
(
_use_wcfs
=
False
)
for
blk
,
data
in
zfDelta
.
iteritems
():
for
blk
,
data
in
zfDelta
.
iteritems
():
dfile
.
ddata
[
blk
]
=
data
data
+=
b'
\
0
'
*
(
zf
.
blksize
-
len
(
data
))
# trailing \0
data
+=
b'
\
0
'
*
(
zf
.
blksize
-
len
(
data
))
# trailing \0
vma
=
zfh
.
mmap
(
blk
,
1
)
vma
=
zfh
.
mmap
(
blk
,
1
)
memcpy
(
vma
,
data
)
memcpy
(
vma
,
data
)
print
(
' δ f<%s>
\
t
%s'
%
(
h
(
zf
.
_p_oid
),
sorted
(
zfDelta
.
keys
())))
print
(
' δ f<%s>
\
t
%s'
%
(
h
(
zf
.
_p_oid
),
sorted
(
zfDelta
.
keys
())))
dF
.
byfile
[
zf
]
=
dfile
t
.
_changed
=
{}
t
.
_changed
=
{}
# NOTE there is no clean way to retrieve tid of just committed transaction
# NOTE there is no clean way to retrieve tid of just committed transaction
...
@@ -206,6 +228,11 @@ class tDB:
...
@@ -206,6 +228,11 @@ class tDB:
t
.
head
=
head
t
.
head
=
head
t
.
_headv
.
append
(
head
)
t
.
_headv
.
append
(
head
)
dF
.
rev
=
head
for
dfile
in
dF
.
byfile
.
values
():
dfile
.
rev
=
head
t
.
dFtail
.
append
(
dF
)
# synchronize wcfs to db
# synchronize wcfs to db
t
.
_wcsync
()
t
.
_wcsync
()
...
@@ -260,7 +287,7 @@ class tDB:
...
@@ -260,7 +287,7 @@ class tDB:
# 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
# blocks are in OS pagecache.
.assertCache and .assertBlk/.assertData assert
# blocks are in OS pagecache. .assertCache and .assertBlk/.assertData assert
# on state of cache and data.
# on state of cache and data.
class
tFile
:
class
tFile
:
# maximum number of pages we mmap for 1 file.
# maximum number of pages we mmap for 1 file.
...
@@ -366,8 +393,8 @@ class tWatch:
...
@@ -366,8 +393,8 @@ class tWatch:
# open new head/watch handle.
# open new head/watch handle.
#
#
# python/stdio lock file object on read/write
# python/stdio lock file object on read/write
, however we need both
#
however we need both
read and write to be working simultaneously.
# read and write to be working simultaneously.
# -> we use 2 separate file objects for rx and tx.
# -> we use 2 separate file objects for rx and tx.
#
#
# fdopen takes ownership of file descriptor and closes it when file
# fdopen takes ownership of file descriptor and closes it when file
...
@@ -623,7 +650,7 @@ def test_wcfs():
...
@@ -623,7 +650,7 @@ def test_wcfs():
# XXX test watch with all at variants
# XXX test watch with all at variants
# XXX both from scratch and going e.g. at1 -> at2 -> at3
# XXX both from scratch and going e.g. at1 -> at2 -> at3
# XXX going not only up, but also down at1 <- at2 <- at3
# XXX going not only up, but also down at1 <- at2 <- at3
?
w
=
t
.
watch
(
zf
,
at1
)
# XXX <- pin @at2 @at3
w
=
t
.
watch
(
zf
,
at1
)
# XXX <- pin @at2 @at3
#t.watch(zf, at1, {2: at1, 3: at1}) # XXX <- pin @at2 @at3
#t.watch(zf, at1, {2: at1, 3: at1}) # XXX <- pin @at2 @at3
...
@@ -655,14 +682,14 @@ def test_wcfs():
...
@@ -655,14 +682,14 @@ def test_wcfs():
# XXX pin message when blk data only first appeared after > w.at - pin
# XXX pin message when blk data only first appeared after > w.at - pin
# needs to pin to zero.
# needs to pin to zero.
# XXX watch @at when file did not existed -> error
# XXX ZBlk copied from blk1 -> blk2 ; for the same file and for file1 -> file2
# XXX ZBlk copied from blk1 -> blk2 ; for the same file and for file1 -> file2
# XXX ZBlk moved from blk1 -> blk2 ; for the same file and for file1 -> file2
# XXX ZBlk moved from blk1 -> blk2 ; for the same file and for file1 -> file2
# XXX read file[blk]=hole; then file[blk]=zblk - must be invalidated and
# XXX read file[blk]=hole; then file[blk]=zblk - must be invalidated and
# setupWatch must send pins.
# setupWatch must send pins.
# XXX watch @at when file did not existed
def
test_wcfs_invproto
():
def
test_wcfs_invproto
():
# XXX
# XXX
...
...
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