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
7126b78b
Commit
7126b78b
authored
Jun 27, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c6f3c3f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
4 deletions
+61
-4
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+61
-4
No files found.
wcfs/wcfs_test.py
View file @
7126b78b
...
...
@@ -36,7 +36,7 @@ from ZODB.utils import z64, u64, p64
import
sys
,
os
,
os
.
path
,
subprocess
,
threading
,
inspect
,
traceback
,
re
from
time
import
gmtime
from
errno
import
EINVAL
from
golang
import
go
,
chan
,
select
,
func
,
defer
from
golang
import
go
,
chan
,
select
,
func
,
defer
,
default
from
golang
import
context
,
sync
,
time
from
golang.gcompat
import
qq
from
zodbtools.util
import
ashex
as
h
,
fromhex
...
...
@@ -1447,6 +1447,57 @@ def test_wcfs_pintimeout_kill():
wg
.
wait
()
# watch with @at > head - must wait for head to become >= at
# XXX too far ahead - error?
@
func
def
test_wcfs_watch_setup_ahead
():
t
=
tDB
();
zf
=
t
.
zfile
defer
(
t
.
close
)
f
=
t
.
open
(
zf
)
at1
=
t
.
commit
(
zf
,
{
2
:
'c1'
})
f
.
assertData
([
''
,
''
,
'c1'
])
wg
=
sync
.
WorkGroup
(
timeout
())
dt
=
100
*
time
.
millisecond
committing
=
chan
()
# becomes ready when T2 starts to commit
# T1: watch @(at1+1·dt)
@
func
def
_
(
ctx
):
wl
=
t
.
openwatch
()
defer
(
wl
.
close
)
wat
=
tidfromtime
(
tidtime
(
at1
)
+
1
*
dt
)
# > at1, but < at2
rxq
=
wl
.
_sendReq
(
ctx
,
b"watch %s @%s"
%
(
h
(
zf
.
_p_oid
),
h
(
wat
)))
_
,
_rx
=
select
(
ctx
.
done
().
recv
,
# 0
rxq
.
recv
,
# 1
)
if
_
==
0
:
raise
ctx
.
err
()
assert
ready
(
committing
)
assert
_rx
==
b"ok"
wg
.
go
(
_
)
# T2: sleep(10·dt); commit
@
func
def
_
(
ctx
):
# reopen connection to database as we are committing from another thread
conn
=
t
.
root
.
_p_jar
.
db
().
open
()
defer
(
conn
.
close
)
root
=
conn
.
root
()
zf
=
root
[
'zfile'
]
time
.
sleep
(
10
*
dt
)
committing
.
close
()
at2
=
t
.
commit
(
zf
,
{
2
:
'c2'
})
assert
tidtime
(
at2
)
-
tidtime
(
at1
)
>=
10
*
dt
wg
.
go
(
_
)
wg
.
wait
()
# verify that watch setup/update sends correct pins.
@
func
def
test_wcfs_watch_setup
():
...
...
@@ -1725,9 +1776,6 @@ def test_wcfs_watch_2files():
# XXX watch with @at > head - must wait for head to become >= at
# XXX new watch request while previous watch request is in progress (over the same /head/watch handle)
...
...
@@ -1886,3 +1934,12 @@ def _xdefer(f):
# replace defer with xdefer
defer
=
xdefer
del
xdefer
# ready reports whether chan ch is ready
def
ready
(
ch
):
_
,
_rx
=
select
(
default
,
# 0
ch
.
recv
,
# 1
)
return
bool
(
_
)
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