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
e328d422
Commit
e328d422
authored
Jan 14, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a035b1cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
32 deletions
+34
-32
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+1
-1
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+33
-31
No files found.
wcfs/internal/wcfs_misc.h
View file @
e328d422
...
...
@@ -51,7 +51,7 @@ using std::tie;
using
std
::
vector
;
// nil is synonym for nullptr and NULL.
// nil is synonym for nullptr and NULL.
XXX -> pygolang
const
nullptr_t
nil
=
nullptr
;
...
...
wcfs/wcfs_test.py
View file @
e328d422
...
...
@@ -19,7 +19,7 @@
# See https://www.nexedi.com/licensing for rationale and options.
"""wcfs_test tests wcfs filesystem from outside as python client process
It also unit-tests
wcfs.py virtmem-level integration. XXX
It also unit-tests
virtmem layer of wcfs virtmem client.
At functional level, the whole wendelin.core test suite is used to verify
wcfs.py/wcfs.go while running tox tests in wcfs mode.
...
...
@@ -1698,18 +1698,23 @@ def test_wcfs_watch_2files():
# XXX @revX/ is automatically removed after some time
# ----
wcfs.py + virtmem integration
----
# ----
unit-tests for virtmem layer of wcfs client
----
# tMapping provides testing environment for Mapping.
class
tMapping
(
object
):
def
__init__
(
t
,
mmap
):
def
__init__
(
t
,
tdb
,
mmap
):
t
.
tdb
=
tdb
t
.
mmap
=
mmap
# XXX assertCache
# assertBlk asserts that mmap[·] with · corresponding to blk reads as dataok.
# pinnedOK: {} blk -> rev of t.mmap.fileh.pinned after access.
#
# see also: tFile.assertBlk .
def
assertBlk
(
t
,
blk
,
dataok
):
# NOTE contrary to tFile, pinnedOK represents full fh.pinned state, not
# only pins that wcfs sent to client after tested access.
def
assertBlk
(
t
,
blk
,
dataok
,
pinnedOK
):
assert
t
.
mmap
.
blk_start
<=
blk
<
t
.
mmap
.
blk_stop
blk_inmmap
=
blk
-
t
.
mmap
.
blk_start
...
...
@@ -1738,14 +1743,24 @@ class tMapping(object):
assert
_
==
dataok
[
0
]
assert
blkview
.
tobytes
()
==
dataok
assert
fhpinned
(
t
.
tdb
,
fh
)
==
pinnedOK
# XXX assertData
# fhpinned(fh) returns fh.pinned with rev wrapped into tAt.
# XXX better wrap FileH into tFileH and do this automatically in .pinned ?
def
fhpinned
(
t
,
fh
):
p
=
fh
.
pinned
.
copy
()
for
blk
in
p
:
p
[
blk
]
=
tAt
(
t
,
p
[
blk
])
return
p
# test_wcfs_virtmem unit-tests virtmem layer of wcfs client.
@
func
def
test_wcfs_virtmem
():
t
=
tDB
();
zf
=
t
.
zfile
t
=
tDB
();
zf
=
t
.
zfile
;
at0
=
t
.
at0
defer
(
t
.
close
)
pinned
=
lambda
fh
:
fhpinned
(
t
,
fh
)
at1
=
t
.
commit
(
zf
,
{
2
:
'c1'
,
3
:
'd1'
})
at2
=
t
.
commit
(
zf
,
{
2
:
'c2'
})
...
...
@@ -1755,13 +1770,6 @@ def test_wcfs_virtmem():
fh
=
wconn
.
open
(
zf
.
_p_oid
)
defer
(
fh
.
close
)
# pinned(fh) returns fh.pinned with rev wrapped into tAt.
# XXX better wrap FileH into tFileH and do this automatically in .pinned ?
def
pinned
(
fh
):
p
=
fh
.
pinned
.
copy
()
for
blk
in
p
:
p
[
blk
]
=
tAt
(
t
,
p
[
blk
])
return
p
# create mmap with 1 block beyond file size
m1
=
fh
.
mmap
(
2
,
3
)
...
...
@@ -1771,43 +1779,37 @@ def test_wcfs_virtmem():
assert
m1
.
blk_stop
==
5
assert
len
(
m1
.
mem
)
==
3
*
zf
.
blksize
tm1
=
tMapping
(
m1
)
tm1
=
tMapping
(
t
,
m1
)
#assertCache(m1, [0,0,0])
assert
pinned
(
fh
)
==
{}
# verify initial data reads
tm1
.
assertBlk
(
2
,
'c1'
)
assert
pinned
(
fh
)
==
{
2
:
at1
}
tm1
.
assertBlk
(
3
,
'd1'
)
assert
pinned
(
fh
)
==
{
2
:
at1
}
tm1
.
assertBlk
(
4
,
''
)
assert
pinned
(
fh
)
==
{
2
:
at1
}
tm1
.
assertBlk
(
2
,
'c1'
,
{
2
:
at1
})
tm1
.
assertBlk
(
3
,
'd1'
,
{
2
:
at1
})
tm1
.
assertBlk
(
4
,
''
,
{
2
:
at1
})
# commit with growing file size -> verify data read as the same, #3 pinned.
# (#4 is not yet pinned because it was not accessed)
at3
=
t
.
commit
(
zf
,
{
3
:
'd3'
,
4
:
'e3'
})
assert
pinned
(
fh
)
==
{
2
:
at1
}
tm1
.
assertBlk
(
2
,
'c1'
)
assert
pinned
(
fh
)
==
{
2
:
at1
}
tm1
.
assertBlk
(
3
,
'd1'
)
assert
pinned
(
fh
)
==
{
2
:
at1
,
3
:
at1
}
tm1
.
assertBlk
(
4
,
''
)
assert
pinned
(
fh
)
==
{
2
:
at1
,
3
:
at1
}
tm1
.
assertBlk
(
2
,
'c1'
,
{
2
:
at1
})
tm1
.
assertBlk
(
3
,
'd1'
,
{
2
:
at1
,
3
:
at1
})
tm1
.
assertBlk
(
4
,
''
,
{
2
:
at1
,
3
:
at1
})
# resync at1 -> at2: #2 must unpin to @head; #4 must stay as zero
wconn
.
resync
(
at2
)
assert
pinned
(
fh
)
==
{
3
:
at1
}
tm1
.
assertBlk
(
2
,
'c2'
)
tm1
.
assertBlk
(
3
,
'd1'
)
tm1
.
assertBlk
(
4
,
''
)
tm1
.
assertBlk
(
2
,
'c2'
,
{
3
:
at1
}
)
tm1
.
assertBlk
(
3
,
'd1'
,
{
3
:
at1
}
)
tm1
.
assertBlk
(
4
,
''
,
{
3
:
at1
,
4
:
at0
})
# XXX 4->ø ?
# resync at2 -> at3: #3 must unpin to @head; #4 - start to read with data
wconn
.
resync
(
at3
)
assert
pinned
(
fh
)
==
{}
tm1
.
assertBlk
(
2
,
'c2'
)
tm1
.
assertBlk
(
3
,
'd3'
)
tm1
.
assertBlk
(
4
,
'e3'
)
tm1
.
assertBlk
(
2
,
'c2'
,
{}
)
tm1
.
assertBlk
(
3
,
'd3'
,
{}
)
tm1
.
assertBlk
(
4
,
'e3'
,
{}
)
# XXX resync ↓ ?
...
...
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