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
155835df
Commit
155835df
authored
Mar 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a436e928
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
52 deletions
+6
-52
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+6
-52
No files found.
wcfs/wcfs_test.py
View file @
155835df
...
...
@@ -19,6 +19,8 @@
# See https://www.nexedi.com/licensing for rationale and options.
"""test wcfs filesystem from outside as python client process"""
from
__future__
import
print_function
from
wendelin.lib.testing
import
getTestDB
from
wendelin.lib.zodb
import
dbclose
from
wendelin.lib.mem
import
memcpy
...
...
@@ -132,11 +134,7 @@ class tDB:
t
.
wc
.
close
()
dbclose
(
t
.
root
)
# commit commits transaction and remembers/returns committed tid.
#
# it also stores:
#
# .head - last committed transaction ID
# commit commits transaction and remembers/returns committed transaction ID.
def
commit
(
t
):
# NOTE there is no clean way to retrieve tid of just committed transaction
# we are using last._p_serial as workaround.
...
...
@@ -144,7 +142,7 @@ class tDB:
last
.
_p_changed
=
1
transaction
.
commit
()
head
=
last
.
_p_serial
print
'commit -> %s'
%
h
(
head
)
#print('commit -> %s' % h(head)
)
t
.
head
=
head
t
.
_headv
.
append
(
head
)
return
head
...
...
@@ -161,7 +159,8 @@ class tDB:
raise
RuntimeError
(
"wcsync #%d: wczhead (%s) != zhead (%s)"
%
(
i
,
wchead
,
t
.
_headv
[
i
]))
t
.
_wc_zheadv
.
append
(
wchead
)
# XXX test
# XXX text ...
# XXX parametrize zblk0, zblk1 XXX or just rely on tox?
@
func
def
test_wcfs
():
...
...
@@ -171,51 +170,6 @@ def test_wcfs():
t
.
root
[
'obj'
]
=
nonfile
=
Persistent
()
t
.
root
[
'zfile'
]
=
f
=
ZBigFile
(
blksize
)
"""
root = testdb.dbopen()
defer(lambda: dbclose(root))
wc = wcfs.join(testzurl, autostart=True)
defer(wc.close)
# commit commits transaction and remembers/returns committed tid.
#
# NOTE there is no clean way to retrieve tid of just committed transaction
# we'll be using last._p_serial as workaround.
#
# we also store:
#
# Z.head - last committed transaction ID
# Z.tidv - [] of all committed tid↑
root['last'] = last = Persistent()
class _: pass
Z = _()
Z.tidv = []
def commit():
last._p_changed = 1
transaction.commit()
tid = last._p_serial
print 'commit -> %s' % h(tid)
Z.head = tid
Z.tidv.append(tid)
return tid
# wcsync makes sure wc synchronized to latest committed transaction
Z.wctidv = []
wc_zhead = open(wc.mountpoint + "/.wcfs/zhead")
defer(wc_zhead.close)
def wcsync():
while len(Z.wctidv) < len(Z.tidv):
l = wc_zhead.readline()
#print '> zhead read: %r' % l
l = l.rstrip('
\
n
')
wctid = fromhex(l)
i = len(Z.wctidv)
if wctid != Z.tidv[i]:
raise RuntimeError("wcsync #%d: Z.wctid (%s) != Z.tid (%s)" % (i, wctid, Z.tidv[i]))
Z.wctidv.append(wctid)
"""
tid1
=
t
.
commit
()
tid2
=
t
.
commit
()
assert
tidtime
(
tid2
)
>
tidtime
(
tid1
)
...
...
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