Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
995d858a
Commit
995d858a
authored
May 01, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates so that it passes all tests
parent
7022bdcf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
49 deletions
+55
-49
src/ZEO/tests/forker.py
src/ZEO/tests/forker.py
+23
-19
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+32
-30
No files found.
src/ZEO/tests/forker.py
View file @
995d858a
...
...
@@ -32,23 +32,7 @@ class ZEOClientExit:
def
close
(
self
):
os
.
write
(
self
.
pipe
,
"done"
)
def
start_zeo
(
storage
,
cache
=
None
,
cleanup
=
None
,
domain
=
"AF_INET"
):
"""Setup ZEO client-server for storage.
Returns a ClientStorage instance and a ZEOClientExit instance.
XXX Don't know if os.pipe() will work on Windows.
"""
if
domain
==
"AF_INET"
:
import
random
addr
=
''
,
random
.
randrange
(
2000
,
3000
)
elif
domain
==
"AF_UNIX"
:
import
tempfile
addr
=
tempfile
.
mktemp
()
else
:
raise
ValueError
,
"bad domain: %s"
%
domain
def
start_zeo_server
(
storage
,
addr
):
rd
,
wr
=
os
.
pipe
()
pid
=
os
.
fork
()
if
pid
==
0
:
...
...
@@ -67,6 +51,26 @@ def start_zeo(storage, cache=None, cleanup=None, domain="AF_INET"):
os
.
_exit
(
0
)
else
:
os
.
close
(
rd
)
s
=
ZEO
.
ClientStorage
.
ClientStorage
(
addr
,
debug
=
1
,
client
=
cache
)
return
s
,
ZEOClientExit
(
wr
),
pid
return
pid
,
ZEOClientExit
(
wr
)
def
start_zeo
(
storage
,
cache
=
None
,
cleanup
=
None
,
domain
=
"AF_INET"
):
"""Setup ZEO client-server for storage.
Returns a ClientStorage instance and a ZEOClientExit instance.
XXX Don't know if os.pipe() will work on Windows.
"""
if
domain
==
"AF_INET"
:
import
random
addr
=
''
,
random
.
randrange
(
2000
,
3000
)
elif
domain
==
"AF_UNIX"
:
import
tempfile
addr
=
tempfile
.
mktemp
()
else
:
raise
ValueError
,
"bad domain: %s"
%
domain
pid
,
exit
=
start_zeo_server
(
storage
,
addr
)
s
=
ZEO
.
ClientStorage
.
ClientStorage
(
addr
,
debug
=
1
,
client
=
cache
)
return
s
,
exit
,
pid
src/ZEO/tests/testZEO.py
View file @
995d858a
"""Test suite for ZEO based on ZODB.tests"""
import
asyncore
import
os
import
random
import
signal
import
tempfile
import
time
import
types
...
...
@@ -10,23 +9,31 @@ import unittest
import
ZEO.ClientStorage
,
ZEO
.
StorageServer
import
ThreadedAsync
,
ZEO
.
trigger
from
ZEO.tests
import
forker
# XXX The ZODB.tests package contains a grab bad things, including,
# apparently, a collection of modules that define mixin classes
# containing tests cases.
from
ZEO.tests
import
forker
from
ZODB.tests
import
StorageTestBase
,
BasicStorage
,
VersionStorage
# Sorry Jim...
from
ZODB.tests
import
StorageTestBase
,
BasicStorage
,
VersionStorage
,
\
TransactionalUndoStorage
,
TransactionalUndoVersionStorage
,
\
PackableStorage
,
Synchronization
ZERO
=
'
\
0
'
*
8
import
pickle
class
FakeDB
:
"""A ClientStorage must be registered with a DB to function"""
class
DummyDB
:
def
invalidate
(
self
,
*
args
):
pass
class
PackWaitWrapper
:
def
__init__
(
self
,
storage
):
self
.
storage
=
storage
def
__getattr__
(
self
,
attr
):
return
getattr
(
self
.
storage
,
attr
)
def
pack
(
self
,
t
,
f
):
self
.
storage
.
pack
(
t
,
f
,
wait
=
1
)
class
ZEOTestBase
(
StorageTestBase
.
StorageTestBase
):
"""Version of the storage test class that supports ZEO.
...
...
@@ -35,7 +42,8 @@ class ZEOTestBase(StorageTestBase.StorageTestBase):
will get no later than the return value from vote.
"""
def
_dostore
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
):
def
_dostore
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
,
already_pickled
=
0
):
"""Do a complete storage transaction.
The defaults are:
...
...
@@ -51,8 +59,8 @@ class ZEOTestBase(StorageTestBase.StorageTestBase):
if
revid
is
None
:
revid
=
ZERO
if
data
is
None
:
data
=
pickle
.
dumps
(
7
)
else
:
data
=
7
if
not
already_pickled
:
data
=
pickle
.
dumps
(
data
)
if
version
is
None
:
version
=
''
...
...
@@ -67,6 +75,7 @@ class ZEOTestBase(StorageTestBase.StorageTestBase):
s2
=
self
.
_get_serial
(
r2
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
# s1, s2 can be None or dict
assert
not
(
s1
and
s2
)
return
s1
and
s1
[
oid
]
or
s2
and
s2
[
oid
]
def
_get_serial
(
self
,
r
):
...
...
@@ -78,15 +87,16 @@ class ZEOTestBase(StorageTestBase.StorageTestBase):
raise
RuntimeError
,
"unexpected ZEO response: no oid"
else
:
for
oid
,
serial
in
r
:
if
type
(
serial
)
!=
types
.
StringType
:
if
isinstance
(
serial
,
Exception
)
:
raise
serial
else
:
d
[
oid
]
=
serial
d
[
oid
]
=
serial
return
d
class
GenericTests
(
ZEOTestBase
,
BasicStorage
.
BasicStorage
,
VersionStorage
.
VersionStorage
,
PackableStorage
.
PackableStorage
,
Synchronization
.
SynchronizedStorage
,
):
"""An abstract base class for ZEO tests
...
...
@@ -106,27 +116,20 @@ class GenericTests(ZEOTestBase,
getStorage() method.
"""
self
.
running
=
1
s
=
self
.
__storage
=
self
.
getStorage
()
storage
,
exit
,
pid
=
forker
.
start_zeo
(
s
)
client
,
exit
,
pid
=
forker
.
start_zeo
(
self
.
getStorage
())
self
.
_pid
=
pid
self
.
_server
_exit
=
exit
self
.
_storage
=
storage
self
.
_storage
.
registerDB
(
Fake
DB
(),
None
)
self
.
_server
=
exit
self
.
_storage
=
PackWaitWrapper
(
client
)
client
.
registerDB
(
Dummy
DB
(),
None
)
self
.
__super_setUp
()
def
tearDown
(
self
):
"""Try to cause the tests to halt"""
self
.
running
=
0
# XXX This only works on Unix
self
.
_server_exit
.
close
()
self
.
_server
.
close
()
os
.
waitpid
(
self
.
_pid
,
0
)
self
.
delStorage
()
self
.
__super_tearDown
()
def
checkFirst
(
self
):
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
_storage
.
tpc_abort
(
self
.
_transaction
)
class
ZEOFileStorageTests
(
GenericTests
):
__super_setUp
=
GenericTests
.
setUp
...
...
@@ -143,8 +146,7 @@ class ZEOFileStorageTests(GenericTests):
# file storage appears to create three files
for
ext
in
''
,
'.index'
,
'.lock'
,
'.tmp'
:
path
=
self
.
__fs_base
+
ext
if
os
.
path
.
exists
(
path
):
os
.
unlink
(
path
)
os
.
unlink
(
path
)
def
main
():
import
sys
,
getopt
...
...
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