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
00ab5fb4
Commit
00ab5fb4
authored
Jul 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0b0d80dd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
bigfile/tests/test_filezodb.py
bigfile/tests/test_filezodb.py
+15
-13
No files found.
bigfile/tests/test_filezodb.py
View file @
00ab5fb4
...
@@ -27,6 +27,7 @@ import transaction
...
@@ -27,6 +27,7 @@ import transaction
from
transaction
import
TransactionManager
from
transaction
import
TransactionManager
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
numpy
import
ndarray
,
array_equal
,
uint32
,
zeros
,
arange
from
numpy
import
ndarray
,
array_equal
,
uint32
,
zeros
,
arange
from
golang
import
defer
,
func
from
threading
import
Thread
from
threading
import
Thread
from
six.moves
import
_thread
from
six.moves
import
_thread
from
six
import
b
from
six
import
b
...
@@ -349,12 +350,14 @@ def test_bigfile_filezodb():
...
@@ -349,12 +350,14 @@ def test_bigfile_filezodb():
# connection can migrate between threads handling requests.
# connection can migrate between threads handling requests.
# verify _ZBigFileH properly adjusts.
# verify _ZBigFileH properly adjusts.
# ( NOTE this test is almost dupped at test_zbigarray_vs_conn_migration() )
# ( NOTE this test is almost dupped at test_zbigarray_vs_conn_migration() )
@
func
def
test_bigfile_filezodb_vs_conn_migration
():
def
test_bigfile_filezodb_vs_conn_migration
():
root01
=
dbopen
()
root01
=
dbopen
()
conn01
=
root01
.
_p_jar
conn01
=
root01
.
_p_jar
db
=
conn01
.
db
()
db
=
conn01
.
db
()
conn01
.
close
()
conn01
.
close
()
del
root01
del
root01
defer
(
db
.
close
)
c12_1
=
NotifyChannel
()
# T11 -> T21
c12_1
=
NotifyChannel
()
# T11 -> T21
c21_1
=
NotifyChannel
()
# T21 -> T11
c21_1
=
NotifyChannel
()
# T21 -> T11
...
@@ -545,17 +548,18 @@ def test_bigfile_filezodb_vs_conn_migration():
...
@@ -545,17 +548,18 @@ def test_bigfile_filezodb_vs_conn_migration():
assert
Blk
(
vma03
,
0
)[
0
]
==
22
assert
Blk
(
vma03
,
0
)[
0
]
==
22
del
vma03
,
fh03
,
f03
del
vma03
,
fh03
,
f03
dbclose
(
root03
)
# ZBlk should properly handle 'invalidate' messages from DB
# ZBlk should properly handle 'invalidate' messages from DB
# ( NOTE this test is almost dupped at test_zbigarray_vs_cache_invalidation() )
# ( NOTE this test is almost dupped at test_zbigarray_vs_cache_invalidation() )
@
func
def
test_bigfile_filezodb_vs_cache_invalidation
():
def
test_bigfile_filezodb_vs_cache_invalidation
():
root
=
dbopen
()
root
=
dbopen
()
conn
=
root
.
_p_jar
conn
=
root
.
_p_jar
db
=
conn
.
db
()
db
=
conn
.
db
()
conn
.
close
()
conn
.
close
()
del
root
,
conn
del
root
,
conn
defer
(
db
.
close
)
tm1
=
TransactionManager
()
tm1
=
TransactionManager
()
tm2
=
TransactionManager
()
tm2
=
TransactionManager
()
...
@@ -601,6 +605,7 @@ def test_bigfile_filezodb_vs_cache_invalidation():
...
@@ -601,6 +605,7 @@ def test_bigfile_filezodb_vs_cache_invalidation():
ram_reclaim_all
()
ram_reclaim_all
()
assert
Blk
(
vma2
,
0
)[
0
]
==
1
assert
Blk
(
vma2
,
0
)[
0
]
==
1
# """
# FIXME: this simulates ZODB Connection cache pressure and currently
# FIXME: this simulates ZODB Connection cache pressure and currently
# removes ZBlk corresponding to blk #0 from conn2 cache.
# removes ZBlk corresponding to blk #0 from conn2 cache.
# In turn this leads to conn2 missing that block invalidation on follow-up
# In turn this leads to conn2 missing that block invalidation on follow-up
...
@@ -608,25 +613,24 @@ def test_bigfile_filezodb_vs_cache_invalidation():
...
@@ -608,25 +613,24 @@ def test_bigfile_filezodb_vs_cache_invalidation():
#
#
# See FIXME notes on ZBlkBase._p_invalidate() for detailed description.
# See FIXME notes on ZBlkBase._p_invalidate() for detailed description.
conn2
.
_cache
.
minimize
()
conn2
.
_cache
.
minimize
()
# """
tm2
.
commit
()
# transaction boundary for t2
tm2
.
commit
()
# transaction boundary for t2
# data from tm1 should propagate -> ZODB -> ram pages for _ZBigFileH in conn2
# data from tm1 should propagate -> ZODB -> ram pages for _ZBigFileH in conn2
assert
Blk
(
vma2
,
0
)[
0
]
==
2
assert
Blk
(
vma2
,
0
)[
0
]
==
2
conn2
.
close
()
del
conn2
,
root2
dbclose
(
root1
)
# verify that conflicts on ZBlk are handled properly
# verify that conflicts on ZBlk are handled properly
# ( NOTE this test is almost dupped at test_zbigarray_vs_conflicts() )
# ( NOTE this test is almost dupped at test_zbigarray_vs_conflicts() )
@
func
def
test_bigfile_filezodb_vs_conflicts
():
def
test_bigfile_filezodb_vs_conflicts
():
root
=
dbopen
()
root
=
dbopen
()
conn
=
root
.
_p_jar
conn
=
root
.
_p_jar
db
=
conn
.
db
()
db
=
conn
.
db
()
conn
.
close
()
conn
.
close
()
del
root
,
conn
del
root
,
conn
defer
(
db
.
close
)
tm1
=
TransactionManager
()
tm1
=
TransactionManager
()
tm2
=
TransactionManager
()
tm2
=
TransactionManager
()
...
@@ -680,16 +684,15 @@ def test_bigfile_filezodb_vs_conflicts():
...
@@ -680,16 +684,15 @@ def test_bigfile_filezodb_vs_conflicts():
assert
Blk
(
vma1
,
0
)[
0
]
==
13
# re-read in conn1
assert
Blk
(
vma1
,
0
)[
0
]
==
13
# re-read in conn1
conn2
.
close
()
dbclose
(
root1
)
# verify that fileh are garbage-collected after user free them
# verify that fileh are garbage-collected after user free them
@
func
def
test_bigfile_filezodb_fileh_gc
():
def
test_bigfile_filezodb_fileh_gc
():
root1
=
dbopen
()
root1
=
dbopen
()
conn1
=
root1
.
_p_jar
conn1
=
root1
.
_p_jar
db
=
conn1
.
db
()
db
=
conn1
.
db
()
defer
(
db
.
close
)
root1
[
'zfile4'
]
=
f1
=
ZBigFile
(
blksize
)
root1
[
'zfile4'
]
=
f1
=
ZBigFile
(
blksize
)
transaction
.
commit
()
transaction
.
commit
()
...
@@ -713,12 +716,13 @@ def test_bigfile_filezodb_fileh_gc():
...
@@ -713,12 +716,13 @@ def test_bigfile_filezodb_fileh_gc():
assert
wfh1
()
is
None
# fh1 should be gone
assert
wfh1
()
is
None
# fh1 should be gone
del
vma2
,
fh2
,
f2
del
vma2
,
fh2
,
f2
dbclose
(
root2
)
# verify how zblk format change works
# verify how zblk format change works
@
func
def
test_bigfile_filezodb_fmt_change
():
def
test_bigfile_filezodb_fmt_change
():
root
=
dbopen
()
root
=
dbopen
()
defer
(
lambda
:
dbclose
(
root
))
root
[
'zfile5'
]
=
f
=
ZBigFile
(
blksize
)
root
[
'zfile5'
]
=
f
=
ZBigFile
(
blksize
)
transaction
.
commit
()
transaction
.
commit
()
...
@@ -751,8 +755,6 @@ def test_bigfile_filezodb_fmt_change():
...
@@ -751,8 +755,6 @@ def test_bigfile_filezodb_fmt_change():
finally
:
finally
:
file_zodb
.
ZBlk_fmt_write
=
fmt_write_save
file_zodb
.
ZBlk_fmt_write
=
fmt_write_save
dbclose
(
root
)
# test that ZData are reused for changed chunks in ZBlk1 format
# test that ZData are reused for changed chunks in ZBlk1 format
def
test_bigfile_zblk1_zdata_reuse
():
def
test_bigfile_zblk1_zdata_reuse
():
...
@@ -764,8 +766,10 @@ def test_bigfile_zblk1_zdata_reuse():
...
@@ -764,8 +766,10 @@ def test_bigfile_zblk1_zdata_reuse():
finally
:
finally
:
file_zodb
.
ZBlk_fmt_write
=
fmt_write_save
file_zodb
.
ZBlk_fmt_write
=
fmt_write_save
@
func
def
_test_bigfile_zblk1_zdata_reuse
():
def
_test_bigfile_zblk1_zdata_reuse
():
root
=
dbopen
()
root
=
dbopen
()
defer
(
lambda
:
dbclose
(
root
))
root
[
'zfile6'
]
=
f
=
ZBigFile
(
blksize
)
root
[
'zfile6'
]
=
f
=
ZBigFile
(
blksize
)
transaction
.
commit
()
transaction
.
commit
()
...
@@ -799,5 +803,3 @@ def _test_bigfile_zblk1_zdata_reuse():
...
@@ -799,5 +803,3 @@ def _test_bigfile_zblk1_zdata_reuse():
assert
len
(
zdata_v1
)
==
len
(
zdata_v2
)
assert
len
(
zdata_v1
)
==
len
(
zdata_v2
)
for
i
in
range
(
len
(
zdata_v1
)):
for
i
in
range
(
len
(
zdata_v1
)):
assert
zdata_v1
[
i
]
is
zdata_v2
[
i
]
assert
zdata_v1
[
i
]
is
zdata_v2
[
i
]
dbclose
(
root
)
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