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
Kirill Smelkov
ZODB
Commits
48358a78
Commit
48358a78
authored
May 29, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revise the test framework to use ZConfig instead of a custom argv.
parent
5bdfa109
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
10 deletions
+31
-10
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+31
-10
No files found.
src/ZEO/tests/testZEO.py
View file @
48358a78
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
import
os
import
os
import
sys
import
sys
import
time
import
time
import
random
import
socket
import
socket
import
asyncore
import
asyncore
import
tempfile
import
tempfile
...
@@ -37,13 +38,8 @@ from ZODB.tests import StorageTestBase, BasicStorage, VersionStorage, \
...
@@ -37,13 +38,8 @@ from ZODB.tests import StorageTestBase, BasicStorage, VersionStorage, \
PackableStorage
,
Synchronization
,
ConflictResolution
,
RevisionStorage
,
\
PackableStorage
,
Synchronization
,
ConflictResolution
,
RevisionStorage
,
\
MTStorage
,
ReadOnlyStorage
MTStorage
,
ReadOnlyStorage
# ZEO imports
from
ZEO.ClientStorage
import
ClientStorage
from
ZEO.ClientStorage
import
ClientStorage
# ZEO test support
from
ZEO.tests
import
forker
,
Cache
from
ZEO.tests
import
forker
,
Cache
# ZEO test mixin classes
from
ZEO.tests
import
CommitLockTests
,
ThreadTests
from
ZEO.tests
import
CommitLockTests
,
ThreadTests
class
DummyDB
:
class
DummyDB
:
...
@@ -80,6 +76,26 @@ class MiscZEOTests:
...
@@ -80,6 +76,26 @@ class MiscZEOTests:
finally
:
finally
:
storage2
.
close
()
storage2
.
close
()
def
get_port
():
"""Return a port that is not in use.
Checks if a port is in use by trying to connect to it. Assumes it
is not in use if connect raises an exception.
Raises RuntimeError after 10 tries.
"""
for
i
in
range
(
10
):
port
=
random
.
randrange
(
20000
,
30000
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
try
:
try
:
s
.
connect
((
'localhost'
,
port
))
except
socket
.
error
:
# XXX check value of error?
return
port
finally
:
s
.
close
()
raise
RuntimeError
,
"Can't find port"
class
GenericTests
(
class
GenericTests
(
# Base class for all ZODB tests
# Base class for all ZODB tests
...
@@ -109,15 +125,20 @@ class GenericTests(
...
@@ -109,15 +125,20 @@ class GenericTests(
def
setUp
(
self
):
def
setUp
(
self
):
zLOG
.
LOG
(
"testZEO"
,
zLOG
.
INFO
,
"setUp() %s"
%
self
.
id
())
zLOG
.
LOG
(
"testZEO"
,
zLOG
.
INFO
,
"setUp() %s"
%
self
.
id
())
zeoport
,
adminaddr
,
pid
=
forker
.
start_zeo_server
(
self
.
getConfig
())
port
=
get_port
()
zconf
=
forker
.
ZEOConfig
((
''
,
port
))
zport
,
adminaddr
,
pid
,
path
=
forker
.
start_zeo_server
(
self
.
getConfig
(),
zconf
,
port
)
self
.
_pids
=
[
pid
]
self
.
_pids
=
[
pid
]
self
.
_servers
=
[
adminaddr
]
self
.
_servers
=
[
adminaddr
]
self
.
_storage
=
ClientStorage
(
zeoport
,
'1'
,
cache_size
=
20000000
,
self
.
_conf_path
=
path
self
.
_storage
=
ClientStorage
(
zport
,
'1'
,
cache_size
=
20000000
,
min_disconnect_poll
=
0.5
,
wait
=
1
)
min_disconnect_poll
=
0.5
,
wait
=
1
)
self
.
_storage
.
registerDB
(
DummyDB
(),
None
)
self
.
_storage
.
registerDB
(
DummyDB
(),
None
)
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
_storage
.
close
()
self
.
_storage
.
close
()
os
.
remove
(
self
.
_conf_path
)
for
server
in
self
.
_servers
:
for
server
in
self
.
_servers
:
forker
.
shutdown_zeo_server
(
server
)
forker
.
shutdown_zeo_server
(
server
)
if
hasattr
(
os
,
'waitpid'
):
if
hasattr
(
os
,
'waitpid'
):
...
@@ -150,7 +171,7 @@ class FileStorageTests(GenericTests):
...
@@ -150,7 +171,7 @@ class FileStorageTests(GenericTests):
def
getConfig
(
self
):
def
getConfig
(
self
):
filename
=
self
.
__fs_base
=
tempfile
.
mktemp
()
filename
=
self
.
__fs_base
=
tempfile
.
mktemp
()
return
"""
\
return
"""
\
<filestorage>
<filestorage
1
>
path %s
path %s
</filestorage>
</filestorage>
"""
%
filename
"""
%
filename
...
@@ -162,7 +183,7 @@ class BDBTests(FileStorageTests):
...
@@ -162,7 +183,7 @@ class BDBTests(FileStorageTests):
def
getConfig
(
self
):
def
getConfig
(
self
):
self
.
_envdir
=
tempfile
.
mktemp
()
self
.
_envdir
=
tempfile
.
mktemp
()
return
"""
\
return
"""
\
<fullstorage>
<fullstorage
1
>
name %s
name %s
</fullstorage>
</fullstorage>
"""
%
self
.
_envdir
"""
%
self
.
_envdir
...
@@ -171,7 +192,7 @@ class MappingStorageTests(FileStorageTests):
...
@@ -171,7 +192,7 @@ class MappingStorageTests(FileStorageTests):
"""ZEO backed by a Mapping storage."""
"""ZEO backed by a Mapping storage."""
def
getConfig
(
self
):
def
getConfig
(
self
):
return
"""<mappingstorage/>"""
return
"""<mappingstorage
1
/>"""
# Tests which MappingStorage can't possibly pass, because it doesn't
# Tests which MappingStorage can't possibly pass, because it doesn't
# support versions or undo.
# support versions or undo.
...
...
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